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
2434 $LFS setstripe -C 4 $DIR/$tdir
2436 echo 1 > $DIR/$tdir/${tfile}.1
2437 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2439 [ $count -eq $setcount ] ||
2440 error "(1) stripe count $count, should be $setcount"
2442 # Capture existing append_stripe_count setting for restore
2443 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2444 local mdts=$(comma_list $(mdts_nodes))
2445 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2447 local appendcount=$orig_count
2448 echo 1 >> $DIR/$tdir/${tfile}.2_append
2449 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2450 [ $count -eq $appendcount ] ||
2451 error "(2)stripe count $count, should be $appendcount for append"
2453 # Disable O_APPEND striping, verify it works
2454 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2456 # Should now get the default striping, which is 4
2458 echo 1 >> $DIR/$tdir/${tfile}.3_append
2459 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2460 [ $count -eq $setcount ] ||
2461 error "(3) stripe count $count, should be $setcount"
2463 # Try changing the stripe count for append files
2464 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2466 # Append striping is now 2 (directory default is still 4)
2468 echo 1 >> $DIR/$tdir/${tfile}.4_append
2469 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2470 [ $count -eq $appendcount ] ||
2471 error "(4) stripe count $count, should be $appendcount for append"
2473 # Test append stripe count of -1
2474 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2475 appendcount=$OSTCOUNT
2476 echo 1 >> $DIR/$tdir/${tfile}.5
2477 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2478 [ $count -eq $appendcount ] ||
2479 error "(5) stripe count $count, should be $appendcount for append"
2481 # Set append striping back to default of 1
2482 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2484 # Try a new default striping, PFL + DOM
2485 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2487 # Create normal DOM file, DOM returns stripe count == 0
2489 touch $DIR/$tdir/${tfile}.6
2490 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2491 [ $count -eq $setcount ] ||
2492 error "(6) stripe count $count, should be $setcount"
2496 echo 1 >> $DIR/$tdir/${tfile}.7_append
2497 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2498 [ $count -eq $appendcount ] ||
2499 error "(7) stripe count $count, should be $appendcount for append"
2501 # Clean up DOM layout
2502 $LFS setstripe -d $DIR/$tdir
2504 # Now test that append striping works when layout is from root
2505 $LFS setstripe -c 2 $MOUNT
2506 # Make a special directory for this
2507 mkdir $DIR/${tdir}/${tdir}.2
2508 stack_trap "$LFS setstripe -d $MOUNT" EXIT
2510 # Verify for normal file
2512 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2513 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2514 [ $count -eq $setcount ] ||
2515 error "(8) stripe count $count, should be $setcount"
2518 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2519 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2520 [ $count -eq $appendcount ] ||
2521 error "(9) stripe count $count, should be $appendcount for append"
2523 # Now test O_APPEND striping with pools
2524 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2525 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2528 pool_add $TESTNAME || error "pool creation failed"
2529 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2531 echo 1 >> $DIR/$tdir/${tfile}.10_append
2533 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2534 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2536 # Check that count is still correct
2538 echo 1 >> $DIR/$tdir/${tfile}.11_append
2539 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2540 [ $count -eq $appendcount ] ||
2541 error "(11) stripe count $count, should be $appendcount for append"
2543 # Disable O_APPEND stripe count, verify pool works separately
2544 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2546 echo 1 >> $DIR/$tdir/${tfile}.12_append
2548 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2549 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2551 # Remove pool setting, verify it's not applied
2552 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
2554 echo 1 >> $DIR/$tdir/${tfile}.13_append
2556 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
2557 [ "$pool" = "" ] || error "(13) pool found: $pool"
2559 run_test 27M "test O_APPEND striping"
2561 # createtest also checks that device nodes are created and
2562 # then visible correctly (#2091)
2563 test_28() { # bug 2091
2565 $CREATETEST $DIR/d28/ct || error "createtest failed"
2567 run_test 28 "create/mknod/mkdir with bad file types ============"
2570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2572 sync; sleep 1; sync # flush out any dirty pages from previous tests
2579 declare -i LOCKCOUNTORIG=0
2580 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2581 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2583 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2585 declare -i LOCKUNUSEDCOUNTORIG=0
2586 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2587 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2594 declare -i LOCKCOUNTCURRENT=0
2595 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2596 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2599 declare -i LOCKUNUSEDCOUNTCURRENT=0
2600 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2601 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2604 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2605 $LCTL set_param -n ldlm.dump_namespaces ""
2606 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2607 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2608 log "dumped log to $TMP/test_29.dk (bug 5793)"
2611 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2612 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2613 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2614 log "dumped log to $TMP/test_29.dk (bug 5793)"
2618 run_test 29 "IT_GETATTR regression ============================"
2620 test_30a() { # was test_30
2621 cp $(which ls) $DIR || cp /bin/ls $DIR
2622 $DIR/ls / || error "Can't execute binary from lustre"
2625 run_test 30a "execute binary from Lustre (execve) =============="
2628 cp `which ls` $DIR || cp /bin/ls $DIR
2630 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2633 run_test 30b "execute binary from Lustre as non-root ==========="
2635 test_30c() { # b=22376
2636 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2638 cp `which ls` $DIR || cp /bin/ls $DIR
2640 cancel_lru_locks mdc
2641 cancel_lru_locks osc
2642 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2645 run_test 30c "execute binary from Lustre without read perms ===="
2648 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2649 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2651 run_test 31a "open-unlink file =================================="
2654 touch $DIR/f31 || error "touch $DIR/f31 failed"
2655 ln $DIR/f31 $DIR/f31b || error "ln failed"
2656 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2657 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2659 run_test 31b "unlink file with multiple links while open ======="
2662 touch $DIR/f31 || error "touch $DIR/f31 failed"
2663 ln $DIR/f31 $DIR/f31c || error "ln failed"
2664 multiop_bg_pause $DIR/f31 O_uc ||
2665 error "multiop_bg_pause for $DIR/f31 failed"
2667 $MULTIOP $DIR/f31c Ouc
2668 kill -USR1 $MULTIPID
2671 run_test 31c "open-unlink file with multiple links ============="
2674 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2675 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2677 run_test 31d "remove of open directory ========================="
2679 test_31e() { # bug 2904
2680 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2682 run_test 31e "remove of open non-empty directory ==============="
2684 test_31f() { # bug 4554
2685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2688 test_mkdir $DIR/d31f
2689 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2690 cp /etc/hosts $DIR/d31f
2692 $GETSTRIPE $DIR/d31f/hosts
2693 multiop_bg_pause $DIR/d31f D_c || return 1
2696 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2697 test_mkdir $DIR/d31f
2698 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2699 cp /etc/hosts $DIR/d31f
2701 $GETSTRIPE $DIR/d31f/hosts
2702 multiop_bg_pause $DIR/d31f D_c || return 1
2705 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2706 wait $MULTIPID || error "first opendir $MULTIPID failed"
2710 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2711 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2714 run_test 31f "remove of open directory with open-unlink file ==="
2717 echo "-- cross directory link --"
2718 test_mkdir -c1 $DIR/${tdir}ga
2719 test_mkdir -c1 $DIR/${tdir}gb
2720 touch $DIR/${tdir}ga/f
2721 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2722 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2723 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2724 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2725 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2727 run_test 31g "cross directory link==============="
2730 echo "-- cross directory link --"
2731 test_mkdir -c1 $DIR/${tdir}
2732 test_mkdir -c1 $DIR/${tdir}/dir
2733 touch $DIR/${tdir}/f
2734 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2735 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2736 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2737 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2738 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2740 run_test 31h "cross directory link under child==============="
2743 echo "-- cross directory link --"
2744 test_mkdir -c1 $DIR/$tdir
2745 test_mkdir -c1 $DIR/$tdir/dir
2746 touch $DIR/$tdir/dir/f
2747 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2748 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2749 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2750 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2751 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2753 run_test 31i "cross directory link under parent==============="
2756 test_mkdir -c1 -p $DIR/$tdir
2757 test_mkdir -c1 -p $DIR/$tdir/dir1
2758 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2759 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2760 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2761 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2764 run_test 31j "link for directory==============="
2767 test_mkdir -c1 -p $DIR/$tdir
2769 touch $DIR/$tdir/exist
2770 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2771 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2772 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2773 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2774 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2775 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2776 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2779 run_test 31k "link to file: the same, non-existing, dir==============="
2785 touch $DIR/d31m2/exist
2786 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2787 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2788 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2789 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2790 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2791 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2794 run_test 31m "link to file: the same, non-existing, dir==============="
2797 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2798 nlink=$(stat --format=%h $DIR/$tfile)
2799 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2801 local cmd="exec $fd<$DIR/$tfile"
2804 trap "eval $cmd" EXIT
2805 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2806 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2807 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2808 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2809 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2812 run_test 31n "check link count of unlinked file"
2815 local TEMPNAME=$(mktemp $1_XXXXXX)
2816 mlink $TEMPNAME $1 2> /dev/null &&
2817 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2821 test_31o() { # LU-2901
2822 test_mkdir $DIR/$tdir
2823 for LOOP in $(seq 100); do
2824 rm -f $DIR/$tdir/$tfile*
2825 for THREAD in $(seq 8); do
2826 link_one $DIR/$tdir/$tfile.$LOOP &
2829 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2830 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2831 error "$LINKS duplicate links to $tfile.$LOOP" &&
2835 run_test 31o "duplicate hard links with same filename"
2838 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2840 test_mkdir $DIR/$tdir
2841 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2842 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2844 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2845 error "open unlink test1 failed"
2846 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2847 error "open unlink test2 failed"
2849 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2850 error "test1 still exists"
2851 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2852 error "test2 still exists"
2854 run_test 31p "remove of open striped directory"
2856 cleanup_test32_mount() {
2859 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2860 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2861 losetup -d $loopdev || true
2867 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2869 echo "== more mountpoints and symlinks ================="
2870 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2871 trap cleanup_test32_mount EXIT
2872 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2873 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2874 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2875 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2876 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2877 cleanup_test32_mount
2879 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2882 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2884 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2885 trap cleanup_test32_mount EXIT
2886 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2887 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2888 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2889 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2890 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2891 cleanup_test32_mount
2893 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2898 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2899 trap cleanup_test32_mount EXIT
2900 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2901 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2902 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2903 test_mkdir -p $DIR/$tdir/d2/test_dir
2904 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2905 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2906 cleanup_test32_mount
2908 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2913 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2914 trap cleanup_test32_mount EXIT
2915 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2916 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2917 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2918 test_mkdir -p $DIR/$tdir/d2/test_dir
2919 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2920 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2921 cleanup_test32_mount
2923 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2927 test_mkdir -p $DIR/$tdir/tmp
2928 local tmp_dir=$DIR/$tdir/tmp
2929 ln -s $DIR/$tdir $tmp_dir/symlink11
2930 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2931 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2932 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2934 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2938 test_mkdir -p $DIR/$tdir/tmp
2939 local tmp_dir=$DIR/$tdir/tmp
2940 ln -s $DIR/$tdir $tmp_dir/symlink11
2941 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2942 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2943 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2945 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2948 local tmp_dir=$DIR/$tdir/tmp
2949 test_mkdir -p $tmp_dir
2950 test_mkdir $DIR/${tdir}2
2951 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2952 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2953 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2954 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2955 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2956 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2958 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2961 rm -fr $DIR/$tdir $DIR/${tdir}2
2962 tmp_dir=$DIR/$tdir/tmp
2963 test_mkdir -p $tmp_dir
2964 test_mkdir $DIR/${tdir}2
2965 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2966 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2967 ls $tmp_dir/symlink12 || error "listing symlink12"
2968 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2970 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2973 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2975 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2976 trap cleanup_test32_mount EXIT
2977 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2978 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2979 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2980 touch $DIR/$tdir/test_file
2981 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2982 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2983 cleanup_test32_mount
2985 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2990 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2991 trap cleanup_test32_mount EXIT
2992 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2993 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2994 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2995 touch $DIR/$tdir/test_file
2996 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2997 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2998 cleanup_test32_mount
3000 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3003 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3006 trap cleanup_test32_mount EXIT
3007 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3008 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3009 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3010 test_mkdir -p $DIR/$tdir/d2
3011 touch $DIR/$tdir/d2/test_file || error "touch failed"
3012 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3013 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3014 cleanup_test32_mount
3016 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3019 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3022 trap cleanup_test32_mount EXIT
3023 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3024 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3025 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3026 test_mkdir -p $DIR/$tdir/d2
3027 touch $DIR/$tdir/d2/test_file || error "touch failed"
3028 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3029 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3030 cleanup_test32_mount
3032 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3036 test_mkdir -p $DIR/d32m/tmp
3037 TMP_DIR=$DIR/d32m/tmp
3038 ln -s $DIR $TMP_DIR/symlink11
3039 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3040 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3041 error "symlink11 not a link"
3042 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3043 error "symlink01 not a link"
3045 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3049 test_mkdir -p $DIR/d32n/tmp
3050 TMP_DIR=$DIR/d32n/tmp
3051 ln -s $DIR $TMP_DIR/symlink11
3052 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3053 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3054 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3056 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3060 test_mkdir -p $DIR/d32o/tmp
3061 TMP_DIR=$DIR/d32o/tmp
3062 ln -s $DIR/$tfile $TMP_DIR/symlink12
3063 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3064 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3065 error "symlink12 not a link"
3066 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3067 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3068 error "$DIR/d32o/tmp/symlink12 not file type"
3069 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3070 error "$DIR/d32o/symlink02 not file type"
3072 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3082 test_mkdir -p $DIR/d32p/tmp
3084 TMP_DIR=$DIR/d32p/tmp
3086 ln -s $DIR/$tfile $TMP_DIR/symlink12
3088 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3090 cat $DIR/d32p/tmp/symlink12 ||
3091 error "Can't open $DIR/d32p/tmp/symlink12"
3093 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3096 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3101 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3102 trap cleanup_test32_mount EXIT
3103 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3104 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3105 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3106 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3107 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3108 cleanup_test32_mount
3110 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3113 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3115 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3116 trap cleanup_test32_mount EXIT
3117 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3118 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3119 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3120 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3121 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3122 cleanup_test32_mount
3124 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3129 chmod 444 $DIR/$tfile
3130 chown $RUNAS_ID $DIR/$tfile
3132 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3135 run_test 33aa "write file with mode 444 (should return error)"
3139 test_mkdir $DIR/$tdir
3140 chown $RUNAS_ID $DIR/$tdir
3141 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3142 error "$RUNAS create $tdir/$tfile failed"
3143 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3144 error "open RDWR" || true
3146 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3150 test_mkdir $DIR/$tdir
3151 chown $RUNAS_ID $DIR/$tdir
3152 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3154 run_test 33b "test open file with malformed flags (No panic)"
3157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3158 remote_ost_nodsh && skip "remote OST with nodsh"
3167 test_mkdir $DIR/$tdir
3168 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3171 for ostnum in $(seq $OSTCOUNT); do
3172 # test-framework's OST numbering is one-based, while Lustre's
3174 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3175 # Parsing llobdstat's output sucks; we could grep the /proc
3176 # path, but that's likely to not be as portable as using the
3177 # llobdstat utility. So we parse lctl output instead.
3178 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3179 obdfilter/$ostname/stats |
3180 awk '/^write_bytes/ {print $7}' )
3181 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3182 if (( ${write_bytes:-0} > 0 ))
3189 $all_zeros || return 0
3192 echo foo > $DIR/$tdir/bar
3196 # Total up write_bytes after writing. We'd better find non-zeros.
3197 for ostnum in $(seq $OSTCOUNT); do
3198 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3199 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3200 obdfilter/$ostname/stats |
3201 awk '/^write_bytes/ {print $7}' )
3202 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3203 if (( ${write_bytes:-0} > 0 ))
3212 for ostnum in $(seq $OSTCOUNT); do
3213 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3214 echo "Check that write_bytes is present in obdfilter/*/stats:"
3215 do_facet ost$ostnum lctl get_param -n \
3216 obdfilter/$ostname/stats
3218 error "OST not keeping write_bytes stats (b22312)"
3221 run_test 33c "test llobdstat and write_bytes"
3224 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3225 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3228 local remote_dir=$DIR/$tdir/remote_dir
3230 test_mkdir $DIR/$tdir
3231 $LFS mkdir -i $MDTIDX $remote_dir ||
3232 error "create remote directory failed"
3234 touch $remote_dir/$tfile
3235 chmod 444 $remote_dir/$tfile
3236 chown $RUNAS_ID $remote_dir/$tfile
3238 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3240 chown $RUNAS_ID $remote_dir
3241 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3242 error "create" || true
3243 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3244 error "open RDWR" || true
3245 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3247 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3250 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3254 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3255 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3256 mkdir $DIR/$tdir/local_dir
3258 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3259 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3260 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3262 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3263 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3265 rmdir $DIR/$tdir/* || error "rmdir failed"
3268 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3269 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3270 mkdir $DIR/$tdir/local_dir
3272 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3273 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3274 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3276 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3277 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3279 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3282 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3283 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3284 mkdir $DIR/$tdir/local_dir
3286 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3287 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3288 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3290 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3291 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3293 run_test 33e "mkdir and striped directory should have same mode"
3297 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3301 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3302 remote_mds_nodsh && skip "remote MDS with nodsh"
3305 chmod go+rwx $DIR/$tdir
3306 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3307 trap cleanup_33f EXIT
3309 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3310 error "cannot create striped directory"
3312 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3313 error "cannot create files in striped directory"
3315 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3316 error "cannot remove files in striped directory"
3318 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3319 error "cannot remove striped directory"
3323 run_test 33f "nonroot user can create, access, and remove a striped directory"
3326 mkdir -p $DIR/$tdir/dir2
3328 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3330 [[ $err =~ "exists" ]] || error "Not exists error"
3332 run_test 33g "nonroot user create already existing root created file"
3334 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3337 $MCREATE $DIR/f34 || error "mcreate failed"
3338 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3339 error "getstripe failed"
3340 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3341 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3342 error "getstripe failed"
3343 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3344 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3346 run_test 34a "truncate file that has not been opened ==========="
3349 [ ! -f $DIR/f34 ] && test_34a
3350 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3351 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3352 $OPENFILE -f O_RDONLY $DIR/f34
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 34b "O_RDONLY opening file doesn't create objects ====="
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_RDWR $DIR/f34
3365 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3366 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3367 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3369 run_test 34c "O_RDWR opening file-with-size works =============="
3372 [ ! -f $DIR/f34 ] && test_34a
3373 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3375 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3376 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3379 run_test 34d "write to sparse file ============================="
3383 $MCREATE $DIR/f34e || error "mcreate failed"
3384 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3385 $CHECKSTAT -s 1000 $DIR/f34e ||
3386 error "Size of $DIR/f34e not equal to 1000 bytes"
3387 $OPENFILE -f O_RDWR $DIR/f34e
3388 $CHECKSTAT -s 1000 $DIR/f34e ||
3389 error "Size of $DIR/f34e not equal to 1000 bytes"
3391 run_test 34e "create objects, some with size and some without =="
3393 test_34f() { # bug 6242, 6243
3394 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3398 $MCREATE $DIR/f34f || error "mcreate failed"
3399 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3400 dd if=$DIR/f34f of=$TMP/f34f
3401 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3402 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3403 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3404 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3405 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3407 run_test 34f "read from a file with no objects until EOF ======="
3410 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3412 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3414 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3415 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3416 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3417 cancel_lru_locks osc
3418 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3419 error "wrong size after lock cancel"
3421 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3422 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3423 error "expanding truncate failed"
3424 cancel_lru_locks osc
3425 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3426 error "wrong expanded size after lock cancel"
3428 run_test 34g "truncate long file ==============================="
3431 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3436 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3437 sync # Flush the cache so that multiop below does not block on cache
3438 # flush when getting the group lock
3439 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3442 # Since just timed wait is not good enough, let's do a sync write
3443 # that way we are sure enough time for a roundtrip + processing
3444 # passed + 2 seconds of extra margin.
3445 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3449 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3450 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3454 local nsz=`stat -c %s $DIR/$tfile`
3455 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3457 run_test 34h "ftruncate file under grouplock should not block"
3460 cp /bin/sh $DIR/f35a
3462 chown $RUNAS_ID $DIR/f35a
3463 $RUNAS $DIR/f35a && error || true
3466 run_test 35a "exec file with mode 444 (should return and not leak)"
3470 utime $DIR/f36 || error "utime failed for MDS"
3472 run_test 36a "MDS utime check (mknod, utime)"
3476 utime $DIR/f36 || error "utime failed for OST"
3478 run_test 36b "OST utime check (open, utime)"
3483 chown $RUNAS_ID $DIR/d36
3484 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3486 run_test 36c "non-root MDS utime check (mknod, utime)"
3489 [ ! -d $DIR/d36 ] && test_36c
3490 echo "" > $DIR/d36/f36
3491 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3493 run_test 36d "non-root OST utime check (open, utime)"
3496 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3498 test_mkdir $DIR/$tdir
3499 touch $DIR/$tdir/$tfile
3500 $RUNAS utime $DIR/$tdir/$tfile &&
3501 error "utime worked, expected failure" || true
3503 run_test 36e "utime on non-owned file (should return error)"
3507 local LANG_SAVE=$LANG
3508 local LC_LANG_SAVE=$LC_LANG
3509 export LANG=C LC_LANG=C # for date language
3511 DATESTR="Dec 20 2000"
3512 test_mkdir $DIR/$tdir
3513 lctl set_param fail_loc=$fl
3515 cp /etc/hosts $DIR/$tdir/$tfile
3516 sync & # write RPC generated with "current" inode timestamp, but delayed
3518 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3519 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3520 cancel_lru_locks $OSC
3521 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3523 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3524 echo "BEFORE: $LS_BEFORE" && \
3525 echo "AFTER : $LS_AFTER" && \
3526 echo "WANT : $DATESTR" && \
3527 error "$DIR/$tdir/$tfile timestamps changed" || true
3529 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3535 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3536 subr_36fh "0x80000214"
3538 run_test 36f "utime on file racing with OST BRW write =========="
3541 remote_ost_nodsh && skip "remote OST with nodsh"
3542 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3543 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3544 skip "Need MDS version at least 2.12.51"
3549 local tgt="obdfilter"
3551 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3553 test_mkdir $DIR/$tdir
3554 fmd_max_age=$(do_facet $facet \
3555 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3558 echo "FMD max age: ${fmd_max_age}s"
3559 touch $DIR/$tdir/$tfile
3560 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3561 gawk '{cnt=cnt+$1} END{print cnt}')
3562 echo "FMD before: $fmd"
3564 error "FMD wasn't create by touch"
3565 sleep $((fmd_max_age + 12))
3566 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3567 gawk '{cnt=cnt+$1} END{print cnt}')
3568 echo "FMD after: $fmd"
3570 error "FMD wasn't expired by ping"
3572 run_test 36g "FMD cache expiry ====================="
3575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3577 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3578 subr_36fh "0x80000227"
3580 run_test 36h "utime on file racing with OST BRW write =========="
3583 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3585 test_mkdir $DIR/$tdir
3586 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3588 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3589 local new_mtime=$((mtime + 200))
3591 #change Modify time of striped dir
3592 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3593 error "change mtime failed"
3595 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3597 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3599 run_test 36i "change mtime on striped directory"
3601 # test_37 - duplicate with tests 32q 32r
3604 local file=$DIR/$tfile
3606 openfile -f O_DIRECTORY $file
3609 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3610 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3612 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3614 test_39a() { # was test_39
3616 touch $DIR/${tfile}2
3617 # ls -l $DIR/$tfile $DIR/${tfile}2
3618 # ls -lu $DIR/$tfile $DIR/${tfile}2
3619 # ls -lc $DIR/$tfile $DIR/${tfile}2
3621 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3622 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3624 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3626 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3628 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3629 error "O_TRUNC didn't change timestamps"
3632 run_test 39a "mtime changed on create"
3635 test_mkdir -c1 $DIR/$tdir
3636 cp -p /etc/passwd $DIR/$tdir/fopen
3637 cp -p /etc/passwd $DIR/$tdir/flink
3638 cp -p /etc/passwd $DIR/$tdir/funlink
3639 cp -p /etc/passwd $DIR/$tdir/frename
3640 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3643 echo "aaaaaa" >> $DIR/$tdir/fopen
3644 echo "aaaaaa" >> $DIR/$tdir/flink
3645 echo "aaaaaa" >> $DIR/$tdir/funlink
3646 echo "aaaaaa" >> $DIR/$tdir/frename
3648 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3649 local link_new=`stat -c %Y $DIR/$tdir/flink`
3650 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3651 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3653 cat $DIR/$tdir/fopen > /dev/null
3654 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3655 rm -f $DIR/$tdir/funlink2
3656 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3658 for (( i=0; i < 2; i++ )) ; do
3659 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3660 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3661 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3662 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3664 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3665 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3666 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3667 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3669 cancel_lru_locks $OSC
3670 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3673 run_test 39b "mtime change on open, link, unlink, rename ======"
3675 # this should be set to past
3676 TEST_39_MTIME=`date -d "1 year ago" +%s`
3682 local mtime0=`stat -c %Y $DIR1/$tfile`
3684 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3685 local mtime1=`stat -c %Y $DIR1/$tfile`
3686 [ "$mtime1" = $TEST_39_MTIME ] || \
3687 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3690 echo hello >> $DIR1/$tfile
3692 local mtime2=`stat -c %Y $DIR1/$tfile`
3693 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3694 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3696 mv $DIR1/$tfile $DIR1/$tfile-1
3698 for (( i=0; i < 2; i++ )) ; do
3699 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3700 [ "$mtime2" = "$mtime3" ] || \
3701 error "mtime ($mtime2) changed (to $mtime3) on rename"
3703 cancel_lru_locks $OSC
3704 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3707 run_test 39c "mtime change on rename ==========================="
3711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3714 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3716 for (( i=0; i < 2; i++ )) ; do
3717 local mtime=`stat -c %Y $DIR1/$tfile`
3718 [ $mtime = $TEST_39_MTIME ] || \
3719 error "mtime($mtime) is not set to $TEST_39_MTIME"
3721 cancel_lru_locks $OSC
3722 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3725 run_test 39d "create, utime, stat =============================="
3729 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3732 local mtime1=`stat -c %Y $DIR1/$tfile`
3734 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3736 for (( i=0; i < 2; i++ )) ; do
3737 local mtime2=`stat -c %Y $DIR1/$tfile`
3738 [ $mtime2 = $TEST_39_MTIME ] || \
3739 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3741 cancel_lru_locks $OSC
3742 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3745 run_test 39e "create, stat, utime, stat ========================"
3749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3752 mtime1=`stat -c %Y $DIR1/$tfile`
3755 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3757 for (( i=0; i < 2; i++ )) ; do
3758 local mtime2=`stat -c %Y $DIR1/$tfile`
3759 [ $mtime2 = $TEST_39_MTIME ] || \
3760 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3762 cancel_lru_locks $OSC
3763 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3766 run_test 39f "create, stat, sleep, utime, stat ================="
3770 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3772 echo hello >> $DIR1/$tfile
3773 local mtime1=`stat -c %Y $DIR1/$tfile`
3776 chmod o+r $DIR1/$tfile
3778 for (( i=0; i < 2; i++ )) ; do
3779 local mtime2=`stat -c %Y $DIR1/$tfile`
3780 [ "$mtime1" = "$mtime2" ] || \
3781 error "lost mtime: $mtime2, should be $mtime1"
3783 cancel_lru_locks $OSC
3784 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3787 run_test 39g "write, chmod, stat ==============================="
3791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3797 echo hello >> $DIR1/$tfile
3798 local mtime1=`stat -c %Y $DIR1/$tfile`
3800 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3802 if [ "$d1" != "$d2" ]; then
3803 echo "write and touch not within one second"
3805 for (( i=0; i < 2; i++ )) ; do
3806 local mtime2=`stat -c %Y $DIR1/$tfile`
3807 [ "$mtime2" = $TEST_39_MTIME ] || \
3808 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3810 cancel_lru_locks $OSC
3811 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3815 run_test 39h "write, utime within one second, stat ============="
3818 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3823 echo hello >> $DIR1/$tfile
3824 local mtime1=`stat -c %Y $DIR1/$tfile`
3826 mv $DIR1/$tfile $DIR1/$tfile-1
3828 for (( i=0; i < 2; i++ )) ; do
3829 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3831 [ "$mtime1" = "$mtime2" ] || \
3832 error "lost mtime: $mtime2, should be $mtime1"
3834 cancel_lru_locks $OSC
3835 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3838 run_test 39i "write, rename, stat =============================="
3841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3843 start_full_debug_logging
3847 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3848 lctl set_param fail_loc=0x80000412
3849 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3850 error "multiop failed"
3852 local mtime1=`stat -c %Y $DIR1/$tfile`
3854 mv $DIR1/$tfile $DIR1/$tfile-1
3856 kill -USR1 $multipid
3857 wait $multipid || error "multiop close failed"
3859 for (( i=0; i < 2; i++ )) ; do
3860 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3861 [ "$mtime1" = "$mtime2" ] ||
3862 error "mtime is lost on close: $mtime2, " \
3865 cancel_lru_locks $OSC
3866 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3868 lctl set_param fail_loc=0
3869 stop_full_debug_logging
3871 run_test 39j "write, rename, close, stat ======================="
3874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3879 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3881 local mtime1=`stat -c %Y $DIR1/$tfile`
3883 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3885 kill -USR1 $multipid
3886 wait $multipid || error "multiop close failed"
3888 for (( i=0; i < 2; i++ )) ; do
3889 local mtime2=`stat -c %Y $DIR1/$tfile`
3891 [ "$mtime2" = $TEST_39_MTIME ] || \
3892 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3894 cancel_lru_locks osc
3895 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3898 run_test 39k "write, utime, close, stat ========================"
3900 # this should be set to future
3901 TEST_39_ATIME=`date -d "1 year" +%s`
3904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3905 remote_mds_nodsh && skip "remote MDS with nodsh"
3907 local atime_diff=$(do_facet $SINGLEMDS \
3908 lctl get_param -n mdd.*MDT0000*.atime_diff)
3912 # test setting directory atime to future
3913 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3914 local atime=$(stat -c %X $DIR/$tdir)
3915 [ "$atime" = $TEST_39_ATIME ] ||
3916 error "atime is not set to future: $atime, $TEST_39_ATIME"
3918 # test setting directory atime from future to now
3919 local now=$(date +%s)
3920 touch -a -d @$now $DIR/$tdir
3922 atime=$(stat -c %X $DIR/$tdir)
3923 [ "$atime" -eq "$now" ] ||
3924 error "atime is not updated from future: $atime, $now"
3926 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3929 # test setting directory atime when now > dir atime + atime_diff
3930 local d1=$(date +%s)
3932 local d2=$(date +%s)
3933 cancel_lru_locks mdc
3934 atime=$(stat -c %X $DIR/$tdir)
3935 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3936 error "atime is not updated : $atime, should be $d2"
3938 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3941 # test not setting directory atime when now < dir atime + atime_diff
3943 cancel_lru_locks mdc
3944 atime=$(stat -c %X $DIR/$tdir)
3945 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3946 error "atime is updated to $atime, should remain $d1<atime<$d2"
3948 do_facet $SINGLEMDS \
3949 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3951 run_test 39l "directory atime update ==========================="
3954 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3958 local far_past_mtime=$(date -d "May 29 1953" +%s)
3959 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3961 touch -m -d @$far_past_mtime $DIR1/$tfile
3962 touch -a -d @$far_past_atime $DIR1/$tfile
3964 for (( i=0; i < 2; i++ )) ; do
3965 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3966 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3967 error "atime or mtime set incorrectly"
3969 cancel_lru_locks $OSC
3970 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3973 run_test 39m "test atime and mtime before 1970"
3975 test_39n() { # LU-3832
3976 remote_mds_nodsh && skip "remote MDS with nodsh"
3978 local atime_diff=$(do_facet $SINGLEMDS \
3979 lctl get_param -n mdd.*MDT0000*.atime_diff)
3984 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3987 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3988 atime0=$(stat -c %X $DIR/$tfile)
3991 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3992 atime1=$(stat -c %X $DIR/$tfile)
3995 cancel_lru_locks mdc
3996 cancel_lru_locks osc
3997 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3998 atime2=$(stat -c %X $DIR/$tfile)
4000 do_facet $SINGLEMDS \
4001 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4003 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4004 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4006 run_test 39n "check that O_NOATIME is honored"
4009 TESTDIR=$DIR/$tdir/$tfile
4010 [ -e $TESTDIR ] && rm -rf $TESTDIR
4017 links2=$(stat -c %h .)
4018 [ $(($links1 + 2)) != $links2 ] &&
4019 error "wrong links count $(($links1 + 2)) != $links2"
4021 links3=$(stat -c %h .)
4022 [ $(($links1 + 1)) != $links3 ] &&
4023 error "wrong links count $links1 != $links3"
4026 run_test 39o "directory cached attributes updated after create"
4029 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4032 TESTDIR=$DIR/$tdir/$tdir
4033 [ -e $TESTDIR ] && rm -rf $TESTDIR
4034 test_mkdir -p $TESTDIR
4038 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4039 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4041 links2=$(stat -c %h .)
4042 [ $(($links1 + 2)) != $links2 ] &&
4043 error "wrong links count $(($links1 + 2)) != $links2"
4045 links3=$(stat -c %h .)
4046 [ $(($links1 + 1)) != $links3 ] &&
4047 error "wrong links count $links1 != $links3"
4050 run_test 39p "remote directory cached attributes updated after create ========"
4053 test_39q() { # LU-8041
4054 local testdir=$DIR/$tdir
4056 multiop_bg_pause $testdir D_c || error "multiop failed"
4058 cancel_lru_locks mdc
4059 kill -USR1 $multipid
4060 local atime=$(stat -c %X $testdir)
4061 [ "$atime" -ne 0 ] || error "atime is zero"
4063 run_test 39q "close won't zero out atime"
4066 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4067 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4068 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4069 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4070 error "$tfile is not 4096 bytes in size"
4072 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4076 small_write $DIR/f41 18
4078 run_test 41 "test small file write + fstat ====================="
4080 count_ost_writes() {
4081 lctl get_param -n ${OSC}.*.stats |
4082 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4083 END { printf("%0.0f", writes) }'
4090 BG_DIRTY_RATIO_SAVE=10
4091 MAX_BG_DIRTY_RATIO=25
4095 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4096 # dirty_ratio, dirty_background_ratio
4097 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4098 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4099 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4100 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4102 # if file not here, we are a 2.4 kernel
4103 kill -CONT `pidof kupdated`
4108 # setup the trap first, so someone cannot exit the test at the
4109 # exact wrong time and mess up a machine
4110 trap start_writeback EXIT
4111 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4112 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4113 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4114 sysctl -w vm.dirty_writeback_centisecs=0
4115 sysctl -w vm.dirty_writeback_centisecs=0
4116 # save and increase /proc/sys/vm/dirty_ratio
4117 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4118 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4119 # save and increase /proc/sys/vm/dirty_background_ratio
4120 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4121 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4123 # if file not here, we are a 2.4 kernel
4124 kill -STOP `pidof kupdated`
4128 # ensure that all stripes have some grant before we test client-side cache
4130 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4131 dd if=/dev/zero of=$i bs=4k count=1
4136 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4137 # file truncation, and file removal.
4139 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4142 cancel_lru_locks $OSC
4144 sync; sleep 1; sync # just to be safe
4145 BEFOREWRITES=`count_ost_writes`
4146 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4147 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4148 AFTERWRITES=`count_ost_writes`
4149 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4150 error "$BEFOREWRITES < $AFTERWRITES"
4153 run_test 42a "ensure that we don't flush on close"
4156 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4159 cancel_lru_locks $OSC
4162 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4163 BEFOREWRITES=$(count_ost_writes)
4164 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4165 AFTERWRITES=$(count_ost_writes)
4166 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4167 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4169 BEFOREWRITES=$(count_ost_writes)
4170 sync || error "sync: $?"
4171 AFTERWRITES=$(count_ost_writes)
4172 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4173 error "$BEFOREWRITES < $AFTERWRITES on sync"
4175 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4179 run_test 42b "test destroy of file with cached dirty data ======"
4181 # if these tests just want to test the effect of truncation,
4182 # they have to be very careful. consider:
4183 # - the first open gets a {0,EOF}PR lock
4184 # - the first write conflicts and gets a {0, count-1}PW
4185 # - the rest of the writes are under {count,EOF}PW
4186 # - the open for truncate tries to match a {0,EOF}PR
4187 # for the filesize and cancels the PWs.
4188 # any number of fixes (don't get {0,EOF} on open, match
4189 # composite locks, do smarter file size management) fix
4190 # this, but for now we want these tests to verify that
4191 # the cancellation with truncate intent works, so we
4192 # start the file with a full-file pw lock to match against
4193 # until the truncate.
4198 cancel_lru_locks $OSC
4200 # prime the file with 0,EOF PW to match
4204 # now the real test..
4205 dd if=/dev/zero of=$file bs=1024 count=100
4206 BEFOREWRITES=`count_ost_writes`
4207 $TRUNCATE $file $offset
4208 cancel_lru_locks $OSC
4209 AFTERWRITES=`count_ost_writes`
4214 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4217 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4218 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4221 run_test 42c "test partial truncate of file with cached dirty data"
4224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4227 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4228 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4231 run_test 42d "test complete truncate of file with cached dirty data"
4233 test_42e() { # bug22074
4234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4236 local TDIR=$DIR/${tdir}e
4237 local pages=16 # hardcoded 16 pages, don't change it.
4238 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4239 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4243 test_mkdir $DIR/${tdir}e
4244 $SETSTRIPE -c 1 $TDIR
4245 createmany -o $TDIR/f $files
4247 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4249 # we assume that with $OSTCOUNT files, at least one of them will
4250 # be allocated on OST0.
4251 warmup_files=$((OSTCOUNT * max_dirty_mb))
4252 createmany -o $TDIR/w $warmup_files
4254 # write a large amount of data into one file and sync, to get good
4255 # avail_grant number from OST.
4256 for ((i=0; i<$warmup_files; i++)); do
4257 idx=$($GETSTRIPE -i $TDIR/w$i)
4258 [ $idx -ne 0 ] && continue
4259 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4262 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4264 $LCTL get_param $proc_osc0/cur_dirty_bytes
4265 $LCTL get_param $proc_osc0/cur_grant_bytes
4267 # create as much dirty pages as we can while not to trigger the actual
4268 # RPCs directly. but depends on the env, VFS may trigger flush during this
4269 # period, hopefully we are good.
4270 for ((i=0; i<$warmup_files; i++)); do
4271 idx=$($GETSTRIPE -i $TDIR/w$i)
4272 [ $idx -ne 0 ] && continue
4273 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4275 $LCTL get_param $proc_osc0/cur_dirty_bytes
4276 $LCTL get_param $proc_osc0/cur_grant_bytes
4278 # perform the real test
4279 $LCTL set_param $proc_osc0/rpc_stats 0
4280 for ((;i<$files; i++)); do
4281 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
4282 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4285 $LCTL get_param $proc_osc0/rpc_stats
4288 local have_ppr=false
4289 $LCTL get_param $proc_osc0/rpc_stats |
4290 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4291 # skip lines until we are at the RPC histogram data
4292 [ "$PPR" == "pages" ] && have_ppr=true && continue
4293 $have_ppr || continue
4295 # we only want the percent stat for < 16 pages
4296 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4298 percent=$((percent + WPCT))
4299 if [[ $percent -gt 15 ]]; then
4300 error "less than 16-pages write RPCs" \
4307 run_test 42e "verify sub-RPC writes are not done synchronously"
4309 test_43A() { # was test_43
4310 test_mkdir $DIR/$tdir
4311 cp -p /bin/ls $DIR/$tdir/$tfile
4312 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4314 # give multiop a chance to open
4317 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4320 run_test 43A "execution of file opened for write should return -ETXTBSY"
4323 test_mkdir $DIR/$tdir
4324 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4325 $DIR/$tdir/sleep 60 &
4327 # Make sure exec of $tdir/sleep wins race with truncate
4329 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4332 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4337 test_mkdir $DIR/$tdir
4338 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4339 $DIR/$tdir/sleep 60 &
4341 # Make sure exec of $tdir/sleep wins race with truncate
4343 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4346 run_test 43b "truncate of file being executed should return -ETXTBSY"
4349 local testdir="$DIR/$tdir"
4352 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4353 ( cd $testdir && md5sum -c )
4355 run_test 43c "md5sum of copy into lustre"
4357 test_44A() { # was test_44
4358 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4360 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4361 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4363 run_test 44A "zero length read from a sparse stripe"
4366 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4368 [ -z "$nstripe" ] && skip "can't get stripe info"
4369 [[ $nstripe -gt $OSTCOUNT ]] &&
4370 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4372 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4374 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4375 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4379 OFFSETS="0 $((stride/2)) $((stride-1))"
4380 for offset in $OFFSETS; do
4381 for i in $(seq 0 $((nstripe-1))); do
4382 local GLOBALOFFSETS=""
4384 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4385 local myfn=$DIR/d44a-$size
4386 echo "--------writing $myfn at $size"
4387 ll_sparseness_write $myfn $size ||
4388 error "ll_sparseness_write"
4389 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4390 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4391 error "ll_sparseness_verify $GLOBALOFFSETS"
4393 for j in $(seq 0 $((nstripe-1))); do
4395 size=$((((j + $nstripe )*$stride + $offset)))
4396 ll_sparseness_write $myfn $size ||
4397 error "ll_sparseness_write"
4398 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4400 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4401 error "ll_sparseness_verify $GLOBALOFFSETS"
4406 run_test 44a "test sparse pwrite ==============================="
4410 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4416 before=`dirty_osc_total`
4417 echo executing "\"$*\""
4419 after=`dirty_osc_total`
4420 echo before $before, after $after
4423 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4426 # Obtain grants from OST if it supports it
4427 echo blah > ${f}_grant
4430 do_dirty_record "echo blah > $f"
4431 [[ $before -eq $after ]] && error "write wasn't cached"
4432 do_dirty_record "> $f"
4433 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4434 do_dirty_record "echo blah > $f"
4435 [[ $before -eq $after ]] && error "write wasn't cached"
4436 do_dirty_record "sync"
4437 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4438 do_dirty_record "echo blah > $f"
4439 [[ $before -eq $after ]] && error "write wasn't cached"
4440 do_dirty_record "cancel_lru_locks osc"
4441 [[ $before -gt $after ]] ||
4442 error "lock cancellation didn't lower dirty count"
4445 run_test 45 "osc io page accounting ============================"
4447 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4448 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4449 # objects offset and an assert hit when an rpc was built with 1023's mapped
4450 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4452 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4457 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4459 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4460 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4464 run_test 46 "dirtying a previously written page ================"
4466 # test_47 is removed "Device nodes check" is moved to test_28
4468 test_48a() { # bug 2399
4469 [ "$mds1_FSTYPE" = "zfs" ] &&
4470 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4471 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4473 test_mkdir $DIR/$tdir
4475 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4476 test_mkdir $DIR/$tdir
4477 touch foo || error "'touch foo' failed after recreating cwd"
4479 touch .foo || error "'touch .foo' failed after recreating cwd"
4481 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4482 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4483 cd . || error "'cd .' failed after recreating cwd"
4484 mkdir . && error "'mkdir .' worked after recreating cwd"
4485 rmdir . && error "'rmdir .' worked after recreating cwd"
4486 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4487 cd .. || error "'cd ..' failed after recreating cwd"
4489 run_test 48a "Access renamed working dir (should return errors)="
4491 test_48b() { # bug 2399
4493 test_mkdir $DIR/$tdir
4495 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4496 touch foo && error "'touch foo' worked after removing cwd"
4497 mkdir foo && error "'mkdir foo' worked after removing cwd"
4498 touch .foo && error "'touch .foo' worked after removing cwd"
4499 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4500 ls . > /dev/null && error "'ls .' worked after removing cwd"
4501 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4502 mkdir . && error "'mkdir .' worked after removing cwd"
4503 rmdir . && error "'rmdir .' worked after removing cwd"
4504 ln -s . foo && error "'ln -s .' worked after removing cwd"
4505 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4507 run_test 48b "Access removed working dir (should return errors)="
4509 test_48c() { # bug 2350
4510 #lctl set_param debug=-1
4513 test_mkdir -p $DIR/$tdir/dir
4515 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4516 $TRACE touch foo && error "touch foo worked after removing cwd"
4517 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4518 touch .foo && error "touch .foo worked after removing cwd"
4519 mkdir .foo && error "mkdir .foo worked after removing cwd"
4520 $TRACE ls . && error "'ls .' worked after removing cwd"
4521 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4522 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4523 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4524 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4525 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4527 run_test 48c "Access removed working subdir (should return errors)"
4529 test_48d() { # bug 2350
4530 #lctl set_param debug=-1
4533 test_mkdir -p $DIR/$tdir/dir
4535 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4536 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4537 $TRACE touch foo && error "'touch foo' worked after removing parent"
4538 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4539 touch .foo && error "'touch .foo' worked after removing parent"
4540 mkdir .foo && error "mkdir .foo worked after removing parent"
4541 $TRACE ls . && error "'ls .' worked after removing parent"
4542 $TRACE ls .. && error "'ls ..' worked after removing parent"
4543 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4544 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4545 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4548 run_test 48d "Access removed parent subdir (should return errors)"
4550 test_48e() { # bug 4134
4551 #lctl set_param debug=-1
4554 test_mkdir -p $DIR/$tdir/dir
4556 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4557 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4558 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4559 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4560 # On a buggy kernel addition of "touch foo" after cd .. will
4561 # produce kernel oops in lookup_hash_it
4562 touch ../foo && error "'cd ..' worked after recreate parent"
4564 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4566 run_test 48e "Access to recreated parent subdir (should return errors)"
4568 test_49() { # LU-1030
4569 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4570 remote_ost_nodsh && skip "remote OST with nodsh"
4572 # get ost1 size - lustre-OST0000
4573 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4575 # write 800M at maximum
4576 [[ $ost1_size -lt 2 ]] && ost1_size=2
4577 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4579 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4580 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4583 # change max_pages_per_rpc while writing the file
4584 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4585 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4586 # loop until dd process exits
4587 while ps ax -opid | grep -wq $dd_pid; do
4588 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4589 sleep $((RANDOM % 5 + 1))
4591 # restore original max_pages_per_rpc
4592 $LCTL set_param $osc1_mppc=$orig_mppc
4593 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4595 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4599 test_mkdir $DIR/$tdir
4601 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4603 run_test 50 "special situations: /proc symlinks ==============="
4605 test_51a() { # was test_51
4606 # bug 1516 - create an empty entry right after ".." then split dir
4607 test_mkdir -c1 $DIR/$tdir
4608 touch $DIR/$tdir/foo
4609 $MCREATE $DIR/$tdir/bar
4611 createmany -m $DIR/$tdir/longfile 201
4613 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4614 $MCREATE $DIR/$tdir/longfile$FNUM
4619 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4621 run_test 51a "special situations: split htree with empty entry =="
4623 cleanup_print_lfs_df () {
4630 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4632 local dir=$DIR/$tdir
4633 local nrdirs=$((65536 + 100))
4635 # cleanup the directory
4642 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4643 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4644 [[ $numfree -lt $nrdirs ]] &&
4645 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4647 # need to check free space for the directories as well
4648 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4649 numfree=$(( blkfree / $(fs_inode_ksize) ))
4650 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4652 trap cleanup_print_lfs_df EXIT
4655 createmany -d $dir/d $nrdirs || {
4656 unlinkmany $dir/d $nrdirs
4657 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4661 nrdirs=$(ls -U $dir | wc -l)
4663 # unlink all but 100 subdirectories, then check it still works
4665 local delete=$((nrdirs - left))
4670 # for ldiskfs the nlink count should be 1, but this is OSD specific
4671 # and so this is listed for informational purposes only
4672 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4673 unlinkmany -d $dir/d $delete ||
4674 error "unlink of first $delete subdirs failed"
4676 echo "nlink between: $(stat -c %h $dir)"
4677 local found=$(ls -U $dir | wc -l)
4678 [ $found -ne $left ] &&
4679 error "can't find subdirs: found only $found, expected $left"
4681 unlinkmany -d $dir/d $delete $left ||
4682 error "unlink of second $left subdirs failed"
4683 # regardless of whether the backing filesystem tracks nlink accurately
4684 # or not, the nlink count shouldn't be more than "." and ".." here
4685 local after=$(stat -c %h $dir)
4686 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4687 echo "nlink after: $after"
4689 cleanup_print_lfs_df
4691 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4694 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4695 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4697 test_mkdir $DIR/$tdir
4698 createmany -o $DIR/$tdir/t- 1000
4699 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4700 for N in $(seq 0 $((OSTCOUNT - 1))); do
4701 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4702 END { printf("%0.0f", objs) }' $TMP/$tfile)
4703 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4704 '($1 == '$N') { objs += 1 } \
4705 END { printf("%0.0f", objs) }')
4706 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4708 unlinkmany $DIR/$tdir/t- 1000
4711 for N in $(seq 1 $((OSTCOUNT - 1))); do
4712 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4713 error "OST $N has less objects vs OST $NLAST" \
4714 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4715 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4716 error "OST $N has less objects vs OST $NLAST" \
4717 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4719 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4720 error "OST $N has less #0 objects vs OST $NLAST" \
4721 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4722 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4723 error "OST $N has less #0 objects vs OST $NLAST" \
4724 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4729 run_test 51d "check object distribution"
4732 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4733 skip_env "ldiskfs only test"
4736 test_mkdir -c1 $DIR/$tdir
4737 test_mkdir -c1 $DIR/$tdir/d0
4739 touch $DIR/$tdir/d0/foo
4740 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4741 error "file exceed 65000 nlink limit!"
4742 unlinkmany $DIR/$tdir/d0/f- 65001
4745 run_test 51e "check file nlink limit"
4748 test_mkdir $DIR/$tdir
4751 local ulimit_old=$(ulimit -n)
4752 local spare=20 # number of spare fd's for scripts/libraries, etc.
4753 local mdt=$($LFS getstripe -m $DIR/$tdir)
4754 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4756 echo "MDT$mdt numfree=$numfree, max=$max"
4757 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4758 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4759 while ! ulimit -n $((numfree + spare)); do
4760 numfree=$((numfree * 3 / 4))
4762 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4764 echo "left ulimit at $ulimit_old"
4767 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4768 unlinkmany $DIR/$tdir/f $numfree
4769 error "create+open $numfree files in $DIR/$tdir failed"
4771 ulimit -n $ulimit_old
4773 # if createmany exits at 120s there will be fewer than $numfree files
4774 unlinkmany $DIR/$tdir/f $numfree || true
4776 run_test 51f "check many open files limit"
4779 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4780 test_mkdir $DIR/$tdir
4781 touch $DIR/$tdir/foo
4782 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4783 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4784 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4785 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4786 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4788 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4789 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4790 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4792 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4793 cp -r $DIR/$tdir $TMP/
4794 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4796 run_test 52a "append-only flag test (should return errors)"
4799 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4800 test_mkdir $DIR/$tdir
4801 touch $DIR/$tdir/foo
4802 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4803 cat test > $DIR/$tdir/foo && error "cat test worked"
4804 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4805 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4806 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4808 echo foo >> $DIR/$tdir/foo && error "echo worked"
4809 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4810 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4811 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4812 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4814 chattr -i $DIR/$tdir/foo || error "chattr failed"
4816 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4818 run_test 52b "immutable flag test (should return errors) ======="
4821 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4822 remote_mds_nodsh && skip "remote MDS with nodsh"
4823 remote_ost_nodsh && skip "remote OST with nodsh"
4836 local support_last_seq=true
4838 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
4839 support_last_seq=false
4842 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4844 for value in $(do_facet $SINGLEMDS \
4845 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
4846 param=$(echo ${value[0]} | cut -d "=" -f1)
4847 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4849 if $support_last_seq; then
4850 param_seq=$(echo $param |
4851 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4852 mds_last_seq=$(do_facet $SINGLEMDS \
4853 $LCTL get_param -n $param_seq)
4855 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4857 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4858 node=$(facet_active_host ost$((ostnum+1)))
4859 param="obdfilter.$ostname.last_id"
4860 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4861 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4862 ost_last_id=$ost_last
4864 if $support_last_seq; then
4865 ost_last_id=$(echo $ost_last |
4866 awk -F':' '{print $2}' |
4868 ost_last_seq=$(echo $ost_last |
4869 awk -F':' '{print $1}')
4870 [[ $ost_last_seq = $mds_last_seq ]] || continue
4873 if [[ $ost_last_id != $mds_last ]]; then
4874 error "$ost_last_id != $mds_last"
4881 $found || error "can not match last_seq/last_id for $mdtosc"
4884 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4887 perl -MSocket -e ';' || skip "no Socket perl module installed"
4889 $SOCKETSERVER $DIR/socket ||
4890 error "$SOCKETSERVER $DIR/socket failed: $?"
4891 $SOCKETCLIENT $DIR/socket ||
4892 error "$SOCKETCLIENT $DIR/socket failed: $?"
4893 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4895 run_test 54a "unix domain socket test =========================="
4901 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
4903 run_test 54b "char device works in lustre ======================"
4906 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4907 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4908 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4910 for i in $(seq 3 7); do
4911 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4920 loopdev="$DIR/loop54c"
4923 $UMOUNT $DIR/$tdir || rc=$?
4924 losetup -d $loopdev || true
4925 losetup -d $LOOPDEV || true
4926 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4931 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4933 loopdev="$DIR/loop54c"
4936 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
4937 trap cleanup_54c EXIT
4938 mknod $loopdev b 7 $LOOPNUM
4939 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4940 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
4941 losetup $loopdev $DIR/$tfile ||
4942 error "can't set up $loopdev for $DIR/$tfile"
4943 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4944 test_mkdir $DIR/$tdir
4945 mount -t ext2 $loopdev $DIR/$tdir ||
4946 error "error mounting $loopdev on $DIR/$tdir"
4947 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
4950 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
4954 run_test 54c "block device works in lustre ====================="
4960 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4962 run_test 54d "fifo device works in lustre ======================"
4967 cp -aL /dev/console $f
4968 echo $string > $f || error "echo $string to $f failed"
4970 run_test 54e "console/tty device works in lustre ======================"
4974 local dir=$DIR/$tdir
4977 test_mkdir -p $dir/dir
4978 for i in $(seq $numfiles); do
4980 touch $dir/dir/file$i
4983 local numcomp=$($LFS getstripe --component-count $dir)
4985 [[ $numcomp == 0 ]] && numcomp=1
4987 # test lfs getstripe with --recursive
4988 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
4990 [[ $filenum -eq $((numfiles * 2)) ]] ||
4991 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
4992 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
4993 [[ $filenum -eq $numfiles ]] ||
4994 error "$LFS getstripe $dir: found $filenum, not $numfiles"
4995 echo "$LFS getstripe showed obdidx or l_ost_idx"
4997 # test lfs getstripe with file instead of dir
4998 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
4999 [[ $filenum -eq 1 ]] ||
5000 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5001 echo "$LFS getstripe file1 passed"
5003 #test lfs getstripe with --verbose
5004 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5005 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5006 error "$LFS getstripe --verbose $dir: "\
5007 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5008 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5009 error "$LFS getstripe $dir: showed lmm_magic"
5011 #test lfs getstripe with -v prints lmm_fid
5012 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5013 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5014 error "$LFS getstripe -v $dir: "\
5015 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5016 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5017 error "$LFS getstripe $dir: showed lmm_fid by default"
5018 echo "$LFS getstripe --verbose passed"
5020 #check for FID information
5021 local fid1=$($LFS getstripe --fid $dir/file1)
5022 local fid2=$($LFS getstripe --verbose $dir/file1 |
5023 awk '/lmm_fid: / { print $2; exit; }')
5024 local fid3=$($LFS path2fid $dir/file1)
5026 [ "$fid1" != "$fid2" ] &&
5027 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5028 [ "$fid1" != "$fid3" ] &&
5029 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5030 echo "$LFS getstripe --fid passed"
5032 #test lfs getstripe with --obd
5033 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5034 error "$LFS getstripe --obd wrong_uuid: should return error"
5036 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5039 local obduuid=$(ostuuid_from_index $ostidx)
5040 local found=$($LFS getstripe -r --obd $obduuid $dir |
5041 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5043 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5044 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5046 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5049 [[ $found -eq $filenum ]] ||
5050 error "$LFS getstripe --obd: found $found expect $filenum"
5051 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5052 sed '/^[ ]*'${ostidx}'[ ]/d' |
5053 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5054 error "$LFS getstripe --obd: should not show file on other obd"
5055 echo "$LFS getstripe --obd passed"
5057 run_test 56a "check $LFS getstripe"
5060 local dir=$DIR/$tdir
5064 for i in $(seq $numdirs); do
5065 test_mkdir $dir/dir$i
5068 # test lfs getdirstripe default mode is non-recursion, which is
5069 # different from lfs getstripe
5070 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5072 [[ $dircnt -eq 1 ]] ||
5073 error "$LFS getdirstripe: found $dircnt, not 1"
5074 dircnt=$($LFS getdirstripe --recursive $dir |
5075 grep -c lmv_stripe_count)
5076 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5077 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5079 run_test 56b "check $LFS getdirstripe"
5082 remote_ost_nodsh && skip "remote OST with nodsh"
5085 local ost_name=$(ostname_from_index $ost_idx)
5086 local old_status=$(ost_dev_status $ost_idx)
5088 [[ -z "$old_status" ]] ||
5089 skip_env "OST $ost_name is in $old_status status"
5091 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5092 [[ $OST1_VERSION -ge $(version_code 2.12.3) ]] && do_facet ost1 \
5093 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
5096 local new_status=$(ost_dev_status $ost_idx)
5098 [[ "$new_status" =~ "D" ]] ||
5099 error "$ost_name status is '$new_status', missing 'D'"
5100 if [[ $OST1_VERSION -ge $(version_code 2.12.3) ]]; then
5101 [[ "$new_status" =~ "N" ]] ||
5102 error "$ost_name status is '$new_status', missing 'N'"
5105 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5106 [[ $OST1_VERSION -ge $(version_code 2.12.3) ]] && do_facet ost1 \
5107 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
5110 new_status=$(ost_dev_status $ost_idx)
5111 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
5112 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
5114 run_test 56c "check 'lfs df' showing device status"
5119 local local_tdir="$1"
5120 local local_numfiles="$2"
5121 local local_numdirs="$3"
5122 local dir_params="$4"
5123 local dir_stripe_params="$5"
5125 if [ ! -d "$local_tdir" ] ; then
5126 test_mkdir -p $dir_stripe_params $local_tdir
5127 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5128 for i in $(seq $local_numfiles) ; do
5129 touch $local_tdir/file$i
5131 for i in $(seq $local_numdirs) ; do
5132 test_mkdir $dir_stripe_params $local_tdir/dir$i
5133 for j in $(seq $local_numfiles) ; do
5134 touch $local_tdir/dir$i/file$j
5140 setup_56_special() {
5142 local local_numfiles=$2
5143 local local_numdirs=$3
5145 setup_56 $local_tdir $local_numfiles $local_numdirs
5147 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5148 for i in $(seq $local_numfiles) ; do
5149 mknod $local_tdir/loop${i}b b 7 $i
5150 mknod $local_tdir/null${i}c c 1 3
5151 ln -s $local_tdir/file1 $local_tdir/link${i}
5153 for i in $(seq $local_numdirs) ; do
5154 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5155 mknod $local_tdir/dir$i/null${i}c c 1 3
5156 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5162 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5163 local expected=$(($NUMDIRS + 2))
5165 setup_56 $dir $NUMFILES $NUMDIRS
5167 # test lfs find with -name
5168 for i in $(seq $NUMFILES) ; do
5169 local nums=$($LFS find -name "*$i" $dir | wc -l)
5171 [ $nums -eq $expected ] ||
5172 error "lfs find -name '*$i' $dir wrong: "\
5173 "found $nums, expected $expected"
5176 run_test 56g "check lfs find -name"
5179 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5180 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5182 setup_56 $dir $NUMFILES $NUMDIRS
5184 # test lfs find with ! -name
5185 for i in $(seq $NUMFILES) ; do
5186 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5188 [ $nums -eq $expected ] ||
5189 error "lfs find ! -name '*$i' $dir wrong: "\
5190 "found $nums, expected $expected"
5193 run_test 56h "check lfs find ! -name"
5196 local dir=$DIR/$tdir
5200 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5203 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5205 run_test 56i "check 'lfs find -ost UUID' skips directories"
5208 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5210 setup_56_special $dir $NUMFILES $NUMDIRS
5212 local expected=$((NUMDIRS + 1))
5213 local cmd="$LFS find -type d $dir"
5214 local nums=$($cmd | wc -l)
5216 [ $nums -eq $expected ] ||
5217 error "'$cmd' wrong: found $nums, expected $expected"
5219 run_test 56j "check lfs find -type d"
5222 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5224 setup_56_special $dir $NUMFILES $NUMDIRS
5226 local expected=$(((NUMDIRS + 1) * NUMFILES))
5227 local cmd="$LFS find -type f $dir"
5228 local nums=$($cmd | wc -l)
5230 [ $nums -eq $expected ] ||
5231 error "'$cmd' wrong: found $nums, expected $expected"
5233 run_test 56k "check lfs find -type f"
5236 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5238 setup_56_special $dir $NUMFILES $NUMDIRS
5240 local expected=$((NUMDIRS + NUMFILES))
5241 local cmd="$LFS find -type b $dir"
5242 local nums=$($cmd | wc -l)
5244 [ $nums -eq $expected ] ||
5245 error "'$cmd' wrong: found $nums, expected $expected"
5247 run_test 56l "check lfs find -type b"
5250 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5252 setup_56_special $dir $NUMFILES $NUMDIRS
5254 local expected=$((NUMDIRS + NUMFILES))
5255 local cmd="$LFS find -type c $dir"
5256 local nums=$($cmd | wc -l)
5257 [ $nums -eq $expected ] ||
5258 error "'$cmd' wrong: found $nums, expected $expected"
5260 run_test 56m "check lfs find -type c"
5263 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 l $dir"
5268 local nums=$($cmd | wc -l)
5270 [ $nums -eq $expected ] ||
5271 error "'$cmd' wrong: found $nums, expected $expected"
5273 run_test 56n "check lfs find -type l"
5276 local dir=$DIR/$tdir
5278 setup_56 $dir $NUMFILES $NUMDIRS
5279 utime $dir/file1 > /dev/null || error "utime (1)"
5280 utime $dir/file2 > /dev/null || error "utime (2)"
5281 utime $dir/dir1 > /dev/null || error "utime (3)"
5282 utime $dir/dir2 > /dev/null || error "utime (4)"
5283 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5284 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5287 local nums=$($LFS find -mtime +0 $dir | wc -l)
5289 [ $nums -eq $expected ] ||
5290 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5293 cmd="$LFS find -mtime 0 $dir"
5294 nums=$($cmd | wc -l)
5295 [ $nums -eq $expected ] ||
5296 error "'$cmd' wrong: found $nums, expected $expected"
5298 run_test 56o "check lfs find -mtime for old files"
5301 [ $RUNAS_ID -eq $UID ] &&
5302 skip_env "RUNAS_ID = UID = $UID -- skipping"
5304 local dir=$DIR/$tdir
5306 setup_56 $dir $NUMFILES $NUMDIRS
5307 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5309 local expected=$NUMFILES
5310 local cmd="$LFS find -uid $RUNAS_ID $dir"
5311 local nums=$($cmd | wc -l)
5313 [ $nums -eq $expected ] ||
5314 error "'$cmd' wrong: found $nums, expected $expected"
5316 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5317 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5318 nums=$($cmd | wc -l)
5319 [ $nums -eq $expected ] ||
5320 error "'$cmd' wrong: found $nums, expected $expected"
5322 run_test 56p "check lfs find -uid and ! -uid"
5325 [ $RUNAS_ID -eq $UID ] &&
5326 skip_env "RUNAS_ID = UID = $UID -- skipping"
5328 local dir=$DIR/$tdir
5330 setup_56 $dir $NUMFILES $NUMDIRS
5331 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5333 local expected=$NUMFILES
5334 local cmd="$LFS find -gid $RUNAS_GID $dir"
5335 local nums=$($cmd | wc -l)
5337 [ $nums -eq $expected ] ||
5338 error "'$cmd' wrong: found $nums, expected $expected"
5340 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5341 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5342 nums=$($cmd | wc -l)
5343 [ $nums -eq $expected ] ||
5344 error "'$cmd' wrong: found $nums, expected $expected"
5346 run_test 56q "check lfs find -gid and ! -gid"
5349 local dir=$DIR/$tdir
5351 setup_56 $dir $NUMFILES $NUMDIRS
5354 local cmd="$LFS find -size 0 -type f -lazy $dir"
5355 local nums=$($cmd | wc -l)
5357 [ $nums -eq $expected ] ||
5358 error "'$cmd' wrong: found $nums, expected $expected"
5359 cmd="$LFS find -size 0 -type f $dir"
5360 nums=$($cmd | wc -l)
5361 [ $nums -eq $expected ] ||
5362 error "'$cmd' wrong: found $nums, expected $expected"
5365 cmd="$LFS find ! -size 0 -type f -lazy $dir"
5366 nums=$($cmd | wc -l)
5367 [ $nums -eq $expected ] ||
5368 error "'$cmd' wrong: found $nums, expected $expected"
5369 cmd="$LFS find ! -size 0 -type f $dir"
5370 nums=$($cmd | wc -l)
5371 [ $nums -eq $expected ] ||
5372 error "'$cmd' wrong: found $nums, expected $expected"
5374 echo "test" > $dir/$tfile
5375 echo "test2" > $dir/$tfile.2 && sync
5377 cmd="$LFS find -size 5 -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 5 -type f $dir"
5382 nums=$($cmd | wc -l)
5383 [ $nums -eq $expected ] ||
5384 error "'$cmd' wrong: found $nums, expected $expected"
5387 cmd="$LFS find -size +5 -type f -lazy $dir"
5388 nums=$($cmd | wc -l)
5389 [ $nums -eq $expected ] ||
5390 error "'$cmd' wrong: found $nums, expected $expected"
5391 cmd="$LFS find -size +5 -type f $dir"
5392 nums=$($cmd | wc -l)
5393 [ $nums -eq $expected ] ||
5394 error "'$cmd' wrong: found $nums, expected $expected"
5397 cmd="$LFS find -size +0 -type f -lazy $dir"
5398 nums=$($cmd | wc -l)
5399 [ $nums -eq $expected ] ||
5400 error "'$cmd' wrong: found $nums, expected $expected"
5401 cmd="$LFS find -size +0 -type f $dir"
5402 nums=$($cmd | wc -l)
5403 [ $nums -eq $expected ] ||
5404 error "'$cmd' wrong: found $nums, expected $expected"
5407 cmd="$LFS find ! -size -5 -type f -lazy $dir"
5408 nums=$($cmd | wc -l)
5409 [ $nums -eq $expected ] ||
5410 error "'$cmd' wrong: found $nums, expected $expected"
5411 cmd="$LFS find ! -size -5 -type f $dir"
5412 nums=$($cmd | wc -l)
5413 [ $nums -eq $expected ] ||
5414 error "'$cmd' wrong: found $nums, expected $expected"
5417 cmd="$LFS find -size -5 -type f -lazy $dir"
5418 nums=$($cmd | wc -l)
5419 [ $nums -eq $expected ] ||
5420 error "'$cmd' wrong: found $nums, expected $expected"
5421 cmd="$LFS find -size -5 -type f $dir"
5422 nums=$($cmd | wc -l)
5423 [ $nums -eq $expected ] ||
5424 error "'$cmd' wrong: found $nums, expected $expected"
5426 run_test 56r "check lfs find -size works"
5433 cancel_lru_locks $OSC
5435 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5436 local nums=$($cmd | wc -l)
5438 [ $nums -eq $expected ] ||
5439 error "'$cmd' wrong: found $nums, expected $expected"
5441 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5443 if (( rpcs_before + glimpses != rpcs_after )); then
5444 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5445 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
5447 if [[ $glimpses == 0 ]]; then
5448 error "'$cmd' should not send glimpse RPCs to OST"
5450 error "'$cmd' should send $glimpses glimpse RPCs to OST"
5456 [[ $MDS1_VERSION -ge $(version_code 2.12.4) ]] ||
5457 skip "MDS < 2.12.4 doesn't return LSOM data"
5458 local dir=$DIR/$tdir
5460 [[ $OSC == "mdc" ]] && skip "DoM files"
5462 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5463 # open and close all files to ensure LSOM is updated
5464 cancel_lru_locks $OSC
5465 find $dir -type f | xargs cat > /dev/null
5467 # expect_found glimpse_rpcs command_to_run
5468 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
5469 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
5470 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
5471 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
5473 echo "test" > $dir/$tfile
5474 echo "test2" > $dir/$tfile.2 && sync
5475 cancel_lru_locks $OSC
5476 cat $dir/$tfile $dir/$tfile.2 > /dev/null
5478 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
5479 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
5480 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
5481 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
5483 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
5484 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
5485 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
5486 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
5487 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
5488 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
5490 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
5492 test_56s() { # LU-611 #LU-9369
5493 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5495 local dir=$DIR/$tdir
5496 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5498 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5499 for i in $(seq $NUMDIRS); do
5500 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5503 local expected=$NUMDIRS
5504 local cmd="$LFS find -c $OSTCOUNT $dir"
5505 local nums=$($cmd | wc -l)
5507 [ $nums -eq $expected ] || {
5508 $LFS getstripe -R $dir
5509 error "'$cmd' wrong: found $nums, expected $expected"
5512 expected=$((NUMDIRS + onestripe))
5513 cmd="$LFS find -stripe-count +0 -type f $dir"
5514 nums=$($cmd | wc -l)
5515 [ $nums -eq $expected ] || {
5516 $LFS getstripe -R $dir
5517 error "'$cmd' wrong: found $nums, expected $expected"
5521 cmd="$LFS find -stripe-count 1 -type f $dir"
5522 nums=$($cmd | wc -l)
5523 [ $nums -eq $expected ] || {
5524 $LFS getstripe -R $dir
5525 error "'$cmd' wrong: found $nums, expected $expected"
5528 cmd="$LFS find -stripe-count -2 -type f $dir"
5529 nums=$($cmd | wc -l)
5530 [ $nums -eq $expected ] || {
5531 $LFS getstripe -R $dir
5532 error "'$cmd' wrong: found $nums, expected $expected"
5536 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5537 nums=$($cmd | wc -l)
5538 [ $nums -eq $expected ] || {
5539 $LFS getstripe -R $dir
5540 error "'$cmd' wrong: found $nums, expected $expected"
5543 run_test 56s "check lfs find -stripe-count works"
5545 test_56t() { # LU-611 #LU-9369
5546 local dir=$DIR/$tdir
5548 setup_56 $dir 0 $NUMDIRS
5549 for i in $(seq $NUMDIRS); do
5550 $LFS setstripe -S 8M $dir/dir$i/$tfile
5553 local expected=$NUMDIRS
5554 local cmd="$LFS find -S 8M $dir"
5555 local nums=$($cmd | wc -l)
5557 [ $nums -eq $expected ] || {
5558 $LFS getstripe -R $dir
5559 error "'$cmd' wrong: found $nums, expected $expected"
5563 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5565 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5567 expected=$(((NUMDIRS + 1) * NUMFILES))
5568 cmd="$LFS find -stripe-size 512k -type f $dir"
5569 nums=$($cmd | wc -l)
5570 [ $nums -eq $expected ] ||
5571 error "'$cmd' wrong: found $nums, expected $expected"
5573 cmd="$LFS find -stripe-size +320k -type f $dir"
5574 nums=$($cmd | wc -l)
5575 [ $nums -eq $expected ] ||
5576 error "'$cmd' wrong: found $nums, expected $expected"
5578 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5579 cmd="$LFS find -stripe-size +200k -type f $dir"
5580 nums=$($cmd | wc -l)
5581 [ $nums -eq $expected ] ||
5582 error "'$cmd' wrong: found $nums, expected $expected"
5584 cmd="$LFS find -stripe-size -640k -type f $dir"
5585 nums=$($cmd | wc -l)
5586 [ $nums -eq $expected ] ||
5587 error "'$cmd' wrong: found $nums, expected $expected"
5590 cmd="$LFS find -stripe-size 256k -type f $dir"
5591 nums=$($cmd | wc -l)
5592 [ $nums -eq $expected ] ||
5593 error "'$cmd' wrong: found $nums, expected $expected"
5595 cmd="$LFS find -stripe-size -320k -type f $dir"
5596 nums=$($cmd | wc -l)
5597 [ $nums -eq $expected ] ||
5598 error "'$cmd' wrong: found $nums, expected $expected"
5601 cmd="$LFS find -stripe-size 1024k -type f $dir"
5602 nums=$($cmd | wc -l)
5603 [ $nums -eq $expected ] ||
5604 error "'$cmd' wrong: found $nums, expected $expected"
5606 run_test 56t "check lfs find -stripe-size works"
5608 test_56u() { # LU-611
5609 local dir=$DIR/$tdir
5611 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5613 if [[ $OSTCOUNT -gt 1 ]]; then
5614 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5620 local expected=$(((NUMDIRS + 1) * NUMFILES))
5621 local cmd="$LFS find -stripe-index 0 -type f $dir"
5622 local nums=$($cmd | wc -l)
5624 [ $nums -eq $expected ] ||
5625 error "'$cmd' wrong: found $nums, expected $expected"
5628 cmd="$LFS find -stripe-index 1 -type f $dir"
5629 nums=$($cmd | wc -l)
5630 [ $nums -eq $expected ] ||
5631 error "'$cmd' wrong: found $nums, expected $expected"
5633 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5634 nums=$($cmd | wc -l)
5635 [ $nums -eq $expected ] ||
5636 error "'$cmd' wrong: found $nums, expected $expected"
5639 # This should produce an error and not return any files
5640 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5641 nums=$($cmd 2>/dev/null | wc -l)
5642 [ $nums -eq $expected ] ||
5643 error "'$cmd' wrong: found $nums, expected $expected"
5645 if [[ $OSTCOUNT -gt 1 ]]; then
5646 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5647 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5648 nums=$($cmd | wc -l)
5649 [ $nums -eq $expected ] ||
5650 error "'$cmd' wrong: found $nums, expected $expected"
5653 run_test 56u "check lfs find -stripe-index works"
5657 local dir=$DIR/$tdir
5659 setup_56 $dir $NUMFILES $NUMDIRS
5661 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5662 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5664 for file in $($LFS find -m $UUID $dir); do
5665 file_midx=$($LFS getstripe -m $file)
5666 [ $file_midx -eq $mdt_idx ] ||
5667 error "lfs find -m $UUID != getstripe -m $file_midx"
5670 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5673 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5676 local dir=$DIR/$tdir
5678 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5680 local stripe_size=$($LFS getstripe -S -d $dir) ||
5681 error "$LFS getstripe -S -d $dir failed"
5682 stripe_size=${stripe_size%% *}
5684 local file_size=$((stripe_size * OSTCOUNT))
5685 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5686 local required_space=$((file_num * file_size))
5687 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5689 [[ $free_space -le $((required_space / 1024)) ]] &&
5690 skip_env "need $required_space, have $free_space kbytes"
5693 local dd_count=$((file_size / dd_bs))
5695 # write data into the files
5700 for i in $(seq $NUMFILES); do
5702 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5703 error "write data into $file failed"
5705 for i in $(seq $NUMDIRS); do
5706 for j in $(seq $NUMFILES); do
5707 file=$dir/dir$i/file$j
5708 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5709 error "write data into $file failed"
5713 # $LFS_MIGRATE will fail if hard link migration is unsupported
5714 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5715 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5716 error "creating links to $dir/dir1/file1 failed"
5721 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5724 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5727 eval $cmd || error "$cmd failed"
5729 check_stripe_count $dir/file1 $expected
5731 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
5733 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5734 # OST 1 if it is on OST 0. This file is small enough to
5735 # be on only one stripe.
5736 file=$dir/migr_1_ost
5737 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5738 error "write data into $file failed"
5739 local obdidx=$($LFS getstripe -i $file)
5740 local oldmd5=$(md5sum $file)
5743 [[ $obdidx -eq 0 ]] && newobdidx=1
5744 cmd="$LFS migrate -i $newobdidx $file"
5746 eval $cmd || error "$cmd failed"
5748 local realobdix=$($LFS getstripe -i $file)
5749 local newmd5=$(md5sum $file)
5751 [[ $newobdidx -ne $realobdix ]] &&
5752 error "new OST is different (was=$obdidx, "\
5753 "wanted=$newobdidx, got=$realobdix)"
5754 [[ "$oldmd5" != "$newmd5" ]] &&
5755 error "md5sum differ: $oldmd5, $newmd5"
5759 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5761 eval $cmd || error "$cmd failed"
5763 for j in $(seq $NUMFILES); do
5764 check_stripe_count $dir/dir1/file$j $expected
5767 # lfs_migrate works with lfs find
5768 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5769 $LFS_MIGRATE -y -c $expected"
5771 eval $cmd || error "$cmd failed"
5773 for i in $(seq 2 $NUMFILES); do
5774 check_stripe_count $dir/file$i $expected
5776 for i in $(seq 2 $NUMDIRS); do
5777 for j in $(seq $NUMFILES); do
5778 check_stripe_count $dir/dir$i/file$j $expected
5782 run_test 56w "check lfs_migrate -c stripe_count works"
5785 local file1=$DIR/$tdir/file1
5786 local create_pool=false
5787 local initial_pool=$($LFS getstripe -p $DIR)
5791 echo -n "Creating test dir..."
5792 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5795 echo -n "Creating test file..."
5796 touch $file1 || error "cannot create file"
5799 echo -n "Detecting existing pools..."
5800 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5802 if [ ${#pool_list[@]} -gt 0 ]; then
5803 echo "${pool_list[@]}"
5804 for thispool in "${pool_list[@]}"; do
5805 if [[ -z "$initial_pool" ||
5806 "$initial_pool" != "$thispool" ]]; then
5808 echo "Using existing pool '$pool'"
5813 echo "none detected."
5815 if [ -z "$pool" ]; then
5816 pool=${POOL:-testpool}
5817 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5818 echo -n "Creating pool '$pool'..."
5820 pool_add $pool &> /dev/null ||
5821 error "pool_add failed"
5824 echo -n "Adding target to pool..."
5825 pool_add_targets $pool 0 0 1 &> /dev/null ||
5826 error "pool_add_targets failed"
5830 echo -n "Setting pool using -p option..."
5831 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5832 error "migrate failed rc = $?"
5835 echo -n "Verifying test file is in pool after migrating..."
5836 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5837 error "file was not migrated to pool $pool"
5840 echo -n "Removing test file from pool '$pool'..."
5841 # "lfs migrate $file" won't remove the file from the pool
5842 # until some striping information is changed.
5843 $LFS migrate -c 1 $file1 &> /dev/null ||
5844 error "cannot remove from pool"
5845 [ "$($LFS getstripe -p $file1)" ] &&
5846 error "pool still set"
5849 echo -n "Setting pool using --pool option..."
5850 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5851 error "migrate failed rc = $?"
5856 if $create_pool; then
5857 destroy_test_pools 2> /dev/null ||
5858 error "destroy test pools failed"
5861 run_test 56wb "check lfs_migrate pool support"
5864 local file1="$DIR/$tdir/file1"
5871 echo -n "Creating test dir..."
5872 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5873 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5874 error "cannot set stripe by '-S 1M -c 1'"
5877 echo -n "Setting initial stripe for test file..."
5878 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5879 error "cannot set stripe"
5880 cur_ssize=$($LFS getstripe -S "$file1")
5881 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
5884 # File currently set to -S 512K -c 1
5886 # Ensure -c and -S options are rejected when -R is set
5887 echo -n "Verifying incompatible options are detected..."
5888 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5889 error "incompatible -c and -R options not detected"
5890 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5891 error "incompatible -S and -R options not detected"
5894 # Ensure unrecognized options are passed through to 'lfs migrate'
5895 echo -n "Verifying -S option is passed through to lfs migrate..."
5896 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5897 error "migration failed"
5898 cur_ssize=$($LFS getstripe -S "$file1")
5899 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
5902 # File currently set to -S 1M -c 1
5904 # Ensure long options are supported
5905 echo -n "Verifying long options supported..."
5906 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5907 error "long option without argument not supported"
5908 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5909 error "long option with argument not supported"
5910 cur_ssize=$($LFS getstripe -S "$file1")
5911 [ $cur_ssize -eq 524288 ] ||
5912 error "migrate --stripe-size $cur_ssize != 524288"
5915 # File currently set to -S 512K -c 1
5917 if [ "$OSTCOUNT" -gt 1 ]; then
5918 echo -n "Verifying explicit stripe count can be set..."
5919 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5920 error "migrate failed"
5921 cur_scount=$($LFS getstripe -c "$file1")
5922 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
5926 # File currently set to -S 512K -c 1 or -S 512K -c 2
5928 # Ensure parent striping is used if -R is set, and no stripe
5929 # count or size is specified
5930 echo -n "Setting stripe for parent directory..."
5931 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5932 error "cannot set stripe '-S 2M -c 1'"
5935 echo -n "Verifying restripe option uses parent stripe settings..."
5936 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5937 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
5938 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5939 error "migrate failed"
5940 cur_ssize=$($LFS getstripe -S "$file1")
5941 [ $cur_ssize -eq $parent_ssize ] ||
5942 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
5943 cur_scount=$($LFS getstripe -c "$file1")
5944 [ $cur_scount -eq $parent_scount ] ||
5945 error "migrate -R stripe_count $cur_scount != $parent_scount"
5948 # File currently set to -S 1M -c 1
5950 # Ensure striping is preserved if -R is not set, and no stripe
5951 # count or size is specified
5952 echo -n "Verifying striping size preserved when not specified..."
5953 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
5954 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5955 error "cannot set stripe on parent directory"
5956 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5957 error "migrate failed"
5958 cur_ssize=$($LFS getstripe -S "$file1")
5959 [ $cur_ssize -eq $orig_ssize ] ||
5960 error "migrate by default $cur_ssize != $orig_ssize"
5963 # Ensure file name properly detected when final option has no argument
5964 echo -n "Verifying file name properly detected..."
5965 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5966 error "file name interpreted as option argument"
5972 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5975 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5977 local file1=$DIR/$tdir/file1
5979 echo -n "Creating test dir..."
5980 test_mkdir $DIR/$tdir || error "cannot create dir"
5983 echo -n "Creating test file..."
5987 # Ensure 'lfs migrate' will fail by using a non-existent option,
5988 # and make sure rsync is not called to recover
5989 echo -n "Make sure --no-rsync option works..."
5990 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5991 grep -q 'refusing to fall back to rsync' ||
5992 error "rsync was called with --no-rsync set"
5995 # Ensure rsync is called without trying 'lfs migrate' first
5996 echo -n "Make sure --rsync option works..."
5997 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5998 grep -q 'falling back to rsync' &&
5999 error "lfs migrate was called with --rsync set"
6002 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6003 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6004 grep -q 'at the same time' ||
6005 error "--rsync and --no-rsync accepted concurrently"
6011 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6014 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6015 check_swap_layouts_support
6017 local dir=$DIR/$tdir
6018 local ref1=/etc/passwd
6019 local file1=$dir/file1
6021 test_mkdir $dir || error "creating dir $dir"
6022 $LFS setstripe -c 2 $file1
6024 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6025 stripe=$($LFS getstripe -c $file1)
6026 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6027 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6032 run_test 56x "lfs migration support"
6035 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6036 check_swap_layouts_support
6038 local dir=$DIR/$tdir/$testnum
6042 local ref1=/etc/passwd
6043 local file1=$dir/file1
6045 $LFS setstripe -c 2 $file1
6047 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6049 local stripe=$($LFS getstripe -c $file1)
6051 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6052 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6057 run_test 56xa "lfs migration --block support"
6059 check_migrate_links() {
6061 local file1="$dir/file1"
6064 local total_count=$(($begin + $count - 1))
6065 local symlink_count=10
6068 if [ ! -f "$file1" ]; then
6069 echo -n "creating initial file..."
6070 $LFS setstripe -c 1 -S "512k" "$file1" ||
6071 error "cannot setstripe initial file"
6074 echo -n "creating symlinks..."
6075 for s in $(seq 1 $symlink_count); do
6076 ln -s "$file1" "$dir/slink$s" ||
6077 error "cannot create symlinks"
6081 echo -n "creating nonlinked files..."
6082 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6083 error "cannot create nonlinked files"
6088 if [ ! -f "$dir/file$total_count" ]; then
6089 echo -n "creating hard links $begin:$total_count..."
6090 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6091 /dev/null || error "cannot create hard links"
6095 echo -n "checking number of hard links listed in xattrs..."
6096 local fid=$($LFS getstripe -F "$file1")
6097 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6100 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6101 skip "hard link list has unexpected size, skipping test"
6103 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6104 error "link names should exceed xattrs size"
6107 echo -n "migrating files..."
6108 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
6110 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6113 # make sure all links have been properly migrated
6114 echo -n "verifying files..."
6115 fid=$($LFS getstripe -F "$file1") ||
6116 error "cannot get fid for file $file1"
6117 for i in $(seq 2 $total_count); do
6118 local fid2=$($LFS getstripe -F $dir/file$i)
6120 [ "$fid2" == "$fid" ] ||
6121 error "migrated hard link has mismatched FID"
6124 # make sure hard links were properly detected, and migration was
6125 # performed only once for the entire link set; nonlinked files should
6127 local actual=$(grep -c 'done' <<< "$migrate_out")
6128 local expected=$(($uniq_count + 1))
6130 [ "$actual" -eq "$expected" ] ||
6131 error "hard links individually migrated ($actual != $expected)"
6133 # make sure the correct number of hard links are present
6134 local hardlinks=$(stat -c '%h' "$file1")
6136 [ $hardlinks -eq $total_count ] ||
6137 error "num hard links $hardlinks != $total_count"
6144 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6145 skip "Need MDS version at least 2.10.55"
6147 local dir="$DIR/$tdir"
6149 test_mkdir "$dir" || error "cannot create dir $dir"
6151 echo "testing lfs migrate mode when all links fit within xattrs"
6152 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6154 echo "testing rsync mode when all links fit within xattrs"
6155 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6157 echo "testing lfs migrate mode when all links do not fit within xattrs"
6158 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6160 echo "testing rsync mode when all links do not fit within xattrs"
6161 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6167 run_test 56xb "lfs migration hard link support"
6170 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6172 local dir="$DIR/$tdir"
6174 test_mkdir "$dir" || error "cannot create dir $dir"
6176 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6177 echo -n "Setting initial stripe for 20MB test file..."
6178 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6179 error "cannot setstripe 20MB file"
6181 echo -n "Sizing 20MB test file..."
6182 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6184 echo -n "Verifying small file autostripe count is 1..."
6185 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6186 error "cannot migrate 20MB file"
6187 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6188 error "cannot get stripe for $dir/20mb"
6189 [ $stripe_count -eq 1 ] ||
6190 error "unexpected stripe count $stripe_count for 20MB file"
6194 # Test 2: File is small enough to fit within the available space on
6195 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6196 # have at least an additional 1KB for each desired stripe for test 3
6197 echo -n "Setting stripe for 1GB test file..."
6198 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
6200 echo -n "Sizing 1GB test file..."
6201 # File size is 1GB + 3KB
6202 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
6205 # need at least 512MB per OST for 1GB file to fit in 2 stripes
6206 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
6207 if (( avail > 524288 * OSTCOUNT )); then
6208 echo -n "Migrating 1GB file..."
6209 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
6210 error "cannot migrate 1GB file"
6212 echo -n "Verifying autostripe count is sqrt(n) + 1..."
6213 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
6214 error "cannot getstripe for 1GB file"
6215 [ $stripe_count -eq 2 ] ||
6216 error "unexpected stripe count $stripe_count != 2"
6220 # Test 3: File is too large to fit within the available space on
6221 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
6222 if [ $OSTCOUNT -ge 3 ]; then
6223 # The required available space is calculated as
6224 # file size (1GB + 3KB) / OST count (3).
6225 local kb_per_ost=349526
6227 echo -n "Migrating 1GB file with limit..."
6228 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
6229 error "cannot migrate 1GB file with limit"
6232 stripe_count=$($LFS getstripe -c "$dir/1gb")
6233 echo -n "Verifying 1GB autostripe count with limited space..."
6234 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
6235 error "unexpected stripe count $stripe_count (min 3)"
6242 run_test 56xc "lfs migration autostripe"
6245 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6247 local dir=$DIR/$tdir
6248 local f_mgrt=$dir/$tfile.mgrt
6249 local f_yaml=$dir/$tfile.yaml
6250 local f_copy=$dir/$tfile.copy
6251 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6252 local layout_copy="-c 2 -S 2M -i 1"
6253 local yamlfile=$dir/yamlfile
6254 local layout_before;
6257 test_mkdir "$dir" || error "cannot create dir $dir"
6258 $LFS setstripe $layout_yaml $f_yaml ||
6259 error "cannot setstripe $f_yaml with layout $layout_yaml"
6260 $LFS getstripe --yaml $f_yaml > $yamlfile
6261 $LFS setstripe $layout_copy $f_copy ||
6262 error "cannot setstripe $f_copy with layout $layout_copy"
6264 dd if=/dev/zero of=$f_mgrt bs=1M count=4
6266 # 1. test option --yaml
6267 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
6268 error "cannot migrate $f_mgrt with --yaml $yamlfile"
6269 layout_before=$(get_layout_param $f_yaml)
6270 layout_after=$(get_layout_param $f_mgrt)
6271 [ "$layout_after" == "$layout_before" ] ||
6272 error "lfs_migrate --yaml: $layout_after != $layout_before"
6274 # 2. test option --copy
6275 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
6276 error "cannot migrate $f_mgrt with --copy $f_copy"
6277 layout_before=$(get_layout_param $f_copy)
6278 layout_after=$(get_layout_param $f_mgrt)
6279 [ "$layout_after" == "$layout_before" ] ||
6280 error "lfs_migrate --copy: $layout_after != $layout_before"
6282 run_test 56xd "check lfs_migrate --yaml and --copy support"
6285 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6287 local dir=$DIR/$tdir
6288 local f_comp=$dir/$tfile
6289 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6290 local layout_before=""
6291 local layout_after=""
6293 test_mkdir "$dir" || error "cannot create dir $dir"
6294 $LFS setstripe $layout $f_comp ||
6295 error "cannot setstripe $f_comp with layout $layout"
6296 layout_before=$(get_layout_param $f_comp)
6297 dd if=/dev/zero of=$f_comp bs=1M count=4
6299 # 1. migrate a comp layout file by lfs_migrate
6300 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
6301 layout_after=$(get_layout_param $f_comp)
6302 [ "$layout_before" == "$layout_after" ] ||
6303 error "lfs_migrate: $layout_before != $layout_after"
6305 # 2. migrate a comp layout file by lfs migrate
6306 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
6307 layout_after=$(get_layout_param $f_comp)
6308 [ "$layout_before" == "$layout_after" ] ||
6309 error "lfs migrate: $layout_before != $layout_after"
6311 run_test 56xe "migrate a composite layout file"
6314 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
6315 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
6318 local dir=$DIR/$tdir
6322 test_mkdir -p $dir || error "creating dir $dir"
6323 touch $f1 || error "creating std file $f1"
6324 $MULTIOP $f2 H2c || error "creating released file $f2"
6326 # a directory can be raid0, so ask only for files
6327 res=$($LFS find $dir -L raid0 -type f | wc -l)
6328 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
6330 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
6331 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
6333 # only files can be released, so no need to force file search
6334 res=$($LFS find $dir -L released)
6335 [[ $res == $f2 ]] || error "search released: found $res != $f2"
6337 res=$($LFS find $dir -type f \! -L released)
6338 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
6340 run_test 56y "lfs find -L raid0|released"
6342 test_56z() { # LU-4824
6343 # This checks to make sure 'lfs find' continues after errors
6344 # There are two classes of errors that should be caught:
6345 # - If multiple paths are provided, all should be searched even if one
6347 # - If errors are encountered during the search, it should not terminate
6349 local dir=$DIR/$tdir
6353 for i in d{0..9}; do
6355 touch $dir/$i/$tfile
6357 $LFS find $DIR/non_existent_dir $dir &&
6358 error "$LFS find did not return an error"
6359 # Make a directory unsearchable. This should NOT be the last entry in
6360 # directory order. Arbitrarily pick the 6th entry
6361 chmod 700 $($LFS find $dir -type d | sed '6!d')
6363 $RUNAS $LFS find $DIR/non_existent $dir
6364 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
6366 # The user should be able to see 10 directories and 9 files
6367 (( count == 19 )) ||
6368 error "$LFS find found $count != 19 entries after error"
6370 run_test 56z "lfs find should continue after an error"
6372 test_56aa() { # LU-5937
6373 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
6375 local dir=$DIR/$tdir
6378 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
6380 createmany -o $dir/striped_dir/${tfile}- 1024
6381 local dirs=$($LFS find --size +8k $dir/)
6383 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
6385 run_test 56aa "lfs find --size under striped dir"
6387 test_56ab() { # LU-10705
6388 test_mkdir $DIR/$tdir
6389 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
6390 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
6391 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
6392 # Flush writes to ensure valid blocks. Need to be more thorough for
6393 # ZFS, since blocks are not allocated/returned to client immediately.
6395 wait_zfs_commit ost1 2
6396 cancel_lru_locks osc
6399 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
6401 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
6403 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
6404 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
6406 rm -f $DIR/$tdir/$tfile.[123]
6408 run_test 56ab "lfs find --blocks"
6411 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
6412 skip "Need MDS version at least 2.10.50"
6414 # Create composite files with one component
6415 local dir=$DIR/$tdir
6417 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
6418 # Create composite files with three components
6419 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
6420 # Create non-composite files
6421 createmany -o $dir/${tfile}- 10
6423 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
6425 [[ $nfiles == 10 ]] ||
6426 error "lfs find -E 1M found $nfiles != 10 files"
6428 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
6429 [[ $nfiles == 25 ]] ||
6430 error "lfs find ! -E 1M found $nfiles != 25 files"
6432 # All files have a component that starts at 0
6433 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
6434 [[ $nfiles == 35 ]] ||
6435 error "lfs find --component-start 0 - $nfiles != 35 files"
6437 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
6438 [[ $nfiles == 15 ]] ||
6439 error "lfs find --component-start 2M - $nfiles != 15 files"
6441 # All files created here have a componenet that does not starts at 2M
6442 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
6443 [[ $nfiles == 35 ]] ||
6444 error "lfs find ! --component-start 2M - $nfiles != 35 files"
6446 # Find files with a specified number of components
6447 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
6448 [[ $nfiles == 15 ]] ||
6449 error "lfs find --component-count 3 - $nfiles != 15 files"
6451 # Remember non-composite files have a component count of zero
6452 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
6453 [[ $nfiles == 10 ]] ||
6454 error "lfs find --component-count 0 - $nfiles != 10 files"
6456 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
6457 [[ $nfiles == 20 ]] ||
6458 error "lfs find ! --component-count 3 - $nfiles != 20 files"
6460 # All files have a flag called "init"
6461 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
6462 [[ $nfiles == 35 ]] ||
6463 error "lfs find --component-flags init - $nfiles != 35 files"
6465 # Multi-component files will have a component not initialized
6466 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
6467 [[ $nfiles == 15 ]] ||
6468 error "lfs find !--component-flags init - $nfiles != 15 files"
6473 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
6476 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
6477 skip "Need MDS version at least 2.10.57"
6487 # create mirrored directories and mirrored files
6488 mkdir $td || error "mkdir $td failed"
6489 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
6490 createmany -o $tf- 10 || error "create $tf- failed"
6492 for i in $(seq 2); do
6494 mkdir $dir || error "mkdir $dir failed"
6495 $LFS mirror create -N$((3 + i)) $dir ||
6496 error "create mirrored dir $dir failed"
6497 createmany -o $dir/$tfile- 10 ||
6498 error "create $dir/$tfile- failed"
6501 # change the states of some mirrored files
6503 for i in $(seq 2); do
6505 for j in $(seq 4 9); do
6506 echo foo > $dir/$tfile-$j
6510 # find mirrored files with specific mirror count
6511 cmd="$LFS find --mirror-count 3 --type f $td"
6512 nfiles=$($cmd | wc -l)
6513 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
6515 cmd="$LFS find ! --mirror-count 3 --type f $td"
6516 nfiles=$($cmd | wc -l)
6517 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
6519 cmd="$LFS find --mirror-count +2 --type f $td"
6520 nfiles=$($cmd | wc -l)
6521 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6523 cmd="$LFS find --mirror-count -6 --type f $td"
6524 nfiles=$($cmd | wc -l)
6525 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6527 # find mirrored files with specific file state
6528 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
6529 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
6531 cmd="$LFS find --mirror-state=ro --type f $td"
6532 nfiles=$($cmd | wc -l)
6533 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6535 cmd="$LFS find ! --mirror-state=ro --type f $td"
6536 nfiles=$($cmd | wc -l)
6537 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6539 cmd="$LFS find --mirror-state=wp --type f $td"
6540 nfiles=$($cmd | wc -l)
6541 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6543 cmd="$LFS find ! --mirror-state=sp --type f $td"
6544 nfiles=$($cmd | wc -l)
6545 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6547 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6550 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6551 # note test will not do anything if MDS is not local
6552 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6553 skip_env "ldiskfs only test"
6555 remote_mds_nodsh && skip "remote MDS with nodsh"
6557 local MNTDEV="osd*.*MDT*.mntdev"
6558 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6559 [ -z "$DEV" ] && error "can't access $MNTDEV"
6560 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6561 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6562 error "can't access $DEV"
6563 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6564 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6568 run_test 57a "verify MDS filesystem created with large inodes =="
6571 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6572 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6573 skip_env "ldiskfs only test"
6575 remote_mds_nodsh && skip "remote MDS with nodsh"
6577 local dir=$DIR/$tdir
6580 local fileN=$dir/f$filecount
6582 rm -rf $dir || error "removing $dir"
6584 local mdtidx=$($LFS getstripe -m $dir)
6585 local mdtname=MDT$(printf %04x $mdtidx)
6586 local facet=mds$((mdtidx + 1))
6588 echo "mcreating $filecount files"
6589 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6591 # verify that files do not have EAs yet
6592 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6593 error "$file1 has an EA"
6594 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6595 error "$fileN has an EA"
6599 df $dir #make sure we get new statfs data
6600 local mdsfree=$(do_facet $facet \
6601 lctl get_param -n osd*.*$mdtname.kbytesfree)
6602 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6605 echo "opening files to create objects/EAs"
6606 for file in $(seq -f $dir/f%g 1 $filecount); do
6607 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6608 error "opening $file"
6611 # verify that files have EAs now
6612 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6613 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6615 sleep 1 #make sure we get new statfs data
6617 local mdsfree2=$(do_facet $facet \
6618 lctl get_param -n osd*.*$mdtname.kbytesfree)
6619 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6621 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6622 if [ "$mdsfree" != "$mdsfree2" ]; then
6623 error "MDC before $mdcfree != after $mdcfree2"
6625 echo "MDC before $mdcfree != after $mdcfree2"
6626 echo "unable to confirm if MDS has large inodes"
6631 run_test 57b "default LOV EAs are stored inside large inodes ==="
6634 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6635 [ -z "$(which wiretest 2>/dev/null)" ] &&
6636 skip_env "could not find wiretest"
6640 run_test 58 "verify cross-platform wire constants =============="
6643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6645 echo "touch 130 files"
6646 createmany -o $DIR/f59- 130
6648 unlinkmany $DIR/f59- 130
6650 # wait for commitment of removal
6651 wait_delete_completed
6653 run_test 59 "verify cancellation of llog records async ========="
6655 TEST60_HEAD="test_60 run $RANDOM"
6657 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6658 remote_mgs_nodsh && skip "remote MGS with nodsh"
6659 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6660 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6661 skip_env "missing subtest run-llog.sh"
6663 log "$TEST60_HEAD - from kernel mode"
6664 do_facet mgs "$LCTL dk > /dev/null"
6665 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6666 do_facet mgs $LCTL dk > $TMP/$tfile
6668 # LU-6388: test llog_reader
6669 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6670 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6671 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6672 skip_env "missing llog_reader"
6673 local fstype=$(facet_fstype mgs)
6674 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6675 skip_env "Only for ldiskfs or zfs type mgs"
6677 local mntpt=$(facet_mntpt mgs)
6678 local mgsdev=$(mgsdevname 1)
6690 #get fid and record list
6691 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6693 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6695 #remount mgs as ldiskfs or zfs type
6696 stop mgs || error "stop mgs failed"
6697 mount_fstype mgs || error "remount mgs failed"
6698 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6701 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6702 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6707 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6709 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6711 echo "obj_file is $obj_file"
6712 do_facet mgs $llog_reader $obj_file
6714 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6715 awk '{ print $3 }' | sed -e "s/^type=//g")
6716 if [ $rec_type != $rec ]; then
6717 echo "FAILED test_60a wrong record type $rec_type," \
6723 #check obj path if record type is LLOG_LOGID_MAGIC
6724 if [ "$rec" == "1064553b" ]; then
6725 path=$(do_facet mgs $llog_reader $obj_file |
6726 grep "path=" | awk '{ print $NF }' |
6727 sed -e "s/^path=//g")
6728 if [ $obj_file != $mntpt/$path ]; then
6729 echo "FAILED test_60a wrong obj path" \
6730 "$montpt/$path, should be $obj_file"
6737 #restart mgs before "error", otherwise it will block the next test
6738 stop mgs || error "stop mgs failed"
6739 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6740 $pass || error "test failed, see FAILED test_60a messages for specifics"
6742 run_test 60a "llog_test run from kernel module and test llog_reader"
6744 test_60b() { # bug 6411
6745 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6748 LLOG_COUNT=$(do_facet mgs dmesg |
6749 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6750 /llog_[a-z]*.c:[0-9]/ {
6762 [[ $LLOG_COUNT -gt 120 ]] &&
6763 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6765 run_test 60b "limit repeated messages from CERROR/CWARN"
6768 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6770 echo "create 5000 files"
6771 createmany -o $DIR/f60c- 5000
6772 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6773 lctl set_param fail_loc=0x80000137
6774 unlinkmany $DIR/f60c- 5000
6775 lctl set_param fail_loc=0
6777 run_test 60c "unlink file when mds full"
6780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6782 SAVEPRINTK=$(lctl get_param -n printk)
6783 # verify "lctl mark" is even working"
6784 MESSAGE="test message ID $RANDOM $$"
6785 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6786 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6788 lctl set_param printk=0 || error "set lnet.printk failed"
6789 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6790 MESSAGE="new test message ID $RANDOM $$"
6791 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6792 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6793 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6795 lctl set_param -n printk="$SAVEPRINTK"
6797 run_test 60d "test printk console message masking"
6800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6801 remote_mds_nodsh && skip "remote MDS with nodsh"
6804 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6805 do_facet mds1 lctl set_param fail_loc=0x15b
6808 run_test 60e "no space while new llog is being created"
6813 test_mkdir -c $MDSCOUNT $DIR/$tdir
6814 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir
6819 mkdir $DIR/$tdir/subdir$index 2>/dev/null
6820 rmdir $DIR/$tdir/subdir$index 2>/dev/null
6821 index=$((index + 1))
6827 for i in $(seq 100); do
6828 # define OBD_FAIL_OSD_TXN_START 0x19a
6829 do_facet mds1 lctl set_param fail_loc=0x8000019a
6835 mkdir $DIR/$tdir/new || error "mkdir failed"
6836 rmdir $DIR/$tdir/new || error "rmdir failed"
6838 run_test 60g "transaction abort won't cause MDT hung"
6841 [ $MDS1_VERSION -le $(version_code 2.12.52) ] ||
6842 skip "Need MDS version at least 2.12.52"
6843 [ $MDSCOUNT -le 2 ] && skip "Need >= 2 MDTs"
6847 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
6848 #define OBD_FAIL_MDS_STRIPE_FID 0x189
6849 for fail_loc in 0x80000188 0x80000189; do
6850 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
6851 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
6852 error "mkdir $dir-$fail_loc failed"
6853 for i in {0..10}; do
6854 # create may fail on missing stripe
6855 echo $i > $DIR/$tdir-$fail_loc/$i
6857 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6858 error "getdirstripe $tdir-$fail_loc failed"
6859 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
6860 error "migrate $tdir-$fail_loc failed"
6861 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6862 error "getdirstripe $tdir-$fail_loc failed"
6863 pushd $DIR/$tdir-$fail_loc
6865 echo $f | cmp $f - || error "$f data mismatch"
6868 rm -rf $DIR/$tdir-$fail_loc
6871 run_test 60h "striped directory with missing stripes can be accessed"
6874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6877 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
6878 cancel_lru_locks osc
6879 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6882 run_test 61a "mmap() writes don't make sync hang ================"
6885 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
6887 run_test 61b "mmap() of unstriped file is successful"
6889 # bug 2330 - insufficient obd_match error checking causes LBUG
6891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6895 cancel_lru_locks osc
6896 lctl set_param fail_loc=0x405
6897 cat $f && error "cat succeeded, expect -EIO"
6898 lctl set_param fail_loc=0
6900 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6901 # match every page all of the time.
6902 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6904 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6905 # Though this test is irrelevant anymore, it helped to reveal some
6906 # other grant bugs (LU-4482), let's keep it.
6907 test_63a() { # was test_63
6908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6910 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6912 for i in `seq 10` ; do
6913 dd if=/dev/zero of=$DIR/f63 bs=8k &
6919 rm -f $DIR/f63 || true
6921 run_test 63a "Verify oig_wait interruption does not crash ======="
6923 # bug 2248 - async write errors didn't return to application on sync
6924 # bug 3677 - async write errors left page locked
6926 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6929 lctl set_param debug=-1
6931 # ensure we have a grant to do async writes
6932 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6935 sync # sync lest earlier test intercept the fail_loc
6937 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6938 lctl set_param fail_loc=0x80000406
6939 $MULTIOP $DIR/$tfile Owy && \
6940 error "sync didn't return ENOMEM"
6941 sync; sleep 2; sync # do a real sync this time to flush page
6942 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6943 error "locked page left in cache after async error" || true
6946 run_test 63b "async write errors should be returned to fsync ==="
6949 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6952 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6954 run_test 64a "verify filter grant calculations (in kernel) ====="
6957 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6959 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6961 run_test 64b "check out-of-space detection on client"
6964 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6966 run_test 64c "verify grant shrink"
6972 $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }"
6975 # this does exactly what osc_request.c:osc_announce_cached() does in
6976 # order to calculate max amount of grants to ask from server
6980 local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc)
6981 local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight)
6983 ((rpc_in_flight++));
6984 nrpages=$((nrpages * rpc_in_flight))
6986 local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb)
6988 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
6990 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6991 local undirty=$((nrpages * PAGE_SIZE))
6993 local max_extent_pages
6994 max_extent_pages=$(import_param $tgt grant_max_extent_size)
6995 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
6996 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6997 local grant_extent_tax
6998 grant_extent_tax=$(import_param $tgt grant_extent_tax)
7000 undirty=$((undirty + nrextents * grant_extent_tax))
7005 # this is size of unit for grant allocation. It should be equal to
7006 # what tgt_grant.c:tgt_grant_chunk() calculates
7010 local grant_extent_tax
7012 max_brw_size=$(import_param $tgt max_brw_size)
7014 grant_extent_tax=$(import_param $tgt grant_extent_tax)
7016 echo $(((max_brw_size + grant_extent_tax) * 2))
7020 [ $OST1_VERSION -ge $(version_code 2.10.56) ] ||
7021 skip "OST < 2.10.55 doesn't limit grants enough"
7023 local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7025 [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] ||
7026 skip "no grant_param connect flag"
7028 local olddebug="$($LCTL get_param -n debug 2> /dev/null)"
7030 $LCTL set_param -n -n debug="$OLDDEBUG" || true
7031 stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT
7034 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7035 stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT
7037 $LFS setstripe $DIR/$tfile -i 0 -c 1
7038 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
7041 while kill -0 $ddpid; do
7042 local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
7044 if [[ $cur_grant -gt $max_cur_granted ]]; then
7046 error "cur_grant $cur_grant > $max_cur_granted"
7052 run_test 64d "check grant limit exceed"
7058 local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes)
7060 ((cur_grants == expected)) ||
7061 error "$msg: grants mismatch: $cur_grants, expected $expected"
7065 echo $((($1 + $2 - 1) & ~($2 - 1)))
7069 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7070 [ $OST1_VERSION -ge $(version_code 2.11.56) ] ||
7071 skip "Need OSS version at least 2.11.56"
7073 # Remount client to reset grant
7074 remount_client $MOUNT || error "failed to remount client"
7075 local osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7076 local init_grants=$(import_param $osc_tgt initial_grant)
7078 check_grants $osc_tgt $init_grants "init grants"
7080 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
7081 local max_brw_size=$(import_param $osc_tgt max_brw_size)
7082 local gbs=$(import_param $osc_tgt grant_block_size)
7084 # write random number of bytes from max_brw_size / 4 to max_brw_size
7085 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
7086 # align for direct io
7087 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
7088 # round to grant consumption unit
7089 local wb_round_up=$(round_up_p2 $write_bytes gbs)
7091 local grants=$((wb_round_up + extent_tax))
7093 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7095 # define OBD_FAIL_TGT_NO_GRANT 0x725
7096 # make the server not grant more back
7097 do_facet ost1 $LCTL set_param fail_loc=0x725
7098 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct
7100 do_facet ost1 $LCTL set_param fail_loc=0
7102 check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc"
7104 rm -f $DIR/$tfile || error "rm failed"
7106 # Remount client to reset grant
7107 remount_client $MOUNT || error "failed to remount client"
7108 osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7110 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7112 # define OBD_FAIL_TGT_NO_GRANT 0x725
7113 # make the server not grant more back
7114 do_facet ost1 $LCTL set_param fail_loc=0x725
7115 $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc"
7116 do_facet ost1 $LCTL set_param fail_loc=0
7118 check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc"
7120 run_test 64e "check grant consumption (no grant allocation)"
7123 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7125 # Remount client to reset grant
7126 remount_client $MOUNT || error "failed to remount client"
7127 local osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7129 local init_grants=$(import_param $osc_tgt initial_grant)
7130 local extent_tax=$(import_param $osc_tgt grant_extent_tax)
7131 local max_brw_size=$(import_param $osc_tgt max_brw_size)
7132 local gbs=$(import_param $osc_tgt grant_block_size)
7133 local chunk=$(grant_chunk $osc_tgt)
7135 # write random number of bytes from max_brw_size / 4 to max_brw_size
7136 local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1)
7137 # align for direct io
7138 write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE)
7139 # round to grant consumption unit
7140 local wb_round_up=$(round_up_p2 $write_bytes gbs)
7142 local grants=$((wb_round_up + extent_tax))
7144 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7145 dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct ||
7146 error "error writing to $DIR/$tfile"
7148 check_grants $osc_tgt $((init_grants - grants + chunk)) \
7149 "direct io with grant allocation"
7151 rm -f $DIR/$tfile || error "rm failed"
7153 # Remount client to reset grant
7154 remount_client $MOUNT || error "failed to remount client"
7155 osc_tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }')
7157 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed"
7159 local cmd="oO_WRONLY:w${write_bytes}_yc"
7161 $MULTIOP $DIR/$tfile $cmd &
7165 check_grants $osc_tgt $((init_grants - grants)) \
7166 "buffered io, not write rpc"
7168 kill -USR1 $MULTIPID
7171 check_grants $osc_tgt $((init_grants - grants + chunk)) \
7172 "buffered io, one RPC"
7174 run_test 64f "check grant consumption (with grant allocation)"
7177 local cli=$($LFS getname $DIR); cli=${cli%% *}; cli=${cli#*-}
7178 local osc_tgt="$FSNAME-OST0000-osc-$cli"
7179 local num_exps=$(do_facet ost1 \
7180 $LCTL get_param -n obdfilter.*OST0000*.num_exports)
7181 local max_brw_size=$(import_param $osc_tgt max_brw_size)
7182 local avail=$($LCTL get_param -n osc.*OST0000-osc-$cli.kbytesavail)
7183 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7185 # 10MiB is for file to be written, max_brw_size * 16 *
7186 # num_exps is space reserve so that tgt_grant_shrink() decided
7188 local expect=$((max_brw_size * 16 * num_exps + 10 * 1048576))
7189 (( avail * 1024 < expect )) &&
7190 skip "need $expect bytes on ost1, have $(( avail * 1024 )) only"
7192 save_lustre_params client "osc.*OST0000*.grant_shrink" > $p
7193 save_lustre_params client "osc.*OST0000*.grant_shrink_interval" >> $p
7194 stack_trap "restore_lustre_params < $p; rm -f $save" EXIT
7195 $LCTL set_param osc.*OST0000*.grant_shrink=1
7196 $LCTL set_param osc.*OST0000*.grant_shrink_interval=10
7198 $LFS setstripe -c 1 -i 0 $DIR/$tfile
7199 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 oflag=sync
7201 # drop cache so that coming read would do rpc
7202 cancel_lru_locks osc
7204 # shrink interval is set to 10, pause for 7 seconds so that
7205 # grant thread did not wake up yet but coming read entered
7206 # shrink mode for rpc (osc_should_shrink_grant())
7209 declare -a cur_grant_bytes
7210 declare -a tot_granted
7211 cur_grant_bytes[0]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
7212 tot_granted[0]=$(do_facet ost1 \
7213 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
7215 dd if=$DIR/$tfile bs=4K count=1 of=/dev/null
7217 cur_grant_bytes[1]=$($LCTL get_param -n osc.*OST0000*.cur_grant_bytes)
7218 tot_granted[1]=$(do_facet ost1 \
7219 $LCTL get_param -n obdfilter.*OST0000*.tot_granted)
7221 # grant change should be equal on both sides
7222 (( cur_grant_bytes[0] - cur_grant_bytes[1] ==
7223 tot_granted[0] - tot_granted[1])) ||
7224 error "grant change mismatch, " \
7225 "server: ${tot_granted[0]} to ${tot_granted[1]}, " \
7226 "client: ${cur_grant_bytes[0]} to ${cur_grant_bytes[1]}"
7228 run_test 64h "grant shrink on read"
7230 # bug 1414 - set/get directories' stripe info
7232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7234 test_mkdir $DIR/$tdir
7236 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7238 run_test 65a "directory with no stripe info"
7241 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7243 test_mkdir $DIR/$tdir
7244 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7246 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7249 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7251 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7254 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7255 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7257 test_mkdir $DIR/$tdir
7258 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
7260 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7261 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7263 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7265 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7268 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7270 test_mkdir $DIR/$tdir
7271 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
7272 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7274 if [[ $STRIPECOUNT -le 0 ]]; then
7276 elif [[ $STRIPECOUNT -gt 2000 ]]; then
7277 #LOV_MAX_STRIPE_COUNT is 2000
7278 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
7280 sc=$(($STRIPECOUNT - 1))
7282 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7283 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7284 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7285 error "lverify failed"
7287 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7290 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7292 test_mkdir $DIR/$tdir
7294 $SETSTRIPE $DIR/$tdir || error "setstripe"
7295 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
7296 error "no stripe info failed"
7298 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
7300 run_test 65e "directory setstripe defaults"
7303 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7305 test_mkdir $DIR/${tdir}f
7306 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
7308 run_test 65f "dir setstripe permission (should return error) ==="
7311 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7313 test_mkdir $DIR/$tdir
7314 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7316 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7317 error "setstripe -S failed"
7318 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7319 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7320 error "delete default stripe failed"
7322 run_test 65g "directory setstripe -d"
7325 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7327 test_mkdir $DIR/$tdir
7328 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7330 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7331 error "setstripe -S failed"
7332 test_mkdir $DIR/$tdir/dd1
7333 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
7334 error "stripe info inherit failed"
7336 run_test 65h "directory stripe info inherit ===================="
7339 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7341 save_layout_restore_at_exit $MOUNT
7343 # bug6367: set non-default striping on root directory
7344 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7346 # bug12836: getstripe on -1 default directory striping
7347 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7349 # bug12836: getstripe -v on -1 default directory striping
7350 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7352 # bug12836: new find on -1 default directory striping
7353 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7355 run_test 65i "various tests to set root directory striping"
7357 test_65j() { # bug6367
7358 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7362 # if we aren't already remounting for each test, do so for this test
7363 if [ "$I_MOUNTED" = "yes" ]; then
7364 cleanup || error "failed to unmount"
7368 save_layout_restore_at_exit $MOUNT
7370 $SETSTRIPE -d $MOUNT || error "setstripe failed"
7372 run_test 65j "set default striping on root directory (bug 6367)="
7376 wait_delete_completed
7377 do_facet $SINGLEMDS "lctl set_param -n \
7378 osp.$ost*MDT0000.max_create_count=$max_count"
7379 do_facet $SINGLEMDS "lctl set_param -n \
7380 osp.$ost*MDT0000.create_count=$count"
7381 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7382 echo $INACTIVE_OSC "is Activate"
7384 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7387 test_65k() { # bug11679
7388 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7389 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7390 remote_mds_nodsh && skip "remote MDS with nodsh"
7392 local disable_precreate=true
7393 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7394 disable_precreate=false
7396 echo "Check OST status: "
7397 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7398 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7400 for OSC in $MDS_OSCS; do
7401 echo $OSC "is active"
7402 do_facet $SINGLEMDS lctl --device %$OSC activate
7405 for INACTIVE_OSC in $MDS_OSCS; do
7406 local ost=$(osc_to_ost $INACTIVE_OSC)
7407 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7408 lov.*md*.target_obd |
7409 awk -F: /$ost/'{ print $1 }' | head -n 1)
7412 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
7413 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7415 echo "Deactivate: " $INACTIVE_OSC
7416 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7418 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7419 osp.$ost*MDT0000.create_count")
7420 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7421 osp.$ost*MDT0000.max_create_count")
7422 $disable_precreate &&
7423 do_facet $SINGLEMDS "lctl set_param -n \
7424 osp.$ost*MDT0000.max_create_count=0"
7426 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7427 [ -f $DIR/$tdir/$idx ] && continue
7428 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
7429 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
7431 error "setstripe $idx should succeed"; }
7432 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7434 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7437 do_facet $SINGLEMDS "lctl set_param -n \
7438 osp.$ost*MDT0000.max_create_count=$max_count"
7439 do_facet $SINGLEMDS "lctl set_param -n \
7440 osp.$ost*MDT0000.create_count=$count"
7441 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7442 echo $INACTIVE_OSC "is Activate"
7444 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7447 run_test 65k "validate manual striping works properly with deactivated OSCs"
7449 test_65l() { # bug 12836
7450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7452 test_mkdir -p $DIR/$tdir/test_dir
7453 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
7454 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7456 run_test 65l "lfs find on -1 stripe dir ========================"
7459 local layout=$(save_layout $MOUNT)
7460 $RUNAS $SETSTRIPE -c 2 $MOUNT && {
7461 restore_layout $MOUNT $layout
7462 error "setstripe should fail by non-root users"
7466 run_test 65m "normal user can't set filesystem default stripe"
7469 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.0) ]] ||
7470 skip "Need MDS version at least 2.12.0"
7471 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7473 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7474 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7475 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7477 save_layout_restore_at_exit $MOUNT
7479 # new subdirectory under root directory should not inherit
7480 # the default layout from root
7481 local dir1=$MOUNT/$tdir-1
7482 mkdir $dir1 || error "mkdir $dir1 failed"
7483 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7484 error "$dir1 shouldn't have LOV EA"
7486 # delete the default layout on root directory
7487 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7489 local dir2=$MOUNT/$tdir-2
7490 mkdir $dir2 || error "mkdir $dir2 failed"
7491 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7492 error "$dir2 shouldn't have LOV EA"
7494 # set a new striping pattern on root directory
7495 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7496 local new_def_stripe_size=$((def_stripe_size * 2))
7497 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7498 error "set stripe size on $MOUNT failed"
7500 # new file created in $dir2 should inherit the new stripe size from
7501 # the filesystem default
7502 local file2=$dir2/$tfile-2
7503 touch $file2 || error "touch $file2 failed"
7505 local file2_stripe_size=$($LFS getstripe -S $file2)
7506 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
7507 error "$file2 didn't inherit stripe size $new_def_stripe_size"
7509 local dir3=$MOUNT/$tdir-3
7510 mkdir $dir3 || error "mkdir $dir3 failed"
7511 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
7512 # the root layout, which is the actual default layout that will be used
7513 # when new files are created in $dir3.
7514 local dir3_layout=$(get_layout_param $dir3)
7515 local root_dir_layout=$(get_layout_param $MOUNT)
7516 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
7517 error "$dir3 should show the default layout from $MOUNT"
7519 # set OST pool on root directory
7520 local pool=$TESTNAME
7521 pool_add $pool || error "add $pool failed"
7522 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
7523 error "add targets to $pool failed"
7525 $LFS setstripe -p $pool $MOUNT ||
7526 error "set OST pool on $MOUNT failed"
7528 # new file created in $dir3 should inherit the pool from
7529 # the filesystem default
7530 local file3=$dir3/$tfile-3
7531 touch $file3 || error "touch $file3 failed"
7533 local file3_pool=$($LFS getstripe -p $file3)
7534 [[ "$file3_pool" = "$pool" ]] ||
7535 error "$file3 didn't inherit OST pool $pool"
7537 local dir4=$MOUNT/$tdir-4
7538 mkdir $dir4 || error "mkdir $dir4 failed"
7539 local dir4_layout=$(get_layout_param $dir4)
7540 root_dir_layout=$(get_layout_param $MOUNT)
7541 echo "$LFS getstripe -d $dir4"
7542 $LFS getstripe -d $dir4
7543 echo "$LFS getstripe -d $MOUNT"
7544 $LFS getstripe -d $MOUNT
7545 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
7546 error "$dir4 should show the default layout from $MOUNT"
7548 # new file created in $dir4 should inherit the pool from
7549 # the filesystem default
7550 local file4=$dir4/$tfile-4
7551 touch $file4 || error "touch $file4 failed"
7553 local file4_pool=$($LFS getstripe -p $file4)
7554 [[ "$file4_pool" = "$pool" ]] ||
7555 error "$file4 didn't inherit OST pool $pool"
7557 # new subdirectory under non-root directory should inherit
7558 # the default layout from its parent directory
7559 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
7560 error "set directory layout on $dir4 failed"
7562 local dir5=$dir4/$tdir-5
7563 mkdir $dir5 || error "mkdir $dir5 failed"
7565 dir4_layout=$(get_layout_param $dir4)
7566 local dir5_layout=$(get_layout_param $dir5)
7567 [[ "$dir4_layout" = "$dir5_layout" ]] ||
7568 error "$dir5 should inherit the default layout from $dir4"
7570 # though subdir under ROOT doesn't inherit default layout, but
7571 # its sub dir/file should be created with default layout.
7572 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
7573 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
7574 [[ $MDS1_VERSION -ge $(version_code 2.12.3) &&
7575 $MDS1_VERSION -lt $(version_code 2.12.50) ]] ||
7576 skip "Need MDS version at least 2.12.3 or 2.12.59"
7578 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
7579 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
7580 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
7582 if [ $default_lmv_hash == "none" ]; then
7583 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
7585 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
7586 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
7589 $LFS setdirstripe -D -c 2 $MOUNT ||
7590 error "setdirstripe -D -c 2 failed"
7591 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
7592 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
7593 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
7595 run_test 65n "don't inherit default layout from root for new subdirectories"
7597 # bug 2543 - update blocks count on client
7599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7602 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
7603 sync; sync_all_data; sync; sync_all_data
7604 cancel_lru_locks osc
7605 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
7606 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
7608 run_test 66 "update inode blocks count on client ==============="
7611 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
7615 swapon -s | awk '($1 == "'$1'") { print $4 }'
7618 # bug5265, obdfilter oa2dentry return -ENOENT
7619 # #define OBD_FAIL_SRV_ENOENT 0x217
7621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7622 remote_ost_nodsh && skip "remote OST with nodsh"
7625 $SETSTRIPE -c 1 -i 0 $f
7627 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
7629 do_facet ost1 lctl set_param fail_loc=0x217
7630 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
7631 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
7633 do_facet ost1 lctl set_param fail_loc=0
7634 $DIRECTIO write $f 0 2 || error "write error"
7636 cancel_lru_locks osc
7637 $DIRECTIO read $f 0 1 || error "read error"
7639 do_facet ost1 lctl set_param fail_loc=0x217
7640 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
7642 do_facet ost1 lctl set_param fail_loc=0
7645 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
7648 test_mkdir $DIR/$tdir
7649 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
7650 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
7652 run_test 71 "Running dbench on lustre (don't segment fault) ===="
7654 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
7655 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7656 [ "$RUNAS_ID" = "$UID" ] &&
7657 skip_env "RUNAS_ID = UID = $UID -- skipping"
7658 # Check that testing environment is properly set up. Skip if not
7659 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
7660 skip_env "User $RUNAS_ID does not exist - skipping"
7663 chmod 777 $DIR/$tfile
7664 chmod ug+s $DIR/$tfile
7665 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
7666 error "$RUNAS dd $DIR/$tfile failed"
7667 # See if we are still setuid/sgid
7668 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7669 error "S/gid is not dropped on write"
7670 # Now test that MDS is updated too
7671 cancel_lru_locks mdc
7672 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7673 error "S/gid is not dropped on MDS"
7676 run_test 72a "Test that remove suid works properly (bug5695) ===="
7678 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7681 [ "$RUNAS_ID" = "$UID" ] &&
7682 skip_env "RUNAS_ID = UID = $UID -- skipping"
7683 [ "$RUNAS_ID" -eq 0 ] &&
7684 skip_env "RUNAS_ID = 0 -- skipping"
7685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7686 # Check that testing environment is properly set up. Skip if not
7687 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7688 skip_env "User $RUNAS_ID does not exist - skipping"
7690 touch $DIR/${tfile}-f{g,u}
7691 test_mkdir $DIR/${tfile}-dg
7692 test_mkdir $DIR/${tfile}-du
7693 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7694 chmod g+s $DIR/${tfile}-{f,d}g
7695 chmod u+s $DIR/${tfile}-{f,d}u
7696 for perm in 777 2777 4777; do
7697 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7698 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7699 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7700 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7704 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7706 # bug 3462 - multiple simultaneous MDC requests
7708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7710 test_mkdir $DIR/d73-1
7711 test_mkdir $DIR/d73-2
7712 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7715 lctl set_param fail_loc=0x80000129
7716 $MULTIOP $DIR/d73-1/f73-2 Oc &
7718 lctl set_param fail_loc=0
7720 $MULTIOP $DIR/d73-2/f73-3 Oc &
7724 wait $pid1 || return 1
7728 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
7729 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
7730 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
7734 run_test 73 "multiple MDC requests (should not deadlock)"
7736 test_74a() { # bug 6149, 6184
7737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7740 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7742 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7743 # will spin in a tight reconnection loop
7744 $LCTL set_param fail_loc=0x8000030e
7745 # get any lock that won't be difficult - lookup works.
7747 $LCTL set_param fail_loc=0
7751 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
7753 test_74b() { # bug 13310
7754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7756 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7758 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7759 # will spin in a tight reconnection loop
7760 $LCTL set_param fail_loc=0x8000030e
7761 # get a "difficult" lock
7763 $LCTL set_param fail_loc=0
7767 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
7770 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7772 #define OBD_FAIL_LDLM_NEW_LOCK
7773 $LCTL set_param fail_loc=0x319
7774 touch $DIR/$tfile && error "touch successful"
7775 $LCTL set_param fail_loc=0
7778 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
7781 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
7784 test_76() { # Now for bug 20433, added originally in bug 1443
7785 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7787 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
7789 cancel_lru_locks osc
7790 BEFORE_INODES=$(num_inodes)
7791 echo "before inodes: $BEFORE_INODES"
7793 [ "$SLOW" = "no" ] && COUNT=100
7794 for i in $(seq $COUNT); do
7798 cancel_lru_locks osc
7799 AFTER_INODES=$(num_inodes)
7800 echo "after inodes: $AFTER_INODES"
7802 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
7804 AFTER_INODES=$(num_inodes)
7806 echo "wait $wait seconds inodes: $AFTER_INODES"
7807 if [ $wait -gt 30 ]; then
7808 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
7812 run_test 76 "confirm clients recycle inodes properly ===="
7818 # Note: in sptlrpc modes which enable its own bulk checksum, the
7819 # original crc32_le bulk checksum will be automatically disabled,
7820 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
7821 # will be checked by sptlrpc code against sptlrpc bulk checksum.
7822 # In this case set_checksums() will not be no-op, because sptlrpc
7823 # bulk checksum will be enabled all through the test.
7825 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
7826 lctl set_param -n osc.*.checksums $1
7830 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7831 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
7832 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7833 tr -d [] | head -n1)}
7836 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
7837 log "set checksum type to $1"
7840 F77_TMP=$TMP/f77-temp
7843 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
7844 error "error writing to $F77_TMP"
7847 test_77a() { # bug 10889
7848 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7849 $GSS && skip_env "could not run with gss"
7851 [ ! -f $F77_TMP ] && setup_f77
7853 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
7857 run_test 77a "normal checksum read/write operation"
7859 test_77b() { # bug 10889
7860 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7861 $GSS && skip_env "could not run with gss"
7863 [ ! -f $F77_TMP ] && setup_f77
7864 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7865 $LCTL set_param fail_loc=0x80000409
7868 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7869 error "dd error: $?"
7870 $LCTL set_param fail_loc=0
7872 for algo in $CKSUM_TYPES; do
7873 cancel_lru_locks osc
7874 set_checksum_type $algo
7875 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7876 $LCTL set_param fail_loc=0x80000408
7877 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7878 $LCTL set_param fail_loc=0
7881 set_checksum_type $ORIG_CSUM_TYPE
7884 run_test 77b "checksum error on client write, read"
7889 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7891 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7892 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7893 $check_ost && [ -n "$ost_file_prefix" ] &&
7894 do_facet ost1 rm -f ${ost_file_prefix}\*
7898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7899 $GSS && skip_env "could not run with gss"
7900 remote_ost_nodsh && skip "remote OST with nodsh"
7903 local osc_file_prefix
7905 local check_ost=false
7906 local ost_file_prefix
7912 # ensure corruption will occur on first OSS/OST
7913 $LFS setstripe -i 0 $DIR/$tfile
7915 [ ! -f $F77_TMP ] && setup_f77
7916 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7917 error "dd write error: $?"
7918 fid=$($LFS path2fid $DIR/$tfile)
7920 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
7923 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7924 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7926 echo "OSS do not support bulk pages dump upon error"
7929 osc_file_prefix=$($LCTL get_param -n debug_path)
7930 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7932 trap cleanup_77c EXIT
7935 # enable bulk pages dump upon error on Client
7936 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7937 # enable bulk pages dump upon error on OSS
7939 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7941 # flush Client cache to allow next read to reach OSS
7942 cancel_lru_locks osc
7944 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7945 $LCTL set_param fail_loc=0x80000408
7946 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7947 $LCTL set_param fail_loc=0
7951 # check cksum dump on Client
7952 osc_file=$(ls ${osc_file_prefix}*)
7953 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7954 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7955 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7956 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7957 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7959 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7960 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7961 error "dump content does not match on Client"
7963 $check_ost || skip "No need to check cksum dump on OSS"
7965 # check cksum dump on OSS
7966 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7967 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7968 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7969 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7970 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7971 error "dump content does not match on OSS"
7975 run_test 77c "checksum error on client read with debug"
7977 test_77d() { # bug 10889
7978 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7979 $GSS && skip_env "could not run with gss"
7981 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7982 $LCTL set_param fail_loc=0x80000409
7984 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7985 error "direct write: rc=$?"
7986 $LCTL set_param fail_loc=0
7989 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7990 $LCTL set_param fail_loc=0x80000408
7992 cancel_lru_locks osc
7993 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7994 error "direct read: rc=$?"
7995 $LCTL set_param fail_loc=0
7998 run_test 77d "checksum error on OST direct write, read"
8000 test_77f() { # bug 10889
8001 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8002 $GSS && skip_env "could not run with gss"
8005 for algo in $CKSUM_TYPES; do
8006 cancel_lru_locks osc
8007 set_checksum_type $algo
8008 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8009 $LCTL set_param fail_loc=0x409
8010 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
8011 error "direct write succeeded"
8012 $LCTL set_param fail_loc=0
8014 set_checksum_type $ORIG_CSUM_TYPE
8017 run_test 77f "repeat checksum error on write (expect error)"
8019 test_77g() { # bug 10889
8020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8021 $GSS && skip_env "could not run with gss"
8022 remote_ost_nodsh && skip "remote OST with nodsh"
8024 [ ! -f $F77_TMP ] && setup_f77
8026 local file=$DIR/$tfile
8027 stack_trap "rm -f $file" EXIT
8029 $SETSTRIPE -c 1 -i 0 $file
8030 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
8031 do_facet ost1 lctl set_param fail_loc=0x8000021a
8033 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
8034 error "write error: rc=$?"
8035 do_facet ost1 lctl set_param fail_loc=0
8038 cancel_lru_locks osc
8039 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
8040 do_facet ost1 lctl set_param fail_loc=0x8000021b
8042 cmp $F77_TMP $file || error "file compare failed"
8043 do_facet ost1 lctl set_param fail_loc=0
8046 run_test 77g "checksum error on OST write, read"
8048 test_77k() { # LU-10906
8049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8050 $GSS && skip_env "could not run with gss"
8052 local cksum_param="osc.$FSNAME*.checksums"
8053 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
8057 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
8058 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
8059 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
8063 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
8064 error "failed to set checksum=$i on MGS"
8065 wait_update $HOSTNAME "$get_checksum" $i
8067 echo "remount client, checksum should be $i"
8068 remount_client $MOUNT || "failed to remount client"
8069 checksum=$(eval $get_checksum)
8070 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8073 for opt in "checksum" "nochecksum"; do
8074 #remount with mount option
8075 echo "remount client with option $opt, checksum should be $i"
8076 umount_client $MOUNT || "failed to umount client"
8077 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8078 "failed to mount client with option '$opt'"
8079 checksum=$(eval $get_checksum)
8080 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8084 remount_client $MOUNT || "failed to remount client"
8086 run_test 77k "enable/disable checksum correctly"
8088 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8097 test_78() { # bug 10901
8098 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8099 remote_ost || skip_env "local OST"
8102 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8103 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8104 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8105 echo "MemTotal: $MEMTOTAL"
8107 # reserve 256MB of memory for the kernel and other running processes,
8108 # and then take 1/2 of the remaining memory for the read/write buffers.
8109 if [ $MEMTOTAL -gt 512 ] ;then
8110 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8112 # for those poor memory-starved high-end clusters...
8113 MEMTOTAL=$((MEMTOTAL / 2))
8115 echo "Mem to use for directio: $MEMTOTAL"
8117 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8118 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8119 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8120 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8122 echo "Smallest OST: $SMALLESTOST"
8123 [[ $SMALLESTOST -lt 10240 ]] &&
8124 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8126 trap cleanup_test_78 EXIT
8128 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8129 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8131 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8132 echo "File size: $F78SIZE"
8133 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8134 for i in $(seq 1 $NSEQ); do
8135 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8136 echo directIO rdwr round $i of $NSEQ
8137 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8142 run_test 78 "handle large O_DIRECT writes correctly ============"
8144 test_79() { # bug 12743
8145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8147 wait_delete_completed
8149 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8150 BKFREE=$(calc_osc_kbytes kbytesfree)
8151 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8153 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8154 DFTOTAL=`echo $STRING | cut -d, -f1`
8155 DFUSED=`echo $STRING | cut -d, -f2`
8156 DFAVAIL=`echo $STRING | cut -d, -f3`
8157 DFFREE=$(($DFTOTAL - $DFUSED))
8159 ALLOWANCE=$((64 * $OSTCOUNT))
8161 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8162 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8163 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8165 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8166 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8167 error "df free($DFFREE) mismatch OST free($BKFREE)"
8169 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8170 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8171 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8174 run_test 79 "df report consistency check ======================="
8176 test_80() { # bug 10718
8177 remote_ost_nodsh && skip "remote OST with nodsh"
8178 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8180 # relax strong synchronous semantics for slow backends like ZFS
8181 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8182 local soc="obdfilter.*.sync_lock_cancel"
8183 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8185 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
8186 if [ -z "$save" ]; then
8187 soc="obdfilter.*.sync_on_lock_cancel"
8188 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8191 if [ "$save" != "never" ]; then
8192 local hosts=$(comma_list $(osts_nodes))
8194 do_nodes $hosts $LCTL set_param $soc=never
8195 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
8199 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
8201 local before=$(date +%s)
8202 cancel_lru_locks osc
8203 local after=$(date +%s)
8204 local diff=$((after - before))
8205 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
8209 run_test 80 "Page eviction is equally fast at high offsets too"
8211 test_81a() { # LU-456
8212 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8213 remote_ost_nodsh && skip "remote OST with nodsh"
8215 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8216 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8217 do_facet ost1 lctl set_param fail_loc=0x80000228
8219 # write should trigger a retry and success
8220 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
8221 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8223 if [ $RC -ne 0 ] ; then
8224 error "write should success, but failed for $RC"
8227 run_test 81a "OST should retry write when get -ENOSPC ==============="
8229 test_81b() { # LU-456
8230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8231 remote_ost_nodsh && skip "remote OST with nodsh"
8233 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8234 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8235 do_facet ost1 lctl set_param fail_loc=0x228
8237 # write should retry several times and return -ENOSPC finally
8238 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
8239 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8242 if [ $RC -ne $ENOSPC ] ; then
8243 error "dd should fail for -ENOSPC, but succeed."
8246 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8248 test_82() { # LU-1031
8249 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
8253 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
8255 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
8257 kill -USR1 $MULTIPID2
8259 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
8260 error "First grouplock does not block second one"
8262 echo "Second grouplock blocks first one"
8264 kill -USR1 $MULTIPID1
8268 run_test 82 "Basic grouplock test"
8271 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
8273 test_mkdir $DIR/$tdir.cvsroot
8274 chown $RUNAS_ID $DIR/$tdir.cvsroot
8277 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
8280 # some versions of cvs import exit(1) when asked to import links or
8281 # files they can't read. ignore those files.
8282 local toignore=$(find . -type l -printf '-I %f\n' -o \
8283 ! -perm /4 -printf '-I %f\n')
8284 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
8285 $tdir.reposname vtag rtag
8288 test_mkdir $DIR/$tdir.reposname
8289 chown $RUNAS_ID $DIR/$tdir.reposname
8290 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
8292 cd $DIR/$tdir.reposname
8294 $RUNAS cvs add -m 'addmsg' foo99
8296 $RUNAS cvs commit -m 'nomsg' foo99
8297 rm -fr $DIR/$tdir.cvsroot
8299 run_test 99 "cvs strange file/directory operations"
8302 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8303 [[ "$NETTYPE" =~ tcp ]] ||
8304 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
8305 remote_ost_nodsh && skip "remote OST with nodsh"
8306 remote_mds_nodsh && skip "remote MDS with nodsh"
8308 skip "useless for local single node setup"
8310 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
8311 [ "$PROT" != "tcp" ] && continue
8312 RPORT=$(echo $REMOTE | cut -d: -f2)
8313 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
8316 LPORT=`echo $LOCAL | cut -d: -f2`
8317 if [ $LPORT -ge 1024 ]; then
8318 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
8320 error_exit "local: $LPORT > 1024, remote: $RPORT"
8323 [ "$rc" = 0 ] || error_exit "privileged port not found" )
8325 run_test 100 "check local port using privileged port ==========="
8327 function get_named_value()
8336 echo $line | sed "s/^$tag[ ]*//"
8343 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
8344 awk '/^max_cached_mb/ { print $2 }')
8347 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
8352 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8353 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
8358 local cache_limit=32
8360 $LCTL set_param -n osc.*-osc*.rpc_stats 0
8361 trap cleanup_101a EXIT
8362 $LCTL set_param -n llite.*.read_ahead_stats 0
8363 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
8366 # randomly read 10000 of 64K chunks from file 3x 32MB in size
8368 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
8369 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
8372 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
8373 get_named_value 'read but discarded' | cut -d" " -f1); do
8374 discard=$(($discard + $s))
8378 if [[ $(($discard * 10)) -gt $nreads ]]; then
8379 $LCTL get_param osc.*-osc*.rpc_stats
8380 $LCTL get_param llite.*.read_ahead_stats
8381 error "too many ($discard) discarded pages"
8383 rm -f $DIR/$tfile || true
8385 run_test 101a "check read-ahead for random reads"
8388 test_mkdir $DIR/$tdir
8389 local STRIPE_SIZE=$1
8390 local FILE_LENGTH=$2
8393 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
8395 local list=$(comma_list $(osts_nodes))
8396 set_osd_param $list '' read_cache_enable 0
8397 set_osd_param $list '' writethrough_cache_enable 0
8399 trap cleanup_test101bc EXIT
8400 # prepare the read-ahead file
8401 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8403 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
8404 count=$FILE_SIZE_MB 2> /dev/null
8408 cleanup_test101bc() {
8413 local list=$(comma_list $(osts_nodes))
8414 set_osd_param $list '' read_cache_enable 1
8415 set_osd_param $list '' writethrough_cache_enable 1
8419 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8424 local STRIPE_SIZE=$2
8425 local FILE_LENGTH=$3
8426 local RA_INC=1048576
8427 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8428 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8429 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8430 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8431 get_named_value 'read but discarded' |
8432 cut -d" " -f1 | calc_total)
8433 if [[ $DISCARD -gt $discard_limit ]]; then
8434 $LCTL get_param llite.*.read_ahead_stats
8435 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8437 echo "Read-ahead success for size ${READ_SIZE}"
8442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8443 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8445 local STRIPE_SIZE=1048576
8446 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8448 if [ $SLOW == "yes" ]; then
8449 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8451 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8454 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8456 # prepare the read-ahead file
8457 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8458 cancel_lru_locks osc
8459 for BIDX in 2 4 8 16 32 64 128 256
8461 local BSIZE=$((BIDX*4096))
8462 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
8463 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
8464 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
8465 $LCTL set_param -n llite.*.read_ahead_stats 0
8466 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
8467 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
8468 cancel_lru_locks osc
8469 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
8474 run_test 101b "check stride-io mode read-ahead ================="
8477 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8479 local STRIPE_SIZE=1048576
8480 local FILE_LENGTH=$((STRIPE_SIZE*100))
8485 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8487 cancel_lru_locks osc
8488 $LCTL set_param osc.*.rpc_stats 0
8489 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
8490 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
8491 local stats=$($LCTL get_param -n $osc_rpc_stats)
8492 local lines=$(echo "$stats" | awk 'END {print NR;}')
8495 if [ $lines -le 20 ]; then
8498 for size in 1 2 4 8; do
8499 local rpc=$(echo "$stats" |
8500 awk '($1 == "'$size':") {print $2; exit; }')
8501 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
8502 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
8504 echo "$osc_rpc_stats check passed!"
8509 run_test 101c "check stripe_size aligned read-ahead ================="
8512 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
8513 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
8517 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8519 local file=$DIR/$tfile
8520 local sz_MB=${FILESIZE_101d:-500}
8521 local ra_MB=${READAHEAD_MB:-40}
8523 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
8524 [ $free_MB -lt $sz_MB ] &&
8525 skip "Need free space ${sz_MB}M, have ${free_MB}M"
8527 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
8528 $SETSTRIPE -c -1 $file || error "setstripe failed"
8530 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
8531 echo Cancel LRU locks on lustre client to flush the client cache
8532 cancel_lru_locks osc
8534 echo Disable read-ahead
8535 local old_READAHEAD=$(set_read_ahead 0)
8537 echo Reading the test file $file with read-ahead disabled
8538 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8540 echo Cancel LRU locks on lustre client to flush the client cache
8541 cancel_lru_locks osc
8542 echo Enable read-ahead with ${ra_MB}MB
8543 set_read_ahead $ra_MB
8545 echo Reading the test file $file with read-ahead enabled
8546 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8548 echo "read-ahead disabled time read $raOFF"
8549 echo "read-ahead enabled time read $raON"
8551 set_read_ahead $old_READAHEAD
8553 wait_delete_completed
8555 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
8556 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
8558 run_test 101d "file read with and without read-ahead enabled"
8561 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8563 local file=$DIR/$tfile
8564 local size_KB=500 #KB
8568 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
8569 local need_KB=$((count * size_KB))
8570 [[ $free_KB -le $need_KB ]] &&
8571 skip_env "Need free space $need_KB, have $free_KB"
8573 echo "Creating $count ${size_KB}K test files"
8574 for ((i = 0; i < $count; i++)); do
8575 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
8578 echo "Cancel LRU locks on lustre client to flush the client cache"
8579 cancel_lru_locks $OSC
8581 echo "Reset readahead stats"
8582 $LCTL set_param -n llite.*.read_ahead_stats 0
8584 for ((i = 0; i < $count; i++)); do
8585 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
8588 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8589 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8591 for ((i = 0; i < $count; i++)); do
8592 rm -rf $file.$i 2>/dev/null
8595 #10000 means 20% reads are missing in readahead
8596 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
8598 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
8601 which iozone || skip_env "no iozone installed"
8603 local old_debug=$($LCTL get_param debug)
8604 old_debug=${old_debug#*=}
8605 $LCTL set_param debug="reada mmap"
8607 # create a test file
8608 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
8610 echo Cancel LRU locks on lustre client to flush the client cache
8611 cancel_lru_locks osc
8613 echo Reset readahead stats
8614 $LCTL set_param -n llite.*.read_ahead_stats 0
8616 echo mmap read the file with small block size
8617 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
8620 echo checking missing pages
8621 $LCTL get_param llite.*.read_ahead_stats
8622 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8623 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8625 $LCTL set_param debug="$old_debug"
8626 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
8629 run_test 101f "check mmap read performance"
8631 test_101g_brw_size_test() {
8633 local pages=$((mb * 1048576 / PAGE_SIZE))
8634 local file=$DIR/$tfile
8636 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
8637 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
8638 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
8639 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
8643 stack_trap "rm -f $file" EXIT
8644 $LCTL set_param -n osc.*.rpc_stats=0
8646 # 10 RPCs should be enough for the test
8648 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
8649 { error "dd write ${mb} MB blocks failed"; return 3; }
8650 cancel_lru_locks osc
8651 dd of=/dev/null if=$file bs=${mb}M count=$count ||
8652 { error "dd write ${mb} MB blocks failed"; return 4; }
8654 # calculate number of full-sized read and write RPCs
8655 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
8656 sed -n '/pages per rpc/,/^$/p' |
8657 awk '/'$pages':/ { reads += $2; writes += $6 }; \
8658 END { print reads,writes }'))
8659 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
8661 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
8668 remote_ost_nodsh && skip "remote OST with nodsh"
8671 local osts=$(get_facets OST)
8672 local list=$(comma_list $(osts_nodes))
8673 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8674 local brw_size="obdfilter.*.brw_size"
8676 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8678 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
8679 if [ $OST1_VERSION -ge $(version_code 2.8.52) -o \
8680 \( $OST1_VERSION -ge $(version_code 2.7.17) -a \
8681 $OST1_VERSION -lt $(version_code 2.7.50) \) ] &&
8682 [ $CLIENT_VERSION -ge $(version_code 2.8.52) -o \
8683 \( $CLIENT_VERSION -ge $(version_code 2.7.17) -a \
8684 $CLIENT_VERSION -lt $(version_code 2.7.50) \) ]; then
8685 [ $OST1_VERSION -ge $(version_code 2.9.52) ] && suffix="M"
8686 if [[ $orig_mb -lt 16 ]]; then
8687 save_lustre_params $osts "$brw_size" > $p
8688 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
8689 error "set 16MB RPC size failed"
8691 echo "remount client to enable new RPC size"
8692 remount_client $MOUNT || error "remount_client failed"
8695 test_101g_brw_size_test 16 || error "16MB RPC test failed"
8696 # should be able to set brw_size=12, but no rpc_stats for that
8697 test_101g_brw_size_test 8 || error "8MB RPC test failed"
8700 test_101g_brw_size_test 4 || error "4MB RPC test failed"
8702 if [[ $orig_mb -lt 16 ]]; then
8703 restore_lustre_params < $p
8704 remount_client $MOUNT || error "remount_client restore failed"
8707 rm -f $p $DIR/$tfile
8709 run_test 101g "Big bulk(4/16 MiB) readahead"
8712 test_mkdir $DIR/$tdir
8713 chown $RUNAS_ID $DIR/$tdir
8716 STRIPE_COUNT=$OSTCOUNT
8717 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
8719 trap cleanup_test102 EXIT
8721 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
8723 for num in 1 2 3 4; do
8724 for count in $(seq 1 $STRIPE_COUNT); do
8725 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
8726 local size=`expr $STRIPE_SIZE \* $num`
8727 local file=file"$num-$idx-$count"
8728 $1 $SETSTRIPE -S $size -i $idx -c $count $file
8734 $1 tar cf $TMP/f102.tar $tdir --xattrs
8740 rm -rf $DIR/d0.sanity/d102
8744 [ "$UID" != 0 ] && skip "must run as root"
8745 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
8746 skip_env "must have user_xattr"
8748 [ -z "$(which setfattr 2>/dev/null)" ] &&
8749 skip_env "could not find setfattr"
8751 local testfile=$DIR/$tfile
8754 echo "set/get xattr..."
8755 setfattr -n trusted.name1 -v value1 $testfile ||
8756 error "setfattr -n trusted.name1=value1 $testfile failed"
8757 getfattr -n trusted.name1 $testfile 2> /dev/null |
8758 grep "trusted.name1=.value1" ||
8759 error "$testfile missing trusted.name1=value1"
8761 setfattr -n user.author1 -v author1 $testfile ||
8762 error "setfattr -n user.author1=author1 $testfile failed"
8763 getfattr -n user.author1 $testfile 2> /dev/null |
8764 grep "user.author1=.author1" ||
8765 error "$testfile missing trusted.author1=author1"
8768 setfattr -n trusted.name2 -v value2 $testfile ||
8769 error "$testfile unable to set trusted.name2"
8770 setfattr -n trusted.name3 -v value3 $testfile ||
8771 error "$testfile unable to set trusted.name3"
8772 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
8773 grep "trusted.name" | wc -l) -eq 3 ] ||
8774 error "$testfile missing 3 trusted.name xattrs"
8776 setfattr -n user.author2 -v author2 $testfile ||
8777 error "$testfile unable to set user.author2"
8778 setfattr -n user.author3 -v author3 $testfile ||
8779 error "$testfile unable to set user.author3"
8780 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
8781 grep "user.author" | wc -l) -eq 3 ] ||
8782 error "$testfile missing 3 user.author xattrs"
8784 echo "remove xattr..."
8785 setfattr -x trusted.name1 $testfile ||
8786 error "$testfile error deleting trusted.name1"
8787 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
8788 error "$testfile did not delete trusted.name1 xattr"
8790 setfattr -x user.author1 $testfile ||
8791 error "$testfile error deleting user.author1"
8792 echo "set lustre special xattr ..."
8793 $LFS setstripe -c1 $testfile
8794 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
8795 awk -F "=" '/trusted.lov/ { print $2 }' )
8796 setfattr -n "trusted.lov" -v $lovea $testfile ||
8797 error "$testfile doesn't ignore setting trusted.lov again"
8798 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
8799 error "$testfile allow setting invalid trusted.lov"
8802 run_test 102a "user xattr test =================================="
8804 check_102b_layout() {
8806 local testfile=$DIR/$tfile
8808 echo "test layout '$layout'"
8809 $LFS setstripe $layout $testfile || error "setstripe failed"
8810 $LFS getstripe -y $testfile
8812 echo "get/set/list trusted.lov xattr ..." # b=10930
8813 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
8814 [[ "$value" =~ "trusted.lov" ]] ||
8815 error "can't get trusted.lov from $testfile"
8816 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
8817 error "getstripe failed"
8819 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
8821 value=$(cut -d= -f2 <<<$value)
8822 # LU-13168: truncated xattr should fail if short lov_user_md header
8823 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
8824 lens="${#value}" || lens="$(seq 4 2 ${#value})"
8825 for len in $lens; do
8826 echo "setfattr $len $testfile.2"
8827 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
8828 [ $len -lt 66 ] && error "short xattr len=$len worked"
8830 local stripe_size=$($LFS getstripe -S $testfile.2)
8831 local stripe_count=$($LFS getstripe -c $testfile.2)
8832 [[ $stripe_size -eq 65536 ]] ||
8833 error "stripe size $stripe_size != 65536"
8834 [[ $stripe_count -eq $stripe_count_orig ]] ||
8835 error "stripe count $stripe_count != $stripe_count_orig"
8836 rm $testfile $testfile.2
8840 [ -z "$(which setfattr 2>/dev/null)" ] &&
8841 skip_env "could not find setfattr"
8842 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8844 # check plain layout
8845 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
8847 # and also check composite layout
8848 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
8851 run_test 102b "getfattr/setfattr for trusted.lov EAs"
8854 [ -z "$(which setfattr 2>/dev/null)" ] &&
8855 skip_env "could not find setfattr"
8856 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8858 # b10930: get/set/list lustre.lov xattr
8859 echo "get/set/list lustre.lov xattr ..."
8860 test_mkdir $DIR/$tdir
8861 chown $RUNAS_ID $DIR/$tdir
8862 local testfile=$DIR/$tdir/$tfile
8863 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8864 error "setstripe failed"
8865 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
8866 error "getstripe failed"
8867 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
8868 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8870 local testfile2=${testfile}2
8871 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8872 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8874 $RUNAS $MCREATE $testfile2
8875 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8876 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
8877 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
8878 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8879 [ $stripe_count -eq $STRIPECOUNT ] ||
8880 error "stripe count $stripe_count != $STRIPECOUNT"
8882 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8884 compare_stripe_info1() {
8885 local stripe_index_all_zero=true
8887 for num in 1 2 3 4; do
8888 for count in $(seq 1 $STRIPE_COUNT); do
8889 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8890 local size=$((STRIPE_SIZE * num))
8891 local file=file"$num-$offset-$count"
8892 stripe_size=$($LFS getstripe -S $PWD/$file)
8893 [[ $stripe_size -ne $size ]] &&
8894 error "$file: size $stripe_size != $size"
8895 stripe_count=$($LFS getstripe -c $PWD/$file)
8896 # allow fewer stripes to be created, ORI-601
8897 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8898 error "$file: count $stripe_count != $count"
8899 stripe_index=$($LFS getstripe -i $PWD/$file)
8900 [[ $stripe_index -ne 0 ]] &&
8901 stripe_index_all_zero=false
8905 $stripe_index_all_zero &&
8906 error "all files are being extracted starting from OST index 0"
8910 have_xattrs_include() {
8911 tar --help | grep -q xattrs-include &&
8912 echo --xattrs-include="lustre.*"
8916 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8917 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8919 XINC=$(have_xattrs_include)
8921 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8923 compare_stripe_info1
8925 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8929 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8931 XINC=$(have_xattrs_include)
8933 test_mkdir $DIR/$tdir.restore
8935 tar cf - --xattrs $tdir | tar xf - \
8936 -C $DIR/$tdir.restore --xattrs $XINC
8937 cd $DIR/$tdir.restore/$tdir
8938 compare_stripe_info1
8940 run_test 102f "tar copy files, not keep osts"
8943 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8944 skip "must have user_xattr"
8945 [ -z "$(which setfattr 2>/dev/null)" ] &&
8946 skip_env "could not find setfattr"
8947 [ -z "$(which getfattr 2>/dev/null)" ] &&
8948 skip_env "could not find getfattr"
8950 local xsize=${1:-1024} # in bytes
8951 local file=$DIR/$tfile
8952 local value="$(generate_string $xsize)"
8953 local xbig=trusted.big
8956 log "save $xbig on $file"
8957 setfattr -n $xbig -v $value $file ||
8958 error "saving $xbig on $file failed"
8960 local orig=$(get_xattr_value $xbig $file)
8961 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8963 local xsml=trusted.sml
8964 log "save $xsml on $file"
8965 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8967 local new=$(get_xattr_value $xbig $file)
8968 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8970 log "grow $xsml on $file"
8971 setfattr -n $xsml -v "$value" $file ||
8972 error "growing $xsml on $file failed"
8974 new=$(get_xattr_value $xbig $file)
8975 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8976 log "$xbig still valid after growing $xsml"
8981 test_102h() { # bug 15777
8984 run_test 102h "grow xattr from inside inode to external block"
8987 large_xattr_enabled || skip_env "ea_inode feature disabled"
8989 grow_xattr $(max_xattr_size)
8991 run_test 102ha "grow xattr from inside inode to external inode"
8993 test_102i() { # bug 17038
8994 [ -z "$(which getfattr 2>/dev/null)" ] &&
8995 skip "could not find getfattr"
8998 ln -s $DIR/$tfile $DIR/${tfile}link
8999 getfattr -n trusted.lov $DIR/$tfile ||
9000 error "lgetxattr on $DIR/$tfile failed"
9001 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
9002 grep -i "no such attr" ||
9003 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
9004 rm -f $DIR/$tfile $DIR/${tfile}link
9006 run_test 102i "lgetxattr test on symbolic link ============"
9009 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9010 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9012 XINC=$(have_xattrs_include)
9013 setup_test102 "$RUNAS"
9014 chown $RUNAS_ID $DIR/$tdir
9015 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9017 compare_stripe_info1 "$RUNAS"
9019 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
9022 [ -z "$(which setfattr 2>/dev/null)" ] &&
9023 skip "could not find setfattr"
9026 # b22187 just check that does not crash for regular file.
9027 setfattr -n trusted.lov $DIR/$tfile
9028 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9029 local test_kdir=$DIR/$tdir
9030 test_mkdir $test_kdir
9031 local default_size=$($LFS getstripe -S $test_kdir)
9032 local default_count=$($LFS getstripe -c $test_kdir)
9033 local default_offset=$($LFS getstripe -i $test_kdir)
9034 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9035 error 'dir setstripe failed'
9036 setfattr -n trusted.lov $test_kdir
9037 local stripe_size=$($LFS getstripe -S $test_kdir)
9038 local stripe_count=$($LFS getstripe -c $test_kdir)
9039 local stripe_offset=$($LFS getstripe -i $test_kdir)
9040 [ $stripe_size -eq $default_size ] ||
9041 error "stripe size $stripe_size != $default_size"
9042 [ $stripe_count -eq $default_count ] ||
9043 error "stripe count $stripe_count != $default_count"
9044 [ $stripe_offset -eq $default_offset ] ||
9045 error "stripe offset $stripe_offset != $default_offset"
9046 rm -rf $DIR/$tfile $test_kdir
9048 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9051 [ -z "$(which getfattr 2>/dev/null)" ] &&
9052 skip "could not find getfattr"
9054 # LU-532 trusted. xattr is invisible to non-root
9055 local testfile=$DIR/$tfile
9059 echo "listxattr as user..."
9060 chown $RUNAS_ID $testfile
9061 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9062 grep -q "trusted" &&
9063 error "$testfile trusted xattrs are user visible"
9067 run_test 102l "listxattr size test =================================="
9069 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9070 local path=$DIR/$tfile
9073 listxattr_size_check $path || error "listattr_size_check $path failed"
9075 run_test 102m "Ensure listxattr fails on small bufffer ========"
9079 getxattr() { # getxattr path name
9080 # Return the base64 encoding of the value of xattr name on path.
9084 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9086 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9088 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9090 getfattr --absolute-names --encoding=base64 --name=$name $path |
9091 awk -F= -v name=$name '$1 == name {
9092 print substr($0, index($0, "=") + 1);
9096 test_102n() { # LU-4101 mdt: protect internal xattrs
9097 [ -z "$(which setfattr 2>/dev/null)" ] &&
9098 skip "could not find setfattr"
9099 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9101 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
9104 local file0=$DIR/$tfile.0
9105 local file1=$DIR/$tfile.1
9106 local xattr0=$TMP/$tfile.0
9107 local xattr1=$TMP/$tfile.1
9108 local namelist="lov lma lmv link fid version som hsm"
9112 rm -rf $file0 $file1 $xattr0 $xattr1
9115 # Get 'before' xattrs of $file1.
9116 getfattr --absolute-names --dump --match=- $file1 > $xattr0
9118 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
9119 namelist+=" lfsck_namespace"
9120 for name in $namelist; do
9121 # Try to copy xattr from $file0 to $file1.
9122 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9124 setfattr --name=trusted.$name --value="$value" $file1 ||
9125 error "setxattr 'trusted.$name' failed"
9127 # Try to set a garbage xattr.
9128 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9130 if [[ x$name == "xlov" ]]; then
9131 setfattr --name=trusted.lov --value="$value" $file1 &&
9132 error "setxattr invalid 'trusted.lov' success"
9134 setfattr --name=trusted.$name --value="$value" $file1 ||
9135 error "setxattr invalid 'trusted.$name' failed"
9138 # Try to remove the xattr from $file1. We don't care if this
9139 # appears to succeed or fail, we just don't want there to be
9140 # any changes or crashes.
9141 setfattr --remove=$trusted.$name $file1 2> /dev/null
9144 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
9147 # Try to copy xattr from $file0 to $file1.
9148 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9150 setfattr --name=trusted.$name --value="$value" $file1 ||
9151 error "setxattr 'trusted.$name' failed"
9153 # Try to set a garbage xattr.
9154 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9156 setfattr --name=trusted.$name --value="$value" $file1 ||
9157 error "setxattr 'trusted.$name' failed"
9159 # Try to remove the xattr from $file1. We don't care if this
9160 # appears to succeed or fail, we just don't want there to be
9161 # any changes or crashes.
9162 setfattr --remove=$trusted.$name $file1 2> /dev/null
9165 # Get 'after' xattrs of file1.
9166 getfattr --absolute-names --dump --match=- $file1 > $xattr1
9168 if ! diff $xattr0 $xattr1; then
9169 error "before and after xattrs of '$file1' differ"
9172 rm -rf $file0 $file1 $xattr0 $xattr1
9176 run_test 102n "silently ignore setxattr on internal trusted xattrs"
9178 test_102p() { # LU-4703 setxattr did not check ownership
9179 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
9180 skip "MDS needs to be at least 2.5.56"
9182 local testfile=$DIR/$tfile
9186 echo "setfacl as user..."
9187 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
9188 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
9190 echo "setfattr as user..."
9191 setfacl -m "u:$RUNAS_ID:---" $testfile
9192 $RUNAS setfattr -x system.posix_acl_access $testfile
9193 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
9195 run_test 102p "check setxattr(2) correctly fails without permission"
9198 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
9199 skip "MDS needs to be at least 2.6.92"
9201 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
9203 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
9206 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
9207 skip "MDS needs to be at least 2.6.93"
9209 touch $DIR/$tfile || error "touch"
9210 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
9211 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
9212 rm $DIR/$tfile || error "rm"
9215 mkdir -p $DIR/$tdir || error "mkdir"
9216 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9217 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9218 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9219 error "$testfile error deleting user.author1"
9220 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9221 grep "user.$(basename $tdir)" &&
9222 error "$tdir did not delete user.$(basename $tdir)"
9223 rmdir $DIR/$tdir || error "rmdir"
9226 test_mkdir $DIR/$tdir
9227 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9228 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9229 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9230 error "$testfile error deleting user.author1"
9231 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9232 grep "user.$(basename $tdir)" &&
9233 error "$tdir did not delete user.$(basename $tdir)"
9234 rmdir $DIR/$tdir || error "rm striped dir"
9236 run_test 102r "set EAs with empty values"
9239 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9240 skip "MDS needs to be at least 2.11.52"
9242 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9244 save_lustre_params client "llite.*.xattr_cache" > $save
9246 for cache in 0 1; do
9247 lctl set_param llite.*.xattr_cache=$cache
9250 touch $DIR/$tfile || error "touch"
9251 for prefix in lustre security system trusted user; do
9252 # Note getxattr() may fail with 'Operation not
9253 # supported' or 'No such attribute' depending
9254 # on prefix and cache.
9255 getfattr -n $prefix.n102s $DIR/$tfile &&
9256 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
9260 restore_lustre_params < $save
9262 run_test 102s "getting nonexistent xattrs should fail"
9265 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9266 skip "MDS needs to be at least 2.11.52"
9268 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9270 save_lustre_params client "llite.*.xattr_cache" > $save
9272 for cache in 0 1; do
9273 lctl set_param llite.*.xattr_cache=$cache
9275 for buf_size in 0 256; do
9277 touch $DIR/$tfile || error "touch"
9278 setfattr -n user.multiop $DIR/$tfile
9279 $MULTIOP $DIR/$tfile oa$buf_size ||
9280 error "cannot get zero length xattr value (buf_size = $buf_size)"
9284 restore_lustre_params < $save
9286 run_test 102t "zero length xattr values handled correctly"
9290 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
9295 [ "$UID" != 0 ] && skip "must run as root"
9296 $GSS && skip_env "could not run under gss"
9297 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
9298 skip_env "must have acl enabled"
9299 [ -z "$(which setfacl 2>/dev/null)" ] &&
9300 skip_env "could not find setfacl"
9301 remote_mds_nodsh && skip "remote MDS with nodsh"
9303 gpasswd -a daemon bin # LU-5641
9304 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
9306 declare -a identity_old
9308 for num in $(seq $MDSCOUNT); do
9309 switch_identity $num true || identity_old[$num]=$?
9317 echo "performing cp ..."
9318 run_acl_subtest cp || error "run_acl_subtest cp failed"
9319 echo "performing getfacl-noacl..."
9320 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
9321 echo "performing misc..."
9322 run_acl_subtest misc || error "misc test failed"
9323 echo "performing permissions..."
9324 run_acl_subtest permissions || error "permissions failed"
9325 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
9326 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
9327 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
9328 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
9330 echo "performing permissions xattr..."
9331 run_acl_subtest permissions_xattr ||
9332 error "permissions_xattr failed"
9334 echo "performing setfacl..."
9335 run_acl_subtest setfacl || error "setfacl test failed"
9337 # inheritance test got from HP
9338 echo "performing inheritance..."
9339 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
9340 chmod +x make-tree || error "chmod +x failed"
9341 run_acl_subtest inheritance || error "inheritance test failed"
9344 echo "LU-974 ignore umask when acl is enabled..."
9345 run_acl_subtest 974 || error "LU-974 umask test failed"
9346 if [ $MDSCOUNT -ge 2 ]; then
9347 run_acl_subtest 974_remote ||
9348 error "LU-974 umask test failed under remote dir"
9351 echo "LU-2561 newly created file is same size as directory..."
9352 if [ "$mds1_FSTYPE" != "zfs" ]; then
9353 run_acl_subtest 2561 || error "LU-2561 test failed"
9355 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
9358 run_acl_subtest 4924 || error "LU-4924 test failed"
9363 for num in $(seq $MDSCOUNT); do
9364 if [ "${identity_old[$num]}" = 1 ]; then
9365 switch_identity $num false || identity_old[$num]=$?
9369 run_test 103a "acl test"
9375 for U in {0..511}; do
9377 local O=$(printf "%04o" $U)
9379 umask $(printf "%04o" $((511 ^ $O)))
9380 $LFS setstripe -c 1 $DIR/$tfile.s$O
9381 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9383 (( $S == ($O & 0666) )) ||
9384 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9386 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9387 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9388 (( $S == ($O & 0666) )) ||
9389 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9391 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9392 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9393 (( $S == ($O & 0666) )) ||
9394 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9395 rm -f $DIR/$tfile.[smp]$0
9399 # limit the concurrently running threads to 64. LU-11878
9400 local idx=$((U % 64))
9401 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9406 run_test 103b "umask lfs setstripe"
9410 cp -rp $DIR/$tdir $DIR/$tdir.bak
9412 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9413 error "$DIR/$tdir shouldn't contain default ACL"
9414 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9415 error "$DIR/$tdir.bak shouldn't contain default ACL"
9418 run_test 103c "'cp -rp' won't set empty acl"
9421 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9424 lfs df || error "lfs df failed"
9425 lfs df -ih || error "lfs df -ih failed"
9426 lfs df -h $DIR || error "lfs df -h $DIR failed"
9427 lfs df -i $DIR || error "lfs df -i $DIR failed"
9428 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9429 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9431 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9432 lctl --device %$OSC deactivate
9433 lfs df || error "lfs df with deactivated OSC failed"
9434 lctl --device %$OSC activate
9435 # wait the osc back to normal
9436 wait_osc_import_ready client ost
9438 lfs df || error "lfs df with reactivated OSC failed"
9441 run_test 104a "lfs df [-ih] [path] test ========================="
9444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9445 [ $RUNAS_ID -eq $UID ] &&
9446 skip_env "RUNAS_ID = UID = $UID -- skipping"
9448 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
9449 grep "Permission denied" | wc -l)))
9450 if [ $denied_cnt -ne 0 ]; then
9451 error "lfs check servers test failed"
9454 run_test 104b "$RUNAS lfs check servers test ===================="
9457 # doesn't work on 2.4 kernels
9459 if $(flock_is_enabled); then
9460 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
9462 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
9466 run_test 105a "flock when mounted without -o flock test ========"
9470 if $(flock_is_enabled); then
9471 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
9473 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
9477 run_test 105b "fcntl when mounted without -o flock test ========"
9481 if $(flock_is_enabled); then
9482 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
9484 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
9488 run_test 105c "lockf when mounted without -o flock test"
9490 test_105d() { # bug 15924
9491 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9493 test_mkdir $DIR/$tdir
9494 flock_is_enabled || skip_env "mount w/o flock enabled"
9495 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
9496 $LCTL set_param fail_loc=0x80000315
9497 flocks_test 2 $DIR/$tdir
9499 run_test 105d "flock race (should not freeze) ========"
9501 test_105e() { # bug 22660 && 22040
9502 flock_is_enabled || skip_env "mount w/o flock enabled"
9505 flocks_test 3 $DIR/$tfile
9507 run_test 105e "Two conflicting flocks from same process"
9509 test_106() { #bug 10921
9510 test_mkdir $DIR/$tdir
9511 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
9512 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
9514 run_test 106 "attempt exec of dir followed by chown of that dir"
9517 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9525 local save_pattern=$(sysctl -n kernel.core_pattern)
9526 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
9527 sysctl -w kernel.core_pattern=$file
9528 sysctl -w kernel.core_uses_pid=0
9536 kill -s 11 $SLEEPPID
9538 if [ -e $file ]; then
9539 size=`stat -c%s $file`
9540 [ $size -eq 0 ] && error "Fail to create core file $file"
9542 error "Fail to create core file $file"
9545 sysctl -w kernel.core_pattern=$save_pattern
9546 sysctl -w kernel.core_uses_pid=$save_uses_pid
9549 run_test 107 "Coredump on SIG"
9552 test_mkdir $DIR/$tdir
9553 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
9554 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
9555 error "mkdir with 256 char should fail, but did not"
9556 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
9557 error "create with 255 char failed"
9558 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
9559 error "create with 256 char should fail, but did not"
9564 run_test 110 "filename length checking"
9567 # Purpose: To verify dynamic thread (OSS) creation.
9570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9571 remote_ost_nodsh && skip "remote OST with nodsh"
9573 # Lustre does not stop service threads once they are started.
9574 # Reset number of running threads to default.
9579 local save_params="$TMP/sanity-$TESTNAME.parameters"
9581 # Get ll_ost_io count before I/O
9582 OSTIO_pre=$(do_facet ost1 \
9583 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9584 # Exit if lustre is not running (ll_ost_io not running).
9585 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9587 echo "Starting with $OSTIO_pre threads"
9588 local thread_max=$((OSTIO_pre * 2))
9589 local rpc_in_flight=$((thread_max * 2))
9590 # Number of I/O Process proposed to be started.
9592 local facets=$(get_facets OST)
9594 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9595 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9597 # Set in_flight to $rpc_in_flight
9598 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9599 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9600 nfiles=${rpc_in_flight}
9601 # Set ost thread_max to $thread_max
9602 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
9604 # 5 Minutes should be sufficient for max number of OSS
9605 # threads(thread_max) to be created.
9609 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
9610 test_mkdir $DIR/$tdir
9611 for i in $(seq $nfiles); do
9612 local file=$DIR/$tdir/${tfile}-$i
9613 $LFS setstripe -c -1 -i 0 $file
9614 ($WTL $file $timeout)&
9617 # I/O Started - Wait for thread_started to reach thread_max or report
9618 # error if thread_started is more than thread_max.
9619 echo "Waiting for thread_started to reach thread_max"
9620 local thread_started=0
9621 local end_time=$((SECONDS + timeout))
9623 while [ $SECONDS -le $end_time ] ; do
9625 # Get ost i/o thread_started count.
9626 thread_started=$(do_facet ost1 \
9628 ost.OSS.ost_io.threads_started | cut -d= -f2")
9629 # Break out if thread_started is equal/greater than thread_max
9630 if [[ $thread_started -ge $thread_max ]]; then
9631 echo ll_ost_io thread_started $thread_started, \
9632 equal/greater than thread_max $thread_max
9638 # Cleanup - We have the numbers, Kill i/o jobs if running.
9639 jobcount=($(jobs -p))
9640 for i in $(seq 0 $((${#jobcount[@]}-1)))
9642 kill -9 ${jobcount[$i]}
9643 if [ $? -ne 0 ] ; then
9645 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
9649 # Cleanup files left by WTL binary.
9650 for i in $(seq $nfiles); do
9651 local file=$DIR/$tdir/${tfile}-$i
9653 if [ $? -ne 0 ] ; then
9654 echo "Warning: Failed to delete file $file"
9658 restore_lustre_params <$save_params
9659 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
9661 # Error out if no new thread has started or Thread started is greater
9663 if [[ $thread_started -le $OSTIO_pre ||
9664 $thread_started -gt $thread_max ]]; then
9665 error "ll_ost_io: thread_started $thread_started" \
9666 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
9667 "No new thread started or thread started greater " \
9671 run_test 115 "verify dynamic thread creation===================="
9674 wait_delete_completed
9675 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
9676 echo "OST kbytes available: ${AVAIL[@]}"
9681 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
9682 #echo OST $i: ${AVAIL[i]}kb
9683 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
9687 if [[ ${AVAIL[i]} -lt $MINV ]]; then
9692 echo "Min free space: OST $MINI: $MINV"
9693 echo "Max free space: OST $MAXI: $MAXV"
9696 test_116a() { # was previously test_116()
9697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9698 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9699 remote_mds_nodsh && skip "remote MDS with nodsh"
9701 echo -n "Free space priority "
9702 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
9707 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
9708 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
9709 trap simple_cleanup_common EXIT
9711 # Check if we need to generate uneven OSTs
9712 test_mkdir -p $DIR/$tdir/OST${MINI}
9713 local FILL=$((MINV / 4))
9714 local DIFF=$((MAXV - MINV))
9715 local DIFF2=$((DIFF * 100 / MINV))
9717 local threshold=$(do_facet $SINGLEMDS \
9718 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
9719 threshold=${threshold%%%}
9720 echo -n "Check for uneven OSTs: "
9721 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
9723 if [[ $DIFF2 -gt $threshold ]]; then
9725 echo "Don't need to fill OST$MINI"
9727 # generate uneven OSTs. Write 2% over the QOS threshold value
9729 DIFF=$((threshold - DIFF2 + 2))
9730 DIFF2=$((MINV * DIFF / 100))
9731 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
9732 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
9733 error "setstripe failed"
9734 DIFF=$((DIFF2 / 2048))
9736 while [ $i -lt $DIFF ]; do
9738 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
9739 bs=2M count=1 2>/dev/null
9748 DIFF=$((MAXV - MINV))
9749 DIFF2=$((DIFF * 100 / MINV))
9750 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
9751 if [ $DIFF2 -gt $threshold ]; then
9754 echo "failed - QOS mode won't be used"
9755 simple_cleanup_common
9756 skip "QOS imbalance criteria not met"
9764 # now fill using QOS
9765 $SETSTRIPE -c 1 $DIR/$tdir
9766 FILL=$((FILL / 200))
9767 if [ $FILL -gt 600 ]; then
9770 echo "writing $FILL files to QOS-assigned OSTs"
9772 while [ $i -lt $FILL ]; do
9774 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
9778 echo "wrote $i 200k files"
9782 echo "Note: free space may not be updated, so measurements might be off"
9784 DIFF2=$((MAXV - MINV))
9785 echo "free space delta: orig $DIFF final $DIFF2"
9786 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
9787 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
9788 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
9789 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
9790 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
9791 if [[ $DIFF -gt 0 ]]; then
9792 FILL=$((DIFF2 * 100 / DIFF - 100))
9793 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
9796 # Figure out which files were written where
9797 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9798 awk '/'$MINI1': / {print $2; exit}')
9800 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9801 echo "$MINC files created on smaller OST $MINI1"
9802 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9803 awk '/'$MAXI1': / {print $2; exit}')
9805 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9806 echo "$MAXC files created on larger OST $MAXI1"
9807 if [[ $MINC -gt 0 ]]; then
9808 FILL=$((MAXC * 100 / MINC - 100))
9809 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
9811 [[ $MAXC -gt $MINC ]] ||
9812 error_ignore LU-9 "stripe QOS didn't balance free space"
9813 simple_cleanup_common
9815 run_test 116a "stripe QOS: free space balance ==================="
9817 test_116b() { # LU-2093
9818 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9819 remote_mds_nodsh && skip "remote MDS with nodsh"
9821 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
9822 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
9823 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
9824 [ -z "$old_rr" ] && skip "no QOS"
9825 do_facet $SINGLEMDS lctl set_param \
9826 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
9828 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
9829 createmany -o $DIR/$tdir/f- 20 || error "can't create"
9830 do_facet $SINGLEMDS lctl set_param fail_loc=0
9832 do_facet $SINGLEMDS lctl set_param \
9833 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
9835 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
9837 test_117() # bug 10891
9839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9841 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
9842 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
9843 lctl set_param fail_loc=0x21e
9844 > $DIR/$tfile || error "truncate failed"
9845 lctl set_param fail_loc=0
9846 echo "Truncate succeeded."
9849 run_test 117 "verify osd extend =========="
9851 NO_SLOW_RESENDCOUNT=4
9852 export OLD_RESENDCOUNT=""
9853 set_resend_count () {
9854 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
9855 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
9856 lctl set_param -n $PROC_RESENDCOUNT $1
9857 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
9860 # for reduce test_118* time (b=14842)
9861 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9863 # Reset async IO behavior after error case
9865 FILE=$DIR/reset_async
9867 # Ensure all OSCs are cleared
9868 $SETSTRIPE -c -1 $FILE
9869 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
9874 test_118a() #bug 11710
9876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9880 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9881 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9882 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9884 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9885 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9890 run_test 118a "verify O_SYNC works =========="
9894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9895 remote_ost_nodsh && skip "remote OST with nodsh"
9899 #define OBD_FAIL_SRV_ENOENT 0x217
9900 set_nodes_failloc "$(osts_nodes)" 0x217
9901 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9903 set_nodes_failloc "$(osts_nodes)" 0
9904 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9905 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9908 if [[ $RC -eq 0 ]]; then
9909 error "Must return error due to dropped pages, rc=$RC"
9913 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9914 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9918 echo "Dirty pages not leaked on ENOENT"
9920 # Due to the above error the OSC will issue all RPCs syncronously
9921 # until a subsequent RPC completes successfully without error.
9922 $MULTIOP $DIR/$tfile Ow4096yc
9927 run_test 118b "Reclaim dirty pages on fatal error =========="
9931 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9933 # for 118c, restore the original resend count, LU-1940
9934 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
9935 set_resend_count $OLD_RESENDCOUNT
9936 remote_ost_nodsh && skip "remote OST with nodsh"
9940 #define OBD_FAIL_OST_EROFS 0x216
9941 set_nodes_failloc "$(osts_nodes)" 0x216
9943 # multiop should block due to fsync until pages are written
9944 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9948 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9949 error "Multiop failed to block on fsync, pid=$MULTIPID"
9952 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9954 if [[ $WRITEBACK -eq 0 ]]; then
9955 error "No page in writeback, writeback=$WRITEBACK"
9958 set_nodes_failloc "$(osts_nodes)" 0
9961 if [[ $RC -ne 0 ]]; then
9962 error "Multiop fsync failed, rc=$RC"
9965 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9966 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9968 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9969 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9973 echo "Dirty pages flushed via fsync on EROFS"
9976 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
9978 # continue to use small resend count to reduce test_118* time (b=14842)
9979 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9984 remote_ost_nodsh && skip "remote OST with nodsh"
9988 #define OBD_FAIL_OST_BRW_PAUSE_BULK
9989 set_nodes_failloc "$(osts_nodes)" 0x214
9990 # multiop should block due to fsync until pages are written
9991 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9995 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9996 error "Multiop failed to block on fsync, pid=$MULTIPID"
9999 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10001 if [[ $WRITEBACK -eq 0 ]]; then
10002 error "No page in writeback, writeback=$WRITEBACK"
10005 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
10006 set_nodes_failloc "$(osts_nodes)" 0
10008 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10009 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10011 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10012 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10016 echo "Dirty pages gaurenteed flushed via fsync"
10019 run_test 118d "Fsync validation inject a delay of the bulk =========="
10022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10026 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10027 lctl set_param fail_loc=0x8000040a
10029 # Should simulate EINVAL error which is fatal
10030 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10032 if [[ $RC -eq 0 ]]; then
10033 error "Must return error due to dropped pages, rc=$RC"
10036 lctl set_param fail_loc=0x0
10038 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10039 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10040 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10042 if [[ $LOCKED -ne 0 ]]; then
10043 error "Locked pages remain in cache, locked=$LOCKED"
10046 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10047 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10051 echo "No pages locked after fsync"
10056 run_test 118f "Simulate unrecoverable OSC side error =========="
10059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10063 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10064 lctl set_param fail_loc=0x406
10066 # simulate local -ENOMEM
10067 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10070 lctl set_param fail_loc=0
10071 if [[ $RC -eq 0 ]]; then
10072 error "Must return error due to dropped pages, rc=$RC"
10075 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10076 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10077 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10079 if [[ $LOCKED -ne 0 ]]; then
10080 error "Locked pages remain in cache, locked=$LOCKED"
10083 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10084 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10088 echo "No pages locked after fsync"
10093 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10097 remote_ost_nodsh && skip "remote OST with nodsh"
10101 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10102 set_nodes_failloc "$(osts_nodes)" 0x20e
10103 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10104 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10107 set_nodes_failloc "$(osts_nodes)" 0
10108 if [[ $RC -eq 0 ]]; then
10109 error "Must return error due to dropped pages, rc=$RC"
10112 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10113 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10114 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10116 if [[ $LOCKED -ne 0 ]]; then
10117 error "Locked pages remain in cache, locked=$LOCKED"
10120 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10121 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10125 echo "No pages locked after fsync"
10129 run_test 118h "Verify timeout in handling recoverables errors =========="
10131 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10135 remote_ost_nodsh && skip "remote OST with nodsh"
10139 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10140 set_nodes_failloc "$(osts_nodes)" 0x20e
10142 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10143 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10146 set_nodes_failloc "$(osts_nodes)" 0
10150 if [[ $RC -ne 0 ]]; then
10151 error "got error, but should be not, rc=$RC"
10154 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10155 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10156 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10157 if [[ $LOCKED -ne 0 ]]; then
10158 error "Locked pages remain in cache, locked=$LOCKED"
10161 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10162 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10166 echo "No pages locked after fsync"
10170 run_test 118i "Fix error before timeout in recoverable error =========="
10172 [ "$SLOW" = "no" ] && set_resend_count 4
10175 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10176 remote_ost_nodsh && skip "remote OST with nodsh"
10180 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
10181 set_nodes_failloc "$(osts_nodes)" 0x220
10183 # return -EIO from OST
10184 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10186 set_nodes_failloc "$(osts_nodes)" 0x0
10187 if [[ $RC -eq 0 ]]; then
10188 error "Must return error due to dropped pages, rc=$RC"
10191 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10192 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10193 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10194 if [[ $LOCKED -ne 0 ]]; then
10195 error "Locked pages remain in cache, locked=$LOCKED"
10198 # in recoverable error on OST we want resend and stay until it finished
10199 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10200 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10204 echo "No pages locked after fsync"
10208 run_test 118j "Simulate unrecoverable OST side error =========="
10212 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10213 remote_ost_nodsh && skip "remote OSTs with nodsh"
10215 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10216 set_nodes_failloc "$(osts_nodes)" 0x20e
10217 test_mkdir $DIR/$tdir
10219 for ((i=0;i<10;i++)); do
10220 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
10221 error "dd to $DIR/$tdir/$tfile-$i failed" )&
10228 set_nodes_failloc "$(osts_nodes)" 0
10231 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
10233 test_118l() # LU-646
10235 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10237 test_mkdir $DIR/$tdir
10238 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
10241 run_test 118l "fsync dir"
10243 test_118m() # LU-3066
10245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10247 test_mkdir $DIR/$tdir
10248 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
10251 run_test 118m "fdatasync dir ========="
10253 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10260 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10261 remote_ost_nodsh && skip "remote OSTs with nodsh"
10263 # Sleep to avoid a cached response.
10264 #define OBD_STATFS_CACHE_SECONDS 1
10267 # Inject a 10 second delay in the OST_STATFS handler.
10268 #define OBD_FAIL_OST_STATFS_DELAY 0x242
10269 set_nodes_failloc "$(osts_nodes)" 0x242
10272 stat --file-system $MOUNT > /dev/null
10275 set_nodes_failloc "$(osts_nodes)" 0
10277 if ((end - begin > 20)); then
10278 error "statfs took $((end - begin)) seconds, expected 10"
10281 run_test 118n "statfs() sends OST_STATFS requests in parallel"
10283 test_119a() # bug 11737
10285 BSIZE=$((512 * 1024))
10286 directio write $DIR/$tfile 0 1 $BSIZE
10287 # We ask to read two blocks, which is more than a file size.
10288 # directio will indicate an error when requested and actual
10289 # sizes aren't equeal (a normal situation in this case) and
10290 # print actual read amount.
10291 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
10292 if [ "$NOB" != "$BSIZE" ]; then
10293 error "read $NOB bytes instead of $BSIZE"
10297 run_test 119a "Short directIO read must return actual read amount"
10299 test_119b() # bug 11737
10301 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10303 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
10304 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
10306 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
10307 error "direct read failed"
10310 run_test 119b "Sparse directIO read must return actual read amount"
10312 test_119c() # bug 13099
10315 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
10316 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
10319 run_test 119c "Testing for direct read hitting hole"
10321 test_119d() # bug 15950
10323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10325 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
10326 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
10328 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
10329 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
10330 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
10331 lctl set_param fail_loc=0x40d
10332 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
10335 cat $DIR/$tfile > /dev/null &
10336 lctl set_param fail_loc=0
10339 log "the DIO writes have completed, now wait for the reads (should not block very long)"
10341 [ -n "`ps h -p $pid_reads -o comm`" ] && \
10342 error "the read rpcs have not completed in 2s"
10344 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
10346 run_test 119d "The DIO path should try to send a new rpc once one is completed"
10349 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10350 remote_mds_nodsh && skip "remote MDS with nodsh"
10351 test_mkdir $DIR/$tdir
10352 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10353 skip_env "no early lock cancel on server"
10355 lru_resize_disable mdc
10356 lru_resize_disable osc
10357 cancel_lru_locks mdc
10358 # asynchronous object destroy at MDT could cause bl ast to client
10359 cancel_lru_locks osc
10361 stat $DIR/$tdir > /dev/null
10362 can1=$(do_facet $SINGLEMDS \
10363 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10364 awk '/ldlm_cancel/ {print $2}')
10365 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10366 awk '/ldlm_bl_callback/ {print $2}')
10367 test_mkdir -c1 $DIR/$tdir/d1
10368 can2=$(do_facet $SINGLEMDS \
10369 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10370 awk '/ldlm_cancel/ {print $2}')
10371 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10372 awk '/ldlm_bl_callback/ {print $2}')
10373 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10374 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10375 lru_resize_enable mdc
10376 lru_resize_enable osc
10378 run_test 120a "Early Lock Cancel: mkdir test"
10381 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10382 remote_mds_nodsh && skip "remote MDS with nodsh"
10383 test_mkdir $DIR/$tdir
10384 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10385 skip_env "no early lock cancel on server"
10387 lru_resize_disable mdc
10388 lru_resize_disable osc
10389 cancel_lru_locks mdc
10390 stat $DIR/$tdir > /dev/null
10391 can1=$(do_facet $SINGLEMDS \
10392 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10393 awk '/ldlm_cancel/ {print $2}')
10394 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10395 awk '/ldlm_bl_callback/ {print $2}')
10396 touch $DIR/$tdir/f1
10397 can2=$(do_facet $SINGLEMDS \
10398 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10399 awk '/ldlm_cancel/ {print $2}')
10400 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10401 awk '/ldlm_bl_callback/ {print $2}')
10402 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10403 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10404 lru_resize_enable mdc
10405 lru_resize_enable osc
10407 run_test 120b "Early Lock Cancel: create test"
10410 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10411 remote_mds_nodsh && skip "remote MDS with nodsh"
10412 test_mkdir -c1 $DIR/$tdir
10413 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10414 skip "no early lock cancel on server"
10416 lru_resize_disable mdc
10417 lru_resize_disable osc
10418 test_mkdir -c1 $DIR/$tdir/d1
10419 test_mkdir -c1 $DIR/$tdir/d2
10420 touch $DIR/$tdir/d1/f1
10421 cancel_lru_locks mdc
10422 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10423 can1=$(do_facet $SINGLEMDS \
10424 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10425 awk '/ldlm_cancel/ {print $2}')
10426 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10427 awk '/ldlm_bl_callback/ {print $2}')
10428 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10429 can2=$(do_facet $SINGLEMDS \
10430 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10431 awk '/ldlm_cancel/ {print $2}')
10432 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10433 awk '/ldlm_bl_callback/ {print $2}')
10434 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10435 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10436 lru_resize_enable mdc
10437 lru_resize_enable osc
10439 run_test 120c "Early Lock Cancel: link test"
10442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10443 remote_mds_nodsh && skip "remote MDS with nodsh"
10444 test_mkdir -c1 $DIR/$tdir
10445 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10446 skip_env "no early lock cancel on server"
10448 lru_resize_disable mdc
10449 lru_resize_disable osc
10451 cancel_lru_locks mdc
10452 stat $DIR/$tdir > /dev/null
10453 can1=$(do_facet $SINGLEMDS \
10454 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10455 awk '/ldlm_cancel/ {print $2}')
10456 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10457 awk '/ldlm_bl_callback/ {print $2}')
10458 chmod a+x $DIR/$tdir
10459 can2=$(do_facet $SINGLEMDS \
10460 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10461 awk '/ldlm_cancel/ {print $2}')
10462 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10463 awk '/ldlm_bl_callback/ {print $2}')
10464 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10465 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10466 lru_resize_enable mdc
10467 lru_resize_enable osc
10469 run_test 120d "Early Lock Cancel: setattr test"
10472 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10473 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10474 skip_env "no early lock cancel on server"
10475 remote_mds_nodsh && skip "remote MDS with nodsh"
10477 local dlmtrace_set=false
10479 test_mkdir -c1 $DIR/$tdir
10480 lru_resize_disable mdc
10481 lru_resize_disable osc
10482 ! $LCTL get_param debug | grep -q dlmtrace &&
10483 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
10484 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
10485 cancel_lru_locks mdc
10486 cancel_lru_locks osc
10487 dd if=$DIR/$tdir/f1 of=/dev/null
10488 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
10489 # XXX client can not do early lock cancel of OST lock
10490 # during unlink (LU-4206), so cancel osc lock now.
10492 cancel_lru_locks osc
10493 can1=$(do_facet $SINGLEMDS \
10494 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10495 awk '/ldlm_cancel/ {print $2}')
10496 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10497 awk '/ldlm_bl_callback/ {print $2}')
10498 unlink $DIR/$tdir/f1
10500 can2=$(do_facet $SINGLEMDS \
10501 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10502 awk '/ldlm_cancel/ {print $2}')
10503 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10504 awk '/ldlm_bl_callback/ {print $2}')
10505 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
10506 $LCTL dk $TMP/cancel.debug.txt
10507 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
10508 $LCTL dk $TMP/blocking.debug.txt
10509 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
10510 lru_resize_enable mdc
10511 lru_resize_enable osc
10513 run_test 120e "Early Lock Cancel: unlink test"
10516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10517 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10518 skip_env "no early lock cancel on server"
10519 remote_mds_nodsh && skip "remote MDS with nodsh"
10521 test_mkdir -c1 $DIR/$tdir
10522 lru_resize_disable mdc
10523 lru_resize_disable osc
10524 test_mkdir -c1 $DIR/$tdir/d1
10525 test_mkdir -c1 $DIR/$tdir/d2
10526 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
10527 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
10528 cancel_lru_locks mdc
10529 cancel_lru_locks osc
10530 dd if=$DIR/$tdir/d1/f1 of=/dev/null
10531 dd if=$DIR/$tdir/d2/f2 of=/dev/null
10532 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
10533 # XXX client can not do early lock cancel of OST lock
10534 # during rename (LU-4206), so cancel osc lock now.
10536 cancel_lru_locks osc
10537 can1=$(do_facet $SINGLEMDS \
10538 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10539 awk '/ldlm_cancel/ {print $2}')
10540 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10541 awk '/ldlm_bl_callback/ {print $2}')
10542 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10544 can2=$(do_facet $SINGLEMDS \
10545 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10546 awk '/ldlm_cancel/ {print $2}')
10547 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10548 awk '/ldlm_bl_callback/ {print $2}')
10549 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10550 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10551 lru_resize_enable mdc
10552 lru_resize_enable osc
10554 run_test 120f "Early Lock Cancel: rename test"
10557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10558 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10559 skip_env "no early lock cancel on server"
10560 remote_mds_nodsh && skip "remote MDS with nodsh"
10562 lru_resize_disable mdc
10563 lru_resize_disable osc
10565 echo create $count files
10566 test_mkdir $DIR/$tdir
10567 cancel_lru_locks mdc
10568 cancel_lru_locks osc
10571 can0=$(do_facet $SINGLEMDS \
10572 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10573 awk '/ldlm_cancel/ {print $2}')
10574 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10575 awk '/ldlm_bl_callback/ {print $2}')
10576 createmany -o $DIR/$tdir/f $count
10578 can1=$(do_facet $SINGLEMDS \
10579 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10580 awk '/ldlm_cancel/ {print $2}')
10581 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10582 awk '/ldlm_bl_callback/ {print $2}')
10584 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
10585 echo rm $count files
10588 can2=$(do_facet $SINGLEMDS \
10589 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10590 awk '/ldlm_cancel/ {print $2}')
10591 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10592 awk '/ldlm_bl_callback/ {print $2}')
10594 echo total: $count removes in $((t2-t1))
10595 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
10597 # wait for commitment of removal
10598 lru_resize_enable mdc
10599 lru_resize_enable osc
10601 run_test 120g "Early Lock Cancel: performance test"
10603 test_121() { #bug #10589
10604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10607 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
10608 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
10609 lctl set_param fail_loc=0x310
10610 cancel_lru_locks osc > /dev/null
10611 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
10612 lctl set_param fail_loc=0
10613 [[ $reads -eq $writes ]] ||
10614 error "read $reads blocks, must be $writes blocks"
10616 run_test 121 "read cancel race ========="
10618 test_123a() { # was test 123, statahead(bug 11401)
10619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10622 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
10623 log "testing UP system. Performance may be lower than expected."
10628 test_mkdir $DIR/$tdir
10629 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
10630 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
10632 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
10633 createmany -o $DIR/$tdir/$tfile $j $((i - j))
10635 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10636 lctl set_param -n llite.*.statahead_max 0
10637 lctl get_param llite.*.statahead_max
10638 cancel_lru_locks mdc
10639 cancel_lru_locks osc
10641 time ls -l $DIR/$tdir | wc -l
10643 delta=$((etime - stime))
10644 log "ls $i files without statahead: $delta sec"
10645 lctl set_param llite.*.statahead_max=$max
10647 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10648 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
10649 cancel_lru_locks mdc
10650 cancel_lru_locks osc
10652 time ls -l $DIR/$tdir | wc -l
10654 delta_sa=$((etime - stime))
10655 log "ls $i files with statahead: $delta_sa sec"
10656 lctl get_param -n llite.*.statahead_stats
10657 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10659 [[ $swrong -lt $ewrong ]] &&
10660 log "statahead was stopped, maybe too many locks held!"
10661 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
10663 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10664 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10665 lctl set_param -n llite.*.statahead_max 0
10666 lctl get_param llite.*.statahead_max
10667 cancel_lru_locks mdc
10668 cancel_lru_locks osc
10670 time ls -l $DIR/$tdir | wc -l
10672 delta=$((etime - stime))
10673 log "ls $i files again without statahead: $delta sec"
10674 lctl set_param llite.*.statahead_max=$max
10675 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10676 if [ $SLOWOK -eq 0 ]; then
10677 error "ls $i files is slower with statahead!"
10679 log "ls $i files is slower with statahead!"
10685 [ $delta -gt 20 ] && break
10686 [ $delta -gt 8 ] && MULT=$((50 / delta))
10687 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
10695 delta=$((etime - stime))
10696 log "rm -r $DIR/$tdir/: $delta seconds"
10698 lctl get_param -n llite.*.statahead_stats
10700 run_test 123a "verify statahead work"
10702 test_123b () { # statahead(bug 15027)
10703 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10705 test_mkdir $DIR/$tdir
10706 createmany -o $DIR/$tdir/$tfile-%d 1000
10708 cancel_lru_locks mdc
10709 cancel_lru_locks osc
10711 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
10712 lctl set_param fail_loc=0x80000803
10713 ls -lR $DIR/$tdir > /dev/null
10715 lctl set_param fail_loc=0x0
10716 lctl get_param -n llite.*.statahead_stats
10721 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
10724 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
10726 test_mkdir -i 0 -c 1 $DIR/$tdir.0
10727 test_mkdir -i 1 -c 1 $DIR/$tdir.1
10728 touch $DIR/$tdir.1/{1..3}
10729 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
10731 remount_client $MOUNT
10733 $MULTIOP $DIR/$tdir.0 Q
10735 # let statahead to complete
10736 ls -l $DIR/$tdir.0 > /dev/null
10738 testid=$(echo $TESTNAME | tr '_' ' ')
10739 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
10740 error "statahead warning" || true
10742 run_test 123c "Can not initialize inode warning on DNE statahead"
10745 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10746 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10747 skip_env "no lru resize on server"
10751 test_mkdir $DIR/$tdir
10753 log "create $NR files at $DIR/$tdir"
10754 createmany -o $DIR/$tdir/f $NR ||
10755 error "failed to create $NR files in $DIR/$tdir"
10757 cancel_lru_locks mdc
10758 ls -l $DIR/$tdir > /dev/null
10762 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
10763 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
10764 LRU_SIZE=$($LCTL get_param -n $PARAM)
10765 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
10766 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
10768 log "NS=$(basename $NSDIR)"
10773 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
10774 skip "Not enough cached locks created!"
10776 log "LRU=$LRU_SIZE"
10780 # We know that lru resize allows one client to hold $LIMIT locks
10781 # for 10h. After that locks begin to be killed by client.
10783 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
10785 if [ $LIMIT -lt $LRU_SIZE ]; then
10786 skip "Limit is too small $LIMIT"
10789 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
10790 # killing locks. Some time was spent for creating locks. This means
10791 # that up to the moment of sleep finish we must have killed some of
10792 # them (10-100 locks). This depends on how fast ther were created.
10793 # Many of them were touched in almost the same moment and thus will
10794 # be killed in groups.
10795 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
10797 # Use $LRU_SIZE_B here to take into account real number of locks
10798 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
10799 local LRU_SIZE_B=$LRU_SIZE
10801 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
10802 log "OLD_LVF=$OLD_LVF"
10803 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
10805 # Let's make sure that we really have some margin. Client checks
10806 # cached locks every 10 sec.
10807 SLEEP=$((SLEEP+20))
10808 log "Sleep ${SLEEP} sec"
10810 while ((SEC<$SLEEP)); do
10814 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
10815 echo -n "$LRU_SIZE"
10818 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
10819 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
10821 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
10822 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
10823 unlinkmany $DIR/$tdir/f $NR
10827 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
10828 log "unlink $NR files at $DIR/$tdir"
10829 unlinkmany $DIR/$tdir/f $NR
10831 run_test 124a "lru resize ======================================="
10833 get_max_pool_limit()
10835 local limit=$($LCTL get_param \
10836 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
10838 for l in $limit; do
10839 if [[ $l -gt $max ]]; then
10847 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10848 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10849 skip_env "no lru resize on server"
10851 LIMIT=$(get_max_pool_limit)
10853 NR=$(($(default_lru_size)*20))
10854 if [[ $NR -gt $LIMIT ]]; then
10855 log "Limit lock number by $LIMIT locks"
10859 IFree=$(mdsrate_inodes_available)
10860 if [ $IFree -lt $NR ]; then
10861 log "Limit lock number by $IFree inodes"
10865 lru_resize_disable mdc
10866 test_mkdir -p $DIR/$tdir/disable_lru_resize
10868 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
10869 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
10870 cancel_lru_locks mdc
10873 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10876 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10879 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10883 nolruresize_delta=$((etime-stime))
10884 log "ls -la time: $nolruresize_delta seconds"
10885 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10886 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
10888 lru_resize_enable mdc
10889 test_mkdir -p $DIR/$tdir/enable_lru_resize
10891 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
10892 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
10893 cancel_lru_locks mdc
10896 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10899 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10902 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10906 lruresize_delta=$((etime-stime))
10907 log "ls -la time: $lruresize_delta seconds"
10908 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10910 if [ $lruresize_delta -gt $nolruresize_delta ]; then
10911 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
10912 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
10913 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
10915 log "lru resize performs the same with no lru resize"
10917 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
10919 run_test 124b "lru resize (performance test) ======================="
10922 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10923 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10924 skip_env "no lru resize on server"
10926 # cache ununsed locks on client
10928 cancel_lru_locks mdc
10929 test_mkdir $DIR/$tdir
10930 createmany -o $DIR/$tdir/f $nr ||
10931 error "failed to create $nr files in $DIR/$tdir"
10932 ls -l $DIR/$tdir > /dev/null
10934 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10935 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10936 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10937 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10938 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10940 # set lru_max_age to 1 sec
10941 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10942 echo "sleep $((recalc_p * 2)) seconds..."
10943 sleep $((recalc_p * 2))
10945 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10946 # restore lru_max_age
10947 $LCTL set_param -n $nsdir.lru_max_age $max_age
10948 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10949 unlinkmany $DIR/$tdir/f $nr
10951 run_test 124c "LRUR cancel very aged locks"
10954 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10955 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10956 skip_env "no lru resize on server"
10958 # cache ununsed locks on client
10961 lru_resize_disable mdc
10962 stack_trap "lru_resize_enable mdc" EXIT
10964 cancel_lru_locks mdc
10966 # asynchronous object destroy at MDT could cause bl ast to client
10967 test_mkdir $DIR/$tdir
10968 createmany -o $DIR/$tdir/f $nr ||
10969 error "failed to create $nr files in $DIR/$tdir"
10970 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
10972 ls -l $DIR/$tdir > /dev/null
10974 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10975 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10976 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10977 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10979 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10981 # set lru_max_age to 1 sec
10982 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10983 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
10985 echo "sleep $((recalc_p * 2)) seconds..."
10986 sleep $((recalc_p * 2))
10988 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10990 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10992 run_test 124d "cancel very aged locks if lru-resize diasbaled"
10994 test_125() { # 13358
10995 $LCTL get_param -n llite.*.client_type | grep -q local ||
10996 skip "must run as local client"
10997 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
10998 skip_env "must have acl enabled"
10999 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11001 test_mkdir $DIR/$tdir
11002 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
11003 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
11004 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
11006 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
11008 test_126() { # bug 12829/13455
11009 $GSS && skip_env "must run as gss disabled"
11010 $LCTL get_param -n llite.*.client_type | grep -q local ||
11011 skip "must run as local client"
11012 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
11014 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
11015 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
11017 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
11019 run_test 126 "check that the fsgid provided by the client is taken into account"
11021 test_127a() { # bug 15521
11022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11024 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
11025 $LCTL set_param osc.*.stats=0
11026 FSIZE=$((2048 * 1024))
11027 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
11028 cancel_lru_locks osc
11029 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
11031 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
11032 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
11033 echo "got $COUNT $NAME"
11034 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
11035 eval $NAME=$COUNT || error "Wrong proc format"
11038 read_bytes|write_bytes)
11039 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
11040 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
11041 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
11042 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
11043 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
11044 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
11045 error "sumsquare is too small: $SUMSQ"
11046 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
11047 error "sumsquare is too big: $SUMSQ"
11051 done < $DIR/${tfile}.tmp
11053 #check that we actually got some stats
11054 [ "$read_bytes" ] || error "Missing read_bytes stats"
11055 [ "$write_bytes" ] || error "Missing write_bytes stats"
11056 [ "$read_bytes" != 0 ] || error "no read done"
11057 [ "$write_bytes" != 0 ] || error "no write done"
11059 run_test 127a "verify the client stats are sane"
11061 test_127b() { # bug LU-333
11062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11063 local name count samp unit min max sum sumsq
11065 $LCTL set_param llite.*.stats=0
11067 # perform 2 reads and writes so MAX is different from SUM.
11068 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11069 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11070 cancel_lru_locks osc
11071 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11072 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11074 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11075 while read name count samp unit min max sum sumsq; do
11076 echo "got $count $name"
11077 eval $name=$count || error "Wrong proc format"
11081 [ $count -ne 2 ] && error "count is not 2: $count"
11082 [ $min -ne $PAGE_SIZE ] &&
11083 error "min is not $PAGE_SIZE: $min"
11084 [ $max -ne $PAGE_SIZE ] &&
11085 error "max is incorrect: $max"
11086 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11087 error "sum is wrong: $sum"
11090 [ $count -ne 2 ] && error "count is not 2: $count"
11091 [ $min -ne $PAGE_SIZE ] &&
11092 error "min is not $PAGE_SIZE: $min"
11093 [ $max -ne $PAGE_SIZE ] &&
11094 error "max is incorrect: $max"
11095 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
11096 error "sum is wrong: $sum"
11100 done < $TMP/$tfile.tmp
11102 #check that we actually got some stats
11103 [ "$read_bytes" ] || error "Missing read_bytes stats"
11104 [ "$write_bytes" ] || error "Missing write_bytes stats"
11105 [ "$read_bytes" != 0 ] || error "no read done"
11106 [ "$write_bytes" != 0 ] || error "no write done"
11108 rm -f $TMP/${tfile}.tmp
11110 run_test 127b "verify the llite client stats are sane"
11112 test_127c() { # LU-12394
11113 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11120 $LCTL set_param llite.*.extents_stats=1
11121 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
11123 # Use two stripes so there is enough space in default config
11124 $LFS setstripe -c 2 $DIR/$tfile
11126 # Extent stats start at 0-4K and go in power of two buckets
11127 # LL_HIST_START = 12 --> 2^12 = 4K
11128 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
11129 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
11131 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
11133 # Write and read, 2x each, second time at a non-zero offset
11134 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
11135 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
11136 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
11137 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
11141 $LCTL get_param llite.*.extents_stats
11144 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
11146 local bucket=$($LCTL get_param -n llite.*.extents_stats |
11148 reads=$(echo $bucket | awk '{print $5}')
11149 writes=$(echo $bucket | awk '{print $9}')
11150 [ "$reads" -eq $count ] ||
11151 error "$reads reads in < $bsize bucket, expect $count"
11152 [ "$writes" -eq $count ] ||
11153 error "$writes writes in < $bsize bucket, expect $count"
11156 # Test mmap write and read
11157 $LCTL set_param llite.*.extents_stats=c
11159 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
11160 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
11161 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
11163 $LCTL get_param llite.*.extents_stats
11165 count=$(((size*1024) / PAGE_SIZE))
11167 bsize=$((2 * PAGE_SIZE / 1024))K
11169 bucket=$($LCTL get_param -n llite.*.extents_stats |
11171 reads=$(echo $bucket | awk '{print $5}')
11172 writes=$(echo $bucket | awk '{print $9}')
11173 # mmap writes fault in the page first, creating an additonal read
11174 [ "$reads" -eq $((2 * count)) ] ||
11175 error "$reads reads in < $bsize bucket, expect $count"
11176 [ "$writes" -eq $count ] ||
11177 error "$writes writes in < $bsize bucket, expect $count"
11179 run_test 127c "test llite extent stats with regular & mmap i/o"
11181 test_128() { # bug 15212
11183 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
11188 result=$(grep error $TMP/$tfile.log)
11189 rm -f $DIR/$tfile $TMP/$tfile.log
11190 [ -z "$result" ] ||
11191 error "consecutive find's under interactive lfs failed"
11193 run_test 128 "interactive lfs for 2 consecutive find's"
11195 set_dir_limits () {
11200 local ldproc=/proc/fs/ldiskfs
11201 local facets=$(get_facets MDS)
11203 for facet in ${facets//,/ }; do
11204 canondev=$(ldiskfs_canon \
11205 *.$(convert_facet2label $facet).mntdev $facet)
11206 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
11207 ldproc=/sys/fs/ldiskfs
11208 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
11209 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
11213 check_mds_dmesg() {
11214 local facets=$(get_facets MDS)
11215 for facet in ${facets//,/ }; do
11216 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
11222 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11223 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
11224 skip "Need MDS version with at least 2.5.56"
11225 if [ "$mds1_FSTYPE" != ldiskfs ]; then
11226 skip_env "ldiskfs only test"
11228 remote_mds_nodsh && skip "remote MDS with nodsh"
11232 local has_warning=false
11235 mkdir -p $DIR/$tdir
11237 # block size of mds1
11238 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
11239 set_dir_limits $maxsize $maxsize
11240 local dirsize=$(stat -c%s "$DIR/$tdir")
11242 while [[ $dirsize -le $maxsize ]]; do
11243 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
11245 if ! $has_warning; then
11246 check_mds_dmesg '"is approaching"' && has_warning=true
11248 # check two errors:
11249 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
11250 # EFBIG for previous versions included in ldiskfs series
11251 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
11253 echo "return code $rc received as expected"
11255 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
11256 error_exit "create failed w/o dir size limit"
11258 check_mds_dmesg '"has reached"' ||
11259 error_exit "reached message should be output"
11261 [ $has_warning = "false" ] &&
11262 error_exit "warning message should be output"
11264 dirsize=$(stat -c%s "$DIR/$tdir")
11266 [[ $dirsize -ge $maxsize ]] && return 0
11267 error_exit "current dir size $dirsize, " \
11268 "previous limit $maxsize"
11269 elif [ $rc -ne 0 ]; then
11271 error_exit "return $rc received instead of expected " \
11272 "$EFBIG or $ENOSPC, files in dir $dirsize"
11274 nfiles=$((nfiles + 1))
11275 dirsize=$(stat -c%s "$DIR/$tdir")
11279 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
11281 run_test 129 "test directory size limit ========================"
11290 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11291 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11293 trap cleanup_130 EXIT RETURN
11295 local fm_file=$DIR/$tfile
11296 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
11297 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
11298 error "dd failed for $fm_file"
11300 # LU-1795: test filefrag/FIEMAP once, even if unsupported
11301 filefrag -ves $fm_file
11303 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11304 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11305 [ $RC != 0 ] && error "filefrag $fm_file failed"
11307 filefrag_op=$(filefrag -ve -k $fm_file |
11308 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11309 lun=$($GETSTRIPE -i $fm_file)
11311 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
11314 for line in $filefrag_op
11316 frag_lun=`echo $line | cut -d: -f5`
11317 ext_len=`echo $line | cut -d: -f4`
11318 if (( $frag_lun != $lun )); then
11320 error "FIEMAP on 1-stripe file($fm_file) failed"
11323 (( tot_len += ext_len ))
11326 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
11328 error "FIEMAP on 1-stripe file($fm_file) failed;"
11334 echo "FIEMAP on single striped file succeeded"
11336 run_test 130a "FIEMAP (1-stripe file)"
11339 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11341 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11342 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11344 trap cleanup_130 EXIT RETURN
11346 local fm_file=$DIR/$tfile
11347 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
11348 error "setstripe on $fm_file"
11349 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11350 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11352 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
11353 error "dd failed on $fm_file"
11355 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11356 filefrag_op=$(filefrag -ve -k $fm_file |
11357 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11359 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11360 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11365 for line in $filefrag_op
11367 frag_lun=$(echo $line | cut -d: -f5 |
11368 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11369 ext_len=$(echo $line | cut -d: -f4)
11370 if (( $frag_lun != $last_lun )); then
11371 if (( tot_len != 1024 )); then
11373 error "FIEMAP on $fm_file failed; returned " \
11374 "len $tot_len for OST $last_lun instead of 1024"
11377 (( num_luns += 1 ))
11381 (( tot_len += ext_len ))
11384 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
11386 error "FIEMAP on $fm_file failed; returned wrong number of " \
11387 "luns or wrong len for OST $last_lun"
11393 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
11395 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
11398 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11400 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11401 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11403 trap cleanup_130 EXIT RETURN
11405 local fm_file=$DIR/$tfile
11406 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
11407 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11408 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11410 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
11411 error "dd failed on $fm_file"
11413 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11414 filefrag_op=$(filefrag -ve -k $fm_file |
11415 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11417 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11418 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11423 for line in $filefrag_op
11425 frag_lun=$(echo $line | cut -d: -f5 |
11426 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11427 ext_len=$(echo $line | cut -d: -f4)
11428 if (( $frag_lun != $last_lun )); then
11429 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
11430 if (( logical != 512 )); then
11432 error "FIEMAP on $fm_file failed; returned " \
11433 "logical start for lun $logical instead of 512"
11436 if (( tot_len != 512 )); then
11438 error "FIEMAP on $fm_file failed; returned " \
11439 "len $tot_len for OST $last_lun instead of 1024"
11442 (( num_luns += 1 ))
11446 (( tot_len += ext_len ))
11449 if (( num_luns != 2 || tot_len != 512 )); then
11451 error "FIEMAP on $fm_file failed; returned wrong number of " \
11452 "luns or wrong len for OST $last_lun"
11458 echo "FIEMAP on 2-stripe file with hole succeeded"
11460 run_test 130c "FIEMAP (2-stripe file with hole)"
11463 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
11465 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11466 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11468 trap cleanup_130 EXIT RETURN
11470 local fm_file=$DIR/$tfile
11471 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
11472 error "setstripe on $fm_file"
11473 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11474 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11476 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
11477 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
11478 error "dd failed on $fm_file"
11480 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11481 filefrag_op=$(filefrag -ve -k $fm_file |
11482 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11484 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11485 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11490 for line in $filefrag_op
11492 frag_lun=$(echo $line | cut -d: -f5 |
11493 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11494 ext_len=$(echo $line | cut -d: -f4)
11495 if (( $frag_lun != $last_lun )); then
11496 if (( tot_len != 1024 )); then
11498 error "FIEMAP on $fm_file failed; returned " \
11499 "len $tot_len for OST $last_lun instead of 1024"
11502 (( num_luns += 1 ))
11506 (( tot_len += ext_len ))
11509 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
11511 error "FIEMAP on $fm_file failed; returned wrong number of " \
11512 "luns or wrong len for OST $last_lun"
11518 echo "FIEMAP on N-stripe file succeeded"
11520 run_test 130d "FIEMAP (N-stripe file)"
11523 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11525 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11526 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11528 trap cleanup_130 EXIT RETURN
11530 local fm_file=$DIR/$tfile
11531 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
11532 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11533 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11536 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
11537 for ((i = 0; i < $NUM_BLKS; i++))
11539 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
11542 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11543 filefrag_op=$(filefrag -ve -k $fm_file |
11544 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11546 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11547 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11552 for line in $filefrag_op
11554 frag_lun=$(echo $line | cut -d: -f5 |
11555 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11556 ext_len=$(echo $line | cut -d: -f4)
11557 if (( $frag_lun != $last_lun )); then
11558 if (( tot_len != $EXPECTED_LEN )); then
11560 error "FIEMAP on $fm_file failed; returned " \
11561 "len $tot_len for OST $last_lun instead " \
11565 (( num_luns += 1 ))
11569 (( tot_len += ext_len ))
11572 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
11574 error "FIEMAP on $fm_file failed; returned wrong number " \
11575 "of luns or wrong len for OST $last_lun"
11581 echo "FIEMAP with continuation calls succeeded"
11583 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
11586 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11587 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11589 local fm_file=$DIR/$tfile
11590 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
11591 error "multiop create with lov_delay_create on $fm_file"
11593 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11594 filefrag_extents=$(filefrag -vek $fm_file |
11595 awk '/extents? found/ { print $2 }')
11596 if [[ "$filefrag_extents" != "0" ]]; then
11597 error "FIEMAP on $fm_file failed; " \
11598 "returned $filefrag_extents expected 0"
11603 run_test 130f "FIEMAP (unstriped file)"
11605 # Test for writev/readv
11607 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
11608 error "writev test failed"
11609 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
11610 error "readv failed"
11613 run_test 131a "test iov's crossing stripe boundary for writev/readv"
11616 local fsize=$((524288 + 1048576 + 1572864))
11617 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
11618 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11619 error "append writev test failed"
11621 ((fsize += 1572864 + 1048576))
11622 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
11623 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11624 error "append writev test failed"
11627 run_test 131b "test append writev"
11630 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
11633 run_test 131c "test read/write on file w/o objects"
11636 rwv -f $DIR/$tfile -w -n 1 1572864
11637 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
11638 if [ "$NOB" != 1572864 ]; then
11639 error "Short read filed: read $NOB bytes instead of 1572864"
11643 run_test 131d "test short read"
11646 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
11647 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
11648 error "read hitting hole failed"
11651 run_test 131e "test read hitting hole"
11660 mds*) res=$(do_facet $facet \
11661 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
11663 ost*) res=$(do_facet $facet \
11664 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
11666 *) error "Wrong facet '$facet'" ;;
11668 [ "$res" ] || error "The counter for $op on $facet was not incremented"
11669 # if the argument $3 is zero, it means any stat increment is ok.
11670 if [[ $want -gt 0 ]]; then
11671 local count=$(echo $res | awk '{ print $2 }')
11672 [[ $count -ne $want ]] &&
11673 error "The $op counter on $facet is $count, not $want"
11678 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11679 remote_ost_nodsh && skip "remote OST with nodsh"
11680 remote_mds_nodsh && skip "remote MDS with nodsh"
11681 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11682 skip_env "MDS doesn't support rename stats"
11684 local testdir=$DIR/${tdir}/stats_testdir
11686 mkdir -p $DIR/${tdir}
11689 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11690 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11692 # verify mdt stats first.
11693 mkdir ${testdir} || error "mkdir failed"
11694 check_stats $SINGLEMDS "mkdir" 1
11695 touch ${testdir}/${tfile} || error "touch failed"
11696 check_stats $SINGLEMDS "open" 1
11697 check_stats $SINGLEMDS "close" 1
11698 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
11699 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
11700 check_stats $SINGLEMDS "mknod" 2
11702 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
11703 check_stats $SINGLEMDS "unlink" 1
11704 rm -f ${testdir}/${tfile} || error "file remove failed"
11705 check_stats $SINGLEMDS "unlink" 2
11707 # remove working dir and check mdt stats again.
11708 rmdir ${testdir} || error "rmdir failed"
11709 check_stats $SINGLEMDS "rmdir" 1
11711 local testdir1=$DIR/${tdir}/stats_testdir1
11712 mkdir -p ${testdir}
11713 mkdir -p ${testdir1}
11714 touch ${testdir1}/test1
11715 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
11716 check_stats $SINGLEMDS "crossdir_rename" 1
11718 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
11719 check_stats $SINGLEMDS "samedir_rename" 1
11721 rm -rf $DIR/${tdir}
11723 run_test 133a "Verifying MDT stats ========================================"
11728 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11729 remote_ost_nodsh && skip "remote OST with nodsh"
11730 remote_mds_nodsh && skip "remote MDS with nodsh"
11732 local testdir=$DIR/${tdir}/stats_testdir
11734 mkdir -p ${testdir} || error "mkdir failed"
11735 touch ${testdir}/${tfile} || error "touch failed"
11736 cancel_lru_locks mdc
11739 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11740 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11742 # extra mdt stats verification.
11743 chmod 444 ${testdir}/${tfile} || error "chmod failed"
11744 check_stats $SINGLEMDS "setattr" 1
11745 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11746 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
11748 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
11749 check_stats $SINGLEMDS "getattr" 1
11751 rm -rf $DIR/${tdir}
11753 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
11754 # so the check below is not reliable
11755 [ $MDSCOUNT -eq 1 ] || return 0
11757 # Sleep to avoid a cached response.
11758 #define OBD_STATFS_CACHE_SECONDS 1
11760 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11761 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11762 $LFS df || error "lfs failed"
11763 check_stats $SINGLEMDS "statfs" 1
11765 # check aggregated statfs (LU-10018)
11766 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
11768 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
11771 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11772 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11774 check_stats $SINGLEMDS "statfs" 1
11776 # We want to check that the client didn't send OST_STATFS to
11777 # ost1 but the MDT also uses OST_STATFS for precreate. So some
11778 # extra care is needed here.
11779 if remote_mds; then
11780 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
11781 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
11783 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
11784 [ "$res" ] && error "OST got STATFS"
11789 run_test 133b "Verifying extra MDT stats =================================="
11792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11793 remote_ost_nodsh && skip "remote OST with nodsh"
11794 remote_mds_nodsh && skip "remote MDS with nodsh"
11796 local testdir=$DIR/$tdir/stats_testdir
11798 test_mkdir -p $testdir
11800 # verify obdfilter stats.
11801 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
11803 cancel_lru_locks osc
11804 wait_delete_completed
11807 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11808 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11810 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
11813 cancel_lru_locks osc
11814 check_stats ost1 "write" 1
11816 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
11817 check_stats ost1 "read" 1
11819 > $testdir/$tfile || error "truncate failed"
11820 check_stats ost1 "punch" 1
11822 rm -f $testdir/$tfile || error "file remove failed"
11823 wait_delete_completed
11824 check_stats ost1 "destroy" 1
11828 run_test 133c "Verifying OST stats ========================================"
11835 while [ $value -ge 2 ]; do
11840 if [ $orig -gt $order ]; then
11848 local size=('K' 'M' 'G' 'T');
11850 local size_string=$value
11852 while [ $value -ge 1024 ]; do
11853 if [ $i -gt 3 ]; then
11854 #T is the biggest unit we get here, if that is bigger,
11856 size_string=${value}T
11859 value=$((value >> 10))
11860 if [ $value -lt 1024 ]; then
11861 size_string=${value}${size[$i]}
11870 get_rename_size() {
11872 local context=${2:-.}
11873 local sample=$(do_facet $SINGLEMDS $LCTL \
11874 get_param mdt.$FSNAME-MDT0000.rename_stats |
11875 grep -A1 $context |
11876 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
11881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11882 remote_ost_nodsh && skip "remote OST with nodsh"
11883 remote_mds_nodsh && skip "remote MDS with nodsh"
11884 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11885 skip_env "MDS doesn't support rename stats"
11887 local testdir1=$DIR/${tdir}/stats_testdir1
11888 local testdir2=$DIR/${tdir}/stats_testdir2
11889 mkdir -p $DIR/${tdir}
11891 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11893 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
11894 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
11896 createmany -o $testdir1/test 512 || error "createmany failed"
11898 # check samedir rename size
11899 mv ${testdir1}/test0 ${testdir1}/test_0
11901 local testdir1_size=$(ls -l $DIR/${tdir} |
11902 awk '/stats_testdir1/ {print $5}')
11903 local testdir2_size=$(ls -l $DIR/${tdir} |
11904 awk '/stats_testdir2/ {print $5}')
11906 testdir1_size=$(order_2 $testdir1_size)
11907 testdir2_size=$(order_2 $testdir2_size)
11909 testdir1_size=$(size_in_KMGT $testdir1_size)
11910 testdir2_size=$(size_in_KMGT $testdir2_size)
11912 echo "source rename dir size: ${testdir1_size}"
11913 echo "target rename dir size: ${testdir2_size}"
11915 local cmd="do_facet $SINGLEMDS $LCTL "
11916 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
11918 eval $cmd || error "$cmd failed"
11919 local samedir=$($cmd | grep 'same_dir')
11920 local same_sample=$(get_rename_size $testdir1_size)
11921 [ -z "$samedir" ] && error "samedir_rename_size count error"
11922 [[ $same_sample -eq 1 ]] ||
11923 error "samedir_rename_size error $same_sample"
11924 echo "Check same dir rename stats success"
11926 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11928 # check crossdir rename size
11929 mv ${testdir1}/test_0 ${testdir2}/test_0
11931 testdir1_size=$(ls -l $DIR/${tdir} |
11932 awk '/stats_testdir1/ {print $5}')
11933 testdir2_size=$(ls -l $DIR/${tdir} |
11934 awk '/stats_testdir2/ {print $5}')
11936 testdir1_size=$(order_2 $testdir1_size)
11937 testdir2_size=$(order_2 $testdir2_size)
11939 testdir1_size=$(size_in_KMGT $testdir1_size)
11940 testdir2_size=$(size_in_KMGT $testdir2_size)
11942 echo "source rename dir size: ${testdir1_size}"
11943 echo "target rename dir size: ${testdir2_size}"
11945 eval $cmd || error "$cmd failed"
11946 local crossdir=$($cmd | grep 'crossdir')
11947 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
11948 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
11949 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
11950 [[ $src_sample -eq 1 ]] ||
11951 error "crossdir_rename_size error $src_sample"
11952 [[ $tgt_sample -eq 1 ]] ||
11953 error "crossdir_rename_size error $tgt_sample"
11954 echo "Check cross dir rename stats success"
11955 rm -rf $DIR/${tdir}
11957 run_test 133d "Verifying rename_stats ========================================"
11960 remote_mds_nodsh && skip "remote MDS with nodsh"
11961 remote_ost_nodsh && skip "remote OST with nodsh"
11962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11964 local testdir=$DIR/${tdir}/stats_testdir
11965 local ctr f0 f1 bs=32768 count=42 sum
11967 mkdir -p ${testdir} || error "mkdir failed"
11969 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
11971 for ctr in {write,read}_bytes; do
11973 cancel_lru_locks osc
11975 do_facet ost1 $LCTL set_param -n \
11976 "obdfilter.*.exports.clear=clear"
11978 if [ $ctr = write_bytes ]; then
11980 f1=${testdir}/${tfile}
11982 f0=${testdir}/${tfile}
11986 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
11989 cancel_lru_locks osc
11991 sum=$(do_facet ost1 $LCTL get_param \
11992 "obdfilter.*.exports.*.stats" |
11993 awk -v ctr=$ctr 'BEGIN { sum = 0 }
11994 $1 == ctr { sum += $7 }
11995 END { printf("%0.0f", sum) }')
11997 if ((sum != bs * count)); then
11998 error "Bad $ctr sum, expected $((bs * count)), got $sum"
12002 rm -rf $DIR/${tdir}
12004 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
12006 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
12008 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
12009 # not honor the -ignore_readdir_race option correctly. So we call
12010 # error_ignore() rather than error() in these cases. See LU-11152.
12012 if (find --version; do_facet mds1 find --version) |
12013 grep -q '\b4\.5\.1[1-4]\b'; then
12014 error_ignore LU-11152 "$@"
12021 # First without trusting modes.
12022 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
12023 echo "proc_dirs='$proc_dirs'"
12024 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
12025 find $proc_dirs -exec cat '{}' \; &> /dev/null
12027 # Second verifying readability.
12028 $LCTL get_param -R '*' &> /dev/null
12030 # Verifing writability with badarea_io.
12032 -ignore_readdir_race \
12034 -not -name force_lbug \
12035 -not -name changelog_mask \
12036 -exec badarea_io '{}' \; ||
12037 error_133 "find $proc_dirs failed"
12039 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
12042 remote_mds_nodsh && skip "remote MDS with nodsh"
12043 remote_ost_nodsh && skip "remote OST with nodsh"
12045 # eventually, this can also be replaced with "lctl get_param -R",
12046 # but not until that option is always available on the server
12048 for facet in mds1 ost1; do
12049 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
12050 skip_noexit "Too old lustre on $facet"
12051 local facet_proc_dirs=$(do_facet $facet \
12052 \\\ls -d $proc_regexp 2>/dev/null)
12053 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12054 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12055 do_facet $facet find $facet_proc_dirs \
12056 ! -name req_history \
12057 -exec cat '{}' \\\; &> /dev/null
12059 do_facet $facet find $facet_proc_dirs \
12060 ! -name req_history \
12062 -exec cat '{}' \\\; &> /dev/null ||
12063 error "proc file read failed"
12065 do_facet $facet find $facet_proc_dirs \
12066 -ignore_readdir_race \
12068 -not -name force_lbug \
12069 -not -name changelog_mask \
12070 -exec badarea_io '{}' \\\; ||
12071 error_133 "$facet find $facet_proc_dirs failed"
12074 # remount the FS in case writes/reads /proc break the FS
12075 cleanup || error "failed to unmount"
12076 setup || error "failed to setup"
12079 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12082 remote_mds_nodsh && skip "remote MDS with nodsh"
12083 remote_ost_nodsh && skip "remote OST with nodsh"
12084 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12085 skip "Need MDS version at least 2.9.54"
12089 for facet in client mds1 ost1; do
12090 local facet_proc_dirs=$(do_facet $facet \
12091 \\\ls -d $proc_regexp 2> /dev/null)
12092 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12093 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12094 # Get the list of files that are missing the terminating newline
12095 local missing=($(do_facet $facet \
12096 find ${facet_proc_dirs} -type f \| \
12097 while read F\; do \
12098 awk -v FS='\v' -v RS='\v\v' \
12099 "'END { if(NR>0 && \
12100 \\\$NF !~ /.*\\\n\$/) \
12101 print FILENAME}'" \
12104 [ ${#missing[*]} -eq 0 ] ||
12105 error "files do not end with newline: ${missing[*]}"
12108 run_test 133h "Proc files should end with newlines"
12111 remote_mds_nodsh && skip "remote MDS with nodsh"
12112 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12113 skip "Need MDS version at least 2.7.54"
12115 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12116 cancel_lru_locks mdc
12118 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12119 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12120 [ $unused -eq 0 ] || error "$unused locks are not cleared"
12123 createmany -o $DIR/$tdir/f $nr ||
12124 error "failed to create $nr files in $DIR/$tdir"
12125 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12127 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
12128 do_facet mds1 $LCTL set_param fail_loc=0x327
12129 do_facet mds1 $LCTL set_param fail_val=500
12132 echo "sleep 10 seconds ..."
12134 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
12136 do_facet mds1 $LCTL set_param fail_loc=0
12137 do_facet mds1 $LCTL set_param fail_val=0
12138 [ $lck_cnt -lt $unused ] ||
12139 error "No locks reclaimed, before:$unused, after:$lck_cnt"
12142 unlinkmany $DIR/$tdir/f $nr
12144 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
12147 remote_mds_nodsh && skip "remote MDS with nodsh"
12148 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12149 skip "Need MDS version at least 2.7.54"
12151 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12152 cancel_lru_locks mdc
12154 local low_wm=$(do_facet mds1 $LCTL get_param -n \
12155 ldlm.lock_reclaim_threshold_mb)
12156 # disable reclaim temporarily
12157 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
12159 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
12160 do_facet mds1 $LCTL set_param fail_loc=0x328
12161 do_facet mds1 $LCTL set_param fail_val=500
12163 $LCTL set_param debug=+trace
12166 createmany -o $DIR/$tdir/f $nr &
12167 local create_pid=$!
12169 echo "Sleep $TIMEOUT seconds ..."
12171 if ! ps -p $create_pid > /dev/null 2>&1; then
12172 do_facet mds1 $LCTL set_param fail_loc=0
12173 do_facet mds1 $LCTL set_param fail_val=0
12174 do_facet mds1 $LCTL set_param \
12175 ldlm.lock_reclaim_threshold_mb=${low_wm}m
12176 error "createmany finished incorrectly!"
12178 do_facet mds1 $LCTL set_param fail_loc=0
12179 do_facet mds1 $LCTL set_param fail_val=0
12180 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
12181 wait $create_pid || return 1
12183 unlinkmany $DIR/$tdir/f $nr
12185 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
12187 test_140() { #bug-17379
12188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12190 test_mkdir $DIR/$tdir
12191 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
12192 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
12194 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
12195 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
12197 while i=$((i + 1)); do
12199 cd $i || error "Changing to $i"
12200 ln -s ../stat stat || error "Creating stat symlink"
12201 # Read the symlink until ELOOP present,
12202 # not LBUGing the system is considered success,
12203 # we didn't overrun the stack.
12204 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
12205 if [ $ret -ne 0 ]; then
12206 if [ $ret -eq 40 ]; then
12209 error "Open stat symlink"
12215 echo "The symlink depth = $i"
12216 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
12217 error "Invalid symlink depth"
12219 # Test recursive symlink
12220 ln -s symlink_self symlink_self
12221 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
12222 echo "open symlink_self returns $ret"
12223 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
12225 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
12228 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12230 local TF="$TMP/$tfile"
12232 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12234 cancel_lru_locks $OSC
12235 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
12236 remount_client $MOUNT
12238 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
12241 $TRUNCATE $DIR/$tfile 6000
12242 cancel_lru_locks $OSC
12243 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
12246 echo "12345" >>$DIR/$tfile
12247 cancel_lru_locks $OSC
12248 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
12251 echo "12345" >>$DIR/$tfile
12252 cancel_lru_locks $OSC
12253 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
12258 run_test 150 "truncate/append tests"
12260 #LU-2902 roc_hit was not able to read all values from lproc
12261 function roc_hit_init() {
12262 local list=$(comma_list $(osts_nodes))
12263 local dir=$DIR/$tdir-check
12264 local file=$dir/$tfile
12270 #use setstripe to do a write to every ost
12271 for i in $(seq 0 $((OSTCOUNT-1))); do
12272 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
12273 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
12274 idx=$(printf %04x $i)
12275 BEFORE=$(get_osd_param $list *OST*$idx stats |
12276 awk '$1 == "cache_access" {sum += $7}
12277 END { printf("%0.0f", sum) }')
12279 cancel_lru_locks osc
12280 cat $file >/dev/null
12282 AFTER=$(get_osd_param $list *OST*$idx stats |
12283 awk '$1 == "cache_access" {sum += $7}
12284 END { printf("%0.0f", sum) }')
12286 echo BEFORE:$BEFORE AFTER:$AFTER
12287 if ! let "AFTER - BEFORE == 4"; then
12289 error "roc_hit is not safe to use"
12297 function roc_hit() {
12298 local list=$(comma_list $(osts_nodes))
12299 echo $(get_osd_param $list '' stats |
12300 awk '$1 == "cache_hit" {sum += $7}
12301 END { printf("%0.0f", sum) }')
12304 function set_cache() {
12307 if [ "$2" == "off" ]; then
12310 local list=$(comma_list $(osts_nodes))
12311 set_osd_param $list '' $1_cache_enable $on
12313 cancel_lru_locks osc
12317 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12318 remote_ost_nodsh && skip "remote OST with nodsh"
12321 local list=$(comma_list $(osts_nodes))
12323 # check whether obdfilter is cache capable at all
12324 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
12325 skip "not cache-capable obdfilter"
12328 # check cache is enabled on all obdfilters
12329 if get_osd_param $list '' read_cache_enable | grep 0; then
12330 skip "oss cache is disabled"
12333 set_osd_param $list '' writethrough_cache_enable 1
12335 # check write cache is enabled on all obdfilters
12336 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
12337 skip "oss write cache is NOT enabled"
12342 #define OBD_FAIL_OBD_NO_LRU 0x609
12343 do_nodes $list $LCTL set_param fail_loc=0x609
12345 # pages should be in the case right after write
12346 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
12349 local BEFORE=$(roc_hit)
12350 cancel_lru_locks osc
12351 cat $DIR/$tfile >/dev/null
12352 local AFTER=$(roc_hit)
12354 do_nodes $list $LCTL set_param fail_loc=0
12356 if ! let "AFTER - BEFORE == CPAGES"; then
12357 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12360 # the following read invalidates the cache
12361 cancel_lru_locks osc
12362 set_osd_param $list '' read_cache_enable 0
12363 cat $DIR/$tfile >/dev/null
12365 # now data shouldn't be found in the cache
12367 cancel_lru_locks osc
12368 cat $DIR/$tfile >/dev/null
12370 if let "AFTER - BEFORE != 0"; then
12371 error "IN CACHE: before: $BEFORE, after: $AFTER"
12374 set_osd_param $list '' read_cache_enable 1
12377 run_test 151 "test cache on oss and controls ==============================="
12380 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12382 local TF="$TMP/$tfile"
12384 # simulate ENOMEM during write
12385 #define OBD_FAIL_OST_NOMEM 0x226
12386 lctl set_param fail_loc=0x80000226
12387 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12389 sync || error "sync failed"
12390 lctl set_param fail_loc=0
12392 # discard client's cache
12393 cancel_lru_locks osc
12395 # simulate ENOMEM during read
12396 lctl set_param fail_loc=0x80000226
12397 cmp $TF $DIR/$tfile || error "cmp failed"
12398 lctl set_param fail_loc=0
12402 run_test 152 "test read/write with enomem ============================"
12405 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
12407 run_test 153 "test if fdatasync does not crash ======================="
12409 dot_lustre_fid_permission_check() {
12411 local ffid=$MOUNT/.lustre/fid/$fid
12414 echo "stat fid $fid"
12415 stat $ffid > /dev/null || error "stat $ffid failed."
12416 echo "touch fid $fid"
12417 touch $ffid || error "touch $ffid failed."
12418 echo "write to fid $fid"
12419 cat /etc/hosts > $ffid || error "write $ffid failed."
12420 echo "read fid $fid"
12421 diff /etc/hosts $ffid || error "read $ffid failed."
12422 echo "append write to fid $fid"
12423 cat /etc/hosts >> $ffid || error "append write $ffid failed."
12424 echo "rename fid $fid"
12425 mv $ffid $test_dir/$tfile.1 &&
12426 error "rename $ffid to $tfile.1 should fail."
12427 touch $test_dir/$tfile.1
12428 mv $test_dir/$tfile.1 $ffid &&
12429 error "rename $tfile.1 to $ffid should fail."
12430 rm -f $test_dir/$tfile.1
12431 echo "truncate fid $fid"
12432 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
12433 echo "link fid $fid"
12434 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
12435 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
12436 echo "setfacl fid $fid"
12437 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
12438 echo "getfacl fid $fid"
12439 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
12441 echo "unlink fid $fid"
12442 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
12443 echo "mknod fid $fid"
12444 mknod $ffid c 1 3 && error "mknod $ffid should fail."
12446 fid=[0xf00000400:0x1:0x0]
12447 ffid=$MOUNT/.lustre/fid/$fid
12449 echo "stat non-exist fid $fid"
12450 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
12451 echo "write to non-exist fid $fid"
12452 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
12453 echo "link new fid $fid"
12454 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
12456 mkdir -p $test_dir/$tdir
12457 touch $test_dir/$tdir/$tfile
12458 fid=$($LFS path2fid $test_dir/$tdir)
12461 error "error: could not get fid for $test_dir/$dir/$tfile."
12463 ffid=$MOUNT/.lustre/fid/$fid
12466 ls $ffid > /dev/null || error "ls $ffid failed."
12467 echo "touch $fid/$tfile.1"
12468 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
12470 echo "touch $MOUNT/.lustre/fid/$tfile"
12471 touch $MOUNT/.lustre/fid/$tfile && \
12472 error "touch $MOUNT/.lustre/fid/$tfile should fail."
12474 echo "setxattr to $MOUNT/.lustre/fid"
12475 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
12477 echo "listxattr for $MOUNT/.lustre/fid"
12478 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
12480 echo "delxattr from $MOUNT/.lustre/fid"
12481 setfattr -x trusted.name1 $MOUNT/.lustre/fid
12483 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
12484 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
12485 error "touch invalid fid should fail."
12487 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
12488 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
12489 error "touch non-normal fid should fail."
12491 echo "rename $tdir to $MOUNT/.lustre/fid"
12492 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
12493 error "rename to $MOUNT/.lustre/fid should fail."
12495 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
12497 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
12498 local new_obf_mode=777
12500 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
12501 chmod $new_obf_mode $DIR/.lustre/fid ||
12502 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
12504 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
12505 [ $obf_mode -eq $new_obf_mode ] ||
12506 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
12508 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
12509 chmod $old_obf_mode $DIR/.lustre/fid ||
12510 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
12513 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
12514 fid=$($LFS path2fid $test_dir/$tfile-2)
12516 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
12518 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
12519 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
12520 error "create lov data thru .lustre failed"
12522 echo "cp /etc/passwd $test_dir/$tfile-2"
12523 cp /etc/passwd $test_dir/$tfile-2 ||
12524 error "copy to $test_dir/$tfile-2 failed."
12525 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
12526 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
12527 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
12529 rm -rf $test_dir/tfile.lnk
12530 rm -rf $test_dir/$tfile-2
12534 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12535 skip "Need MDS version at least 2.4.1"
12537 local tf=$DIR/$tfile
12540 local fid=$($LFS path2fid $tf)
12541 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
12543 # check that we get the same pathname back
12544 local found=$($LFS fid2path $MOUNT "$fid")
12545 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
12546 [ "$found" == "$tf" ] ||
12547 error "fid2path($fid=path2fid($tf)) = $found != $tf"
12549 run_test 154A "lfs path2fid and fid2path basic checks"
12552 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12553 skip "Need MDS version at least 2.4.1"
12555 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
12556 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
12557 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
12558 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
12560 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
12561 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
12563 # check that we get the same pathname
12564 echo "PFID: $PFID, name: $name"
12565 local FOUND=$($LFS fid2path $MOUNT "$PFID")
12566 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
12567 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
12568 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
12570 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
12572 run_test 154B "verify the ll_decode_linkea tool"
12575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12576 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12577 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12578 skip "Need MDS version at least 2.2.51"
12579 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12581 cp /etc/hosts $DIR/$tfile
12583 fid=$($LFS path2fid $DIR/$tfile)
12585 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
12587 dot_lustre_fid_permission_check "$fid" $DIR ||
12588 error "dot lustre permission check $fid failed"
12590 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
12592 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
12594 touch $MOUNT/.lustre/file &&
12595 error "creation is not allowed under .lustre"
12597 mkdir $MOUNT/.lustre/dir &&
12598 error "mkdir is not allowed under .lustre"
12602 run_test 154a "Open-by-FID"
12605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12606 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12607 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12608 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12609 skip "Need MDS version at least 2.2.51"
12611 local remote_dir=$DIR/$tdir/remote_dir
12615 mkdir -p $DIR/$tdir
12616 $LFS mkdir -i $MDTIDX $remote_dir ||
12617 error "create remote directory failed"
12619 cp /etc/hosts $remote_dir/$tfile
12621 fid=$($LFS path2fid $remote_dir/$tfile)
12623 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
12625 dot_lustre_fid_permission_check "$fid" $remote_dir ||
12626 error "dot lustre permission check $fid failed"
12629 run_test 154b "Open-by-FID for remote directory"
12632 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12633 skip "Need MDS version at least 2.4.1"
12635 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
12636 local FID1=$($LFS path2fid $DIR/$tfile.1)
12637 local FID2=$($LFS path2fid $DIR/$tfile.2)
12638 local FID3=$($LFS path2fid $DIR/$tfile.3)
12641 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
12642 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
12643 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
12645 [ "$FID" = "${!want}" ] ||
12646 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
12650 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
12652 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
12653 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
12657 run_test 154c "lfs path2fid and fid2path multiple arguments"
12660 remote_mds_nodsh && skip "remote MDS with nodsh"
12661 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
12662 skip "Need MDS version at least 2.5.53"
12664 if remote_mds; then
12665 nid=$($LCTL list_nids | sed "s/\./\\\./g")
12669 local proc_ofile="mdt.*.exports.'$nid'.open_files"
12676 local fid=$($LFS path2fid $DIR/$tfile)
12679 cmd="exec $fd<$DIR/$tfile"
12681 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
12682 echo "$fid_list" | grep "$fid"
12685 cmd="exec $fd>/dev/null"
12687 if [ $rc -ne 0 ]; then
12688 error "FID $fid not found in open files list $fid_list"
12691 run_test 154d "Verify open file fid"
12695 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
12696 skip "Need MDS version at least 2.6.50"
12698 if ls -a $MOUNT | grep -q '^\.lustre$'; then
12699 error ".lustre returned by readdir"
12702 run_test 154e ".lustre is not returned by readdir"
12705 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12707 # create parent directory on a single MDT to avoid cross-MDT hardlinks
12708 test_mkdir -p -c1 $DIR/$tdir/d
12709 # test dirs inherit from its stripe
12710 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
12711 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
12712 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
12713 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
12716 # get fid of parents
12717 local FID0=$($LFS path2fid $DIR/$tdir/d)
12718 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
12719 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
12720 local FID3=$($LFS path2fid $DIR)
12722 # check that path2fid --parents returns expected <parent_fid>/name
12723 # 1) test for a directory (single parent)
12724 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
12725 [ "$parent" == "$FID0/foo1" ] ||
12726 error "expected parent: $FID0/foo1, got: $parent"
12728 # 2) test for a file with nlink > 1 (multiple parents)
12729 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
12730 echo "$parent" | grep -F "$FID1/$tfile" ||
12731 error "$FID1/$tfile not returned in parent list"
12732 echo "$parent" | grep -F "$FID2/link" ||
12733 error "$FID2/link not returned in parent list"
12735 # 3) get parent by fid
12736 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
12737 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12738 echo "$parent" | grep -F "$FID1/$tfile" ||
12739 error "$FID1/$tfile not returned in parent list (by fid)"
12740 echo "$parent" | grep -F "$FID2/link" ||
12741 error "$FID2/link not returned in parent list (by fid)"
12743 # 4) test for entry in root directory
12744 parent=$($LFS path2fid --parents $DIR/f)
12745 echo "$parent" | grep -F "$FID3/f" ||
12746 error "$FID3/f not returned in parent list"
12748 # 5) test it on root directory
12749 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
12750 error "$MOUNT should not have parents"
12752 # enable xattr caching and check that linkea is correctly updated
12753 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12754 save_lustre_params client "llite.*.xattr_cache" > $save
12755 lctl set_param llite.*.xattr_cache 1
12757 # 6.1) linkea update on rename
12758 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
12760 # get parents by fid
12761 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12762 # foo1 should no longer be returned in parent list
12763 echo "$parent" | grep -F "$FID1" &&
12764 error "$FID1 should no longer be in parent list"
12765 # the new path should appear
12766 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
12767 error "$FID2/$tfile.moved is not in parent list"
12769 # 6.2) linkea update on unlink
12770 rm -f $DIR/$tdir/d/foo2/link
12771 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12772 # foo2/link should no longer be returned in parent list
12773 echo "$parent" | grep -F "$FID2/link" &&
12774 error "$FID2/link should no longer be in parent list"
12778 restore_lustre_params < $save
12781 run_test 154f "get parent fids by reading link ea"
12785 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12786 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
12787 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
12788 skip "Need MDS version at least 2.6.92"
12790 mkdir -p $DIR/$tdir
12791 llapi_fid_test -d $DIR/$tdir
12793 run_test 154g "various llapi FID tests"
12795 test_155_small_load() {
12796 local temp=$TMP/$tfile
12797 local file=$DIR/$tfile
12799 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
12800 error "dd of=$temp bs=6096 count=1 failed"
12802 cancel_lru_locks $OSC
12803 cmp $temp $file || error "$temp $file differ"
12805 $TRUNCATE $temp 6000
12806 $TRUNCATE $file 6000
12807 cmp $temp $file || error "$temp $file differ (truncate1)"
12809 echo "12345" >>$temp
12810 echo "12345" >>$file
12811 cmp $temp $file || error "$temp $file differ (append1)"
12813 echo "12345" >>$temp
12814 echo "12345" >>$file
12815 cmp $temp $file || error "$temp $file differ (append2)"
12821 test_155_big_load() {
12822 remote_ost_nodsh && skip "remote OST with nodsh"
12824 local temp=$TMP/$tfile
12825 local file=$DIR/$tfile
12828 local cache_size=$(do_facet ost$((MAXI+1)) \
12829 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
12830 local large_file_size=$((cache_size * 2))
12832 echo "OSS cache size: $cache_size KB"
12833 echo "Large file size: $large_file_size KB"
12835 [ $MAXV -le $large_file_size ] &&
12836 skip_env "max available OST size needs > $large_file_size KB"
12838 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
12840 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
12841 error "dd of=$temp bs=$large_file_size count=1k failed"
12844 cancel_lru_locks osc
12845 cmp $temp $file || error "$temp $file differ"
12851 save_writethrough() {
12852 local facets=$(get_facets OST)
12854 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
12858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12860 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12862 save_writethrough $p
12865 set_cache writethrough on
12866 test_155_small_load
12867 restore_lustre_params < $p
12870 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
12873 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12875 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12877 save_writethrough $p
12880 set_cache writethrough off
12881 test_155_small_load
12882 restore_lustre_params < $p
12885 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
12888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12890 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12892 save_writethrough $p
12895 set_cache writethrough on
12896 test_155_small_load
12897 restore_lustre_params < $p
12900 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
12903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12905 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12907 save_writethrough $p
12910 set_cache writethrough off
12911 test_155_small_load
12912 restore_lustre_params < $p
12915 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
12918 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12920 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12922 save_writethrough $p
12925 set_cache writethrough on
12927 restore_lustre_params < $p
12930 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
12933 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12935 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12937 save_writethrough $p
12940 set_cache writethrough off
12942 restore_lustre_params < $p
12945 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
12948 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12950 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12952 save_writethrough $p
12955 set_cache writethrough on
12957 restore_lustre_params < $p
12960 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
12963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12965 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12967 save_writethrough $p
12970 set_cache writethrough off
12972 restore_lustre_params < $p
12975 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
12978 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12979 remote_ost_nodsh && skip "remote OST with nodsh"
12980 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
12981 skip "stats not implemented on old servers"
12982 [ "$ost1_FSTYPE" = "zfs" ] &&
12983 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
12988 local file="$DIR/$tfile"
12989 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12991 save_writethrough $p
12994 log "Turn on read and write cache"
12996 set_cache writethrough on
12998 log "Write data and read it back."
12999 log "Read should be satisfied from the cache."
13000 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13002 cancel_lru_locks osc
13003 cat $file >/dev/null
13005 if ! let "AFTER - BEFORE == CPAGES"; then
13006 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13008 log "cache hits:: before: $BEFORE, after: $AFTER"
13011 log "Read again; it should be satisfied from the cache."
13013 cancel_lru_locks osc
13014 cat $file >/dev/null
13016 if ! let "AFTER - BEFORE == CPAGES"; then
13017 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13019 log "cache hits:: before: $BEFORE, after: $AFTER"
13022 log "Turn off the read cache and turn on the write cache"
13024 set_cache writethrough on
13026 log "Read again; it should be satisfied from the cache."
13028 cancel_lru_locks osc
13029 cat $file >/dev/null
13031 if ! let "AFTER - BEFORE == CPAGES"; then
13032 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13034 log "cache hits:: before: $BEFORE, after: $AFTER"
13037 log "Read again; it should not be satisfied from the cache."
13039 cancel_lru_locks osc
13040 cat $file >/dev/null
13042 if ! let "AFTER - BEFORE == 0"; then
13043 error "IN CACHE: before: $BEFORE, after: $AFTER"
13045 log "cache hits:: before: $BEFORE, after: $AFTER"
13048 log "Write data and read it back."
13049 log "Read should be satisfied from the cache."
13050 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13052 cancel_lru_locks osc
13053 cat $file >/dev/null
13055 if ! let "AFTER - BEFORE == CPAGES"; then
13056 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13058 log "cache hits:: before: $BEFORE, after: $AFTER"
13061 log "Read again; it should not be satisfied from the cache."
13063 cancel_lru_locks osc
13064 cat $file >/dev/null
13066 if ! let "AFTER - BEFORE == 0"; then
13067 error "IN CACHE: before: $BEFORE, after: $AFTER"
13069 log "cache hits:: before: $BEFORE, after: $AFTER"
13072 log "Turn off read and write cache"
13074 set_cache writethrough off
13076 log "Write data and read it back"
13077 log "It should not be satisfied from the cache."
13079 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13080 cancel_lru_locks osc
13082 cat $file >/dev/null
13084 if ! let "AFTER - BEFORE == 0"; then
13085 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13087 log "cache hits:: before: $BEFORE, after: $AFTER"
13090 log "Turn on the read cache and turn off the write cache"
13092 set_cache writethrough off
13094 log "Write data and read it back"
13095 log "It should not be satisfied from the cache."
13097 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13099 cancel_lru_locks osc
13100 cat $file >/dev/null
13102 if ! let "AFTER - BEFORE == 0"; then
13103 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
13105 log "cache hits:: before: $BEFORE, after: $AFTER"
13108 log "Read again; it should be satisfied from the cache."
13110 cancel_lru_locks osc
13111 cat $file >/dev/null
13113 if ! let "AFTER - BEFORE == CPAGES"; then
13114 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13116 log "cache hits:: before: $BEFORE, after: $AFTER"
13119 restore_lustre_params < $p
13122 run_test 156 "Verification of tunables"
13125 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13126 remote_mds_nodsh && skip "remote MDS with nodsh"
13127 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13128 skip "Need MDS version at least 2.2.0"
13130 changelog_register || error "changelog_register failed"
13131 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13132 changelog_users $SINGLEMDS | grep -q $cl_user ||
13133 error "User $cl_user not found in changelog_users"
13136 test_mkdir -p $DIR/$tdir/pics/2008/zachy
13137 changelog_clear 0 || error "changelog_clear failed"
13138 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
13139 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
13140 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
13141 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
13142 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
13143 rm $DIR/$tdir/pics/desktop.jpg
13145 changelog_dump | tail -10
13147 echo "verifying changelog mask"
13148 changelog_chmask "-MKDIR"
13149 changelog_chmask "-CLOSE"
13151 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
13152 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
13154 changelog_chmask "+MKDIR"
13155 changelog_chmask "+CLOSE"
13157 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
13158 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
13160 changelog_dump | tail -10
13161 MKDIRS=$(changelog_dump | grep -c "MKDIR")
13162 CLOSES=$(changelog_dump | grep -c "CLOSE")
13163 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
13164 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
13167 echo "verifying target fid"
13168 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
13169 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
13170 [ "$fidc" == "$fidf" ] ||
13171 error "changelog '$tfile' fid $fidc != file fid $fidf"
13172 echo "verifying parent fid"
13173 # The FID returned from the Changelog may be the directory shard on
13174 # a different MDT, and not the FID returned by path2fid on the parent.
13175 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
13176 # since this is what will matter when recreating this file in the tree.
13177 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
13178 local pathp=$($LFS fid2path $MOUNT "$fidp")
13179 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
13180 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
13182 echo "getting records for $cl_user"
13183 changelog_users $SINGLEMDS
13184 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
13186 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
13187 error "changelog_clear failed"
13188 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
13189 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
13190 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
13191 error "user index expect $user_rec1 + $nclr != $user_rec2"
13193 local min0_rec=$(changelog_users $SINGLEMDS |
13194 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
13195 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
13196 awk '{ print $1; exit; }')
13198 changelog_dump | tail -n 5
13199 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
13200 [ $first_rec == $((min0_rec + 1)) ] ||
13201 error "first index should be $min0_rec + 1 not $first_rec"
13203 # LU-3446 changelog index reset on MDT restart
13204 local cur_rec1=$(changelog_users $SINGLEMDS |
13205 awk '/^current.index:/ { print $NF }')
13206 changelog_clear 0 ||
13207 error "clear all changelog records for $cl_user failed"
13208 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
13209 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
13210 error "Fail to start $SINGLEMDS"
13211 local cur_rec2=$(changelog_users $SINGLEMDS |
13212 awk '/^current.index:/ { print $NF }')
13213 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
13214 [ $cur_rec1 == $cur_rec2 ] ||
13215 error "current index should be $cur_rec1 not $cur_rec2"
13217 echo "verifying users from this test are deregistered"
13218 changelog_deregister || error "changelog_deregister failed"
13219 changelog_users $SINGLEMDS | grep -q $cl_user &&
13220 error "User '$cl_user' still in changelog_users"
13222 # lctl get_param -n mdd.*.changelog_users
13223 # current index: 144
13224 # ID index (idle seconds)
13226 if ! changelog_users $SINGLEMDS | grep "^cl"; then
13227 # this is the normal case where all users were deregistered
13228 # make sure no new records are added when no users are present
13229 local last_rec1=$(changelog_users $SINGLEMDS |
13230 awk '/^current.index:/ { print $NF }')
13231 touch $DIR/$tdir/chloe
13232 local last_rec2=$(changelog_users $SINGLEMDS |
13233 awk '/^current.index:/ { print $NF }')
13234 echo "verify changelogs are off: $last_rec1 == $last_rec2"
13235 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
13237 # any changelog users must be leftovers from a previous test
13238 changelog_users $SINGLEMDS
13239 echo "other changelog users; can't verify off"
13242 run_test 160a "changelog sanity"
13244 test_160b() { # LU-3587
13245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13246 remote_mds_nodsh && skip "remote MDS with nodsh"
13247 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13248 skip "Need MDS version at least 2.2.0"
13250 changelog_register || error "changelog_register failed"
13251 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13252 changelog_users $SINGLEMDS | grep -q $cl_user ||
13253 error "User '$cl_user' not found in changelog_users"
13255 local longname1=$(str_repeat a 255)
13256 local longname2=$(str_repeat b 255)
13259 echo "creating very long named file"
13260 touch $longname1 || error "create of '$longname1' failed"
13261 echo "renaming very long named file"
13262 mv $longname1 $longname2
13264 changelog_dump | grep RENME | tail -n 5
13267 run_test 160b "Verify that very long rename doesn't crash in changelog"
13270 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13271 remote_mds_nodsh && skip "remote MDS with nodsh"
13273 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
13274 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
13275 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
13276 skip "Need MDS version at least 2.5.58 or 2.5.2+"
13280 # Registration step
13281 changelog_register || error "changelog_register failed"
13284 mkdir -p $DIR/$tdir
13285 $MCREATE $DIR/$tdir/foo_160c
13286 changelog_chmask "-TRUNC"
13287 $TRUNCATE $DIR/$tdir/foo_160c 200
13288 changelog_chmask "+TRUNC"
13289 $TRUNCATE $DIR/$tdir/foo_160c 199
13290 changelog_dump | tail -n 5
13291 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
13292 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
13294 run_test 160c "verify that changelog log catch the truncate event"
13297 remote_mds_nodsh && skip "remote MDS with nodsh"
13298 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13299 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13300 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
13301 skip "Need MDS version at least 2.7.60"
13303 # Registration step
13304 changelog_register || error "changelog_register failed"
13306 mkdir -p $DIR/$tdir/migrate_dir
13307 changelog_clear 0 || error "changelog_clear failed"
13309 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
13310 changelog_dump | tail -n 5
13311 local migrates=$(changelog_dump | grep -c "MIGRT")
13312 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
13314 run_test 160d "verify that changelog log catch the migrate event"
13317 remote_mds_nodsh && skip "remote MDS with nodsh"
13320 changelog_register || error "changelog_register failed"
13322 # Delete a future user (expect fail)
13323 local MDT0=$(facet_svc $SINGLEMDS)
13324 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
13327 if [ $rc -eq 0 ]; then
13328 error "Deleted non-existant user cl77"
13329 elif [ $rc -ne 2 ]; then
13330 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
13333 # Clear to a bad index (1 billion should be safe)
13334 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
13337 if [ $rc -eq 0 ]; then
13338 error "Successfully cleared to invalid CL index"
13339 elif [ $rc -ne 22 ]; then
13340 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
13343 run_test 160e "changelog negative testing (should return errors)"
13346 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13347 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13348 skip "Need MDS version at least 2.10.56"
13350 local mdts=$(comma_list $(mdts_nodes))
13353 changelog_register || error "first changelog_register failed"
13354 changelog_register || error "second changelog_register failed"
13356 declare -A cl_user1
13357 declare -A cl_user2
13362 # generate some changelog records to accumulate on each MDT
13363 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13364 log "$(date +%s): creating first files"
13365 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13366 error "create $DIR/$tdir/$tfile failed"
13368 # check changelogs have been generated
13369 local start=$SECONDS
13370 local idle_time=$((MDSCOUNT * 5 + 5))
13371 local nbcl=$(changelog_dump | wc -l)
13372 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13374 for param in "changelog_max_idle_time=$idle_time" \
13376 "changelog_min_gc_interval=2" \
13377 "changelog_min_free_cat_entries=3"; do
13378 local MDT0=$(facet_svc $SINGLEMDS)
13379 local var="${param%=*}"
13380 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13382 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13383 do_nodes $mdts $LCTL set_param mdd.*.$param
13386 # force cl_user2 to be idle (1st part), but also cancel the
13387 # cl_user1 records so that it is not evicted later in the test.
13388 local sleep1=$((idle_time / 2))
13389 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
13392 # simulate changelog catalog almost full
13393 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13394 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13396 for i in $(seq $MDSCOUNT); do
13397 cl_users=(${CL_USERS[mds$i]})
13398 cl_user1[mds$i]="${cl_users[0]}"
13399 cl_user2[mds$i]="${cl_users[1]}"
13401 [ -n "${cl_user1[mds$i]}" ] ||
13402 error "mds$i: no user registered"
13403 [ -n "${cl_user2[mds$i]}" ] ||
13404 error "mds$i: only ${cl_user2[mds$i]} is registered"
13406 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13407 [ -n "$user_rec1" ] ||
13408 error "mds$i: User ${cl_user1[mds$i]} not registered"
13409 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13410 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13411 [ -n "$user_rec2" ] ||
13412 error "mds$i: User ${cl_user1[mds$i]} not registered"
13413 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13414 "$user_rec1 + 2 == $user_rec2"
13415 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13416 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13417 "$user_rec1 + 2, but is $user_rec2"
13418 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13419 [ -n "$user_rec2" ] ||
13420 error "mds$i: User ${cl_user2[mds$i]} not registered"
13421 [ $user_rec1 == $user_rec2 ] ||
13422 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13423 "$user_rec1, but is $user_rec2"
13426 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
13427 local sleep2=$((idle_time - (SECONDS - start) + 1))
13428 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
13431 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
13432 # cl_user1 should be OK because it recently processed records.
13433 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
13434 createmany -m $DIR/$tdir/${tfile}b $((MDSCOUNT * 2)) ||
13435 error "create $DIR/$tdir/${tfile}b failed"
13437 # ensure gc thread is done
13438 for i in $(mdts_nodes); do
13440 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13441 error "$i: GC-thread not done"
13445 for i in $(seq $MDSCOUNT); do
13446 # check cl_user1 still registered
13447 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13448 error "mds$i: User ${cl_user1[mds$i]} not registered"
13449 # check cl_user2 unregistered
13450 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13451 error "mds$i: User ${cl_user2[mds$i]} still registered"
13453 # check changelogs are present and starting at $user_rec1 + 1
13454 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13455 [ -n "$user_rec1" ] ||
13456 error "mds$i: User ${cl_user1[mds$i]} not registered"
13457 first_rec=$($LFS changelog $(facet_svc mds$i) |
13458 awk '{ print $1; exit; }')
13460 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13461 [ $((user_rec1 + 1)) == $first_rec ] ||
13462 error "mds$i: first index should be $user_rec1 + 1, " \
13463 "but is $first_rec"
13466 run_test 160f "changelog garbage collect (timestamped users)"
13469 remote_mds_nodsh && skip "remote MDS with nodsh"
13470 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13471 skip "Need MDS version at least 2.10.56"
13473 local mdts=$(comma_list $(mdts_nodes))
13475 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
13476 do_nodes $mdts $LCTL set_param fail_loc=0x1314
13479 changelog_register || error "first changelog_register failed"
13480 changelog_register || error "second changelog_register failed"
13482 declare -A cl_user1
13483 declare -A cl_user2
13488 # generate some changelog records to accumulate on each MDT
13489 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13490 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13491 error "create $DIR/$tdir/$tfile failed"
13493 # check changelogs have been generated
13494 local nbcl=$(changelog_dump | wc -l)
13495 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13497 # reduce the max_idle_indexes value to make sure we exceed it
13498 max_ndx=$((nbcl / 2 - 1))
13500 for param in "changelog_max_idle_indexes=$max_ndx" \
13502 "changelog_min_gc_interval=2" \
13503 "changelog_min_free_cat_entries=3"; do
13504 local MDT0=$(facet_svc $SINGLEMDS)
13505 local var="${param%=*}"
13506 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13508 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13509 do_nodes $mdts $LCTL set_param mdd.*.$param ||
13510 error "unable to set mdd.*.$param"
13513 # simulate changelog catalog almost full
13514 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13515 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13517 for i in $(seq $MDSCOUNT); do
13518 cl_users=(${CL_USERS[mds$i]})
13519 cl_user1[mds$i]="${cl_users[0]}"
13520 cl_user2[mds$i]="${cl_users[1]}"
13522 [ -n "${cl_user1[mds$i]}" ] ||
13523 error "mds$i: no user registered"
13524 [ -n "${cl_user2[mds$i]}" ] ||
13525 error "mds$i: only ${cl_user1[mds$i]} is registered"
13527 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13528 [ -n "$user_rec1" ] ||
13529 error "mds$i: User ${cl_user1[mds$i]} not registered"
13530 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13531 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13532 [ -n "$user_rec2" ] ||
13533 error "mds$i: User ${cl_user1[mds$i]} not registered"
13534 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13535 "$user_rec1 + 2 == $user_rec2"
13536 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13537 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13538 "$user_rec1 + 2, but is $user_rec2"
13539 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13540 [ -n "$user_rec2" ] ||
13541 error "mds$i: User ${cl_user2[mds$i]} not registered"
13542 [ $user_rec1 == $user_rec2 ] ||
13543 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13544 "$user_rec1, but is $user_rec2"
13547 # ensure we are past the previous changelog_min_gc_interval set above
13550 # generate one more changelog to trigger fail_loc
13551 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13552 error "create $DIR/$tdir/${tfile}bis failed"
13554 # ensure gc thread is done
13555 for i in $(mdts_nodes); do
13557 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13558 error "$i: GC-thread not done"
13562 for i in $(seq $MDSCOUNT); do
13563 # check cl_user1 still registered
13564 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13565 error "mds$i: User ${cl_user1[mds$i]} not registered"
13566 # check cl_user2 unregistered
13567 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13568 error "mds$i: User ${cl_user2[mds$i]} still registered"
13570 # check changelogs are present and starting at $user_rec1 + 1
13571 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13572 [ -n "$user_rec1" ] ||
13573 error "mds$i: User ${cl_user1[mds$i]} not registered"
13574 first_rec=$($LFS changelog $(facet_svc mds$i) |
13575 awk '{ print $1; exit; }')
13577 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13578 [ $((user_rec1 + 1)) == $first_rec ] ||
13579 error "mds$i: first index should be $user_rec1 + 1, " \
13580 "but is $first_rec"
13583 run_test 160g "changelog garbage collect (old users)"
13586 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13587 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13588 skip "Need MDS version at least 2.10.56"
13590 local mdts=$(comma_list $(mdts_nodes))
13593 changelog_register || error "first changelog_register failed"
13594 changelog_register || error "second changelog_register failed"
13596 declare -A cl_user1
13597 declare -A cl_user2
13602 # generate some changelog records to accumulate on each MDT
13603 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13604 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13605 error "create $DIR/$tdir/$tfile failed"
13607 # check changelogs have been generated
13608 local nbcl=$(changelog_dump | wc -l)
13609 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13611 for param in "changelog_max_idle_time=10" \
13613 "changelog_min_gc_interval=2"; do
13614 local MDT0=$(facet_svc $SINGLEMDS)
13615 local var="${param%=*}"
13616 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13618 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13619 do_nodes $mdts $LCTL set_param mdd.*.$param
13622 # force cl_user2 to be idle (1st part)
13625 for i in $(seq $MDSCOUNT); do
13626 cl_users=(${CL_USERS[mds$i]})
13627 cl_user1[mds$i]="${cl_users[0]}"
13628 cl_user2[mds$i]="${cl_users[1]}"
13630 [ -n "${cl_user1[mds$i]}" ] ||
13631 error "mds$i: no user registered"
13632 [ -n "${cl_user2[mds$i]}" ] ||
13633 error "mds$i: only ${cl_user2[mds$i]} is registered"
13635 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13636 [ -n "$user_rec1" ] ||
13637 error "mds$i: User ${cl_user1[mds$i]} not registered"
13638 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13639 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13640 [ -n "$user_rec2" ] ||
13641 error "mds$i: User ${cl_user1[mds$i]} not registered"
13642 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13643 "$user_rec1 + 2 == $user_rec2"
13644 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13645 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13646 "$user_rec1 + 2, but is $user_rec2"
13647 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13648 [ -n "$user_rec2" ] ||
13649 error "mds$i: User ${cl_user2[mds$i]} not registered"
13650 [ $user_rec1 == $user_rec2 ] ||
13651 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13652 "$user_rec1, but is $user_rec2"
13655 # force cl_user2 to be idle (2nd part) and to reach
13656 # changelog_max_idle_time
13659 # force each GC-thread start and block then
13660 # one per MDT/MDD, set fail_val accordingly
13661 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
13662 do_nodes $mdts $LCTL set_param fail_loc=0x1316
13664 # generate more changelogs to trigger fail_loc
13665 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13666 error "create $DIR/$tdir/${tfile}bis failed"
13668 # stop MDT to stop GC-thread, should be done in back-ground as it will
13669 # block waiting for the thread to be released and exit
13670 declare -A stop_pids
13671 for i in $(seq $MDSCOUNT); do
13673 stop_pids[mds$i]=$!
13676 for i in $(mdts_nodes); do
13679 local facets=$(facets_up_on_host $i)
13681 for facet in ${facets//,/ }; do
13682 if [[ $facet == mds* ]]; then
13686 # ensure each MDS's gc threads are still present and all in "R"
13687 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
13688 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
13689 error "$i: expected $nb GC-thread"
13691 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
13693 error "$i: GC-thread not found in R-state"
13694 # check umounts of each MDT on MDS have reached kthread_stop()
13695 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
13696 error "$i: expected $nb umount"
13698 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
13699 error "$i: umount not found in D-state"
13702 # release all GC-threads
13703 do_nodes $mdts $LCTL set_param fail_loc=0
13705 # wait for MDT stop to complete
13706 for i in $(seq $MDSCOUNT); do
13707 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
13711 # may try to check if any orphan changelog records are present
13712 # via ldiskfs/zfs and llog_reader...
13714 # re-start/mount MDTs
13715 for i in $(seq $MDSCOUNT); do
13716 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
13717 error "Fail to start mds$i"
13721 for i in $(seq $MDSCOUNT); do
13722 # check cl_user1 still registered
13723 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13724 error "mds$i: User ${cl_user1[mds$i]} not registered"
13725 # check cl_user2 unregistered
13726 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13727 error "mds$i: User ${cl_user2[mds$i]} still registered"
13729 # check changelogs are present and starting at $user_rec1 + 1
13730 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13731 [ -n "$user_rec1" ] ||
13732 error "mds$i: User ${cl_user1[mds$i]} not registered"
13733 first_rec=$($LFS changelog $(facet_svc mds$i) |
13734 awk '{ print $1; exit; }')
13736 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13737 [ $((user_rec1 + 1)) == $first_rec ] ||
13738 error "mds$i: first index should be $user_rec1 + 1, " \
13739 "but is $first_rec"
13742 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
13747 local mdts=$(comma_list $(mdts_nodes))
13749 changelog_register || error "first changelog_register failed"
13751 # generate some changelog records to accumulate on each MDT
13752 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13753 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13754 error "create $DIR/$tdir/$tfile failed"
13756 # check changelogs have been generated
13757 local nbcl=$(changelog_dump | wc -l)
13758 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13760 # simulate race between register and unregister
13761 # XXX as fail_loc is set per-MDS, with DNE configs the race
13762 # simulation will only occur for one MDT per MDS and for the
13763 # others the normal race scenario will take place
13764 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
13765 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
13766 do_nodes $mdts $LCTL set_param fail_val=1
13768 # unregister 1st user
13769 changelog_deregister &
13771 # wait some time for deregister work to reach race rdv
13773 # register 2nd user
13774 changelog_register || error "2nd user register failed"
13776 wait $pid1 || error "1st user deregister failed"
13780 declare -A LAST_REC
13781 for i in $(seq $MDSCOUNT); do
13782 if changelog_users mds$i | grep "^cl"; then
13783 # make sure new records are added with one user present
13784 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
13785 awk '/^current.index:/ { print $NF }')
13787 error "mds$i has no user registered"
13791 # generate more changelog records to accumulate on each MDT
13792 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13793 error "create $DIR/$tdir/${tfile}bis failed"
13795 for i in $(seq $MDSCOUNT); do
13796 last_rec=$(changelog_users $SINGLEMDS |
13797 awk '/^current.index:/ { print $NF }')
13798 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
13799 [ $last_rec != ${LAST_REC[mds$i]} ] ||
13800 error "changelogs are off on mds$i"
13803 run_test 160i "changelog user register/unregister race"
13806 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13807 remote_mds_nodsh && skip "remote MDS with nodsh"
13809 mkdir -p $DIR/$tdir/1/1
13811 changelog_register || error "changelog_register failed"
13812 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13814 changelog_users $SINGLEMDS | grep -q $cl_user ||
13815 error "User '$cl_user' not found in changelog_users"
13816 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
13817 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
13818 rmdir $DIR/$tdir/1/1 & sleep 1
13820 touch $DIR/$tdir/2/2
13821 rm -rf $DIR/$tdir/2
13826 changelog_dump | grep rmdir || error "rmdir not recorded"
13829 changelog_deregister
13831 run_test 160k "Verify that changelog records are not lost"
13834 remote_mds_nodsh && skip "remote MDS with nodsh"
13835 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
13836 skip "Need MDS version at least 2.12.56"
13838 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
13840 changelog_register || error "first changelog_register failed"
13842 # generate some changelog
13843 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13844 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13845 error "create $DIR/$tdir/${tfile}bis failed"
13847 # open the changelog device
13848 exec 3>/dev/changelog-$FSNAME-MDT0000
13849 exec 4</dev/changelog-$FSNAME-MDT0000
13851 # umount the first lustre mount
13855 cat <&4 >/dev/null || error "read changelog failed"
13858 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13859 changelog_users $SINGLEMDS | grep -q $cl_user ||
13860 error "User $cl_user not found in changelog_users"
13862 printf 'clear:'$cl_user':0' >&3
13869 changelog_deregister || error "changelog_deregister failed"
13872 mount_client $MOUNT || error "mount_client on $MOUNT failed"
13874 run_test 160j "client can be umounted while its chanangelog is being used"
13877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13879 test_mkdir -c1 $DIR/$tdir
13880 cp /etc/hosts $DIR/$tdir/$tfile
13881 test_mkdir -c1 $DIR/$tdir/foo1
13882 test_mkdir -c1 $DIR/$tdir/foo2
13883 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
13884 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
13885 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
13886 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
13887 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
13888 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13889 $LFS fid2path $DIR $FID
13890 error "bad link ea"
13893 rm $DIR/$tdir/foo2/zachary
13895 rm $DIR/$tdir/foo2/thor
13897 rm $DIR/$tdir/$tfile
13899 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
13900 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
13901 { $LFS fid2path $DIR $FID; error "bad link rename"; }
13902 rm $DIR/$tdir/foo2/maggie
13905 local longname=$tfile.avg_len_is_thirty_two_
13906 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
13907 error_noexit 'failed to unlink many hardlinks'" EXIT
13908 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
13909 error "failed to hardlink many files"
13910 links=$($LFS fid2path $DIR $FID | wc -l)
13911 echo -n "${links}/1000 links in link EA"
13912 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
13914 run_test 161a "link ea sanity"
13917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13918 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
13921 local remote_dir=$DIR/$tdir/remote_dir
13923 mkdir -p $DIR/$tdir
13924 $LFS mkdir -i $MDTIDX $remote_dir ||
13925 error "create remote directory failed"
13927 cp /etc/hosts $remote_dir/$tfile
13928 mkdir -p $remote_dir/foo1
13929 mkdir -p $remote_dir/foo2
13930 ln $remote_dir/$tfile $remote_dir/foo1/sofia
13931 ln $remote_dir/$tfile $remote_dir/foo2/zachary
13932 ln $remote_dir/$tfile $remote_dir/foo1/luna
13933 ln $remote_dir/$tfile $remote_dir/foo2/thor
13935 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
13937 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13938 $LFS fid2path $DIR $FID
13939 error "bad link ea"
13942 rm $remote_dir/foo2/zachary
13944 rm $remote_dir/foo2/thor
13946 rm $remote_dir/$tfile
13948 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
13949 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
13950 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
13951 $LFS fid2path $DIR $FID
13952 error "bad link rename"
13954 rm $remote_dir/foo2/maggie
13957 local longname=filename_avg_len_is_thirty_two_
13958 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
13959 error "failed to hardlink many files"
13960 links=$($LFS fid2path $DIR $FID | wc -l)
13961 echo -n "${links}/1000 links in link EA"
13962 [[ ${links} -gt 60 ]] ||
13963 error "expected at least 60 links in link EA"
13964 unlinkmany $remote_dir/foo2/$longname 1000 ||
13965 error "failed to unlink many hardlinks"
13967 run_test 161b "link ea sanity under remote directory"
13970 remote_mds_nodsh && skip "remote MDS with nodsh"
13971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13972 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
13973 skip "Need MDS version at least 2.1.5"
13975 # define CLF_RENAME_LAST 0x0001
13976 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
13977 changelog_register || error "changelog_register failed"
13980 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
13981 touch $DIR/$tdir/foo_161c
13982 touch $DIR/$tdir/bar_161c
13983 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13984 changelog_dump | grep RENME | tail -n 5
13985 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13986 changelog_clear 0 || error "changelog_clear failed"
13987 if [ x$flags != "x0x1" ]; then
13988 error "flag $flags is not 0x1"
13991 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
13992 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
13993 touch $DIR/$tdir/foo_161c
13994 touch $DIR/$tdir/bar_161c
13995 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13996 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13997 changelog_dump | grep RENME | tail -n 5
13998 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13999 changelog_clear 0 || error "changelog_clear failed"
14000 if [ x$flags != "x0x0" ]; then
14001 error "flag $flags is not 0x0"
14003 echo "rename overwrite a target having nlink > 1," \
14004 "changelog record has flags of $flags"
14006 # rename doesn't overwrite a target (changelog flag 0x0)
14007 touch $DIR/$tdir/foo_161c
14008 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
14009 changelog_dump | grep RENME | tail -n 5
14010 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
14011 changelog_clear 0 || error "changelog_clear failed"
14012 if [ x$flags != "x0x0" ]; then
14013 error "flag $flags is not 0x0"
14015 echo "rename doesn't overwrite a target," \
14016 "changelog record has flags of $flags"
14018 # define CLF_UNLINK_LAST 0x0001
14019 # unlink a file having nlink = 1 (changelog flag 0x1)
14020 rm -f $DIR/$tdir/foo2_161c
14021 changelog_dump | grep UNLNK | tail -n 5
14022 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14023 changelog_clear 0 || error "changelog_clear failed"
14024 if [ x$flags != "x0x1" ]; then
14025 error "flag $flags is not 0x1"
14027 echo "unlink a file having nlink = 1," \
14028 "changelog record has flags of $flags"
14030 # unlink a file having nlink > 1 (changelog flag 0x0)
14031 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14032 rm -f $DIR/$tdir/foobar_161c
14033 changelog_dump | grep UNLNK | tail -n 5
14034 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14035 changelog_clear 0 || error "changelog_clear failed"
14036 if [ x$flags != "x0x0" ]; then
14037 error "flag $flags is not 0x0"
14039 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
14041 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
14044 remote_mds_nodsh && skip "remote MDS with nodsh"
14049 changelog_register || error "changelog_register failed"
14051 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
14052 # interfer with $MOUNT/.lustre/fid/ access
14054 [[ $? -eq 0 ]] || error "mkdir failed"
14056 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
14057 $LCTL set_param fail_loc=0x8000140c
14059 $LCTL set_param fail_val=5
14062 echo foofoo > $DIR/$tdir/$tfile &
14065 # wait for create to be delayed
14069 [[ $? -eq 0 ]] || error "create should be blocked"
14071 local tempfile=$(mktemp)
14072 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
14073 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
14074 # some delay may occur during ChangeLog publishing and file read just
14075 # above, that could allow file write to happen finally
14076 [[ -s $tempfile ]] && echo "file should be empty"
14078 $LCTL set_param fail_loc=0
14081 [[ $? -eq 0 ]] || error "create failed"
14083 run_test 161d "create with concurrent .lustre/fid access"
14086 local expected="$1"
14091 path=$($LFS fid2path "$@")
14094 if [ $rc -ne 0 ]; then
14095 error "path looked up of '$expected' failed: rc=$rc"
14096 elif [ "$path" != "$expected" ]; then
14097 error "path looked up '$path' instead of '$expected'"
14099 echo "FID '$fid' resolves to path '$path' as expected"
14103 test_162a() { # was test_162
14104 test_mkdir -p -c1 $DIR/$tdir/d2
14105 touch $DIR/$tdir/d2/$tfile
14106 touch $DIR/$tdir/d2/x1
14107 touch $DIR/$tdir/d2/x2
14108 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
14109 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
14111 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
14112 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
14115 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
14116 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
14117 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
14119 # softlink to wrong file
14120 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
14121 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
14122 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
14125 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
14126 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
14127 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
14128 # fid2path dir/fsname should both work
14129 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
14130 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
14132 # hardlink count: check that there are 2 links
14133 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
14134 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
14136 # hardlink indexing: remove the first link
14137 rm $DIR/$tdir/d2/p/q/r/hlink
14138 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
14140 run_test 162a "path lookup sanity"
14143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14144 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14147 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
14148 error "create striped dir failed"
14150 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
14151 tail -n 1 | awk '{print $2}')
14152 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
14154 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
14155 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
14158 for ((i=0;i<5;i++)); do
14159 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
14160 error "get fid for f$i failed"
14161 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
14163 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
14164 error "get fid for d$i failed"
14165 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
14170 run_test 162b "striped directory path lookup sanity"
14172 # LU-4239: Verify fid2path works with paths 100 or more directories deep
14174 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
14175 skip "Need MDS version at least 2.7.51"
14177 local lpath=$tdir.local
14178 local rpath=$tdir.remote
14180 test_mkdir $DIR/$lpath
14181 test_mkdir $DIR/$rpath
14183 for ((i = 0; i <= 101; i++)); do
14186 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
14187 error "get fid for local directory $DIR/$lpath failed"
14188 check_path "$DIR/$lpath" $MOUNT $FID --link 0
14191 test_mkdir $DIR/$rpath
14192 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
14193 error "get fid for remote directory $DIR/$rpath failed"
14194 check_path "$DIR/$rpath" $MOUNT $FID --link 0
14199 run_test 162c "fid2path works with paths 100 or more directories deep"
14202 # do directio so as not to populate the page cache
14203 log "creating a 10 Mb file"
14204 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14205 log "starting reads"
14206 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14207 log "truncating the file"
14208 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14210 kill %+ || true # reads might have finished
14211 echo "wait until dd is finished"
14213 log "removing the temporary file"
14214 rm -rf $DIR/$tfile || error "tmp file removal failed"
14216 run_test 169 "parallel read and truncate should not deadlock"
14219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14221 $LCTL clear # bug 18514
14222 $LCTL debug_daemon start $TMP/${tfile}_log_good
14224 $LCTL debug_daemon stop
14225 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
14226 error "sed failed to read log_good"
14228 $LCTL debug_daemon start $TMP/${tfile}_log_good
14230 $LCTL debug_daemon stop
14232 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
14233 error "lctl df log_bad failed"
14235 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14236 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14238 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
14239 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
14241 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
14242 error "bad_line good_line1 good_line2 are empty"
14244 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14245 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
14246 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14248 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
14249 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14250 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14252 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
14253 error "bad_line_new good_line_new are empty"
14255 local expected_good=$((good_line1 + good_line2*2))
14257 rm -f $TMP/${tfile}*
14258 # LU-231, short malformed line may not be counted into bad lines
14259 if [ $bad_line -ne $bad_line_new ] &&
14260 [ $bad_line -ne $((bad_line_new - 1)) ]; then
14261 error "expected $bad_line bad lines, but got $bad_line_new"
14265 if [ $expected_good -ne $good_line_new ]; then
14266 error "expected $expected_good good lines, but got $good_line_new"
14271 run_test 170 "test lctl df to handle corrupted log ====================="
14273 test_171() { # bug20592
14274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14276 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
14277 $LCTL set_param fail_loc=0x50e
14278 $LCTL set_param fail_val=3000
14279 multiop_bg_pause $DIR/$tfile O_s || true
14281 kill -USR1 $MULTIPID
14285 if dmesg | grep "recursive fault"; then
14286 error "caught a recursive fault"
14288 $LCTL set_param fail_loc=0
14291 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
14293 # it would be good to share it with obdfilter-survey/iokit-libecho code
14294 setup_obdecho_osc () {
14297 local obdfilter_name=$2
14298 echo "Creating new osc for $obdfilter_name on $ost_nid"
14299 # make sure we can find loopback nid
14300 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
14302 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
14303 ${obdfilter_name}_osc_UUID || rc=2; }
14304 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
14305 ${obdfilter_name}_UUID $ost_nid || rc=3; }
14309 cleanup_obdecho_osc () {
14310 local obdfilter_name=$1
14311 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
14312 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
14319 local pages=${3:-64}
14324 local obd_size=$(get_obd_size $node $OBD)
14325 local page_size=$(get_page_size $node)
14326 if [[ -n "$obd_size" ]]; then
14327 local new_count=$((obd_size / (pages * page_size / 1024)))
14328 [[ $new_count -ge $count ]] || count=$new_count
14331 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
14332 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
14334 if [ $rc -eq 0 ]; then
14335 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
14336 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
14338 echo "New object id is $id"
14339 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
14341 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
14342 "test_brw $count w v $pages $id" || rc=4; }
14343 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
14345 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
14346 "cleanup" || rc=5; }
14347 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
14348 "detach" || rc=6; }
14349 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
14354 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14356 if ! module_loaded obdecho; then
14357 load_module obdecho/obdecho &&
14358 stack_trap "rmmod obdecho" EXIT ||
14359 error "unable to load obdecho on client"
14362 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
14363 local host=$($LCTL get_param -n osc.$osc.import |
14364 awk '/current_connection:/ { print $2 }' )
14365 local target=$($LCTL get_param -n osc.$osc.import |
14366 awk '/target:/ { print $2 }' )
14367 target=${target%_UUID}
14369 if [ -n "$target" ]; then
14370 setup_obdecho_osc $host $target &&
14371 stack_trap "cleanup_obdecho_osc $target" EXIT ||
14372 { error "obdecho setup failed with $?"; return; }
14374 obdecho_test ${target}_osc client ||
14375 error "obdecho_test failed on ${target}_osc"
14377 $LCTL get_param osc.$osc.import
14378 error "there is no osc.$osc.import target"
14381 run_test 180a "test obdecho on osc"
14384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14385 remote_ost_nodsh && skip "remote OST with nodsh"
14387 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14388 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14389 error "failed to load module obdecho"
14391 local target=$(do_facet ost1 $LCTL dl |
14392 awk '/obdfilter/ { print $4; exit; }')
14394 if [ -n "$target" ]; then
14395 obdecho_test $target ost1 || error "obdecho_test failed with $?"
14397 do_facet ost1 $LCTL dl
14398 error "there is no obdfilter target on ost1"
14401 run_test 180b "test obdecho directly on obdfilter"
14403 test_180c() { # LU-2598
14404 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14405 remote_ost_nodsh && skip "remote OST with nodsh"
14406 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
14407 skip "Need MDS version at least 2.4.0"
14409 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14410 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14411 error "failed to load module obdecho"
14413 local target=$(do_facet ost1 $LCTL dl |
14414 awk '/obdfilter/ { print $4; exit; }')
14416 if [ -n "$target" ]; then
14417 local pages=16384 # 64MB bulk I/O RPC size
14419 obdecho_test "$target" ost1 "$pages" ||
14420 error "obdecho_test with pages=$pages failed with $?"
14422 do_facet ost1 $LCTL dl
14423 error "there is no obdfilter target on ost1"
14426 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
14428 test_181() { # bug 22177
14429 test_mkdir $DIR/$tdir
14430 # create enough files to index the directory
14431 createmany -o $DIR/$tdir/foobar 4000
14432 # print attributes for debug purpose
14435 multiop_bg_pause $DIR/$tdir D_Sc || return 1
14437 # remove the files & current working dir
14438 unlinkmany $DIR/$tdir/foobar 4000
14440 kill -USR1 $MULTIPID
14442 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
14445 run_test 181 "Test open-unlinked dir ========================"
14451 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14453 $LCTL set_param mdc.*.rpc_stats=clear
14455 for (( i = 0; i < $tcount; i++ )) ; do
14456 mkdir $DIR/$tdir/$i
14459 for (( i = 0; i < $tcount; i++ )) ; do
14460 createmany -o $DIR/$tdir/$i/f- $fcount &
14464 for (( i = 0; i < $tcount; i++ )) ; do
14465 unlinkmany $DIR/$tdir/$i/f- $fcount &
14469 $LCTL get_param mdc.*.rpc_stats
14473 run_test 182 "Test parallel modify metadata operations ================"
14475 test_183() { # LU-2275
14476 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14477 remote_mds_nodsh && skip "remote MDS with nodsh"
14478 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
14479 skip "Need MDS version at least 2.3.56"
14481 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14482 echo aaa > $DIR/$tdir/$tfile
14484 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
14485 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
14487 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
14488 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
14490 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14492 # Flush negative dentry cache
14493 touch $DIR/$tdir/$tfile
14495 # We are not checking for any leaked references here, they'll
14496 # become evident next time we do cleanup with module unload.
14499 run_test 183 "No crash or request leak in case of strange dispositions ========"
14501 # test suite 184 is for LU-2016, LU-2017
14503 check_swap_layouts_support
14505 dir0=$DIR/$tdir/$testnum
14506 test_mkdir -p -c1 $dir0
14511 $SETSTRIPE -c1 $file1
14513 $SETSTRIPE -c2 $file2
14515 gen1=$($GETSTRIPE -g $file1)
14516 gen2=$($GETSTRIPE -g $file2)
14518 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
14519 gen=$($GETSTRIPE -g $file1)
14520 [[ $gen1 != $gen ]] ||
14521 "Layout generation on $file1 does not change"
14522 gen=$($GETSTRIPE -g $file2)
14523 [[ $gen2 != $gen ]] ||
14524 "Layout generation on $file2 does not change"
14526 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
14527 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14529 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
14531 run_test 184a "Basic layout swap"
14534 check_swap_layouts_support
14536 dir0=$DIR/$tdir/$testnum
14537 mkdir -p $dir0 || error "creating dir $dir0"
14544 $SETSTRIPE -c1 $file1
14545 $SETSTRIPE -c2 $file2
14546 $SETSTRIPE -c1 $file3
14547 chown $RUNAS_ID $file3
14548 gen1=$($GETSTRIPE -g $file1)
14549 gen2=$($GETSTRIPE -g $file2)
14551 $LFS swap_layouts $dir1 $dir2 &&
14552 error "swap of directories layouts should fail"
14553 $LFS swap_layouts $dir1 $file1 &&
14554 error "swap of directory and file layouts should fail"
14555 $RUNAS $LFS swap_layouts $file1 $file2 &&
14556 error "swap of file we cannot write should fail"
14557 $LFS swap_layouts $file1 $file3 &&
14558 error "swap of file with different owner should fail"
14559 /bin/true # to clear error code
14561 run_test 184b "Forbidden layout swap (will generate errors)"
14564 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
14565 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
14566 check_swap_layouts_support
14568 local dir0=$DIR/$tdir/$testnum
14569 mkdir -p $dir0 || error "creating dir $dir0"
14571 local ref1=$dir0/ref1
14572 local ref2=$dir0/ref2
14573 local file1=$dir0/file1
14574 local file2=$dir0/file2
14575 # create a file large enough for the concurrent test
14576 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
14577 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
14578 echo "ref file size: ref1($(stat -c %s $ref1))," \
14579 "ref2($(stat -c %s $ref2))"
14582 dd if=$ref1 of=$file1 bs=16k &
14585 # Make sure dd starts to copy file
14586 while [ ! -f $file1 ]; do sleep 0.1; done
14588 $LFS swap_layouts $file1 $file2
14591 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
14592 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
14594 # how many bytes copied before swapping layout
14595 local copied=$(stat -c %s $file2)
14596 local remaining=$(stat -c %s $ref1)
14597 remaining=$((remaining - copied))
14598 echo "Copied $copied bytes before swapping layout..."
14600 cmp -n $copied $file1 $ref2 | grep differ &&
14601 error "Content mismatch [0, $copied) of ref2 and file1"
14602 cmp -n $copied $file2 $ref1 ||
14603 error "Content mismatch [0, $copied) of ref1 and file2"
14604 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
14605 error "Content mismatch [$copied, EOF) of ref1 and file1"
14608 rm -f $ref1 $ref2 $file1 $file2
14610 run_test 184c "Concurrent write and layout swap"
14613 check_swap_layouts_support
14614 [ -z "$(which getfattr 2>/dev/null)" ] &&
14615 skip_env "no getfattr command"
14617 local file1=$DIR/$tdir/$tfile-1
14618 local file2=$DIR/$tdir/$tfile-2
14619 local file3=$DIR/$tdir/$tfile-3
14623 mkdir -p $DIR/$tdir
14624 touch $file1 || error "create $file1 failed"
14625 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14626 error "create $file2 failed"
14627 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14628 error "create $file3 failed"
14629 lovea1=$(get_layout_param $file1)
14631 $LFS swap_layouts $file2 $file3 ||
14632 error "swap $file2 $file3 layouts failed"
14633 $LFS swap_layouts $file1 $file2 ||
14634 error "swap $file1 $file2 layouts failed"
14636 lovea2=$(get_layout_param $file2)
14639 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
14641 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14642 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
14644 run_test 184d "allow stripeless layouts swap"
14647 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
14648 skip "Need MDS version at least 2.6.94"
14649 check_swap_layouts_support
14650 [ -z "$(which getfattr 2>/dev/null)" ] &&
14651 skip_env "no getfattr command"
14653 local file1=$DIR/$tdir/$tfile-1
14654 local file2=$DIR/$tdir/$tfile-2
14655 local file3=$DIR/$tdir/$tfile-3
14658 mkdir -p $DIR/$tdir
14659 touch $file1 || error "create $file1 failed"
14660 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14661 error "create $file2 failed"
14662 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14663 error "create $file3 failed"
14665 $LFS swap_layouts $file1 $file2 ||
14666 error "swap $file1 $file2 layouts failed"
14668 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14669 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
14671 echo 123 > $file1 || error "Should be able to write into $file1"
14673 $LFS swap_layouts $file1 $file3 ||
14674 error "swap $file1 $file3 layouts failed"
14676 echo 123 > $file1 || error "Should be able to write into $file1"
14678 rm -rf $file1 $file2 $file3
14680 run_test 184e "Recreate layout after stripeless layout swaps"
14683 # Create a file with name longer than sizeof(struct stat) ==
14684 # 144 to see if we can get chars from the file name to appear
14685 # in the returned striping. Note that 'f' == 0x66.
14686 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
14688 mkdir -p $DIR/$tdir
14689 mcreate $DIR/$tdir/$file
14690 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
14691 error "IOC_MDC_GETFILEINFO returned garbage striping"
14694 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
14696 test_185() { # LU-2441
14697 # LU-3553 - no volatile file support in old servers
14698 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
14699 skip "Need MDS version at least 2.3.60"
14701 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14702 touch $DIR/$tdir/spoo
14703 local mtime1=$(stat -c "%Y" $DIR/$tdir)
14704 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
14705 error "cannot create/write a volatile file"
14706 [ "$FILESET" == "" ] &&
14707 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
14708 error "FID is still valid after close"
14710 multiop_bg_pause $DIR/$tdir vVw4096_c
14717 # assume that the next FID for this client is sequential, since stdout
14718 # is unfortunately eaten by multiop_bg_pause
14719 local n=$((${fidv[1]} + 1))
14720 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
14721 if [ "$FILESET" == "" ]; then
14722 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
14723 error "FID is missing before close"
14725 kill -USR1 $multi_pid
14726 # 1 second delay, so if mtime change we will see it
14728 local mtime2=$(stat -c "%Y" $DIR/$tdir)
14729 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
14731 run_test 185 "Volatile file support"
14733 function create_check_volatile() {
14737 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
14740 local FID=$(cat /tmp/${tfile}.fid)
14741 [ "$FID" == "" ] && error "can't get FID for volatile"
14742 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
14743 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
14744 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
14748 cancel_lru_locks mdc # flush opencache
14749 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
14754 # LU-12516 - volatile creation via .lustre
14755 [[ $MDS1_VERSION -ge $(version_code 2.12.2) ]] ||
14756 skip "Need MDS version at least 2.12.2"
14758 create_check_volatile 0
14759 [ $MDSCOUNT -lt 2 ] && return 0
14762 create_check_volatile 1
14766 run_test 185a "Volatile file creation in .lustre/fid/"
14769 remote_mds_nodsh && skip "remote MDS with nodsh"
14770 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14771 skip "Need MDS version at least 2.3.0"
14773 local dir0=$DIR/$tdir/$testnum
14774 mkdir -p $dir0 || error "creating dir $dir0"
14776 local file=$dir0/file1
14777 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
14778 local dv1=$($LFS data_version $file)
14779 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
14780 local dv2=$($LFS data_version $file)
14781 [[ $dv1 != $dv2 ]] ||
14782 error "data version did not change on write $dv1 == $dv2"
14787 run_test 187a "Test data version change"
14790 remote_mds_nodsh && skip "remote MDS with nodsh"
14791 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14792 skip "Need MDS version at least 2.3.0"
14794 local dir0=$DIR/$tdir/$testnum
14795 mkdir -p $dir0 || error "creating dir $dir0"
14797 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
14798 [[ ${DV[0]} != ${DV[1]} ]] ||
14799 error "data version did not change on write"\
14800 " ${DV[0]} == ${DV[1]}"
14805 run_test 187b "Test data version change on volatile file"
14808 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14809 remote_mgs_nodsh && skip "remote MGS with nodsh"
14810 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14812 local POOL=${POOL:-cea1}
14813 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
14814 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
14817 local last_ost=$(($OSTCOUNT - 1))
14819 local ost_list=$(seq $first_ost $ost_step $last_ost)
14820 local ost_range="$first_ost $last_ost $ost_step"
14821 local test_path=$POOL_ROOT/$POOL_DIR_NAME
14822 local file_dir=$POOL_ROOT/file_tst
14823 local subdir=$test_path/subdir
14827 # former test_200a test_200b
14828 pool_add $POOL || { rc=$? ; break; }
14829 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
14830 # former test_200c test_200d
14831 mkdir -p $test_path
14832 pool_set_dir $POOL $test_path || { rc=$? ; break; }
14833 pool_check_dir $POOL $test_path || { rc=$? ; break; }
14835 pool_check_dir $POOL $subdir || { rc=$? ; break; }
14836 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
14837 || { rc=$? ; break; }
14838 # former test_200e test_200f
14839 local files=$((OSTCOUNT*3))
14840 pool_alloc_files $POOL $test_path $files "$ost_list" \
14841 || { rc=$? ; break; }
14842 pool_create_files $POOL $file_dir $files "$ost_list" \
14843 || { rc=$? ; break; }
14844 # former test_200g test_200h
14845 pool_lfs_df $POOL || { rc=$? ; break; }
14846 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
14848 # former test_201a test_201b test_201c
14849 pool_remove_first_target $POOL || { rc=$? ; break; }
14851 local f=$test_path/$tfile
14852 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
14853 pool_remove $POOL $f || { rc=$? ; break; }
14861 run_test 200 "OST pools"
14863 # usage: default_attr <count | size | offset>
14865 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
14868 # usage: check_default_stripe_attr
14869 check_default_stripe_attr() {
14870 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
14873 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
14875 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
14879 error "unknown getstripe attr '$1'"
14882 [ $ACTUAL == $EXPECTED ] ||
14883 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
14887 test_mkdir $DIR/$tdir
14888 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
14890 check_default_stripe_attr --stripe-count
14891 check_default_stripe_attr --stripe-size
14892 check_default_stripe_attr --stripe-index
14894 run_test 204a "Print default stripe attributes"
14897 test_mkdir $DIR/$tdir
14898 $SETSTRIPE --stripe-count 1 $DIR/$tdir
14900 check_default_stripe_attr --stripe-size
14901 check_default_stripe_attr --stripe-index
14903 run_test 204b "Print default stripe size and offset"
14906 test_mkdir $DIR/$tdir
14907 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
14909 check_default_stripe_attr --stripe-count
14910 check_default_stripe_attr --stripe-index
14912 run_test 204c "Print default stripe count and offset"
14915 test_mkdir $DIR/$tdir
14916 $SETSTRIPE --stripe-index 0 $DIR/$tdir
14918 check_default_stripe_attr --stripe-count
14919 check_default_stripe_attr --stripe-size
14921 run_test 204d "Print default stripe count and size"
14924 test_mkdir $DIR/$tdir
14925 $SETSTRIPE -d $DIR/$tdir
14927 check_default_stripe_attr --stripe-count --raw
14928 check_default_stripe_attr --stripe-size --raw
14929 check_default_stripe_attr --stripe-index --raw
14931 run_test 204e "Print raw stripe attributes"
14934 test_mkdir $DIR/$tdir
14935 $SETSTRIPE --stripe-count 1 $DIR/$tdir
14937 check_default_stripe_attr --stripe-size --raw
14938 check_default_stripe_attr --stripe-index --raw
14940 run_test 204f "Print raw stripe size and offset"
14943 test_mkdir $DIR/$tdir
14944 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
14946 check_default_stripe_attr --stripe-count --raw
14947 check_default_stripe_attr --stripe-index --raw
14949 run_test 204g "Print raw stripe count and offset"
14952 test_mkdir $DIR/$tdir
14953 $SETSTRIPE --stripe-index 0 $DIR/$tdir
14955 check_default_stripe_attr --stripe-count --raw
14956 check_default_stripe_attr --stripe-size --raw
14958 run_test 204h "Print raw stripe count and size"
14960 # Figure out which job scheduler is being used, if any,
14961 # or use a fake one
14962 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
14963 JOBENV=SLURM_JOB_ID
14964 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
14966 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
14968 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
14969 JOBENV=LOADL_STEP_ID
14970 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
14973 $LCTL list_param jobid_name > /dev/null 2>&1
14974 if [ $? -eq 0 ]; then
14980 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
14982 verify_jobstats() {
14987 # we don't really need to clear the stats for this test to work, since each
14988 # command has a unique jobid, but it makes debugging easier if needed.
14989 # for facet in $facets; do
14990 # local dev=$(convert_facet2label $facet)
14991 # # clear old jobstats
14992 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
14995 # use a new JobID for each test, or we might see an old one
14996 [ "$JOBENV" = "FAKE_JOBID" ] &&
14997 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
14999 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
15001 [ "$JOBENV" = "nodelocal" ] && {
15002 FAKE_JOBID=id.$testnum.%e.$RANDOM
15003 $LCTL set_param jobid_name=$FAKE_JOBID
15004 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
15007 log "Test: ${cmd[*]}"
15008 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
15010 if [ $JOBENV = "FAKE_JOBID" ]; then
15011 FAKE_JOBID=$JOBVAL ${cmd[*]}
15016 # all files are created on OST0000
15017 for facet in $facets; do
15018 local stats="*.$(convert_facet2label $facet).job_stats"
15020 # strip out libtool wrappers for in-tree executables
15021 if [ $(do_facet $facet lctl get_param $stats |
15022 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
15023 do_facet $facet lctl get_param $stats
15024 error "No jobstats for $JOBVAL found on $facet::$stats"
15030 local new_jobenv=$1
15032 set_persistent_param_and_check client "jobid_var" \
15033 "$FSNAME.sys.jobid_var" $new_jobenv
15036 test_205a() { # Job stats
15037 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15038 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
15039 skip "Need MDS version with at least 2.7.1"
15040 remote_mgs_nodsh && skip "remote MGS with nodsh"
15041 remote_mds_nodsh && skip "remote MDS with nodsh"
15042 remote_ost_nodsh && skip "remote OST with nodsh"
15043 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
15044 skip "Server doesn't support jobstats"
15045 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
15047 local old_jobenv=$($LCTL get_param -n jobid_var)
15048 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
15050 if [[ $PERM_CMD = *"set_param -P"* ]]; then
15051 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
15053 stack_trap "do_facet mgs $PERM_CMD \
15054 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
15058 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
15059 mdt.*.job_cleanup_interval | head -n 1)
15060 local new_interval=5
15061 do_facet $SINGLEMDS \
15062 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
15063 stack_trap "do_facet $SINGLEMDS \
15064 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
15065 local start=$SECONDS
15069 cmd="mkdir $DIR/$tdir"
15070 verify_jobstats "$cmd" "$SINGLEMDS"
15072 cmd="rmdir $DIR/$tdir"
15073 verify_jobstats "$cmd" "$SINGLEMDS"
15074 # mkdir on secondary MDT
15075 if [ $MDSCOUNT -gt 1 ]; then
15076 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
15077 verify_jobstats "$cmd" "mds2"
15080 cmd="mknod $DIR/$tfile c 1 3"
15081 verify_jobstats "$cmd" "$SINGLEMDS"
15083 cmd="rm -f $DIR/$tfile"
15084 verify_jobstats "$cmd" "$SINGLEMDS"
15085 # create all files on OST0000 so verify_jobstats can find OST stats
15087 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
15088 verify_jobstats "$cmd" "$SINGLEMDS"
15090 cmd="touch $DIR/$tfile"
15091 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15093 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
15094 verify_jobstats "$cmd" "ost1"
15096 cancel_lru_locks osc
15097 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
15098 verify_jobstats "$cmd" "ost1"
15100 cmd="$TRUNCATE $DIR/$tfile 0"
15101 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15103 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
15104 verify_jobstats "$cmd" "$SINGLEMDS"
15105 # jobstats expiry - sleep until old stats should be expired
15106 local left=$((new_interval + 5 - (SECONDS - start)))
15107 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
15108 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
15110 cmd="mkdir $DIR/$tdir.expire"
15111 verify_jobstats "$cmd" "$SINGLEMDS"
15112 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
15113 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
15115 # Ensure that jobid are present in changelog (if supported by MDS)
15116 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
15117 changelog_dump | tail -10
15118 jobids=$(changelog_dump | tail -9 | grep -c "j=")
15119 [ $jobids -eq 9 ] ||
15120 error "Wrong changelog jobid count $jobids != 9"
15124 jobstats_set $JOBENV
15126 changelog_dump | grep $tfile
15127 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
15128 [ $jobids -eq 0 ] ||
15129 error "Unexpected jobids when jobid_var=$JOBENV"
15132 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
15133 JOBENV="JOBCOMPLEX"
15134 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
15136 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
15138 run_test 205a "Verify job stats"
15142 $LCTL set_param jobid_var=USER jobid_name="%e.%u"
15143 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
15144 do_facet $SINGLEMDS $LCTL get_param mdt.*.job_stats |
15145 grep job_id: | grep foolish &&
15146 error "Unexpected jobid found"
15149 run_test 205b "Verify job stats jobid parsing"
15151 # LU-1480, LU-1773 and LU-1657
15153 mkdir -p $DIR/$tdir
15154 $SETSTRIPE -c -1 $DIR/$tdir
15155 #define OBD_FAIL_LOV_INIT 0x1403
15156 $LCTL set_param fail_loc=0xa0001403
15157 $LCTL set_param fail_val=1
15158 touch $DIR/$tdir/$tfile || true
15160 run_test 206 "fail lov_init_raid0() doesn't lbug"
15163 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15164 local fsz=`stat -c %s $DIR/$tfile`
15165 cancel_lru_locks mdc
15167 # do not return layout in getattr intent
15168 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
15169 $LCTL set_param fail_loc=0x170
15170 local sz=`stat -c %s $DIR/$tfile`
15172 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
15176 run_test 207a "can refresh layout at glimpse"
15179 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15180 local cksum=`md5sum $DIR/$tfile`
15181 local fsz=`stat -c %s $DIR/$tfile`
15182 cancel_lru_locks mdc
15183 cancel_lru_locks osc
15185 # do not return layout in getattr intent
15186 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
15187 $LCTL set_param fail_loc=0x171
15189 # it will refresh layout after the file is opened but before read issues
15190 echo checksum is "$cksum"
15191 echo "$cksum" |md5sum -c --quiet || error "file differs"
15195 run_test 207b "can refresh layout at open"
15198 # FIXME: in this test suite, only RD lease is used. This is okay
15199 # for now as only exclusive open is supported. After generic lease
15200 # is done, this test suite should be revised. - Jinshan
15202 remote_mds_nodsh && skip "remote MDS with nodsh"
15203 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
15204 skip "Need MDS version at least 2.4.52"
15206 echo "==== test 1: verify get lease work"
15207 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
15209 echo "==== test 2: verify lease can be broken by upcoming open"
15210 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15214 $MULTIOP $DIR/$tfile oO_RDONLY:c
15215 kill -USR1 $PID && wait $PID || error "break lease error"
15217 echo "==== test 3: verify lease can't be granted if an open already exists"
15218 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
15222 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
15223 kill -USR1 $PID && wait $PID || error "open file error"
15225 echo "==== test 4: lease can sustain over recovery"
15226 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
15232 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
15234 echo "==== test 5: lease broken can't be regained by replay"
15235 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15239 # open file to break lease and then recovery
15240 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
15243 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
15247 run_test 208 "Exclusive open"
15250 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
15251 skip_env "must have disp_stripe"
15254 sync; sleep 5; sync;
15256 echo 3 > /proc/sys/vm/drop_caches
15257 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15259 # open/close 500 times
15260 for i in $(seq 500); do
15264 echo 3 > /proc/sys/vm/drop_caches
15265 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15267 echo "before: $req_before, after: $req_after"
15268 [ $((req_after - req_before)) -ge 300 ] &&
15269 error "open/close requests are not freed"
15272 run_test 209 "read-only open/close requests should be freed promptly"
15276 size=$((size % 8192 + 1))
15277 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
15278 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
15279 rm -f $DIR/f212 $DIR/f212.xyz
15281 run_test 212 "Sendfile test ============================================"
15284 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
15285 cancel_lru_locks osc
15286 lctl set_param fail_loc=0x8000040f
15287 # generate a read lock
15288 cat $DIR/$tfile > /dev/null
15289 # write to the file, it will try to cancel the above read lock.
15290 cat /etc/hosts >> $DIR/$tfile
15292 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
15294 test_214() { # for bug 20133
15295 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
15296 for (( i=0; i < 340; i++ )) ; do
15297 touch $DIR/$tdir/d214c/a$i
15300 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
15301 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
15302 ls $DIR/d214c || error "ls $DIR/d214c failed"
15303 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
15304 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
15306 run_test 214 "hash-indexed directory test - bug 20133"
15308 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
15309 create_lnet_proc_files() {
15310 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
15313 # counterpart of create_lnet_proc_files
15314 remove_lnet_proc_files() {
15315 rm -f $TMP/lnet_$1.sys
15318 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15319 # 3rd arg as regexp for body
15320 check_lnet_proc_stats() {
15321 local l=$(cat "$TMP/lnet_$1" |wc -l)
15322 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
15324 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
15327 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15328 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
15329 # optional and can be regexp for 2nd line (lnet.routes case)
15330 check_lnet_proc_entry() {
15331 local blp=2 # blp stands for 'position of 1st line of body'
15332 [ -z "$5" ] || blp=3 # lnet.routes case
15334 local l=$(cat "$TMP/lnet_$1" |wc -l)
15335 # subtracting one from $blp because the body can be empty
15336 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
15338 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
15339 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
15341 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
15342 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
15344 # bail out if any unexpected line happened
15345 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
15346 [ "$?" != 0 ] || error "$2 misformatted"
15349 test_215() { # for bugs 18102, 21079, 21517
15350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15352 local N='(0|[1-9][0-9]*)' # non-negative numeric
15353 local P='[1-9][0-9]*' # positive numeric
15354 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
15355 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
15356 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
15357 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
15359 local L1 # regexp for 1st line
15360 local L2 # regexp for 2nd line (optional)
15361 local BR # regexp for the rest (body)
15363 # lnet.stats should look as 11 space-separated non-negative numerics
15364 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
15365 create_lnet_proc_files "stats"
15366 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
15367 remove_lnet_proc_files "stats"
15369 # lnet.routes should look like this:
15370 # Routing disabled/enabled
15371 # net hops priority state router
15372 # where net is a string like tcp0, hops > 0, priority >= 0,
15373 # state is up/down,
15374 # router is a string like 192.168.1.1@tcp2
15375 L1="^Routing (disabled|enabled)$"
15376 L2="^net +hops +priority +state +router$"
15377 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
15378 create_lnet_proc_files "routes"
15379 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
15380 remove_lnet_proc_files "routes"
15382 # lnet.routers should look like this:
15383 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
15384 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
15385 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
15386 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
15387 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
15388 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
15389 create_lnet_proc_files "routers"
15390 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
15391 remove_lnet_proc_files "routers"
15393 # lnet.peers should look like this:
15394 # nid refs state last max rtr min tx min queue
15395 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
15396 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
15397 # numeric (0 or >0 or <0), queue >= 0.
15398 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
15399 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
15400 create_lnet_proc_files "peers"
15401 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
15402 remove_lnet_proc_files "peers"
15404 # lnet.buffers should look like this:
15405 # pages count credits min
15406 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
15407 L1="^pages +count +credits +min$"
15408 BR="^ +$N +$N +$I +$I$"
15409 create_lnet_proc_files "buffers"
15410 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
15411 remove_lnet_proc_files "buffers"
15413 # lnet.nis should look like this:
15414 # nid status alive refs peer rtr max tx min
15415 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
15416 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
15417 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
15418 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
15419 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
15420 create_lnet_proc_files "nis"
15421 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
15422 remove_lnet_proc_files "nis"
15424 # can we successfully write to lnet.stats?
15425 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
15427 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
15429 test_216() { # bug 20317
15430 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15431 remote_ost_nodsh && skip "remote OST with nodsh"
15434 local facets=$(get_facets OST)
15435 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15437 save_lustre_params client "osc.*.contention_seconds" > $p
15438 save_lustre_params $facets \
15439 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
15440 save_lustre_params $facets \
15441 "ldlm.namespaces.filter-*.contended_locks" >> $p
15442 save_lustre_params $facets \
15443 "ldlm.namespaces.filter-*.contention_seconds" >> $p
15444 clear_stats osc.*.osc_stats
15446 # agressive lockless i/o settings
15447 do_nodes $(comma_list $(osts_nodes)) \
15448 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
15449 ldlm.namespaces.filter-*.contended_locks=0 \
15450 ldlm.namespaces.filter-*.contention_seconds=60"
15451 lctl set_param -n osc.*.contention_seconds=60
15453 $DIRECTIO write $DIR/$tfile 0 10 4096
15454 $CHECKSTAT -s 40960 $DIR/$tfile
15456 # disable lockless i/o
15457 do_nodes $(comma_list $(osts_nodes)) \
15458 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
15459 ldlm.namespaces.filter-*.contended_locks=32 \
15460 ldlm.namespaces.filter-*.contention_seconds=0"
15461 lctl set_param -n osc.*.contention_seconds=0
15462 clear_stats osc.*.osc_stats
15464 dd if=/dev/zero of=$DIR/$tfile count=0
15465 $CHECKSTAT -s 0 $DIR/$tfile
15467 restore_lustre_params <$p
15471 run_test 216 "check lockless direct write updates file size and kms correctly"
15473 test_217() { # bug 22430
15474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15479 for node in $(nodes_list); do
15480 nid=$(host_nids_address $node $NETTYPE)
15481 if [[ $nid = *-* ]] ; then
15482 echo "lctl ping $(h2nettype $nid)"
15483 lctl ping $(h2nettype $nid)
15485 echo "skipping $node (no hyphen detected)"
15489 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
15492 # do directio so as not to populate the page cache
15493 log "creating a 10 Mb file"
15494 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
15495 log "starting reads"
15496 dd if=$DIR/$tfile of=/dev/null bs=4096 &
15497 log "truncating the file"
15498 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
15500 kill %+ || true # reads might have finished
15501 echo "wait until dd is finished"
15503 log "removing the temporary file"
15504 rm -rf $DIR/$tfile || error "tmp file removal failed"
15506 run_test 218 "parallel read and truncate should not deadlock"
15509 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15511 # write one partial page
15512 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
15513 # set no grant so vvp_io_commit_write will do sync write
15514 $LCTL set_param fail_loc=0x411
15515 # write a full page at the end of file
15516 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
15518 $LCTL set_param fail_loc=0
15519 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
15520 $LCTL set_param fail_loc=0x411
15521 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
15524 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
15525 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
15527 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
15529 test_220() { #LU-325
15530 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15531 remote_ost_nodsh && skip "remote OST with nodsh"
15532 remote_mds_nodsh && skip "remote MDS with nodsh"
15533 remote_mgs_nodsh && skip "remote MGS with nodsh"
15537 # create on MDT0000 so the last_id and next_id are correct
15539 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
15543 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
15544 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
15545 osp.$mdtosc_proc1.prealloc_last_id)
15546 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
15547 osp.$mdtosc_proc1.prealloc_next_id)
15551 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
15552 #define OBD_FAIL_OST_ENOINO 0x229
15553 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
15554 create_pool $FSNAME.$TESTNAME || return 1
15555 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
15557 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
15559 MDSOBJS=$((last_id - next_id))
15560 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
15562 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
15563 echo "OST still has $count kbytes free"
15565 echo "create $MDSOBJS files @next_id..."
15566 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
15568 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15569 osp.$mdtosc_proc1.prealloc_last_id)
15570 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15571 osp.$mdtosc_proc1.prealloc_next_id)
15573 echo "after creation, last_id=$last_id2, next_id=$next_id2"
15578 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
15579 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
15581 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
15582 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
15583 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15584 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
15585 echo "unlink $MDSOBJS files @$next_id..."
15586 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
15588 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
15591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15593 dd if=`which date` of=$MOUNT/date oflag=sync
15594 chmod +x $MOUNT/date
15596 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
15597 $LCTL set_param fail_loc=0x80001401
15599 $MOUNT/date > /dev/null
15602 run_test 221 "make sure fault and truncate race to not cause OOM"
15605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15608 test_mkdir $DIR/$tdir
15609 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15610 createmany -o $DIR/$tdir/$tfile 10
15611 cancel_lru_locks mdc
15612 cancel_lru_locks osc
15613 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15614 $LCTL set_param fail_loc=0x31a
15615 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
15616 $LCTL set_param fail_loc=0
15619 run_test 222a "AGL for ls should not trigger CLIO lock failure"
15622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15625 test_mkdir $DIR/$tdir
15626 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15627 createmany -o $DIR/$tdir/$tfile 10
15628 cancel_lru_locks mdc
15629 cancel_lru_locks osc
15630 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15631 $LCTL set_param fail_loc=0x31a
15632 rm -r $DIR/$tdir || error "AGL for rmdir failed"
15633 $LCTL set_param fail_loc=0
15635 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
15638 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15641 test_mkdir $DIR/$tdir
15642 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15643 createmany -o $DIR/$tdir/$tfile 10
15644 cancel_lru_locks mdc
15645 cancel_lru_locks osc
15646 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
15647 $LCTL set_param fail_loc=0x31b
15648 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
15649 $LCTL set_param fail_loc=0
15652 run_test 223 "osc reenqueue if without AGL lock granted ======================="
15654 test_224a() { # LU-1039, MRP-303
15655 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15657 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
15658 $LCTL set_param fail_loc=0x508
15659 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
15660 $LCTL set_param fail_loc=0
15663 run_test 224a "Don't panic on bulk IO failure"
15665 test_224b() { # LU-1039, MRP-303
15666 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15668 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
15669 cancel_lru_locks osc
15670 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
15671 $LCTL set_param fail_loc=0x515
15672 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
15673 $LCTL set_param fail_loc=0
15676 run_test 224b "Don't panic on bulk IO failure"
15678 test_224c() { # LU-6441
15679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15680 remote_mds_nodsh && skip "remote MDS with nodsh"
15682 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15683 save_writethrough $p
15684 set_cache writethrough on
15686 local pages_per_rpc=$($LCTL get_param \
15687 osc.*.max_pages_per_rpc)
15688 local at_max=$($LCTL get_param -n at_max)
15689 local timeout=$($LCTL get_param -n timeout)
15690 local test_at="at_max"
15691 local param_at="$FSNAME.sys.at_max"
15692 local test_timeout="timeout"
15693 local param_timeout="$FSNAME.sys.timeout"
15695 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
15697 set_persistent_param_and_check client "$test_at" "$param_at" 0
15698 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
15700 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
15701 do_facet ost1 $LCTL set_param fail_loc=0x520
15702 $LFS setstripe -c 1 -i 0 $DIR/$tfile
15703 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
15705 do_facet ost1 $LCTL set_param fail_loc=0
15707 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
15708 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
15711 $LCTL set_param -n $pages_per_rpc
15712 restore_lustre_params < $p
15715 run_test 224c "Don't hang if one of md lost during large bulk RPC"
15717 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
15719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15720 if [ -z ${MDSSURVEY} ]; then
15721 skip_env "mds-survey not found"
15723 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15724 skip "Need MDS version at least 2.2.51"
15726 local mds=$(facet_host $SINGLEMDS)
15727 local target=$(do_nodes $mds 'lctl dl' |
15728 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15730 local cmd1="file_count=1000 thrhi=4"
15731 local cmd2="dir_count=2 layer=mdd stripe_count=0"
15732 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15733 local cmd="$cmd1 $cmd2 $cmd3"
15735 rm -f ${TMP}/mds_survey*
15737 eval $cmd || error "mds-survey with zero-stripe failed"
15738 cat ${TMP}/mds_survey*
15739 rm -f ${TMP}/mds_survey*
15741 run_test 225a "Metadata survey sanity with zero-stripe"
15744 if [ -z ${MDSSURVEY} ]; then
15745 skip_env "mds-survey not found"
15747 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15748 skip "Need MDS version at least 2.2.51"
15749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15750 remote_mds_nodsh && skip "remote MDS with nodsh"
15751 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
15752 skip_env "Need to mount OST to test"
15755 local mds=$(facet_host $SINGLEMDS)
15756 local target=$(do_nodes $mds 'lctl dl' |
15757 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15759 local cmd1="file_count=1000 thrhi=4"
15760 local cmd2="dir_count=2 layer=mdd stripe_count=1"
15761 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15762 local cmd="$cmd1 $cmd2 $cmd3"
15764 rm -f ${TMP}/mds_survey*
15766 eval $cmd || error "mds-survey with stripe_count failed"
15767 cat ${TMP}/mds_survey*
15768 rm -f ${TMP}/mds_survey*
15770 run_test 225b "Metadata survey sanity with stripe_count = 1"
15772 mcreate_path2fid () {
15778 local path=$DIR/$tdir/$name
15783 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
15784 error "cannot create $desc"
15786 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
15788 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
15790 fid_path=$($LFS fid2path $MOUNT $fid)
15792 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
15794 [ "$path" == "$fid_path" ] ||
15795 error "fid2path returned $fid_path, expected $path"
15797 echo "pass with $path and $fid"
15802 mkdir -p $DIR/$tdir
15804 mcreate_path2fid 0010666 0 0 fifo "FIFO"
15805 mcreate_path2fid 0020666 1 3 null "character special file (null)"
15806 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
15807 mcreate_path2fid 0040666 0 0 dir "directory"
15808 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
15809 mcreate_path2fid 0100666 0 0 file "regular file"
15810 mcreate_path2fid 0120666 0 0 link "symbolic link"
15811 mcreate_path2fid 0140666 0 0 sock "socket"
15813 run_test 226a "call path2fid and fid2path on files of all type"
15816 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15821 mkdir -p $DIR/$tdir
15822 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
15823 error "create remote directory failed"
15824 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
15825 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
15826 "character special file (null)"
15827 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
15828 "character special file (no device)"
15829 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
15830 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
15831 "block special file (loop)"
15832 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
15833 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
15834 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
15836 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
15838 # LU-1299 Executing or running ldd on a truncated executable does not
15839 # cause an out-of-memory condition.
15841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15842 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
15844 dd if=$(which date) of=$MOUNT/date bs=1k count=1
15845 chmod +x $MOUNT/date
15847 $MOUNT/date > /dev/null
15848 ldd $MOUNT/date > /dev/null
15851 run_test 227 "running truncated executable does not cause OOM"
15853 # LU-1512 try to reuse idle OI blocks
15855 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15856 remote_mds_nodsh && skip "remote MDS with nodsh"
15857 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15859 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15860 local myDIR=$DIR/$tdir
15863 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15864 $LCTL set_param fail_loc=0x80001002
15865 createmany -o $myDIR/t- 10000
15866 $LCTL set_param fail_loc=0
15867 # The guard is current the largest FID holder
15869 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15871 local IDX=$(($SEQ % 64))
15873 do_facet $SINGLEMDS sync
15874 # Make sure journal flushed.
15876 local blk1=$(do_facet $SINGLEMDS \
15877 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15878 grep Blockcount | awk '{print $4}')
15880 # Remove old files, some OI blocks will become idle.
15881 unlinkmany $myDIR/t- 10000
15882 # Create new files, idle OI blocks should be reused.
15883 createmany -o $myDIR/t- 2000
15884 do_facet $SINGLEMDS sync
15885 # Make sure journal flushed.
15887 local blk2=$(do_facet $SINGLEMDS \
15888 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15889 grep Blockcount | awk '{print $4}')
15891 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15893 run_test 228a "try to reuse idle OI blocks"
15896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15897 remote_mds_nodsh && skip "remote MDS with nodsh"
15898 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15900 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15901 local myDIR=$DIR/$tdir
15904 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15905 $LCTL set_param fail_loc=0x80001002
15906 createmany -o $myDIR/t- 10000
15907 $LCTL set_param fail_loc=0
15908 # The guard is current the largest FID holder
15910 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15912 local IDX=$(($SEQ % 64))
15914 do_facet $SINGLEMDS sync
15915 # Make sure journal flushed.
15917 local blk1=$(do_facet $SINGLEMDS \
15918 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15919 grep Blockcount | awk '{print $4}')
15921 # Remove old files, some OI blocks will become idle.
15922 unlinkmany $myDIR/t- 10000
15925 stop $SINGLEMDS || error "Fail to stop MDT."
15927 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
15929 df $MOUNT || error "Fail to df."
15930 # Create new files, idle OI blocks should be reused.
15931 createmany -o $myDIR/t- 2000
15932 do_facet $SINGLEMDS sync
15933 # Make sure journal flushed.
15935 local blk2=$(do_facet $SINGLEMDS \
15936 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15937 grep Blockcount | awk '{print $4}')
15939 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15941 run_test 228b "idle OI blocks can be reused after MDT restart"
15945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15946 remote_mds_nodsh && skip "remote MDS with nodsh"
15947 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15949 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15950 local myDIR=$DIR/$tdir
15953 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15954 $LCTL set_param fail_loc=0x80001002
15955 # 20000 files can guarantee there are index nodes in the OI file
15956 createmany -o $myDIR/t- 20000
15957 $LCTL set_param fail_loc=0
15958 # The guard is current the largest FID holder
15960 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15962 local IDX=$(($SEQ % 64))
15964 do_facet $SINGLEMDS sync
15965 # Make sure journal flushed.
15967 local blk1=$(do_facet $SINGLEMDS \
15968 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15969 grep Blockcount | awk '{print $4}')
15971 # Remove old files, some OI blocks will become idle.
15972 unlinkmany $myDIR/t- 20000
15974 # The OI file should become empty now
15976 # Create new files, idle OI blocks should be reused.
15977 createmany -o $myDIR/t- 2000
15978 do_facet $SINGLEMDS sync
15979 # Make sure journal flushed.
15981 local blk2=$(do_facet $SINGLEMDS \
15982 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15983 grep Blockcount | awk '{print $4}')
15985 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15987 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
15989 test_229() { # LU-2482, LU-3448
15990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15991 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
15992 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
15993 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
15997 # Create a file with a released layout and stripe count 2.
15998 $MULTIOP $DIR/$tfile H2c ||
15999 error "failed to create file with released layout"
16001 $GETSTRIPE -v $DIR/$tfile
16003 local pattern=$($GETSTRIPE -L $DIR/$tfile)
16004 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
16006 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
16007 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
16008 stat $DIR/$tfile || error "failed to stat released file"
16010 chown $RUNAS_ID $DIR/$tfile ||
16011 error "chown $RUNAS_ID $DIR/$tfile failed"
16013 chgrp $RUNAS_ID $DIR/$tfile ||
16014 error "chgrp $RUNAS_ID $DIR/$tfile failed"
16016 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
16017 rm $DIR/$tfile || error "failed to remove released file"
16019 run_test 229 "getstripe/stat/rm/attr changes work on released files"
16022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16023 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16024 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16025 skip "Need MDS version at least 2.11.52"
16029 test_mkdir $DIR/$tdir
16030 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
16031 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
16032 [ $mdt_idx -ne 0 ] &&
16033 error "create local directory on wrong MDT $mdt_idx"
16035 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
16036 error "create remote directory failed"
16037 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
16038 [ $mdt_idx -ne $MDTIDX ] &&
16039 error "create remote directory on wrong MDT $mdt_idx"
16041 createmany -o $DIR/$tdir/test_230/t- 10 ||
16042 error "create files on remote directory failed"
16043 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
16044 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
16045 rm -r $DIR/$tdir || error "unlink remote directory failed"
16047 run_test 230a "Create remote directory and files under the remote directory"
16050 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16051 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16052 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16053 skip "Need MDS version at least 2.11.52"
16061 local migrate_dir=$DIR/$tdir/migrate_dir
16062 local other_dir=$DIR/$tdir/other_dir
16064 test_mkdir $DIR/$tdir
16065 test_mkdir -i0 -c1 $migrate_dir
16066 test_mkdir -i0 -c1 $other_dir
16067 for ((i=0; i<10; i++)); do
16068 mkdir -p $migrate_dir/dir_${i}
16069 createmany -o $migrate_dir/dir_${i}/f 10 ||
16070 error "create files under remote dir failed $i"
16073 cp /etc/passwd $migrate_dir/$tfile
16074 cp /etc/passwd $other_dir/$tfile
16075 chattr +SAD $migrate_dir
16076 chattr +SAD $migrate_dir/$tfile
16078 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16079 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16080 local old_dir_mode=$(stat -c%f $migrate_dir)
16081 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
16083 mkdir -p $migrate_dir/dir_default_stripe2
16084 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
16085 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
16087 mkdir -p $other_dir
16088 ln $migrate_dir/$tfile $other_dir/luna
16089 ln $migrate_dir/$tfile $migrate_dir/sofia
16090 ln $other_dir/$tfile $migrate_dir/david
16091 ln -s $migrate_dir/$tfile $other_dir/zachary
16092 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
16093 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
16099 for len in 58 59 60; do
16100 lnktgt=$(str_repeat 'l' $len)
16101 touch $migrate_dir/$lnktgt
16102 ln -s $lnktgt $migrate_dir/${len}char_ln
16106 for len in 4094 4095; do
16107 lnktgt=$(str_repeat 'l' $len)
16108 ln -s $lnktgt $migrate_dir/${len}char_ln
16112 for len in 254 255; do
16113 touch $migrate_dir/$(str_repeat 'l' $len)
16116 $LFS migrate -m $MDTIDX $migrate_dir ||
16117 error "fails on migrating remote dir to MDT1"
16119 echo "migratate to MDT1, then checking.."
16120 for ((i = 0; i < 10; i++)); do
16121 for file in $(find $migrate_dir/dir_${i}); do
16122 mdt_index=$($LFS getstripe -m $file)
16123 # broken symlink getstripe will fail
16124 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
16125 error "$file is not on MDT${MDTIDX}"
16129 # the multiple link file should still in MDT0
16130 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
16131 [ $mdt_index == 0 ] ||
16132 error "$file is not on MDT${MDTIDX}"
16134 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16135 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16136 error " expect $old_dir_flag get $new_dir_flag"
16138 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16139 [ "$old_file_flag" = "$new_file_flag" ] ||
16140 error " expect $old_file_flag get $new_file_flag"
16142 local new_dir_mode=$(stat -c%f $migrate_dir)
16143 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16144 error "expect mode $old_dir_mode get $new_dir_mode"
16146 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16147 [ "$old_file_mode" = "$new_file_mode" ] ||
16148 error "expect mode $old_file_mode get $new_file_mode"
16150 diff /etc/passwd $migrate_dir/$tfile ||
16151 error "$tfile different after migration"
16153 diff /etc/passwd $other_dir/luna ||
16154 error "luna different after migration"
16156 diff /etc/passwd $migrate_dir/sofia ||
16157 error "sofia different after migration"
16159 diff /etc/passwd $migrate_dir/david ||
16160 error "david different after migration"
16162 diff /etc/passwd $other_dir/zachary ||
16163 error "zachary different after migration"
16165 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16166 error "${tfile}_ln different after migration"
16168 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16169 error "${tfile}_ln_other different after migration"
16171 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
16172 [ $stripe_count = 2 ] ||
16173 error "dir strpe_count $d != 2 after migration."
16175 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
16176 [ $stripe_count = 2 ] ||
16177 error "file strpe_count $d != 2 after migration."
16179 #migrate back to MDT0
16182 $LFS migrate -m $MDTIDX $migrate_dir ||
16183 error "fails on migrating remote dir to MDT0"
16185 echo "migrate back to MDT0, checking.."
16186 for file in $(find $migrate_dir); do
16187 mdt_index=$($LFS getstripe -m $file)
16188 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
16189 error "$file is not on MDT${MDTIDX}"
16192 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16193 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16194 error " expect $old_dir_flag get $new_dir_flag"
16196 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16197 [ "$old_file_flag" = "$new_file_flag" ] ||
16198 error " expect $old_file_flag get $new_file_flag"
16200 local new_dir_mode=$(stat -c%f $migrate_dir)
16201 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16202 error "expect mode $old_dir_mode get $new_dir_mode"
16204 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16205 [ "$old_file_mode" = "$new_file_mode" ] ||
16206 error "expect mode $old_file_mode get $new_file_mode"
16208 diff /etc/passwd ${migrate_dir}/$tfile ||
16209 error "$tfile different after migration"
16211 diff /etc/passwd ${other_dir}/luna ||
16212 error "luna different after migration"
16214 diff /etc/passwd ${migrate_dir}/sofia ||
16215 error "sofia different after migration"
16217 diff /etc/passwd ${other_dir}/zachary ||
16218 error "zachary different after migration"
16220 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16221 error "${tfile}_ln different after migration"
16223 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16224 error "${tfile}_ln_other different after migration"
16226 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
16227 [ $stripe_count = 2 ] ||
16228 error "dir strpe_count $d != 2 after migration."
16230 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
16231 [ $stripe_count = 2 ] ||
16232 error "file strpe_count $d != 2 after migration."
16234 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16236 run_test 230b "migrate directory"
16239 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16240 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16241 remote_mds_nodsh && skip "remote MDS with nodsh"
16242 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16243 skip "Need MDS version at least 2.11.52"
16249 local migrate_dir=$DIR/$tdir/migrate_dir
16251 #If migrating directory fails in the middle, all entries of
16252 #the directory is still accessiable.
16253 test_mkdir $DIR/$tdir
16254 test_mkdir -i0 -c1 $migrate_dir
16255 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
16257 createmany -o $migrate_dir/f $total ||
16258 error "create files under ${migrate_dir} failed"
16260 # fail after migrating top dir, and this will fail only once, so the
16261 # first sub file migration will fail (currently f3), others succeed.
16262 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
16263 do_facet mds1 lctl set_param fail_loc=0x1801
16264 local t=$(ls $migrate_dir | wc -l)
16265 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
16266 error "migrate should fail"
16267 local u=$(ls $migrate_dir | wc -l)
16268 [ "$u" == "$t" ] || error "$u != $t during migration"
16270 # add new dir/file should succeed
16271 mkdir $migrate_dir/dir ||
16272 error "mkdir failed under migrating directory"
16273 touch $migrate_dir/file ||
16274 error "create file failed under migrating directory"
16276 # add file with existing name should fail
16277 for file in $migrate_dir/f*; do
16278 stat $file > /dev/null || error "stat $file failed"
16279 $OPENFILE -f O_CREAT:O_EXCL $file &&
16280 error "open(O_CREAT|O_EXCL) $file should fail"
16281 $MULTIOP $file m && error "create $file should fail"
16282 touch $DIR/$tdir/remote_dir/$tfile ||
16283 error "touch $tfile failed"
16284 ln $DIR/$tdir/remote_dir/$tfile $file &&
16285 error "link $file should fail"
16286 mdt_index=$($LFS getstripe -m $file)
16287 if [ $mdt_index == 0 ]; then
16288 # file failed to migrate is not allowed to rename to
16289 mv $DIR/$tdir/remote_dir/$tfile $file &&
16290 error "rename to $file should fail"
16292 mv $DIR/$tdir/remote_dir/$tfile $file ||
16293 error "rename to $file failed"
16295 echo hello >> $file || error "write $file failed"
16298 # resume migration with different options should fail
16299 $LFS migrate -m 0 $migrate_dir &&
16300 error "migrate -m 0 $migrate_dir should fail"
16302 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
16303 error "migrate -c 2 $migrate_dir should fail"
16305 # resume migration should succeed
16306 $LFS migrate -m $MDTIDX $migrate_dir ||
16307 error "migrate $migrate_dir failed"
16309 echo "Finish migration, then checking.."
16310 for file in $(find $migrate_dir); do
16311 mdt_index=$($LFS getstripe -m $file)
16312 [ $mdt_index == $MDTIDX ] ||
16313 error "$file is not on MDT${MDTIDX}"
16316 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16318 run_test 230c "check directory accessiblity if migration failed"
16321 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16322 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16323 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16324 skip "Need MDS version at least 2.11.52"
16326 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
16328 local migrate_dir=$DIR/$tdir/migrate_dir
16338 old_index=$((RANDOM % MDSCOUNT))
16339 old_count=$((MDSCOUNT - old_index))
16340 new_index=$((RANDOM % MDSCOUNT))
16341 new_count=$((MDSCOUNT - new_index))
16342 new_hash="all_char"
16344 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
16345 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
16347 test_mkdir $DIR/$tdir
16348 test_mkdir -i $old_index -c $old_count $migrate_dir
16350 for ((i=0; i<100; i++)); do
16351 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
16352 createmany -o $migrate_dir/dir_${i}/f 100 ||
16353 error "create files under remote dir failed $i"
16356 echo -n "Migrate from MDT$old_index "
16357 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
16358 echo -n "to MDT$new_index"
16359 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
16362 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
16363 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
16364 error "migrate remote dir error"
16366 echo "Finish migration, then checking.."
16367 for file in $(find $migrate_dir); do
16368 mdt_index=$($LFS getstripe -m $file)
16369 if [ $mdt_index -lt $new_index ] ||
16370 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
16371 error "$file is on MDT$mdt_index"
16375 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16377 run_test 230d "check migrate big directory"
16380 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16381 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16382 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16383 skip "Need MDS version at least 2.11.52"
16390 mkdir -p $DIR/$tdir
16391 mkdir $DIR/$tdir/migrate_dir
16392 mkdir $DIR/$tdir/other_dir
16393 touch $DIR/$tdir/migrate_dir/a
16394 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
16395 ls $DIR/$tdir/other_dir
16397 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16398 error "migrate dir fails"
16400 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16401 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16403 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16404 [ $mdt_index == 0 ] || error "a is not on MDT0"
16406 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
16407 error "migrate dir fails"
16409 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
16410 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
16412 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16413 [ $mdt_index == 1 ] || error "a is not on MDT1"
16415 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
16416 [ $mdt_index == 1 ] || error "b is not on MDT1"
16418 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16419 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
16421 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
16423 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16425 run_test 230e "migrate mulitple local link files"
16428 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16429 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16430 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16431 skip "Need MDS version at least 2.11.52"
16436 mkdir -p $DIR/$tdir
16437 mkdir $DIR/$tdir/migrate_dir
16438 $LFS mkdir -i1 $DIR/$tdir/other_dir
16439 touch $DIR/$tdir/migrate_dir/a
16440 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
16441 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
16442 ls $DIR/$tdir/other_dir
16444 # a should be migrated to MDT1, since no other links on MDT0
16445 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16446 error "#1 migrate dir fails"
16447 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16448 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16449 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16450 [ $mdt_index == 1 ] || error "a is not on MDT1"
16452 # a should stay on MDT1, because it is a mulitple link file
16453 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16454 error "#2 migrate dir fails"
16455 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16456 [ $mdt_index == 1 ] || error "a is not on MDT1"
16458 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16459 error "#3 migrate dir fails"
16461 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16462 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
16463 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
16465 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
16466 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
16468 # a should be migrated to MDT0, since no other links on MDT1
16469 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16470 error "#4 migrate dir fails"
16471 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16472 [ $mdt_index == 0 ] || error "a is not on MDT0"
16474 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16476 run_test 230f "migrate mulitple remote link files"
16479 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16480 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16481 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16482 skip "Need MDS version at least 2.11.52"
16484 mkdir -p $DIR/$tdir/migrate_dir
16486 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
16487 error "migrating dir to non-exist MDT succeeds"
16490 run_test 230g "migrate dir to non-exist MDT"
16493 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16494 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16495 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16496 skip "Need MDS version at least 2.11.52"
16500 mkdir -p $DIR/$tdir/migrate_dir
16502 $LFS migrate -m1 $DIR &&
16503 error "migrating mountpoint1 should fail"
16505 $LFS migrate -m1 $DIR/$tdir/.. &&
16506 error "migrating mountpoint2 should fail"
16509 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
16510 error "migrating $tdir/migrate_dir/.. should fail"
16514 run_test 230h "migrate .. and root"
16517 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16518 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16519 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16520 skip "Need MDS version at least 2.11.52"
16522 mkdir -p $DIR/$tdir/migrate_dir
16524 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
16525 error "migration fails with a tailing slash"
16527 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
16528 error "migration fails with two tailing slashes"
16530 run_test 230i "lfs migrate -m tolerates trailing slashes"
16533 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16534 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16535 skip "Need MDS version at least 2.11.52"
16537 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
16538 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
16539 error "create $tfile failed"
16540 cat /etc/passwd > $DIR/$tdir/$tfile
16542 $LFS migrate -m 1 $DIR/$tdir
16544 cmp /etc/passwd $DIR/$tdir/$tfile ||
16545 error "DoM file mismatch after migration"
16547 run_test 230j "DoM file data not changed after dir migration"
16550 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
16551 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16552 skip "Need MDS version at least 2.11.56"
16555 local files_on_starting_mdt=0
16557 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
16558 $LFS getdirstripe $DIR/$tdir
16559 for i in $(seq $total); do
16560 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
16561 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16562 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16565 echo "$files_on_starting_mdt files on MDT0"
16567 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
16568 $LFS getdirstripe $DIR/$tdir
16570 files_on_starting_mdt=0
16571 for i in $(seq $total); do
16572 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16573 error "file $tfile.$i mismatch after migration"
16574 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
16575 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16578 echo "$files_on_starting_mdt files on MDT1 after migration"
16579 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
16581 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
16582 $LFS getdirstripe $DIR/$tdir
16584 files_on_starting_mdt=0
16585 for i in $(seq $total); do
16586 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16587 error "file $tfile.$i mismatch after 2nd migration"
16588 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16589 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16592 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
16593 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
16597 run_test 230k "file data not changed after dir migration"
16600 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16601 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16602 skip "Need MDS version at least 2.11.56"
16604 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
16605 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
16606 error "create files under remote dir failed $i"
16607 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
16609 run_test 230l "readdir between MDTs won't crash"
16612 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16613 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16614 skip "Need MDS version at least 2.11.56"
16617 local mig_dir=$DIR/$tdir/migrate_dir
16618 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
16622 echo "Creating files and dirs with xattrs"
16623 test_mkdir $DIR/$tdir
16624 test_mkdir -i0 -c1 $mig_dir
16626 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
16627 error "cannot set xattr attr1 on dir"
16628 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
16629 error "cannot set xattr attr2 on dir"
16630 touch $mig_dir/dir/f0
16631 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
16632 error "cannot set xattr attr1 on file"
16633 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
16634 error "cannot set xattr attr2 on file"
16635 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
16636 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
16637 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
16638 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
16639 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
16640 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
16641 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
16642 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
16643 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
16645 echo "Migrating to MDT1"
16646 $LFS migrate -m $MDTIDX $mig_dir ||
16647 error "fails on migrating dir to MDT1"
16649 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
16650 echo "Checking xattrs"
16651 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
16652 [ "$val" = $longstr ] ||
16653 error "expecting xattr1 $longstr on dir, found $val"
16654 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
16655 [ "$val" = $shortstr ] ||
16656 error "expecting xattr2 $shortstr on dir, found $val"
16657 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
16658 [ "$val" = $longstr ] ||
16659 error "expecting xattr1 $longstr on file, found $val"
16660 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
16661 [ "$val" = $shortstr ] ||
16662 error "expecting xattr2 $shortstr on file, found $val"
16664 run_test 230m "xattrs not changed after dir migration"
16667 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
16668 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
16669 [[ $MDS1_VERSION -ge $(version_code 2.12.5) ]] ||
16670 skip "Need MDS version at least 2.12.5"
16672 # maximum amount of local locks:
16673 # parent striped dir - 2 locks
16674 # new stripe in parent to migrate to - 1 lock
16675 # source and target - 2 locks
16676 # Total 5 locks for regular file
16677 mkdir -p $DIR/$tdir
16678 $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
16679 touch $DIR/$tdir/dir1/eee
16681 # create 4 hardlink for 4 more locks
16682 # Total: 9 locks > RS_MAX_LOCKS (8)
16683 $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
16684 $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
16685 $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
16686 $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
16687 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
16688 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
16689 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
16690 ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
16692 cancel_lru_locks mdc
16694 $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
16695 error "migrate dir fails"
16697 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16699 run_test 230r "migrate with too many local locks"
16703 # For simplicity this test assumes that max_pages_per_rpc
16704 # is the same across all OSCs
16705 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
16706 local bulk_size=$((max_pages * PAGE_SIZE))
16707 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
16710 mkdir -p $DIR/$tdir
16711 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
16712 error "failed to set stripe with -S ${brw_size}M option"
16714 # clear the OSC stats
16715 $LCTL set_param osc.*.stats=0 &>/dev/null
16718 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
16719 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
16720 oflag=direct &>/dev/null || error "dd failed"
16722 sync; sleep 1; sync # just to be safe
16723 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
16724 if [ x$nrpcs != "x1" ]; then
16725 $LCTL get_param osc.*.stats
16726 error "found $nrpcs ost_write RPCs, not 1 as expected"
16730 # Drop the OSC cache, otherwise we will read from it
16731 cancel_lru_locks osc
16733 # clear the OSC stats
16734 $LCTL set_param osc.*.stats=0 &>/dev/null
16736 # Client reads $bulk_size.
16737 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
16738 iflag=direct &>/dev/null || error "dd failed"
16740 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
16741 if [ x$nrpcs != "x1" ]; then
16742 $LCTL get_param osc.*.stats
16743 error "found $nrpcs ost_read RPCs, not 1 as expected"
16746 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
16749 mkdir -p $DIR/$tdir
16751 for i in {0..1023}; do
16752 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
16753 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
16754 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
16758 run_test 231b "must not assert on fully utilized OST request buffer"
16761 mkdir -p $DIR/$tdir
16762 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16764 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16765 do_facet ost1 $LCTL set_param fail_loc=0x31c
16767 # ignore dd failure
16768 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
16770 do_facet ost1 $LCTL set_param fail_loc=0
16771 umount_client $MOUNT || error "umount failed"
16772 mount_client $MOUNT || error "mount failed"
16773 stop ost1 || error "cannot stop ost1"
16774 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16776 run_test 232a "failed lock should not block umount"
16779 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
16780 skip "Need MDS version at least 2.10.58"
16782 mkdir -p $DIR/$tdir
16783 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16784 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
16786 cancel_lru_locks osc
16788 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16789 do_facet ost1 $LCTL set_param fail_loc=0x31c
16792 $LFS data_version $DIR/$tdir/$tfile || true
16794 do_facet ost1 $LCTL set_param fail_loc=0
16795 umount_client $MOUNT || error "umount failed"
16796 mount_client $MOUNT || error "mount failed"
16797 stop ost1 || error "cannot stop ost1"
16798 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16800 run_test 232b "failed data version lock should not block umount"
16803 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
16804 skip "Need MDS version at least 2.3.64"
16805 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16807 local fid=$($LFS path2fid $MOUNT)
16809 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16810 error "cannot access $MOUNT using its FID '$fid'"
16812 run_test 233a "checking that OBF of the FS root succeeds"
16815 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
16816 skip "Need MDS version at least 2.5.90"
16817 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16819 local fid=$($LFS path2fid $MOUNT/.lustre)
16821 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16822 error "cannot access $MOUNT/.lustre using its FID '$fid'"
16824 fid=$($LFS path2fid $MOUNT/.lustre/fid)
16825 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16826 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
16828 run_test 233b "checking that OBF of the FS .lustre succeeds"
16831 local p="$TMP/sanityN-$TESTNAME.parameters"
16832 save_lustre_params client "llite.*.xattr_cache" > $p
16833 lctl set_param llite.*.xattr_cache 1 ||
16834 skip_env "xattr cache is not supported"
16836 mkdir -p $DIR/$tdir || error "mkdir failed"
16837 touch $DIR/$tdir/$tfile || error "touch failed"
16838 # OBD_FAIL_LLITE_XATTR_ENOMEM
16839 $LCTL set_param fail_loc=0x1405
16840 getfattr -n user.attr $DIR/$tdir/$tfile &&
16841 error "getfattr should have failed with ENOMEM"
16842 $LCTL set_param fail_loc=0x0
16845 restore_lustre_params < $p
16848 run_test 234 "xattr cache should not crash on ENOMEM"
16851 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
16852 skip "Need MDS version at least 2.4.52"
16854 flock_deadlock $DIR/$tfile
16859 124) error "process hangs on a deadlock"
16861 *) error "error executing flock_deadlock $DIR/$tfile"
16865 run_test 235 "LU-1715: flock deadlock detection does not work properly"
16869 check_swap_layouts_support
16871 local ref1=/etc/passwd
16872 local ref2=/etc/group
16873 local file1=$DIR/$tdir/f1
16874 local file2=$DIR/$tdir/f2
16876 test_mkdir -c1 $DIR/$tdir
16877 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
16878 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
16879 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
16880 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
16881 local fd=$(free_fd)
16882 local cmd="exec $fd<>$file2"
16885 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
16886 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
16889 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
16894 run_test 236 "Layout swap on open unlinked file"
16896 # LU-4659 linkea consistency
16898 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16899 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16900 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16901 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16904 ln $DIR/$tfile $DIR/$tfile.lnk
16905 touch $DIR/$tfile.new
16906 mv $DIR/$tfile.new $DIR/$tfile
16907 local fid1=$($LFS path2fid $DIR/$tfile)
16908 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
16909 local path1=$($LFS fid2path $FSNAME "$fid1")
16910 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
16911 local path2=$($LFS fid2path $FSNAME "$fid2")
16912 [ $tfile.lnk == $path2 ] ||
16913 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
16916 run_test 238 "Verify linkea consistency"
16918 test_239A() { # was test_239
16919 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
16920 skip "Need MDS version at least 2.5.60"
16922 local list=$(comma_list $(mdts_nodes))
16924 mkdir -p $DIR/$tdir
16925 createmany -o $DIR/$tdir/f- 5000
16926 unlinkmany $DIR/$tdir/f- 5000
16927 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
16928 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
16929 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
16930 osp.*MDT*.sync_in_flight" | calc_sum)
16931 [ "$changes" -eq 0 ] || error "$changes not synced"
16933 run_test 239A "osp_sync test"
16935 test_239a() { #LU-5297
16936 remote_mds_nodsh && skip "remote MDS with nodsh"
16939 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
16940 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
16941 chgrp $RUNAS_GID $DIR/$tfile
16942 wait_delete_completed
16944 run_test 239a "process invalid osp sync record correctly"
16946 test_239b() { #LU-5297
16947 remote_mds_nodsh && skip "remote MDS with nodsh"
16950 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
16951 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
16952 chgrp $RUNAS_GID $DIR/$tfile1
16953 wait_delete_completed
16954 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16956 chgrp $RUNAS_GID $DIR/$tfile2
16957 wait_delete_completed
16959 run_test 239b "process osp sync record with ENOMEM error correctly"
16962 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16963 remote_mds_nodsh && skip "remote MDS with nodsh"
16965 mkdir -p $DIR/$tdir
16967 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
16968 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
16969 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
16970 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
16972 umount_client $MOUNT || error "umount failed"
16973 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
16974 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
16975 mount_client $MOUNT || error "failed to mount client"
16977 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
16978 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
16980 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
16986 for LOOP in $(seq $count); do
16987 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
16988 cancel_lru_locks $OSC || true
16996 for LOOP in $(seq $1); do
16997 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
17002 test_241a() { # was test_241
17003 local bsize=$PAGE_SIZE
17005 (( bsize < 40960 )) && bsize=40960
17006 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17008 cancel_lru_locks $OSC
17009 test_241_bio 1000 $bsize &
17011 test_241_dio 1000 $bsize
17014 run_test 241a "bio vs dio"
17017 local bsize=$PAGE_SIZE
17019 (( bsize < 40960 )) && bsize=40960
17020 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17022 test_241_dio 1000 $bsize &
17024 test_241_dio 1000 $bsize
17027 run_test 241b "dio vs dio"
17030 remote_mds_nodsh && skip "remote MDS with nodsh"
17032 mkdir -p $DIR/$tdir
17033 touch $DIR/$tdir/$tfile
17035 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
17036 do_facet mds1 lctl set_param fail_loc=0x105
17037 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
17039 do_facet mds1 lctl set_param fail_loc=0
17040 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
17042 run_test 242 "mdt_readpage failure should not cause directory unreadable"
17046 test_mkdir $DIR/$tdir
17047 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
17049 run_test 243 "various group lock tests"
17053 test_mkdir $DIR/$tdir
17054 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
17055 sendfile_grouplock $DIR/$tdir/$tfile || \
17056 error "sendfile+grouplock failed"
17059 run_test 244 "sendfile with group lock tests"
17062 local flagname="multi_mod_rpcs"
17063 local connect_data_name="max_mod_rpcs"
17066 # check if multiple modify RPCs flag is set
17067 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
17068 grep "connect_flags:")
17071 echo "$out" | grep -qw $flagname
17072 if [ $? -ne 0 ]; then
17073 echo "connect flag $flagname is not set"
17077 # check if multiple modify RPCs data is set
17078 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
17081 echo "$out" | grep -qw $connect_data_name ||
17082 error "import should have connect data $connect_data_name"
17084 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
17086 test_246() { # LU-7371
17087 remote_ost_nodsh && skip "remote OST with nodsh"
17088 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
17089 skip "Need OST version >= 2.7.62"
17091 do_facet ost1 $LCTL set_param fail_val=4095
17092 #define OBD_FAIL_OST_READ_SIZE 0x234
17093 do_facet ost1 $LCTL set_param fail_loc=0x234
17094 $LFS setstripe $DIR/$tfile -i 0 -c 1
17095 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
17096 cancel_lru_locks $FSNAME-OST0000
17097 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
17099 run_test 246 "Read file of size 4095 should return right length"
17105 umount_client $submount
17110 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17112 skip_env "Fileset feature is not supported"
17114 local submount=${MOUNT}_$tdir
17117 mkdir -p $submount || error "mkdir $submount failed"
17118 FILESET="$FILESET/$tdir" mount_client $submount ||
17119 error "mount $submount failed"
17120 trap "cleanup_247 $submount" EXIT
17121 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
17122 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
17123 error "read $MOUNT/$tdir/$tfile failed"
17124 cleanup_247 $submount
17126 run_test 247a "mount subdir as fileset"
17129 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17130 skip_env "Fileset feature is not supported"
17132 local submount=${MOUNT}_$tdir
17134 rm -rf $MOUNT/$tdir
17135 mkdir -p $submount || error "mkdir $submount failed"
17137 FILESET="$FILESET/$tdir" mount_client $submount &&
17138 error "mount $submount should fail"
17141 run_test 247b "mount subdir that dose not exist"
17144 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17145 skip_env "Fileset feature is not supported"
17147 local submount=${MOUNT}_$tdir
17149 mkdir -p $MOUNT/$tdir/dir1
17150 mkdir -p $submount || error "mkdir $submount failed"
17151 trap "cleanup_247 $submount" EXIT
17152 FILESET="$FILESET/$tdir" mount_client $submount ||
17153 error "mount $submount failed"
17154 local fid=$($LFS path2fid $MOUNT/)
17155 $LFS fid2path $submount $fid && error "fid2path should fail"
17156 cleanup_247 $submount
17158 run_test 247c "running fid2path outside root"
17161 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17162 skip "Fileset feature is not supported"
17164 local submount=${MOUNT}_$tdir
17166 mkdir -p $MOUNT/$tdir/dir1
17167 mkdir -p $submount || error "mkdir $submount failed"
17168 FILESET="$FILESET/$tdir" mount_client $submount ||
17169 error "mount $submount failed"
17170 trap "cleanup_247 $submount" EXIT
17171 local fid=$($LFS path2fid $submount/dir1)
17172 $LFS fid2path $submount $fid || error "fid2path should succeed"
17173 cleanup_247 $submount
17175 run_test 247d "running fid2path inside root"
17179 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17181 skip "Fileset feature is not supported"
17183 local submount=${MOUNT}_$tdir
17186 mkdir -p $submount || error "mkdir $submount failed"
17187 FILESET="$FILESET/.." mount_client $submount &&
17188 error "mount $submount should fail"
17191 run_test 247e "mount .. as fileset"
17194 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17195 [ $MDS1_VERSION -lt $(version_code 2.12.6) ] &&
17196 skip "Need at least version 2.12.6"
17197 [ $CLIENT_VERSION -lt $(version_code 2.12.6) ] &&
17198 skip "Need at least version 2.12.6"
17199 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17201 skip "Fileset feature is not supported"
17203 mkdir $DIR/$tdir || error "mkdir $tdir failed"
17204 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
17205 error "mkdir remote failed"
17206 mkdir $DIR/$tdir/remote/subdir || error "mkdir remote/subdir failed"
17207 $LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
17208 error "mkdir striped failed"
17209 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
17211 local submount=${MOUNT}_$tdir
17213 mkdir -p $submount || error "mkdir $submount failed"
17214 stack_trap "rmdir $submount"
17218 local fileset=$FILESET
17219 local mdts=$(comma_list $(mdts_nodes))
17221 stat=$(do_facet mds1 $LCTL get_param -n \
17222 mdt.*MDT0000.enable_remote_subdir_mount)
17223 stack_trap "do_nodes $mdts $LCTL set_param \
17224 mdt.*.enable_remote_subdir_mount=$stat"
17226 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
17227 stack_trap "umount_client $submount"
17228 FILESET="$fileset/$tdir/remote" mount_client $submount &&
17229 error "mount remote dir $dir should fail"
17231 for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
17232 $tdir/striped/. ; do
17233 FILESET="$fileset/$dir" mount_client $submount ||
17234 error "mount $dir failed"
17235 umount_client $submount
17238 do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
17239 FILESET="$fileset/$tdir/remote" mount_client $submount ||
17240 error "mount $tdir/remote failed"
17242 run_test 247f "mount striped or remote directory as fileset"
17245 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
17246 [ $CLIENT_VERSION -lt $(version_code 2.12.6) ] &&
17247 skip "Need at least version 2.12.6"
17249 $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
17250 error "mkdir $tdir failed"
17251 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
17253 local submount=${MOUNT}_$tdir
17255 mkdir -p $submount || error "mkdir $submount failed"
17256 stack_trap "rmdir $submount"
17258 FILESET="$fileset/$tdir" mount_client $submount ||
17259 error "mount $dir failed"
17260 stack_trap "umount $submount"
17262 local mdts=$(comma_list $(mdts_nodes))
17266 stat $submount > /dev/null
17267 cancel_lru_locks $MDC
17268 stat $submount > /dev/null
17269 stat $submount/$tfile > /dev/null
17270 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
17271 stat $submount/$tfile > /dev/null
17272 nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
17273 awk '/getattr/ {sum += $2} END {print sum}')
17275 [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
17277 run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
17280 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
17281 [ -z "$fast_read_sav" ] && skip "no fast read support"
17283 # create a large file for fast read verification
17284 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
17286 # make sure the file is created correctly
17287 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
17288 { rm -f $DIR/$tfile; skip "file creation error"; }
17290 echo "Test 1: verify that fast read is 4 times faster on cache read"
17292 # small read with fast read enabled
17293 $LCTL set_param -n llite.*.fast_read=1
17294 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17295 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17296 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17297 # small read with fast read disabled
17298 $LCTL set_param -n llite.*.fast_read=0
17299 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17300 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17301 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17303 # verify that fast read is 4 times faster for cache read
17304 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
17305 error_not_in_vm "fast read was not 4 times faster: " \
17306 "$t_fast vs $t_slow"
17308 echo "Test 2: verify the performance between big and small read"
17309 $LCTL set_param -n llite.*.fast_read=1
17311 # 1k non-cache read
17312 cancel_lru_locks osc
17313 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17314 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17315 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17317 # 1M non-cache read
17318 cancel_lru_locks osc
17319 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17320 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17321 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17323 # verify that big IO is not 4 times faster than small IO
17324 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
17325 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
17327 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
17330 run_test 248 "fast read verification"
17332 test_249() { # LU-7890
17333 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
17334 skip "Need at least version 2.8.54"
17337 $SETSTRIPE -c 1 $DIR/$tfile
17338 # Offset 2T == 4k * 512M
17339 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
17340 error "dd to 2T offset failed"
17342 run_test 249 "Write above 2T file size"
17345 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
17346 && skip "no 16TB file size limit on ZFS"
17348 $SETSTRIPE -c 1 $DIR/$tfile
17349 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
17350 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
17351 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
17352 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
17353 conv=notrunc,fsync && error "append succeeded"
17356 run_test 250 "Write above 16T limit"
17359 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
17361 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
17362 #Skip once - writing the first stripe will succeed
17363 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17364 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
17365 error "short write happened"
17367 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17368 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
17369 error "short read happened"
17373 run_test 251 "Handling short read and write correctly"
17376 remote_mds_nodsh && skip "remote MDS with nodsh"
17377 remote_ost_nodsh && skip "remote OST with nodsh"
17378 if [ "$ost1_FSTYPE" != "ldiskfs" -o "$mds1_FSTYPE" != "ldiskfs" ]; then
17379 skip_env "ldiskfs only test"
17389 # check lr_reader on OST0000
17391 dev=$(facet_device $tgt)
17392 out=$(do_facet $tgt $LR_READER $dev)
17393 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17395 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
17396 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
17397 error "Invalid uuid returned by $LR_READER on target $tgt"
17398 echo -e "uuid returned by $LR_READER is '$uuid'\n"
17400 # check lr_reader -c on MDT0000
17402 dev=$(facet_device $tgt)
17403 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
17404 skip "$LR_READER does not support additional options"
17406 out=$(do_facet $tgt $LR_READER -c $dev)
17407 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17409 num=$(echo "$out" | grep -c "mdtlov")
17410 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
17411 error "Invalid number of mdtlov clients returned by $LR_READER"
17412 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
17414 # check lr_reader -cr on MDT0000
17415 out=$(do_facet $tgt $LR_READER -cr $dev)
17416 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17418 echo "$out" | grep -q "^reply_data:$" ||
17419 error "$LR_READER should have returned 'reply_data' section"
17420 num=$(echo "$out" | grep -c "client_generation")
17421 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
17423 run_test 252 "check lr_reader tool"
17425 test_253_fill_ost() {
17426 local size_mb #how many MB should we write to pass watermark
17427 local lwm=$3 #low watermark
17428 local free_10mb #10% of free space
17430 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
17431 size_mb=$((free_kb / 1024 - lwm))
17432 free_10mb=$((free_kb / 10240))
17433 #If 10% of free space cross low watermark use it
17434 if (( free_10mb > size_mb )); then
17437 #At least we need to store 1.1 of difference between
17438 #free space and low watermark
17439 size_mb=$((size_mb + size_mb / 10))
17441 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
17442 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
17443 oflag=append conv=notrunc
17448 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
17449 echo "OST still has $((free_kb / 1024)) mbytes free"
17453 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17454 remote_mds_nodsh && skip "remote MDS with nodsh"
17455 remote_mgs_nodsh && skip "remote MGS with nodsh"
17460 local ost_name=$($LFS osts |
17461 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
17463 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
17464 do_facet $SINGLEMDS $LCTL get_param -n \
17465 osp.$mdtosc_proc1.reserved_mb_high ||
17466 skip "remote MDS does not support reserved_mb_high"
17470 wait_delete_completed
17473 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
17474 osp.$mdtosc_proc1.reserved_mb_high)
17475 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
17476 osp.$mdtosc_proc1.reserved_mb_low)
17477 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
17479 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
17480 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
17481 error "Adding $ost_name to pool failed"
17483 # Wait for client to see a OST at pool
17484 wait_update $HOSTNAME "$LCTL get_param -n
17485 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
17486 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
17487 error "Client can not see the pool"
17488 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
17489 error "Setstripe failed"
17491 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
17492 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
17493 echo "OST still has $((blocks/1024)) mbytes free"
17495 local new_lwm=$((blocks/1024-10))
17496 do_facet $SINGLEMDS $LCTL set_param \
17497 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
17498 do_facet $SINGLEMDS $LCTL set_param \
17499 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
17501 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
17503 #First enospc could execute orphan deletion so repeat.
17504 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
17506 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17507 osp.$mdtosc_proc1.prealloc_status)
17508 echo "prealloc_status $oa_status"
17510 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
17511 error "File creation should fail"
17512 #object allocation was stopped, but we still able to append files
17513 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
17514 error "Append failed"
17515 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
17517 wait_delete_completed
17521 for i in $(seq 10 12); do
17522 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
17523 error "File creation failed after rm";
17526 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17527 osp.$mdtosc_proc1.prealloc_status)
17528 echo "prealloc_status $oa_status"
17530 if (( oa_status != 0 )); then
17531 error "Object allocation still disable after rm"
17533 do_facet $SINGLEMDS $LCTL set_param \
17534 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
17535 do_facet $SINGLEMDS $LCTL set_param \
17536 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
17539 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
17540 error "Remove $ost_name from pool failed"
17541 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
17542 error "Pool destroy fialed"
17544 run_test 253 "Check object allocation limit"
17547 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17548 remote_mds_nodsh && skip "remote MDS with nodsh"
17549 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
17550 skip "MDS does not support changelog_size"
17553 local MDT0=$(facet_svc $SINGLEMDS)
17555 changelog_register || error "changelog_register failed"
17557 changelog_clear 0 || error "changelog_clear failed"
17559 local size1=$(do_facet $SINGLEMDS \
17560 $LCTL get_param -n mdd.$MDT0.changelog_size)
17561 echo "Changelog size $size1"
17564 $LFS mkdir -i 0 $DIR/$tdir
17566 mkdir -p $DIR/$tdir/pics/2008/zachy
17567 touch $DIR/$tdir/pics/2008/zachy/timestamp
17568 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
17569 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
17570 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
17571 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
17572 rm $DIR/$tdir/pics/desktop.jpg
17574 local size2=$(do_facet $SINGLEMDS \
17575 $LCTL get_param -n mdd.$MDT0.changelog_size)
17576 echo "Changelog size after work $size2"
17578 (( $size2 > $size1 )) ||
17579 error "new Changelog size=$size2 less than old size=$size1"
17581 run_test 254 "Check changelog size"
17588 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
17589 awk -F: '{print $2}' | grep $type > /dev/null
17590 if [ $? -ne 0 ]; then
17600 lfs ladvise -a willread $file > /dev/null 2>&1
17601 if [ $? -eq 0 ]; then
17605 lfs ladvise -a willread $file 2>&1 |
17606 grep "Inappropriate ioctl for device" > /dev/null
17607 if [ $? -eq 0 ]; then
17614 bc <<<"scale=2; ($1 - $2) * 100 / $2"
17617 # run a random read IO workload
17618 # usage: random_read_iops <filename> <filesize> <iosize>
17619 random_read_iops() {
17622 local iosize=${3:-4096}
17624 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
17625 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
17628 drop_file_oss_cache() {
17632 $LFS ladvise -a dontneed $file 2>/dev/null ||
17633 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
17636 ladvise_willread_performance()
17639 local average_origin=0
17640 local average_cache=0
17641 local average_ladvise=0
17643 for ((i = 1; i <= $repeat; i++)); do
17644 echo "Iter $i/$repeat: reading without willread hint"
17645 cancel_lru_locks osc
17646 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17647 local speed_origin=$(random_read_iops $DIR/$tfile $size)
17648 echo "Iter $i/$repeat: uncached speed: $speed_origin"
17649 average_origin=$(bc <<<"$average_origin + $speed_origin")
17651 cancel_lru_locks osc
17652 local speed_cache=$(random_read_iops $DIR/$tfile $size)
17653 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
17654 average_cache=$(bc <<<"$average_cache + $speed_cache")
17656 cancel_lru_locks osc
17657 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17658 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
17659 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
17660 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
17661 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
17663 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
17664 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
17665 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
17667 speedup_cache=$(percent $average_cache $average_origin)
17668 speedup_ladvise=$(percent $average_ladvise $average_origin)
17670 echo "Average uncached read: $average_origin"
17671 echo "Average speedup with OSS cached read: " \
17672 "$average_cache = +$speedup_cache%"
17673 echo "Average speedup with ladvise willread: " \
17674 "$average_ladvise = +$speedup_ladvise%"
17676 local lowest_speedup=20
17677 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
17678 echo "Speedup with OSS cached read less than $lowest_speedup%," \
17679 "got $average_cache%. Skipping ladvise willread check."
17683 # the test won't work on ZFS until it supports 'ladvise dontneed', but
17684 # it is still good to run until then to exercise 'ladvise willread'
17685 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17686 [ "$ost1_FSTYPE" = "zfs" ] &&
17687 echo "osd-zfs does not support dontneed or drop_caches" &&
17690 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
17691 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
17692 error_not_in_vm "Speedup with willread is less than " \
17693 "$lowest_speedup%, got $average_ladvise%"
17697 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17698 skip "lustre < 2.8.54 does not support ladvise "
17699 remote_ost_nodsh && skip "remote OST with nodsh"
17701 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
17703 ladvise_no_type willread $DIR/$tfile &&
17704 skip "willread ladvise is not supported"
17706 ladvise_no_ioctl $DIR/$tfile &&
17707 skip "ladvise ioctl is not supported"
17710 local size=$((size_mb * 1048576))
17711 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17712 error "dd to $DIR/$tfile failed"
17714 lfs ladvise -a willread $DIR/$tfile ||
17715 error "Ladvise failed with no range argument"
17717 lfs ladvise -a willread -s 0 $DIR/$tfile ||
17718 error "Ladvise failed with no -l or -e argument"
17720 lfs ladvise -a willread -e 1 $DIR/$tfile ||
17721 error "Ladvise failed with only -e argument"
17723 lfs ladvise -a willread -l 1 $DIR/$tfile ||
17724 error "Ladvise failed with only -l argument"
17726 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
17727 error "End offset should not be smaller than start offset"
17729 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
17730 error "End offset should not be equal to start offset"
17732 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
17733 error "Ladvise failed with overflowing -s argument"
17735 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
17736 error "Ladvise failed with overflowing -e argument"
17738 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
17739 error "Ladvise failed with overflowing -l argument"
17741 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
17742 error "Ladvise succeeded with conflicting -l and -e arguments"
17744 echo "Synchronous ladvise should wait"
17746 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
17747 do_nodes $(comma_list $(osts_nodes)) \
17748 $LCTL set_param fail_val=$delay fail_loc=0x237
17750 local start_ts=$SECONDS
17751 lfs ladvise -a willread $DIR/$tfile ||
17752 error "Ladvise failed with no range argument"
17753 local end_ts=$SECONDS
17754 local inteval_ts=$((end_ts - start_ts))
17756 if [ $inteval_ts -lt $(($delay - 1)) ]; then
17757 error "Synchronous advice didn't wait reply"
17760 echo "Asynchronous ladvise shouldn't wait"
17761 local start_ts=$SECONDS
17762 lfs ladvise -a willread -b $DIR/$tfile ||
17763 error "Ladvise failed with no range argument"
17764 local end_ts=$SECONDS
17765 local inteval_ts=$((end_ts - start_ts))
17767 if [ $inteval_ts -gt $(($delay / 2)) ]; then
17768 error "Asynchronous advice blocked"
17771 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
17772 ladvise_willread_performance
17774 run_test 255a "check 'lfs ladvise -a willread'"
17780 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
17784 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17785 skip "lustre < 2.8.54 does not support ladvise "
17786 remote_ost_nodsh && skip "remote OST with nodsh"
17788 lfs setstripe -c 1 -i 0 $DIR/$tfile
17790 ladvise_no_type dontneed $DIR/$tfile &&
17791 skip "dontneed ladvise is not supported"
17793 ladvise_no_ioctl $DIR/$tfile &&
17794 skip "ladvise ioctl is not supported"
17796 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17797 [ "$ost1_FSTYPE" = "zfs" ] &&
17798 skip "zfs-osd does not support 'ladvise dontneed'"
17801 local size=$((size_mb * 1048576))
17802 # In order to prevent disturbance of other processes, only check 3/4
17803 # of the memory usage
17804 local kibibytes=$((size_mb * 1024 * 3 / 4))
17806 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17807 error "dd to $DIR/$tfile failed"
17809 #force write to complete before dropping OST cache & checking memory
17812 local total=$(facet_meminfo ost1 MemTotal)
17813 echo "Total memory: $total KiB"
17815 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
17816 local before_read=$(facet_meminfo ost1 Cached)
17817 echo "Cache used before read: $before_read KiB"
17819 lfs ladvise -a willread $DIR/$tfile ||
17820 error "Ladvise willread failed"
17821 local after_read=$(facet_meminfo ost1 Cached)
17822 echo "Cache used after read: $after_read KiB"
17824 lfs ladvise -a dontneed $DIR/$tfile ||
17825 error "Ladvise dontneed again failed"
17826 local no_read=$(facet_meminfo ost1 Cached)
17827 echo "Cache used after dontneed ladvise: $no_read KiB"
17829 if [ $total -lt $((before_read + kibibytes)) ]; then
17830 echo "Memory is too small, abort checking"
17834 if [ $((before_read + kibibytes)) -gt $after_read ]; then
17835 error "Ladvise willread should use more memory" \
17836 "than $kibibytes KiB"
17839 if [ $((no_read + kibibytes)) -gt $after_read ]; then
17840 error "Ladvise dontneed should release more memory" \
17841 "than $kibibytes KiB"
17844 run_test 255b "check 'lfs ladvise -a dontneed'"
17847 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
17848 skip "lustre < 2.10.50 does not support lockahead"
17850 local ost1_imp=$(get_osc_import_name client ost1)
17851 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
17859 test_mkdir -p $DIR/$tdir
17860 $SETSTRIPE -i 0 $DIR/$tdir
17862 #test 10 returns only success/failure
17864 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17866 if [ $rc -eq 255 ]; then
17867 error "Ladvise test${i} failed, ${rc}"
17870 #test 11 counts lock enqueue requests, all others count new locks
17872 count=$(do_facet ost1 \
17873 $LCTL get_param -n ost.OSS.ost.stats)
17874 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
17876 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17878 if [ $rc -eq 255 ]; then
17879 error "Ladvise test${i} failed, ${rc}"
17882 new_count=$(do_facet ost1 \
17883 $LCTL get_param -n ost.OSS.ost.stats)
17884 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
17885 awk '{ print $2 }')
17887 difference="$((new_count - count))"
17888 if [ $difference -ne $rc ]; then
17889 error "Ladvise test${i}, bad enqueue count, returned " \
17890 "${rc}, actual ${difference}"
17893 for i in $(seq 12 21); do
17894 # If we do not do this, we run the risk of having too many
17895 # locks and starting lock cancellation while we are checking
17897 cancel_lru_locks osc
17899 count=$($LCTL get_param -n \
17900 ldlm.namespaces.$imp_name.lock_unused_count)
17902 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17904 if [ $rc -eq 255 ]; then
17905 error "Ladvise test ${i} failed, ${rc}"
17908 new_count=$($LCTL get_param -n \
17909 ldlm.namespaces.$imp_name.lock_unused_count)
17910 difference="$((new_count - count))"
17912 # Test 15 output is divided by 100 to map down to valid return
17913 if [ $i -eq 15 ]; then
17917 if [ $difference -ne $rc ]; then
17918 error "Ladvise test ${i}, bad lock count, returned " \
17919 "${rc}, actual ${difference}"
17923 #test 22 returns only success/failure
17925 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17927 if [ $rc -eq 255 ]; then
17928 error "Ladvise test${i} failed, ${rc}"
17931 run_test 255c "suite of ladvise lockahead tests"
17934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17935 remote_mds_nodsh && skip "remote MDS with nodsh"
17936 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
17937 changelog_users $SINGLEMDS | grep "^cl" &&
17938 skip "active changelog user"
17944 mdt_dev=$(mdsdevname 1)
17947 changelog_register || error "changelog_register failed"
17950 mkdir -p $DIR/$tdir
17952 changelog_clear 0 || error "changelog_clear failed"
17955 touch $DIR/$tdir/{1..10}
17958 stop $SINGLEMDS || error "Fail to stop MDT"
17962 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
17964 #after mount new plainllog is used
17965 touch $DIR/$tdir/{11..19}
17966 local tmpfile=$(mktemp -u $tfile.XXXXXX)
17967 cat_sl=$(do_facet $SINGLEMDS "sync; \
17968 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17969 llog_reader $tmpfile | grep -c type=1064553b")
17970 do_facet $SINGLEMDS llog_reader $tmpfile
17972 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
17974 changelog_clear 0 || error "changelog_clear failed"
17976 cat_sl=$(do_facet $SINGLEMDS "sync; \
17977 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17978 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
17980 if (( cat_sl == 2 )); then
17981 error "Empty plain llog was not deleted from changelog catalog"
17982 elif (( cat_sl != 1 )); then
17983 error "Active plain llog shouldn't be deleted from catalog"
17986 run_test 256 "Check llog delete for empty and not full state"
17989 remote_mds_nodsh && skip "remote MDS with nodsh"
17990 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
17991 skip "Need MDS version at least 2.8.55"
17993 test_mkdir $DIR/$tdir
17995 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
17996 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
17999 #define OBD_FAIL_MDS_XATTR_REP 0x161
18000 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18001 local facet=mds$((mdtidx + 1))
18002 set_nodes_failloc $(facet_active_host $facet) 0x80000161
18003 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
18005 stop $facet || error "stop MDS failed"
18006 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
18007 error "start MDS fail"
18009 run_test 257 "xattr locks are not lost"
18011 # Verify we take the i_mutex when security requires it
18013 #define OBD_FAIL_IMUTEX_SEC 0x141c
18014 $LCTL set_param fail_loc=0x141c
18016 chmod u+s $DIR/$tfile
18017 chmod a+rwx $DIR/$tfile
18018 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18020 if [ $RC -ne 0 ]; then
18021 error "error, failed to take i_mutex, rc=$?"
18025 run_test 258a "verify i_mutex security behavior when suid attributes is set"
18027 # Verify we do NOT take the i_mutex in the normal case
18029 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
18030 $LCTL set_param fail_loc=0x141d
18033 chmod a+rw $DIR/$tfile
18034 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18036 if [ $RC -ne 0 ]; then
18037 error "error, took i_mutex unnecessarily, rc=$?"
18042 run_test 258b "verify i_mutex security behavior"
18045 local file=$DIR/$tfile
18049 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18051 stack_trap "rm -f $file" EXIT
18053 wait_delete_completed
18054 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18055 echo "before: $before"
18057 $LFS setstripe -i 0 -c 1 $file
18058 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
18060 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18061 echo "after write: $after"
18063 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
18064 do_facet ost1 $LCTL set_param fail_loc=0x2301
18066 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18067 echo "after truncate: $after"
18070 do_facet ost1 $LCTL set_param fail_loc=0
18071 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18073 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18074 echo "after restart: $after"
18075 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
18076 error "missing truncate?"
18080 run_test 259 "crash at delayed truncate"
18083 #define OBD_FAIL_MDC_CLOSE 0x806
18084 $LCTL set_param fail_loc=0x80000806
18088 run_test 260 "Check mdc_close fail"
18090 ### Data-on-MDT sanity tests ###
18092 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18093 skip "Need MDS version at least 2.10.55 for DoM"
18096 local dom=$DIR/$tdir/dom_file
18097 local tmp=$DIR/$tdir/tmp_file
18099 mkdir -p $DIR/$tdir
18101 # basic checks for DoM component creation
18102 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
18103 error "Can set MDT layout to non-first entry"
18105 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
18106 error "Can define multiple entries as MDT layout"
18108 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
18110 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
18111 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
18112 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
18114 local mdtidx=$($LFS getstripe -m $dom)
18115 local mdtname=MDT$(printf %04x $mdtidx)
18116 local facet=mds$((mdtidx + 1))
18117 local space_check=1
18119 # Skip free space checks with ZFS
18120 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
18124 local size_tmp=$((65536 * 3))
18125 local mdtfree1=$(do_facet $facet \
18126 lctl get_param -n osd*.*$mdtname.kbytesfree)
18128 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18129 # check also direct IO along write
18130 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
18131 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18133 cmp $tmp $dom || error "file data is different"
18134 [ $(stat -c%s $dom) == $size_tmp ] ||
18135 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18136 if [ $space_check == 1 ]; then
18137 local mdtfree2=$(do_facet $facet \
18138 lctl get_param -n osd*.*$mdtname.kbytesfree)
18140 # increase in usage from by $size_tmp
18141 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18142 error "MDT free space wrong after write: " \
18143 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18147 local size_dom=10000
18149 $TRUNCATE $dom $size_dom
18150 [ $(stat -c%s $dom) == $size_dom ] ||
18151 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
18152 if [ $space_check == 1 ]; then
18153 mdtfree1=$(do_facet $facet \
18154 lctl get_param -n osd*.*$mdtname.kbytesfree)
18155 # decrease in usage from $size_tmp to new $size_dom
18156 [ $(($mdtfree1 - $mdtfree2)) -ge \
18157 $(((size_tmp - size_dom) / 1024)) ] ||
18158 error "MDT free space is wrong after truncate: " \
18159 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
18165 size_dom=$((size_dom + size_tmp))
18166 [ $(stat -c%s $dom) == $size_dom ] ||
18167 error "bad size after append: $(stat -c%s $dom) != $size_dom"
18168 if [ $space_check == 1 ]; then
18169 mdtfree2=$(do_facet $facet \
18170 lctl get_param -n osd*.*$mdtname.kbytesfree)
18171 # increase in usage by $size_tmp from previous
18172 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18173 error "MDT free space is wrong after append: " \
18174 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18179 if [ $space_check == 1 ]; then
18180 mdtfree1=$(do_facet $facet \
18181 lctl get_param -n osd*.*$mdtname.kbytesfree)
18182 # decrease in usage by $size_dom from previous
18183 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
18184 error "MDT free space is wrong after removal: " \
18185 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
18188 # combined striping
18189 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
18190 error "Can't create DoM + OST striping"
18192 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
18193 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18194 # check also direct IO along write
18195 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18197 cmp $tmp $dom || error "file data is different"
18198 [ $(stat -c%s $dom) == $size_tmp ] ||
18199 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18204 run_test 270a "DoM: basic functionality tests"
18207 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18208 skip "Need MDS version at least 2.10.55"
18210 local dom=$DIR/$tdir/dom_file
18211 local max_size=1048576
18213 mkdir -p $DIR/$tdir
18214 $LFS setstripe -E $max_size -L mdt $dom
18216 # truncate over the limit
18217 $TRUNCATE $dom $(($max_size + 1)) &&
18218 error "successful truncate over the maximum size"
18219 # write over the limit
18220 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
18221 error "successful write over the maximum size"
18222 # append over the limit
18223 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
18224 echo "12345" >> $dom && error "successful append over the maximum size"
18229 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
18232 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18233 skip "Need MDS version at least 2.10.55"
18235 mkdir -p $DIR/$tdir
18236 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18238 # check files inherit DoM EA
18239 touch $DIR/$tdir/first
18240 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
18241 error "bad pattern"
18242 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
18243 error "bad stripe count"
18244 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
18245 error "bad stripe size"
18247 # check directory inherits DoM EA and uses it as default
18248 mkdir $DIR/$tdir/subdir
18249 touch $DIR/$tdir/subdir/second
18250 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
18251 error "bad pattern in sub-directory"
18252 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
18253 error "bad stripe count in sub-directory"
18254 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
18255 error "bad stripe size in sub-directory"
18258 run_test 270c "DoM: DoM EA inheritance tests"
18261 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18262 skip "Need MDS version at least 2.10.55"
18264 mkdir -p $DIR/$tdir
18265 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18267 # inherit default DoM striping
18268 mkdir $DIR/$tdir/subdir
18269 touch $DIR/$tdir/subdir/f1
18271 # change default directory striping
18272 $LFS setstripe -c 1 $DIR/$tdir/subdir
18273 touch $DIR/$tdir/subdir/f2
18274 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
18275 error "wrong default striping in file 2"
18276 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
18277 error "bad pattern in file 2"
18280 run_test 270d "DoM: change striping from DoM to RAID0"
18283 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18284 skip "Need MDS version at least 2.10.55"
18286 mkdir -p $DIR/$tdir/dom
18287 mkdir -p $DIR/$tdir/norm
18290 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
18291 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
18293 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
18294 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
18296 # find DoM files by layout
18297 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
18298 [ $NUM -eq $DOMFILES ] ||
18299 error "lfs find -L: found $NUM, expected $DOMFILES"
18300 echo "Test 1: lfs find 20 DOM files by layout: OK"
18302 # there should be 1 dir with default DOM striping
18303 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
18305 error "lfs find -L: found $NUM, expected 1 dir"
18306 echo "Test 2: lfs find 1 DOM dir by layout: OK"
18308 # find DoM files by stripe size
18309 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
18310 [ $NUM -eq $DOMFILES ] ||
18311 error "lfs find -S: found $NUM, expected $DOMFILES"
18312 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
18314 # find files by stripe offset except DoM files
18315 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
18316 [ $NUM -eq $NORMFILES ] ||
18317 error "lfs find -i: found $NUM, expected $NORMFILES"
18318 echo "Test 5: lfs find no DOM files by stripe index: OK"
18321 run_test 270e "DoM: lfs find with DoM files test"
18324 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18325 skip "Need MDS version at least 2.10.55"
18327 local mdtname=${FSNAME}-MDT0000-mdtlov
18328 local dom=$DIR/$tdir/dom_file
18329 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
18330 lod.$mdtname.dom_stripesize)
18331 local dom_limit=131072
18333 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
18334 local dom_current=$(do_facet mds1 $LCTL get_param -n \
18335 lod.$mdtname.dom_stripesize)
18336 [ ${dom_limit} -eq ${dom_current} ] ||
18337 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
18339 $LFS mkdir -i 0 -c 1 $DIR/$tdir
18340 $LFS setstripe -d $DIR/$tdir
18341 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
18342 error "Can't set directory default striping"
18344 # exceed maximum stripe size
18345 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18346 error "Can't create file with $((dom_limit * 2)) DoM stripe"
18347 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
18348 error "Able to create DoM component size more than LOD limit"
18350 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
18351 dom_current=$(do_facet mds1 $LCTL get_param -n \
18352 lod.$mdtname.dom_stripesize)
18353 [ 0 -eq ${dom_current} ] ||
18354 error "Can't set zero DoM stripe limit"
18357 # attempt to create DoM file on server with disabled DoM should
18358 # remove DoM entry from layout and be succeed
18359 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
18360 error "Can't create DoM file (DoM is disabled)"
18361 [ $($LFS getstripe -L $dom) == "mdt" ] &&
18362 error "File has DoM component while DoM is disabled"
18365 # attempt to create DoM file with only DoM stripe should return error
18366 $LFS setstripe -E $dom_limit -L mdt $dom &&
18367 error "Able to create DoM-only file while DoM is disabled"
18369 # too low values to be aligned with smallest stripe size 64K
18370 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
18371 dom_current=$(do_facet mds1 $LCTL get_param -n \
18372 lod.$mdtname.dom_stripesize)
18373 [ 30000 -eq ${dom_current} ] &&
18374 error "Can set too small DoM stripe limit"
18376 # 64K is a minimal stripe size in Lustre, expect limit of that size
18377 [ 65536 -eq ${dom_current} ] ||
18378 error "Limit is not set to 64K but ${dom_current}"
18380 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
18381 dom_current=$(do_facet mds1 $LCTL get_param -n \
18382 lod.$mdtname.dom_stripesize)
18384 [ 2147483648 -eq ${dom_current} ] &&
18385 error "Can set too large DoM stripe limit"
18387 do_facet mds1 $LCTL set_param -n \
18388 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
18389 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18390 error "Can't create DoM component size after limit change"
18391 do_facet mds1 $LCTL set_param -n \
18392 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
18393 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
18394 error "Can't create DoM file after limit decrease"
18395 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
18396 error "Can create big DoM component after limit decrease"
18397 touch ${dom}_def ||
18398 error "Can't create file with old default layout"
18400 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
18403 run_test 270f "DoM: maximum DoM stripe size checks"
18406 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18407 skip "Need MDS version at least 2.10.55"
18409 local dom=$DIR/$tdir/dom
18411 mkdir -p $DIR/$tdir
18413 $LFS setstripe -E 1024K -L mdt $dom
18415 lctl set_param -n mdc.*.stats=clear
18416 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18417 cat $dom > /dev/null
18418 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
18419 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
18423 run_test 271a "DoM: data is cached for read after write"
18426 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18427 skip "Need MDS version at least 2.10.55"
18429 local dom=$DIR/$tdir/dom
18431 mkdir -p $DIR/$tdir
18433 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18435 lctl set_param -n mdc.*.stats=clear
18436 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18437 cancel_lru_locks mdc
18438 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
18439 # second stat to check size is cached on client
18440 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
18441 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18442 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
18445 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
18448 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18449 skip "Need MDS version at least 2.10.55"
18451 local dom=$DIR/$tdir/dom
18453 mkdir -p $DIR/$tdir
18455 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18457 lctl set_param -n mdc.*.stats=clear
18458 lctl set_param -n osc.*.stats=clear
18459 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
18460 cancel_lru_locks mdc
18461 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18462 # second stat to check size is cached on client
18463 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18464 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18465 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
18466 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
18467 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
18470 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
18476 local mdt=MDT$(printf %04x $mdtidx)
18478 if [ -z $param ]; then
18479 lctl get_param -n mdc.*$mdt*.stats
18481 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
18486 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18487 skip "Need MDS version at least 2.10.55"
18489 local dom=$DIR/$tdir/dom
18491 mkdir -p $DIR/$tdir
18493 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18495 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18496 local facet=mds$((mdtidx + 1))
18498 cancel_lru_locks mdc
18499 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
18500 createmany -o $dom 1000
18501 lctl set_param -n mdc.*.stats=clear
18502 smalliomany -w $dom 1000 200
18503 get_mdc_stats $mdtidx
18504 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18505 # Each file has 1 open, 1 IO enqueues, total 2000
18506 # but now we have also +1 getxattr for security.capability, total 3000
18507 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
18508 unlinkmany $dom 1000
18510 cancel_lru_locks mdc
18511 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
18512 createmany -o $dom 1000
18513 lctl set_param -n mdc.*.stats=clear
18514 smalliomany -w $dom 1000 200
18515 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18516 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
18517 # for OPEN and IO lock.
18518 [ $((enq - enq_2)) -ge 1000 ] ||
18519 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
18520 unlinkmany $dom 1000
18523 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
18525 cleanup_271def_tests() {
18531 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18532 skip "Need MDS version at least 2.10.57"
18534 local dom=$DIR/$tdir/dom
18535 local tmp=$TMP/$tfile
18536 trap "cleanup_271def_tests $tmp" EXIT
18538 mkdir -p $DIR/$tdir
18540 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18542 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18544 cancel_lru_locks mdc
18545 dd if=/dev/urandom of=$tmp bs=1000 count=1
18546 dd if=$tmp of=$dom bs=1000 count=1
18547 cancel_lru_locks mdc
18549 cat /etc/hosts >> $tmp
18550 lctl set_param -n mdc.*.stats=clear
18552 # append data to the same file it should update local page
18553 echo "Append to the same page"
18554 cat /etc/hosts >> $dom
18555 local num=$(get_mdc_stats $mdtidx ost_read)
18556 local ra=$(get_mdc_stats $mdtidx req_active)
18557 local rw=$(get_mdc_stats $mdtidx req_waittime)
18559 [ -z $num ] || error "$num READ RPC occured"
18560 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18564 cmp $tmp $dom || error "file miscompare"
18566 cancel_lru_locks mdc
18567 lctl set_param -n mdc.*.stats=clear
18569 echo "Open and read file"
18570 cat $dom > /dev/null
18571 local num=$(get_mdc_stats $mdtidx ost_read)
18572 local ra=$(get_mdc_stats $mdtidx req_active)
18573 local rw=$(get_mdc_stats $mdtidx req_waittime)
18575 [ -z $num ] || error "$num READ RPC occured"
18576 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18580 cmp $tmp $dom || error "file miscompare"
18584 run_test 271d "DoM: read on open (1K file in reply buffer)"
18587 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18588 skip "Need MDS version at least 2.10.57"
18590 local dom=$DIR/$tdir/dom
18591 local tmp=$TMP/$tfile
18592 trap "cleanup_271def_tests $tmp" EXIT
18594 mkdir -p $DIR/$tdir
18596 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18598 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18600 cancel_lru_locks mdc
18601 dd if=/dev/urandom of=$tmp bs=200000 count=1
18602 dd if=$tmp of=$dom bs=200000 count=1
18603 cancel_lru_locks mdc
18604 cat /etc/hosts >> $tmp
18605 lctl set_param -n mdc.*.stats=clear
18607 echo "Append to the same page"
18608 cat /etc/hosts >> $dom
18609 local num=$(get_mdc_stats $mdtidx ost_read)
18610 local ra=$(get_mdc_stats $mdtidx req_active)
18611 local rw=$(get_mdc_stats $mdtidx req_waittime)
18613 [ -z $num ] || error "$num READ RPC occured"
18614 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18618 cmp $tmp $dom || error "file miscompare"
18620 cancel_lru_locks mdc
18621 lctl set_param -n mdc.*.stats=clear
18623 echo "Open and read file"
18624 cat $dom > /dev/null
18625 local num=$(get_mdc_stats $mdtidx ost_read)
18626 local ra=$(get_mdc_stats $mdtidx req_active)
18627 local rw=$(get_mdc_stats $mdtidx req_waittime)
18629 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
18630 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18634 cmp $tmp $dom || error "file miscompare"
18638 run_test 271f "DoM: read on open (200K file and read tail)"
18641 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
18642 skip "Skipping due to old client or server version"
18644 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
18646 $CHECKSTAT -t file $DIR1/$tfile
18648 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
18651 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
18652 $LCTL set_param fail_loc=0x80000314
18653 rm $DIR1/$tfile || error "Unlink fails"
18655 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
18656 [ $RC -eq 0 ] || error "Failed write to stale object"
18658 run_test 271g "Discard DoM data vs client flush race"
18661 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18662 skip "Need MDS version at least 2.11.50"
18664 local dom=$DIR/$tdir/dom
18665 mkdir -p $DIR/$tdir
18667 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
18668 dd if=/dev/urandom of=$dom bs=512K count=1 ||
18669 error "failed to write data into $dom"
18670 local old_md5=$(md5sum $dom)
18672 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
18673 error "failed to migrate to the same DoM component"
18675 [ $($LFS getstripe -c $dom) -eq 2 ] ||
18676 error "layout was not changed silently"
18678 local new_md5=$(md5sum $dom)
18680 [ "$old_md5" != "$new_md5" ] &&
18681 error "md5sum differ: $old_md5, $new_md5"
18684 run_test 272a "DoM migration: new layout with the same DOM component"
18687 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18688 skip "Need MDS version at least 2.11.50"
18690 local dom=$DIR/$tdir/dom
18691 mkdir -p $DIR/$tdir
18692 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18694 local mdtidx=$($LFS getstripe -m $dom)
18695 local mdtname=MDT$(printf %04x $mdtidx)
18696 local facet=mds$((mdtidx + 1))
18698 local mdtfree1=$(do_facet $facet \
18699 lctl get_param -n osd*.*$mdtname.kbytesfree)
18700 dd if=/dev/urandom of=$dom bs=2M count=1 ||
18701 error "failed to write data into $dom"
18702 local old_md5=$(md5sum $dom)
18703 cancel_lru_locks mdc
18704 local mdtfree1=$(do_facet $facet \
18705 lctl get_param -n osd*.*$mdtname.kbytesfree)
18707 $LFS migrate -c2 $dom ||
18708 error "failed to migrate to the new composite layout"
18709 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18710 error "MDT stripe was not removed"
18712 cancel_lru_locks mdc
18713 local new_md5=$(md5sum $dom)
18714 [ "$old_md5" != "$new_md5" ] &&
18715 error "$old_md5 != $new_md5"
18717 # Skip free space checks with ZFS
18718 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18719 local mdtfree2=$(do_facet $facet \
18720 lctl get_param -n osd*.*$mdtname.kbytesfree)
18721 [ $mdtfree2 -gt $mdtfree1 ] ||
18722 error "MDT space is not freed after migration"
18726 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
18729 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18730 skip "Need MDS version at least 2.11.50"
18732 local dom=$DIR/$tdir/$tfile
18733 mkdir -p $DIR/$tdir
18734 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18736 local mdtidx=$($LFS getstripe -m $dom)
18737 local mdtname=MDT$(printf %04x $mdtidx)
18738 local facet=mds$((mdtidx + 1))
18740 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
18741 error "failed to write data into $dom"
18742 local old_md5=$(md5sum $dom)
18743 cancel_lru_locks mdc
18744 local mdtfree1=$(do_facet $facet \
18745 lctl get_param -n osd*.*$mdtname.kbytesfree)
18747 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
18748 error "failed to migrate to the new composite layout"
18749 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18750 error "MDT stripe was not removed"
18752 cancel_lru_locks mdc
18753 local new_md5=$(md5sum $dom)
18754 [ "$old_md5" != "$new_md5" ] &&
18755 error "$old_md5 != $new_md5"
18757 # Skip free space checks with ZFS
18758 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18759 local mdtfree2=$(do_facet $facet \
18760 lctl get_param -n osd*.*$mdtname.kbytesfree)
18761 [ $mdtfree2 -gt $mdtfree1 ] ||
18762 error "MDS space is not freed after migration"
18766 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
18769 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18770 skip "Need MDS version at least 2.11.50"
18772 # Layout swap cannot be done if either file has DOM component,
18773 # this will never be supported, migration should be used instead
18775 local dom=$DIR/$tdir/$tfile
18776 mkdir -p $DIR/$tdir
18778 $LFS setstripe -c2 ${dom}_plain
18779 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
18780 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
18781 error "can swap layout with DoM component"
18782 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
18783 error "can swap layout with DoM component"
18785 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
18786 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
18787 error "can swap layout with DoM component"
18788 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
18789 error "can swap layout with DoM component"
18792 run_test 273a "DoM: layout swapping should fail with DOM"
18795 remote_ost_nodsh && skip "remote OST with nodsh"
18796 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
18797 skip "Need OST version >= 2.10.57"
18799 local file=$DIR/$tfile
18802 oss=$(comma_list $(osts_nodes))
18804 dd if=/dev/urandom of=$file bs=1M count=2 ||
18805 error "failed to create a file"
18806 cancel_lru_locks osc
18809 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18810 error "failed to read a file"
18812 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
18813 $LCTL set_param fail_loc=0x8000031f
18815 cancel_lru_locks osc &
18818 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
18819 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
18820 #IO takes another lock, but matches the PENDING one
18821 #and places it to the IO RPC
18822 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18823 error "failed to read a file with PENDING lock"
18825 run_test 275 "Read on a canceled duplicate lock"
18828 remote_ost_nodsh && skip "remote OST with nodsh"
18831 do_facet ost1 "(while true; do \
18832 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
18833 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
18836 for LOOP in $(seq 20); do
18838 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
18841 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
18842 rm $TMP/sanity_276_pid"
18844 run_test 276 "Race between mount and obd_statfs"
18846 cleanup_test_300() {
18850 test_striped_dir() {
18855 mkdir -p $DIR/$tdir
18857 SAVE_UMASK=$(umask)
18858 trap cleanup_test_300 RETURN EXIT
18860 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
18861 $DIR/$tdir/striped_dir ||
18862 error "set striped dir error"
18864 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
18865 [ "$mode" = "755" ] || error "expect 755 got $mode"
18867 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
18868 error "getdirstripe failed"
18869 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
18870 if [ "$stripe_count" != "2" ]; then
18871 error "1:stripe_count is $stripe_count, expect 2"
18873 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
18874 if [ "$stripe_count" != "2" ]; then
18875 error "2:stripe_count is $stripe_count, expect 2"
18878 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
18879 if [ "$stripe_index" != "$mdt_index" ]; then
18880 error "stripe_index is $stripe_index, expect $mdt_index"
18883 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18884 error "nlink error after create striped dir"
18886 mkdir $DIR/$tdir/striped_dir/a
18887 mkdir $DIR/$tdir/striped_dir/b
18889 stat $DIR/$tdir/striped_dir/a ||
18890 error "create dir under striped dir failed"
18891 stat $DIR/$tdir/striped_dir/b ||
18892 error "create dir under striped dir failed"
18894 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
18895 error "nlink error after mkdir"
18897 rmdir $DIR/$tdir/striped_dir/a
18898 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
18899 error "nlink error after rmdir"
18901 rmdir $DIR/$tdir/striped_dir/b
18902 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18903 error "nlink error after rmdir"
18905 chattr +i $DIR/$tdir/striped_dir
18906 createmany -o $DIR/$tdir/striped_dir/f 10 &&
18907 error "immutable flags not working under striped dir!"
18908 chattr -i $DIR/$tdir/striped_dir
18910 rmdir $DIR/$tdir/striped_dir ||
18911 error "rmdir striped dir error"
18919 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18920 skip "skipped for lustre < 2.7.0"
18921 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18922 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18924 test_striped_dir 0 || error "failed on striped dir on MDT0"
18925 test_striped_dir 1 || error "failed on striped dir on MDT0"
18927 run_test 300a "basic striped dir sanity test"
18930 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18931 skip "skipped for lustre < 2.7.0"
18932 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18933 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18940 test_mkdir $DIR/$tdir || error "mkdir fail"
18941 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18942 error "set striped dir error"
18943 for i in {0..9}; do
18944 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
18946 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
18947 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
18948 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
18950 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
18951 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
18952 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
18956 run_test 300b "check ctime/mtime for striped dir"
18959 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18960 skip "skipped for lustre < 2.7.0"
18961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18962 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18966 mkdir -p $DIR/$tdir
18967 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
18968 error "set striped dir error"
18970 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
18971 error "chown striped dir failed"
18973 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
18974 error "create 5k files failed"
18976 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
18978 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
18982 run_test 300c "chown && check ls under striped directory"
18985 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18986 skip "skipped for lustre < 2.7.0"
18987 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18988 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18993 mkdir -p $DIR/$tdir
18994 $SETSTRIPE -c 2 $DIR/$tdir
18996 #local striped directory
18997 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18998 error "set striped dir error"
18999 #look at the directories for debug purposes
19001 $LFS getdirstripe $DIR/$tdir
19002 ls -l $DIR/$tdir/striped_dir
19003 $LFS getdirstripe $DIR/$tdir/striped_dir
19004 createmany -o $DIR/$tdir/striped_dir/f 10 ||
19005 error "create 10 files failed"
19007 #remote striped directory
19008 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
19009 error "set striped dir error"
19010 #look at the directories for debug purposes
19012 $LFS getdirstripe $DIR/$tdir
19013 ls -l $DIR/$tdir/remote_striped_dir
19014 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
19015 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
19016 error "create 10 files failed"
19018 for file in $(find $DIR/$tdir); do
19019 stripe_count=$($LFS getstripe -c $file)
19020 [ $stripe_count -eq 2 ] ||
19021 error "wrong stripe $stripe_count for $file"
19026 run_test 300d "check default stripe under striped directory"
19029 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19030 skip "Need MDS version at least 2.7.55"
19031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19032 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19037 mkdir -p $DIR/$tdir
19039 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19040 error "set striped dir error"
19042 touch $DIR/$tdir/striped_dir/a
19043 touch $DIR/$tdir/striped_dir/b
19044 touch $DIR/$tdir/striped_dir/c
19046 mkdir $DIR/$tdir/striped_dir/dir_a
19047 mkdir $DIR/$tdir/striped_dir/dir_b
19048 mkdir $DIR/$tdir/striped_dir/dir_c
19050 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
19051 error "set striped adir under striped dir error"
19053 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
19054 error "set striped bdir under striped dir error"
19056 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
19057 error "set striped cdir under striped dir error"
19059 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
19060 error "rename dir under striped dir fails"
19062 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
19063 error "rename dir under different stripes fails"
19065 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
19066 error "rename file under striped dir should succeed"
19068 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
19069 error "rename dir under striped dir should succeed"
19073 run_test 300e "check rename under striped directory"
19076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19077 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19078 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19079 skip "Need MDS version at least 2.7.55"
19085 mkdir -p $DIR/$tdir
19087 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19088 error "set striped dir error"
19090 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
19091 error "set striped dir error"
19093 touch $DIR/$tdir/striped_dir/a
19094 mkdir $DIR/$tdir/striped_dir/dir_a
19095 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
19096 error "create striped dir under striped dir fails"
19098 touch $DIR/$tdir/striped_dir1/b
19099 mkdir $DIR/$tdir/striped_dir1/dir_b
19100 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
19101 error "create striped dir under striped dir fails"
19103 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
19104 error "rename dir under different striped dir should fail"
19106 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
19107 error "rename striped dir under diff striped dir should fail"
19109 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
19110 error "rename file under diff striped dirs fails"
19114 run_test 300f "check rename cross striped directory"
19116 test_300_check_default_striped_dir()
19119 local default_count=$2
19120 local default_index=$3
19123 local dir_stripe_index
19126 echo "checking $dirname $default_count $default_index"
19127 $LFS setdirstripe -D -c $default_count -i $default_index \
19128 -t all_char $DIR/$tdir/$dirname ||
19129 error "set default stripe on striped dir error"
19130 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
19131 [ $stripe_count -eq $default_count ] ||
19132 error "expect $default_count get $stripe_count for $dirname"
19134 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
19135 [ $stripe_index -eq $default_index ] ||
19136 error "expect $default_index get $stripe_index for $dirname"
19138 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
19139 error "create dirs failed"
19141 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
19142 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
19143 for dir in $(find $DIR/$tdir/$dirname/*); do
19144 stripe_count=$($LFS getdirstripe -c $dir)
19145 [ $stripe_count -eq $default_count ] ||
19146 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
19147 error "stripe count $default_count != $stripe_count for $dir"
19149 stripe_index=$($LFS getdirstripe -i $dir)
19150 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
19151 error "$stripe_index != $default_index for $dir"
19153 #check default stripe
19154 stripe_count=$($LFS getdirstripe -D -c $dir)
19155 [ $stripe_count -eq $default_count ] ||
19156 error "default count $default_count != $stripe_count for $dir"
19158 stripe_index=$($LFS getdirstripe -D -i $dir)
19159 [ $stripe_index -eq $default_index ] ||
19160 error "default index $default_index != $stripe_index for $dir"
19162 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
19166 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19167 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19168 skip "Need MDS version at least 2.7.55"
19175 mkdir $DIR/$tdir/normal_dir
19177 #Checking when client cache stripe index
19178 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
19179 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
19180 error "create striped_dir failed"
19182 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
19183 error "create dir0 fails"
19184 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
19185 [ $stripe_index -eq 0 ] ||
19186 error "dir0 expect index 0 got $stripe_index"
19188 mkdir $DIR/$tdir/striped_dir/dir1 ||
19189 error "create dir1 fails"
19190 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
19191 [ $stripe_index -eq 1 ] ||
19192 error "dir1 expect index 1 got $stripe_index"
19194 #check default stripe count/stripe index
19195 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
19196 test_300_check_default_striped_dir normal_dir 1 0
19197 test_300_check_default_striped_dir normal_dir 2 1
19198 test_300_check_default_striped_dir normal_dir 2 -1
19200 #delete default stripe information
19201 echo "delete default stripeEA"
19202 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
19203 error "set default stripe on striped dir error"
19205 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
19206 for dir in $(find $DIR/$tdir/normal_dir/*); do
19207 stripe_count=$($LFS getdirstripe -c $dir)
19208 [ $stripe_count -eq 0 ] ||
19209 error "expect 1 get $stripe_count for $dir"
19210 stripe_index=$($LFS getdirstripe -i $dir)
19211 [ $stripe_index -eq 0 ] ||
19212 error "expect 0 get $stripe_index for $dir"
19215 run_test 300g "check default striped directory for normal directory"
19218 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19219 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19220 skip "Need MDS version at least 2.7.55"
19226 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19227 error "set striped dir error"
19229 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
19230 test_300_check_default_striped_dir striped_dir 1 0
19231 test_300_check_default_striped_dir striped_dir 2 1
19232 test_300_check_default_striped_dir striped_dir 2 -1
19234 #delete default stripe information
19235 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
19236 error "set default stripe on striped dir error"
19238 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
19239 for dir in $(find $DIR/$tdir/striped_dir/*); do
19240 stripe_count=$($LFS getdirstripe -c $dir)
19241 [ $stripe_count -eq 0 ] ||
19242 error "expect 1 get $stripe_count for $dir"
19245 run_test 300h "check default striped directory for striped directory"
19248 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19249 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19250 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19251 skip "Need MDS version at least 2.7.55"
19258 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19259 error "set striped dir error"
19261 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19262 error "create files under striped dir failed"
19264 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
19265 error "set striped hashdir error"
19267 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
19268 error "create dir0 under hash dir failed"
19269 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
19270 error "create dir1 under hash dir failed"
19272 # unfortunately, we need to umount to clear dir layout cache for now
19273 # once we fully implement dir layout, we can drop this
19274 umount_client $MOUNT || error "umount failed"
19275 mount_client $MOUNT || error "mount failed"
19277 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
19278 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
19279 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
19281 #set the stripe to be unknown hash type
19282 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
19283 $LCTL set_param fail_loc=0x1901
19284 for ((i = 0; i < 10; i++)); do
19285 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
19286 error "stat f-$i failed"
19287 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
19290 touch $DIR/$tdir/striped_dir/f0 &&
19291 error "create under striped dir with unknown hash should fail"
19293 $LCTL set_param fail_loc=0
19295 umount_client $MOUNT || error "umount failed"
19296 mount_client $MOUNT || error "mount failed"
19300 run_test 300i "client handle unknown hash type striped directory"
19303 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19304 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19305 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19306 skip "Need MDS version at least 2.7.55"
19313 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
19314 $LCTL set_param fail_loc=0x1702
19315 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19316 error "set striped dir error"
19318 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19319 error "create files under striped dir failed"
19321 $LCTL set_param fail_loc=0
19323 rm -rf $DIR/$tdir || error "unlink striped dir fails"
19327 run_test 300j "test large update record"
19330 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19331 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19332 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19333 skip "Need MDS version at least 2.7.55"
19340 #define OBD_FAIL_LARGE_STRIPE 0x1703
19341 $LCTL set_param fail_loc=0x1703
19342 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
19343 error "set striped dir error"
19344 $LCTL set_param fail_loc=0
19346 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19347 error "getstripeddir fails"
19348 rm -rf $DIR/$tdir/striped_dir ||
19349 error "unlink striped dir fails"
19353 run_test 300k "test large striped directory"
19356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19357 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19358 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19359 skip "Need MDS version at least 2.7.55"
19363 test_mkdir -p $DIR/$tdir/striped_dir
19364 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
19365 error "chown $RUNAS_ID failed"
19366 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
19367 error "set default striped dir failed"
19369 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
19370 $LCTL set_param fail_loc=0x80000158
19371 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
19373 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
19374 [ $stripe_index -eq 1 ] ||
19375 error "expect 1 get $stripe_index for $dir"
19377 run_test 300l "non-root user to create dir under striped dir with stale layout"
19380 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19381 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
19382 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19383 skip "Need MDS version at least 2.7.55"
19385 mkdir -p $DIR/$tdir/striped_dir
19386 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
19387 error "set default stripes dir error"
19389 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
19391 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
19392 [ $stripe_count -eq 0 ] ||
19393 error "expect 0 get $stripe_count for a"
19395 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
19396 error "set default stripes dir error"
19398 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
19400 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
19401 [ $stripe_count -eq 0 ] ||
19402 error "expect 0 get $stripe_count for b"
19404 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
19405 error "set default stripes dir error"
19407 mkdir $DIR/$tdir/striped_dir/c &&
19408 error "default stripe_index is invalid, mkdir c should fails"
19410 rm -rf $DIR/$tdir || error "rmdir fails"
19412 run_test 300m "setstriped directory on single MDT FS"
19415 local list=$(comma_list $(mdts_nodes))
19418 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19422 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19423 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19424 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19425 skip "Need MDS version at least 2.7.55"
19426 remote_mds_nodsh && skip "remote MDS with nodsh"
19429 local list=$(comma_list $(mdts_nodes))
19431 trap cleanup_300n RETURN EXIT
19432 mkdir -p $DIR/$tdir
19433 chmod 777 $DIR/$tdir
19434 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
19435 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19436 error "create striped dir succeeds with gid=0"
19438 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19439 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
19440 error "create striped dir fails with gid=-1"
19442 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19443 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
19444 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19445 error "set default striped dir succeeds with gid=0"
19448 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19449 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
19450 error "set default striped dir fails with gid=-1"
19453 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19454 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
19455 error "create test_dir fails"
19456 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
19457 error "create test_dir1 fails"
19458 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
19459 error "create test_dir2 fails"
19462 run_test 300n "non-root user to create dir under striped dir with default EA"
19465 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19466 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19467 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19468 skip "Need MDS version at least 2.7.55"
19473 mkdir -p $DIR/$tdir
19475 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
19476 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
19477 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
19478 skip "not enough free inodes $numfree1 $numfree2"
19481 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
19482 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
19483 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
19484 skip "not enough free space $numfree1 $numfree2"
19487 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
19488 error "setdirstripe fails"
19490 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
19491 error "create dirs fails"
19493 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
19494 ls $DIR/$tdir/striped_dir > /dev/null ||
19495 error "ls striped dir fails"
19496 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
19497 error "unlink big striped dir fails"
19499 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
19502 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19503 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19504 remote_mds_nodsh && skip "remote MDS with nodsh"
19506 mkdir -p $DIR/$tdir
19508 #define OBD_FAIL_OUT_ENOSPC 0x1704
19509 do_facet mds2 lctl set_param fail_loc=0x80001704
19510 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
19511 && error "create striped directory should fail"
19513 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
19515 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
19518 run_test 300p "create striped directory without space"
19521 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19522 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19524 local fd=$(free_fd)
19525 local cmd="exec $fd<$tdir"
19527 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
19530 trap "eval $cmd" EXIT
19531 cd $tdir || error "cd $tdir fails"
19532 rmdir ../$tdir || error "rmdir $tdir fails"
19533 mkdir local_dir && error "create dir succeeds"
19534 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
19538 run_test 300q "create remote directory under orphan directory"
19541 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
19542 skip "Need MDS version at least 2.7.55" && return
19543 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19547 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
19548 error "set striped dir error"
19550 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19551 error "getstripeddir fails"
19554 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
19555 awk '/lmv_stripe_count:/ { print $2 }')
19557 [ $MDSCOUNT -ne $stripe_count ] &&
19558 error "wrong stripe count $stripe_count expected $MDSCOUNT"
19560 rm -rf $DIR/$tdir/striped_dir ||
19561 error "unlink striped dir fails"
19563 run_test 300r "test -1 striped directory"
19565 test_300s_helper() {
19568 local stripe_dir=$DIR/$tdir/striped_dir.$count
19570 $LFS mkdir -c $count $stripe_dir ||
19571 error "lfs mkdir -c error"
19573 $LFS getdirstripe $stripe_dir ||
19574 error "lfs getdirstripe fails"
19577 stripe_count=$($LFS getdirstripe $stripe_dir |
19578 awk '/lmv_stripe_count:/ { print $2 }')
19580 [ $count -ne $stripe_count ] &&
19581 error_noexit "bad stripe count $stripe_count expected $count"
19584 dupe_stripes=$($LFS getdirstripe $stripe_dir |
19585 awk '/0x/ {count[$1] += 1}; END {
19586 for (idx in count) {
19587 if (count[idx]>1) {
19588 print "index " idx " count " count[idx]
19593 if [[ -n "$dupe_stripes" ]] ; then
19594 lfs getdirstripe $stripe_dir
19595 error_noexit "Dupe MDT above: $dupe_stripes "
19598 rm -rf $stripe_dir ||
19599 error_noexit "unlink $stripe_dir fails"
19603 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19604 skip "Need MDS version at least 2.7.55" && return
19605 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19608 for count in $(seq 2 $MDSCOUNT); do
19609 test_300s_helper $count
19612 run_test 300s "test lfs mkdir -c without -i"
19615 prepare_remote_file() {
19616 mkdir $DIR/$tdir/src_dir ||
19617 error "create remote source failed"
19619 cp /etc/hosts $DIR/$tdir/src_dir/a ||
19620 error "cp to remote source failed"
19621 touch $DIR/$tdir/src_dir/a
19623 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
19624 error "create remote target dir failed"
19626 touch $DIR/$tdir/tgt_dir/b
19628 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
19629 error "rename dir cross MDT failed!"
19631 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
19632 error "src_child still exists after rename"
19634 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
19635 error "missing file(a) after rename"
19637 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
19638 error "diff after rename"
19642 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19645 local remote_file=$DIR/$tdir/tgt_dir/b
19647 mkdir -p $DIR/$tdir
19649 prepare_remote_file || error "prepare remote file failed"
19652 $OPENUNLINK $remote_file $remote_file ||
19653 error "openunlink $remote_file failed"
19654 $CHECKSTAT -a $remote_file || error "$remote_file exists"
19656 run_test 310a "open unlink remote file"
19659 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19662 local remote_file=$DIR/$tdir/tgt_dir/b
19664 mkdir -p $DIR/$tdir
19666 prepare_remote_file || error "prepare remote file failed"
19668 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19669 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
19670 $CHECKSTAT -t file $remote_file || error "check file failed"
19672 run_test 310b "unlink remote file with multiple links while open"
19675 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19676 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
19678 local remote_file=$DIR/$tdir/tgt_dir/b
19680 mkdir -p $DIR/$tdir
19682 prepare_remote_file || error "prepare remote file failed"
19684 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19685 multiop_bg_pause $remote_file O_uc ||
19686 error "mulitop failed for remote file"
19688 $MULTIOP $DIR/$tfile Ouc
19689 kill -USR1 $MULTIPID
19692 run_test 310c "open-unlink remote file with multiple links"
19696 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19697 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19698 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
19699 skip "lustre < 2.8.54 does not contain LU-4825 fix"
19700 remote_mds_nodsh && skip "remote MDS with nodsh"
19702 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19703 local mdts=$(comma_list $(mdts_nodes))
19705 mkdir -p $DIR/$tdir
19706 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
19707 createmany -o $DIR/$tdir/$tfile. 1000
19709 # statfs data is not real time, let's just calculate it
19710 old_iused=$((old_iused + 1000))
19712 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19713 osp.*OST0000*MDT0000.create_count")
19714 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19715 osp.*OST0000*MDT0000.max_create_count")
19716 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
19718 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
19719 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
19720 [ $index -ne 0 ] || error "$tfile stripe index is 0"
19722 unlinkmany $DIR/$tdir/$tfile. 1000
19724 do_nodes $mdts "$LCTL set_param -n \
19725 osp.*OST0000*.max_create_count=$max_count"
19726 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
19727 do_nodes $mdts "$LCTL set_param -n \
19728 osp.*OST0000*.create_count=$count"
19729 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
19730 grep "=0" && error "create_count is zero"
19733 for i in $(seq 120); do
19734 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19735 # system may be too busy to destroy all objs in time, use
19736 # a somewhat small value to not fail autotest
19737 [ $((old_iused - new_iused)) -gt 400 ] && break
19741 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
19742 [ $((old_iused - new_iused)) -gt 400 ] ||
19743 error "objs not destroyed after unlink"
19745 run_test 311 "disable OSP precreate, and unlink should destroy objs"
19752 local vdevdir=$(dirname $(facet_vdevice $ost))
19753 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
19754 local zfs_zapid=$(do_facet $ost $cmd |
19755 grep -w "/O/0/d$((objid%32))" -C 5 |
19756 awk '/Object/{getline; print $1}')
19757 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
19758 awk "/$objid = /"'{printf $3}')
19763 zfs_object_blksz() {
19767 local vdevdir=$(dirname $(facet_vdevice $ost))
19768 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
19769 local blksz=$(do_facet $ost $cmd $objid |
19770 awk '/dblk/{getline; printf $4}')
19772 case "${blksz: -1}" in
19773 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
19774 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
19781 test_312() { # LU-4856
19782 remote_ost_nodsh && skip "remote OST with nodsh"
19783 [ "$ost1_FSTYPE" = "zfs" ] ||
19784 skip_env "the test only applies to zfs"
19786 local max_blksz=$(do_facet ost1 \
19787 $ZFS get -p recordsize $(facet_device ost1) |
19788 awk '!/VALUE/{print $3}')
19790 # to make life a little bit easier
19791 $LFS mkdir -c 1 -i 0 $DIR/$tdir
19792 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19794 local tf=$DIR/$tdir/$tfile
19796 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19798 # Get ZFS object id
19799 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19800 # block size change by sequential overwrite
19803 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
19804 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
19806 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
19807 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
19811 # block size change by sequential append write
19812 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
19813 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19814 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19817 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
19818 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
19819 oflag=sync conv=notrunc
19821 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19822 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
19823 error "blksz error, actual $blksz, " \
19824 "expected: 2 * $count * $PAGE_SIZE"
19830 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19831 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19833 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
19834 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19835 [ $blksz -eq $PAGE_SIZE ] ||
19836 error "blksz error: $blksz, expected: $PAGE_SIZE"
19838 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
19839 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19840 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
19842 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
19843 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19844 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
19846 run_test 312 "make sure ZFS adjusts its block size by write pattern"
19849 remote_ost_nodsh && skip "remote OST with nodsh"
19851 local file=$DIR/$tfile
19854 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
19856 # define OBD_FAIL_TGT_RCVD_EIO 0x720
19857 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19858 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
19859 error "write should failed"
19860 do_facet ost1 "$LCTL set_param fail_loc=0"
19863 run_test 313 "io should fail after last_rcvd update fail"
19866 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19868 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
19869 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19871 wait_delete_completed
19872 do_facet ost1 "$LCTL set_param fail_loc=0"
19874 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
19876 test_315() { # LU-618
19877 local file=$DIR/$tfile
19880 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
19881 error "multiop file write failed"
19882 $MULTIOP $file oO_RDONLY:r4063232_c &
19887 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
19890 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
19893 run_test 315 "read should be accounted"
19896 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19897 large_xattr_enabled || skip_env "ea_inode feature disabled"
19899 rm -rf $DIR/$tdir/d
19900 mkdir -p $DIR/$tdir/d
19901 chown nobody $DIR/$tdir/d
19902 touch $DIR/$tdir/d/file
19904 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
19906 run_test 316 "lfs mv"
19909 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
19910 skip "Need MDS version at least 2.11.53"
19911 if [ "$ost1_FSTYPE" == "zfs" ]; then
19912 skip "LU-10370: no implementation for ZFS"
19916 local grant_blk_size
19918 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
19919 awk '/grant_block_size:/ { print $2; exit; }')
19921 # Create File of size 5M. Truncate it to below size's and verify
19924 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
19925 error "Create file $DIR/$tfile failed"
19926 stack_trap "rm -f $DIR/$tfile" EXIT
19928 for trunc_sz in 2097152 4097 4000 509 0; do
19929 $TRUNCATE $DIR/$tfile $trunc_sz ||
19930 error "truncate $tfile to $trunc_sz failed"
19931 local sz=$(stat --format=%s $DIR/$tfile)
19932 local blk=$(stat --format=%b $DIR/$tfile)
19933 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
19934 grant_blk_size) * 8))
19936 if [[ $blk -ne $trunc_blk ]]; then
19937 $(which stat) $DIR/$tfile
19938 error "Expected Block $trunc_blk got $blk for $tfile"
19941 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19942 error "Expected Size $trunc_sz got $sz for $tfile"
19947 # Create file with a hole and write actual two blocks. Block count
19950 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
19951 conv=fsync || error "Create file : $DIR/$tfile"
19953 # Calculate the final truncate size.
19954 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
19957 # truncate to size $trunc_sz bytes. Strip the last block
19958 # The block count must drop to 8
19960 $TRUNCATE $DIR/$tfile $trunc_sz ||
19961 error "truncate $tfile to $trunc_sz failed"
19963 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
19964 sz=$(stat --format=%s $DIR/$tfile)
19965 blk=$(stat --format=%b $DIR/$tfile)
19967 if [[ $blk -ne $trunc_bsz ]]; then
19968 $(which stat) $DIR/$tfile
19969 error "Expected Block $trunc_bsz got $blk for $tfile"
19972 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19973 error "Expected Size $trunc_sz got $sz for $tfile"
19975 run_test 317 "Verify blocks get correctly update after truncate"
19978 local read_write=$1
19979 if [ "$read_write" = "write" ]; then
19980 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
19981 elif [ "$read_write" = "read" ]; then
19982 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
19984 error "argument error"
19987 # turn off debug for performance testing
19988 local saved_debug=$($LCTL get_param -n debug)
19989 $LCTL set_param debug=0
19991 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
19993 # get ost1 size - lustre-OST0000
19994 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
19995 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
19996 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
19998 if [ "$read_write" = "read" ]; then
19999 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
20002 local start_time=$(date +%s.%N)
20003 $dd_cmd bs=1M count=$blocks oflag=sync ||
20004 error "real dd $read_write error"
20005 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
20007 if [ "$read_write" = "write" ]; then
20011 # define OBD_FAIL_OST_FAKE_RW 0x238
20012 do_facet ost1 $LCTL set_param fail_loc=0x238
20014 local start_time=$(date +%s.%N)
20015 $dd_cmd bs=1M count=$blocks oflag=sync ||
20016 error "fake dd $read_write error"
20017 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
20019 if [ "$read_write" = "write" ]; then
20021 cancel_lru_locks osc
20022 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
20023 error "$tfile size not $blocks MB"
20025 do_facet ost1 $LCTL set_param fail_loc=0
20027 echo "fake $read_write $duration_fake vs. normal $read_write" \
20028 "$duration in seconds"
20029 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
20030 error_not_in_vm "fake write is slower"
20032 $LCTL set_param -n debug="$saved_debug"
20035 test_399a() { # LU-7655 for OST fake write
20036 remote_ost_nodsh && skip "remote OST with nodsh"
20040 run_test 399a "fake write should not be slower than normal write"
20042 test_399b() { # LU-8726 for OST fake read
20043 remote_ost_nodsh && skip "remote OST with nodsh"
20044 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
20045 skip_env "ldiskfs only test"
20050 run_test 399b "fake read should not be slower than normal read"
20052 test_400a() { # LU-1606, was conf-sanity test_74
20053 if ! which $CC > /dev/null 2>&1; then
20054 skip_env "$CC is not installed"
20057 local extra_flags=''
20058 local out=$TMP/$tfile
20059 local prefix=/usr/include/lustre
20062 # Oleg removes c files in his test rig so test if any c files exist
20063 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
20064 skip_env "Needed c test files are missing"
20066 if ! [[ -d $prefix ]]; then
20067 # Assume we're running in tree and fixup the include path.
20068 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
20069 extra_flags+=" -L$LUSTRE/utils/.lib"
20072 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
20073 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
20074 error "client api broken"
20078 run_test 400a "Lustre client api program can compile and link"
20080 test_400b() { # LU-1606, LU-5011
20082 local out=$TMP/$tfile
20083 local prefix=/usr/include/linux/lustre
20085 # We use a hard coded prefix so that this test will not fail
20086 # when run in tree. There are headers in lustre/include/lustre/
20087 # that are not packaged (like lustre_idl.h) and have more
20088 # complicated include dependencies (like config.h and lnet/types.h).
20089 # Since this test about correct packaging we just skip them when
20090 # they don't exist (see below) rather than try to fixup cppflags.
20092 if ! which $CC > /dev/null 2>&1; then
20093 skip_env "$CC is not installed"
20096 for header in $prefix/*.h; do
20097 if ! [[ -f "$header" ]]; then
20101 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
20102 continue # lustre_ioctl.h is internal header
20105 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
20106 error "cannot compile '$header'"
20110 run_test 400b "packaged headers can be compiled"
20112 test_401a() { #LU-7437
20113 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
20114 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
20116 #count the number of parameters by "list_param -R"
20117 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
20118 #count the number of parameters by listing proc files
20119 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
20120 echo "proc_dirs='$proc_dirs'"
20121 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
20122 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
20125 [ $params -eq $procs ] ||
20126 error "found $params parameters vs. $procs proc files"
20128 # test the list_param -D option only returns directories
20129 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
20130 #count the number of parameters by listing proc directories
20131 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
20134 [ $params -eq $procs ] ||
20135 error "found $params parameters vs. $procs proc files"
20137 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
20140 local save=$($LCTL get_param -n jobid_var)
20143 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
20144 error "no error returned when setting bad parameters"
20146 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
20147 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
20149 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
20150 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
20151 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
20153 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
20156 local jobid_var_old=$($LCTL get_param -n jobid_var)
20157 local jobid_var_new
20159 $LCTL set_param jobid_var= &&
20160 error "no error returned for 'set_param a='"
20162 jobid_var_new=$($LCTL get_param -n jobid_var)
20163 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20164 error "jobid_var was changed by setting without value"
20166 $LCTL set_param jobid_var &&
20167 error "no error returned for 'set_param a'"
20169 jobid_var_new=$($LCTL get_param -n jobid_var)
20170 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20171 error "jobid_var was changed by setting without value"
20173 run_test 401c "Verify 'lctl set_param' without value fails in either format."
20176 local jobid_var_old=$($LCTL get_param -n jobid_var)
20177 local jobid_var_new
20178 local new_value="foo=bar"
20180 $LCTL set_param jobid_var=$new_value ||
20181 error "'set_param a=b' did not accept a value containing '='"
20183 jobid_var_new=$($LCTL get_param -n jobid_var)
20184 [[ "$jobid_var_new" == "$new_value" ]] ||
20185 error "'set_param a=b' failed on a value containing '='"
20187 # Reset the jobid_var to test the other format
20188 $LCTL set_param jobid_var=$jobid_var_old
20189 jobid_var_new=$($LCTL get_param -n jobid_var)
20190 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20191 error "failed to reset jobid_var"
20193 $LCTL set_param jobid_var $new_value ||
20194 error "'set_param a b' did not accept a value containing '='"
20196 jobid_var_new=$($LCTL get_param -n jobid_var)
20197 [[ "$jobid_var_new" == "$new_value" ]] ||
20198 error "'set_param a b' failed on a value containing '='"
20200 $LCTL set_param jobid_var $jobid_var_old
20201 jobid_var_new=$($LCTL get_param -n jobid_var)
20202 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20203 error "failed to reset jobid_var"
20205 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
20208 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
20209 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
20210 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
20211 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
20212 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
20213 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
20214 remote_mds_nodsh && skip "remote MDS with nodsh"
20216 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
20217 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
20218 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
20219 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
20220 echo "Touch failed - OK"
20222 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
20225 local file1=$DIR/$tfile.1
20226 local file2=$DIR/$tfile.2
20227 local tfile=$TMP/$tfile
20229 rm -f $file1 $file2 $tfile
20234 # 30 sec OBD_TIMEOUT in ll_getattr()
20235 # right before populating st_nlink
20236 $LCTL set_param fail_loc=0x80001409
20237 stat -c %h $file1 > $tfile &
20239 # create an alias, drop all locks and reclaim the dentry
20241 cancel_lru_locks mdc
20242 cancel_lru_locks osc
20243 sysctl -w vm.drop_caches=2
20247 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
20249 rm -f $tfile $file1 $file2
20251 run_test 403 "i_nlink should not drop to zero due to aliasing"
20253 test_404() { # LU-6601
20254 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
20255 skip "Need server version newer than 2.8.52"
20256 remote_mds_nodsh && skip "remote MDS with nodsh"
20258 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
20259 awk '/osp .*-osc-MDT/ { print $4}')
20262 for osp in $mosps; do
20263 echo "Deactivate: " $osp
20264 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
20265 local stat=$(do_facet $SINGLEMDS $LCTL dl |
20266 awk -vp=$osp '$4 == p { print $2 }')
20267 [ $stat = IN ] || {
20268 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
20269 error "deactivate error"
20271 echo "Activate: " $osp
20272 do_facet $SINGLEMDS $LCTL --device %$osp activate
20273 local stat=$(do_facet $SINGLEMDS $LCTL dl |
20274 awk -vp=$osp '$4 == p { print $2 }')
20275 [ $stat = UP ] || {
20276 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
20277 error "activate error"
20281 run_test 404 "validate manual {de}activated works properly for OSPs"
20284 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
20285 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
20286 skip "Layout swap lock is not supported"
20288 check_swap_layouts_support
20290 test_mkdir $DIR/$tdir
20291 swap_lock_test -d $DIR/$tdir ||
20292 error "One layout swap locked test failed"
20294 run_test 405 "Various layout swap lock tests"
20297 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20298 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
20299 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
20300 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20301 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
20302 skip "Need MDS version at least 2.8.50"
20304 local def_stripe_size=$($LFS getstripe -S $MOUNT)
20305 local test_pool=$TESTNAME
20307 pool_add $test_pool || error "pool_add failed"
20308 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
20309 error "pool_add_targets failed"
20311 save_layout_restore_at_exit $MOUNT
20313 # parent set default stripe count only, child will stripe from both
20314 # parent and fs default
20315 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
20316 error "setstripe $MOUNT failed"
20317 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
20318 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
20319 for i in $(seq 10); do
20320 local f=$DIR/$tdir/$tfile.$i
20321 touch $f || error "touch failed"
20322 local count=$($LFS getstripe -c $f)
20323 [ $count -eq $OSTCOUNT ] ||
20324 error "$f stripe count $count != $OSTCOUNT"
20325 local offset=$($LFS getstripe -i $f)
20326 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
20327 local size=$($LFS getstripe -S $f)
20328 [ $size -eq $((def_stripe_size * 2)) ] ||
20329 error "$f stripe size $size != $((def_stripe_size * 2))"
20330 local pool=$($LFS getstripe -p $f)
20331 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
20334 # change fs default striping, delete parent default striping, now child
20335 # will stripe from new fs default striping only
20336 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
20337 error "change $MOUNT default stripe failed"
20338 $LFS setstripe -c 0 $DIR/$tdir ||
20339 error "delete $tdir default stripe failed"
20340 for i in $(seq 11 20); do
20341 local f=$DIR/$tdir/$tfile.$i
20342 touch $f || error "touch $f failed"
20343 local count=$($LFS getstripe -c $f)
20344 [ $count -eq 1 ] || error "$f stripe count $count != 1"
20345 local offset=$($LFS getstripe -i $f)
20346 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
20347 local size=$($LFS getstripe -S $f)
20348 [ $size -eq $def_stripe_size ] ||
20349 error "$f stripe size $size != $def_stripe_size"
20350 local pool=$($LFS getstripe -p $f)
20351 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
20354 unlinkmany $DIR/$tdir/$tfile. 1 20
20356 local f=$DIR/$tdir/$tfile
20357 pool_remove_all_targets $test_pool $f
20358 pool_remove $test_pool $f
20360 run_test 406 "DNE support fs default striping"
20363 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20364 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
20365 skip "Need MDS version at least 2.8.55"
20366 remote_mds_nodsh && skip "remote MDS with nodsh"
20368 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
20369 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
20370 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
20371 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
20372 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
20374 #define OBD_FAIL_DT_TXN_STOP 0x2019
20375 for idx in $(seq $MDSCOUNT); do
20376 do_facet mds$idx "lctl set_param fail_loc=0x2019"
20378 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
20379 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
20380 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
20383 run_test 407 "transaction fail should cause operation fail"
20386 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
20388 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
20389 lctl set_param fail_loc=0x8000040a
20390 # let ll_prepare_partial_page() fail
20391 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
20395 # create at least 100 unused inodes so that
20396 # shrink_icache_memory(0) should not return 0
20397 touch $DIR/$tfile-{0..100}
20398 rm -f $DIR/$tfile-{0..100}
20401 echo 2 > /proc/sys/vm/drop_caches
20403 run_test 408 "drop_caches should not hang due to page leaks"
20407 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20408 check_mount_and_prep
20410 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
20411 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
20412 touch $DIR/$tdir/guard || error "(2) Fail to create"
20414 local PREFIX=$(str_repeat 'A' 128)
20415 echo "Create 1K hard links start at $(date)"
20416 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20417 error "(3) Fail to hard link"
20419 echo "Links count should be right although linkEA overflow"
20420 stat $DIR/$tdir/guard || error "(4) Fail to stat"
20421 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
20422 [ $linkcount -eq 1001 ] ||
20423 error "(5) Unexpected hard links count: $linkcount"
20425 echo "List all links start at $(date)"
20426 ls -l $DIR/$tdir/foo > /dev/null ||
20427 error "(6) Fail to list $DIR/$tdir/foo"
20429 echo "Unlink hard links start at $(date)"
20430 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20431 error "(7) Fail to unlink"
20433 run_test 409 "Large amount of cross-MDTs hard links on the same file"
20437 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
20438 skip "Need client version at least 2.9.59"
20440 # Create a file, and stat it from the kernel
20441 local testfile=$DIR/$tfile
20444 local run_id=$RANDOM
20445 local my_ino=$(stat --format "%i" $testfile)
20447 # Try to insert the module. This will always fail as the
20448 # module is designed to not be inserted.
20449 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
20452 # Anything but success is a test failure
20454 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
20455 error "no inode match"
20457 run_test 410 "Test inode number returned from kernel thread"
20459 cleanup_test411_cgroup() {
20465 local cg_basedir=/sys/fs/cgroup/memory
20467 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
20468 skip "no setup for cgroup"
20470 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
20471 error "test file creation failed"
20472 cancel_lru_locks osc
20474 # Create a very small memory cgroup to force a slab allocation error
20475 local cgdir=$cg_basedir/osc_slab_alloc
20476 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
20477 trap "cleanup_test411_cgroup $cgdir" EXIT
20478 echo 2M > $cgdir/memory.kmem.limit_in_bytes
20479 echo 1M > $cgdir/memory.limit_in_bytes
20481 # Should not LBUG, just be killed by oom-killer
20482 # dd will return 0 even allocation failure in some environment.
20483 # So don't check return value
20484 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
20485 cleanup_test411_cgroup $cgdir
20489 run_test 411 "Slab allocation error with cgroup does not LBUG"
20492 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20493 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20494 skip "Need server version at least 2.10.55"
20497 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
20498 error "mkdir failed"
20499 $LFS getdirstripe $DIR/$tdir
20500 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20501 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
20502 error "expect $((MDSCOUT - 1)) get $stripe_index"
20503 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
20504 [ $stripe_count -eq 2 ] ||
20505 error "expect 2 get $stripe_count"
20507 run_test 412 "mkdir on specific MDTs"
20510 [ $MDSCOUNT -lt 2 ] &&
20511 skip "We need at least 2 MDTs for this test"
20513 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20514 skip "Need server version at least 2.10.55"
20517 mkdir $DIR/$tdir || error "mkdir failed"
20519 # find MDT that is the most full
20520 local max=$($LFS df | grep MDT |
20529 END { split(b, c, ":")
20534 for i in $(seq $((MDSCOUNT - 1))); do
20535 $LFS mkdir -c $i $DIR/$tdir/d$i ||
20536 error "mkdir d$i failed"
20537 $LFS getdirstripe $DIR/$tdir/d$i
20538 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
20539 [ $stripe_index -ne $max ] ||
20540 error "don't expect $max"
20543 run_test 413 "mkdir on less full MDTs"
20546 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
20547 $LCTL set_param fail_loc=0x80000521
20548 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
20551 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
20554 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20555 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
20556 skip "Need server version at least 2.11.52"
20566 # this test may be slow on ZFS
20567 [ "$mds1_FSTYPE" == "zfs" ] && total=100
20569 # though this test is designed for striped directory, let's test normal
20570 # directory too since lock is always saved as CoS lock.
20571 test_mkdir $DIR/$tdir || error "mkdir $tdir"
20572 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
20581 start_time=$(date +%s)
20582 for i in $(seq $total); do
20583 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
20586 end_time=$(date +%s)
20587 duration=$((end_time - start_time))
20589 kill -9 $setattr_pid
20591 echo "rename $total files took $duration sec"
20592 [ $duration -lt 100 ] || error "rename took $duration sec"
20594 run_test 415 "lock revoke is not missing"
20597 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
20598 skip "Need server version at least 2.11.55"
20600 # define OBD_FAIL_OSD_TXN_START 0x19a
20601 do_facet mds1 lctl set_param fail_loc=0x19a
20603 lfs mkdir -c $MDSCOUNT $DIR/$tdir
20607 run_test 416 "transaction start failure won't cause system hung"
20611 do_nodes $(comma_list $(mdts_nodes)) \
20612 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
20613 do_nodes $(comma_list $(mdts_nodes)) \
20614 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
20615 do_nodes $(comma_list $(mdts_nodes)) \
20616 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
20620 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20621 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
20622 skip "Need MDS version at least 2.11.56"
20624 trap cleanup_417 RETURN EXIT
20626 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
20627 do_nodes $(comma_list $(mdts_nodes)) \
20628 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
20629 $LFS migrate -m 0 $DIR/$tdir.1 &&
20630 error "migrate dir $tdir.1 should fail"
20632 do_nodes $(comma_list $(mdts_nodes)) \
20633 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
20634 $LFS mkdir -i 1 $DIR/$tdir.2 &&
20635 error "create remote dir $tdir.2 should fail"
20637 do_nodes $(comma_list $(mdts_nodes)) \
20638 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
20639 $LFS mkdir -c 2 $DIR/$tdir.3 &&
20640 error "create striped dir $tdir.3 should fail"
20643 run_test 417 "disable remote dir, striped dir and dir migration"
20645 # Checks that the outputs of df [-i] and lfs df [-i] match
20647 # usage: check_lfs_df <blocks | inodes> <mountpoint>
20657 [ "$1" == "blocks" ] && inodes= || inodes="-i"
20659 for count in {1..100}; do
20663 # read the lines of interest
20664 df_out=($(df -P $inodes $dir | tail -n +2)) ||
20665 error "df $inodes $dir | tail -n +2 failed"
20666 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
20667 error "lfs df $inodes $dir | grep summary: failed"
20669 # skip first substrings of each output as they are different
20670 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
20671 # compare the remaining fields of the two outputs
20673 for i in {1..5}; do
20674 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
20682 lfs df $inodes $dir
20683 error "df and lfs df $1 output mismatch: " \
20684 "df ${inodes}: ${df_out[*]}, " \
20685 "lfs df ${inodes}: ${lfs_df_out[*]}"
20690 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20692 local dir=$DIR/$tdir
20693 local numfiles=$((RANDOM % 4096 + 2))
20694 local numblocks=$((RANDOM % 256 + 1))
20696 wait_delete_completed
20699 # check block output
20700 check_lfs_df blocks $dir
20701 # check inode output
20702 check_lfs_df inodes $dir
20704 # create a single file and retest
20705 echo "Creating a single file and testing"
20706 createmany -o $dir/$tfile- 1 &>/dev/null ||
20707 error "creating 1 file in $dir failed"
20708 check_lfs_df blocks $dir
20709 check_lfs_df inodes $dir
20711 # create a random number of files
20712 echo "Creating $((numfiles - 1)) files and testing"
20713 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
20714 error "creating $((numfiles - 1)) files in $dir failed"
20716 # write a random number of blocks to the first test file
20717 echo "Writing $numblocks 4K blocks and testing"
20718 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
20719 count=$numblocks &>/dev/null ||
20720 error "dd to $dir/${tfile}-0 failed"
20723 check_lfs_df blocks $dir
20724 check_lfs_df inodes $dir
20726 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
20727 error "unlinking $numfiles files in $dir failed"
20729 run_test 418 "df and lfs df outputs match"
20733 local dir=$DIR/$tdir
20738 cancel_lru_locks mdc
20740 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
20741 $LCTL set_param fail_loc=0x1410
20743 $LCTL set_param fail_loc=0
20746 run_test 419 "Verify open file by name doesn't crash kernel"
20750 [[ $MDS1_VERSION -ge $(version_code 2.12.1) ]] ||
20751 skip "Need MDS version at least 2.12.1"
20753 local SAVE_UMASK=$(umask)
20754 local dir=$DIR/$tdir
20755 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
20759 mkdir -m03777 $dir/testdir
20760 ls -dn $dir/testdir
20761 # Need to remove trailing '.' when SELinux is enabled
20762 local dirperms=$(ls -dn $dir/testdir |
20763 awk '{ sub(/\.$/, "", $1); print $1}')
20764 [ $dirperms == "drwxrwsrwt" ] ||
20765 error "incorrect perms on $dir/testdir"
20767 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
20768 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
20769 ls -n $dir/testdir/testfile
20770 local fileperms=$(ls -n $dir/testdir/testfile |
20771 awk '{ sub(/\.$/, "", $1); print $1}')
20772 [ $fileperms == "-rwxr-xr-x" ] ||
20773 error "incorrect perms on $dir/testdir/testfile"
20777 run_test 420 "clear SGID bit on non-directories for non-members"
20784 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20785 skip "Need MDS version at least 2.12.2"
20787 test_mkdir $DIR/$tdir
20788 createmany -o $DIR/$tdir/f 3
20789 cnt=$(ls -1 $DIR/$tdir | wc -l)
20790 [ $cnt != 3 ] && error "unexpected #files: $cnt"
20792 fid1=$(lfs path2fid $DIR/$tdir/f1)
20793 fid2=$(lfs path2fid $DIR/$tdir/f2)
20794 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
20796 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
20797 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
20799 cnt=$(ls -1 $DIR/$tdir | wc -l)
20800 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
20802 rm -f $DIR/$tdir/f3 || error "can't remove f3"
20803 createmany -o $DIR/$tdir/f 3
20804 cnt=$(ls -1 $DIR/$tdir | wc -l)
20805 [ $cnt != 3 ] && error "unexpected #files: $cnt"
20807 fid1=$(lfs path2fid $DIR/$tdir/f1)
20808 fid2=$(lfs path2fid $DIR/$tdir/f2)
20809 echo "remove using fsname $FSNAME"
20810 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
20812 cnt=$(ls -1 $DIR/$tdir | wc -l)
20813 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
20815 run_test 421a "simple rm by fid"
20822 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20823 skip "Need MDS version at least 2.12.2"
20825 test_mkdir $DIR/$tdir
20826 createmany -o $DIR/$tdir/f 3
20827 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
20830 FID1=$(lfs path2fid $DIR/$tdir/f1)
20831 FID2=$(lfs path2fid $DIR/$tdir/f2)
20832 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
20834 kill -USR1 $MULTIPID
20837 cnt=$(ls $DIR/$tdir | wc -l)
20838 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
20840 run_test 421b "rm by fid on open file"
20846 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20847 skip "Need MDS version at least 2.12.2"
20849 test_mkdir $DIR/$tdir
20850 createmany -o $DIR/$tdir/f 3
20851 touch $DIR/$tdir/$tfile
20852 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
20853 cnt=$(ls -1 $DIR/$tdir | wc -l)
20854 [ $cnt != 184 ] && error "unexpected #files: $cnt"
20856 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
20857 $LFS rmfid $DIR $FID1 || error "rmfid failed"
20859 cnt=$(ls $DIR/$tdir | wc -l)
20860 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
20862 run_test 421c "rm by fid against hardlinked files"
20868 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20869 skip "Need MDS version at least 2.12.2"
20871 test_mkdir $DIR/$tdir
20872 createmany -o $DIR/$tdir/f 4097
20873 cnt=$(ls -1 $DIR/$tdir | wc -l)
20874 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
20876 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
20877 $LFS rmfid $DIR $FIDS || error "rmfid failed"
20879 cnt=$(ls $DIR/$tdir | wc -l)
20881 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
20883 run_test 421d "rmfid en masse"
20889 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20890 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20891 skip "Need MDS version at least 2.12.2"
20893 mkdir -p $DIR/$tdir
20894 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
20895 createmany -o $DIR/$tdir/striped_dir/f 512
20896 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
20897 [ $cnt != 512 ] && error "unexpected #files: $cnt"
20899 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
20900 sed "s/[/][^:]*://g")
20901 $LFS rmfid $DIR $FIDS || error "rmfid failed"
20903 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
20905 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
20907 run_test 421e "rmfid in DNE"
20913 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20914 skip "Need MDS version at least 2.12.2"
20916 test_mkdir $DIR/$tdir
20918 cnt=$(ls -1 $DIR/$tdir | wc -l)
20919 [ $cnt != 1 ] && error "unexpected #files: $cnt"
20921 FID=$(lfs path2fid $DIR/$tdir/f)
20922 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
20923 # rmfid should fail
20924 cnt=$(ls -1 $DIR/$tdir | wc -l)
20925 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
20927 chmod a+rw $DIR/$tdir
20929 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
20930 # rmfid should fail
20931 cnt=$(ls -1 $DIR/$tdir | wc -l)
20932 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
20935 $RUNAS touch $DIR/$tdir/f
20936 FID=$(lfs path2fid $DIR/$tdir/f)
20937 echo "rmfid as root"
20938 $LFS rmfid $DIR $FID || error "rmfid as root failed"
20939 cnt=$(ls -1 $DIR/$tdir | wc -l)
20940 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
20943 $RUNAS touch $DIR/$tdir/f
20944 cnt=$(ls -1 $DIR/$tdir | wc -l)
20945 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
20946 FID=$(lfs path2fid $DIR/$tdir/f)
20947 # rmfid w/o user_fid2path mount option should fail
20948 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
20949 cnt=$(ls -1 $DIR/$tdir | wc -l)
20950 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
20952 umount_client $MOUNT || "failed to umount client"
20953 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
20954 "failed to mount client'"
20956 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
20957 # rmfid should succeed
20958 cnt=$(ls -1 $DIR/$tdir | wc -l)
20959 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
20961 # rmfid shouldn't allow to remove files due to dir's permission
20962 chmod a+rwx $DIR/$tdir
20965 FID=$(lfs path2fid $DIR/$tdir/f)
20966 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
20968 umount_client $MOUNT || "failed to umount client"
20969 mount_client $MOUNT "$MOUNT_OPTS" ||
20970 "failed to mount client'"
20973 run_test 421f "rmfid checks permissions"
20979 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20980 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20981 skip "Need MDS version at least 2.12.2"
20983 mkdir -p $DIR/$tdir
20984 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
20985 createmany -o $DIR/$tdir/striped_dir/f 512
20986 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
20987 [ $cnt != 512 ] && error "unexpected #files: $cnt"
20989 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
20990 sed "s/[/][^:]*://g")
20992 rm -f $DIR/$tdir/striped_dir/f1*
20993 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
20994 removed=$((512 - cnt))
20996 # few files have been just removed, so we expect
20997 # rmfid to fail on their fids
20998 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
20999 [ $removed != $errors ] && error "$errors != $removed"
21001 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21003 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21005 run_test 421g "rmfid to return errors properly"
21018 # ensure statfs cache is expired
21021 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
21022 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
21026 run_test 423 "statfs should return a right data"
21029 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21030 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
21031 skip "Need server version at least 2.9.55"
21033 start_full_debug_logging
21037 stop_full_debug_logging
21041 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
21042 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
21043 awk '/The barrier for/ { print $7 }')
21046 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
21051 barrier_expired() {
21054 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
21055 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
21056 awk '/will be expired/ { print $7 }')
21058 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
21067 echo "Start barrier_freeze at: $(date)"
21068 #define OBD_FAIL_BARRIER_DELAY 0x2202
21069 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
21070 # Do not reduce barrier time - See LU-11873
21071 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
21074 local b_status=$(barrier_stat)
21075 echo "Got barrier status at: $(date)"
21076 [ "$b_status" = "'freezing_p1'" ] ||
21077 error "(1) unexpected barrier status $b_status"
21079 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
21081 b_status=$(barrier_stat)
21082 [ "$b_status" = "'frozen'" ] ||
21083 error "(2) unexpected barrier status $b_status"
21085 local expired=$(barrier_expired)
21086 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
21087 sleep $((expired + 3))
21089 b_status=$(barrier_stat)
21090 [ "$b_status" = "'expired'" ] ||
21091 error "(3) unexpected barrier status $b_status"
21093 # Do not reduce barrier time - See LU-11873
21094 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
21095 error "(4) fail to freeze barrier"
21097 b_status=$(barrier_stat)
21098 [ "$b_status" = "'frozen'" ] ||
21099 error "(5) unexpected barrier status $b_status"
21101 echo "Start barrier_thaw at: $(date)"
21102 #define OBD_FAIL_BARRIER_DELAY 0x2202
21103 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
21104 do_facet mgs $LCTL barrier_thaw $FSNAME &
21107 b_status=$(barrier_stat)
21108 echo "Got barrier status at: $(date)"
21109 [ "$b_status" = "'thawing'" ] ||
21110 error "(6) unexpected barrier status $b_status"
21112 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
21114 b_status=$(barrier_stat)
21115 [ "$b_status" = "'thawed'" ] ||
21116 error "(7) unexpected barrier status $b_status"
21118 #define OBD_FAIL_BARRIER_FAILURE 0x2203
21119 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
21120 do_facet mgs $LCTL barrier_freeze $FSNAME
21122 b_status=$(barrier_stat)
21123 [ "$b_status" = "'failed'" ] ||
21124 error "(8) unexpected barrier status $b_status"
21126 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
21127 do_facet mgs $LCTL barrier_thaw $FSNAME
21131 run_test 801a "write barrier user interfaces and stat machine"
21136 mkdir $DIR/$tdir || error "(1) fail to mkdir"
21137 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
21138 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
21139 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
21140 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
21142 cancel_lru_locks mdc
21144 # 180 seconds should be long enough
21145 do_facet mgs $LCTL barrier_freeze $FSNAME 180
21147 local b_status=$(barrier_stat)
21148 [ "$b_status" = "'frozen'" ] ||
21149 error "(6) unexpected barrier status $b_status"
21151 mkdir $DIR/$tdir/d0/d10 &
21154 touch $DIR/$tdir/d1/f13 &
21157 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
21160 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
21163 rm -f $DIR/$tdir/d4/f12 &
21166 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
21168 # To guarantee taht the 'stat' is not blocked
21169 b_status=$(barrier_stat)
21170 [ "$b_status" = "'frozen'" ] ||
21171 error "(8) unexpected barrier status $b_status"
21173 # let above commands to run at background
21176 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
21177 ps -p $touch_pid || error "(10) touch should be blocked"
21178 ps -p $ln_pid || error "(11) link should be blocked"
21179 ps -p $mv_pid || error "(12) rename should be blocked"
21180 ps -p $rm_pid || error "(13) unlink should be blocked"
21182 b_status=$(barrier_stat)
21183 [ "$b_status" = "'frozen'" ] ||
21184 error "(14) unexpected barrier status $b_status"
21186 do_facet mgs $LCTL barrier_thaw $FSNAME
21187 b_status=$(barrier_stat)
21188 [ "$b_status" = "'thawed'" ] ||
21189 error "(15) unexpected barrier status $b_status"
21191 wait $mkdir_pid || error "(16) mkdir should succeed"
21192 wait $touch_pid || error "(17) touch should succeed"
21193 wait $ln_pid || error "(18) link should succeed"
21194 wait $mv_pid || error "(19) rename should succeed"
21195 wait $rm_pid || error "(20) unlink should succeed"
21199 run_test 801b "modification will be blocked by write barrier"
21202 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21206 stop mds2 || error "(1) Fail to stop mds2"
21208 do_facet mgs $LCTL barrier_freeze $FSNAME 30
21210 local b_status=$(barrier_stat)
21211 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
21212 do_facet mgs $LCTL barrier_thaw $FSNAME
21213 error "(2) unexpected barrier status $b_status"
21216 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21217 error "(3) Fail to rescan barrier bitmap"
21219 # Do not reduce barrier time - See LU-11873
21220 do_facet mgs $LCTL barrier_freeze $FSNAME 20
21222 b_status=$(barrier_stat)
21223 [ "$b_status" = "'frozen'" ] ||
21224 error "(4) unexpected barrier status $b_status"
21226 do_facet mgs $LCTL barrier_thaw $FSNAME
21227 b_status=$(barrier_stat)
21228 [ "$b_status" = "'thawed'" ] ||
21229 error "(5) unexpected barrier status $b_status"
21231 local devname=$(mdsdevname 2)
21233 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
21235 do_facet mgs $LCTL barrier_rescan $FSNAME ||
21236 error "(7) Fail to rescan barrier bitmap"
21240 run_test 801c "rescan barrier bitmap"
21242 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
21243 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
21244 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
21245 saved_MOUNT_OPTS=$MOUNT_OPTS
21251 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
21252 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
21253 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
21254 MOUNT_OPTS=$saved_MOUNT_OPTS
21259 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
21260 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
21261 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
21262 skip "Need server version at least 2.9.55"
21264 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
21266 mkdir $DIR/$tdir || error "(1) fail to mkdir"
21268 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
21269 error "(2) Fail to copy"
21271 trap cleanup_802 EXIT
21273 # sync by force before remount as readonly
21274 sync; sync_all_data; sleep 3; sync_all_data
21278 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
21279 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
21280 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
21282 echo "Mount the server as read only"
21283 setupall server_only || error "(3) Fail to start servers"
21285 echo "Mount client without ro should fail"
21286 mount_client $MOUNT &&
21287 error "(4) Mount client without 'ro' should fail"
21289 echo "Mount client with ro should succeed"
21290 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
21291 mount_client $MOUNT ||
21292 error "(5) Mount client with 'ro' should succeed"
21294 echo "Modify should be refused"
21295 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
21297 echo "Read should be allowed"
21298 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
21299 error "(7) Read should succeed under ro mode"
21303 run_test 802 "simulate readonly device"
21306 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21307 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21308 skip "MDS needs to be newer than 2.10.54"
21310 mkdir -p $DIR/$tdir
21311 # Create some objects on all MDTs to trigger related logs objects
21312 for idx in $(seq $MDSCOUNT); do
21313 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
21314 $DIR/$tdir/dir${idx} ||
21315 error "Fail to create $DIR/$tdir/dir${idx}"
21319 wait_delete_completed # ensure old test cleanups are finished
21320 echo "before create:"
21322 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21324 for i in {1..10}; do
21325 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
21326 error "Fail to create $DIR/$tdir/foo$i"
21330 echo "after create:"
21332 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21334 # allow for an llog to be cleaned up during the test
21335 [ $after_used -ge $((before_used + 10 - 1)) ] ||
21336 error "before ($before_used) + 10 > after ($after_used)"
21338 for i in {1..10}; do
21339 rm -rf $DIR/$tdir/foo$i ||
21340 error "Fail to remove $DIR/$tdir/foo$i"
21343 sleep 3 # avoid MDT return cached statfs
21344 wait_delete_completed
21345 echo "after unlink:"
21347 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
21349 # allow for an llog to be created during the test
21350 [ $after_used -le $((before_used + 1)) ] ||
21351 error "after ($after_used) > before ($before_used) + 1"
21353 run_test 803a "verify agent object for remote object"
21356 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21357 [ $MDS1_VERSION -lt $(version_code 2.13.56) ] &&
21358 skip "MDS needs to be newer than 2.13.56"
21359 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21361 for i in $(seq 0 $((MDSCOUNT - 1))); do
21362 $LFS mkdir -i $i $DIR/$tdir.$i || error "mkdir $tdir.$i"
21370 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
21371 for i in $(seq 0 $((MDSCOUNT - 1))); do
21372 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
21373 awk '/getattr/ { print $2 }')
21374 before=$((before + tmp))
21376 stat $DIR/$tdir.* >/dev/null || error "stat $tdir.*"
21377 for i in $(seq 0 $((MDSCOUNT - 1))); do
21378 tmp=$(do_facet mds$i $LCTL get_param mdt.*-MDT000$i.md_stats |
21379 awk '/getattr/ { print $2 }')
21380 after=$((after + tmp))
21383 [ $before -eq $after ] || error "getattr count $before != $after"
21385 run_test 803b "remote object can getattr from cache"
21388 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
21389 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
21390 skip "MDS needs to be newer than 2.10.54"
21391 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
21393 mkdir -p $DIR/$tdir
21394 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
21395 error "Fail to create $DIR/$tdir/dir0"
21397 local fid=$($LFS path2fid $DIR/$tdir/dir0)
21398 local dev=$(mdsdevname 2)
21400 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21401 grep ${fid} || error "NOT found agent entry for dir0"
21403 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
21404 error "Fail to create $DIR/$tdir/dir1"
21406 touch $DIR/$tdir/dir1/foo0 ||
21407 error "Fail to create $DIR/$tdir/dir1/foo0"
21408 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
21411 for idx in $(seq $MDSCOUNT); do
21412 dev=$(mdsdevname $idx)
21413 do_facet mds${idx} \
21414 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21415 grep ${fid} && rc=$idx
21418 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
21419 error "Fail to rename foo0 to foo1"
21420 if [ $rc -eq 0 ]; then
21421 for idx in $(seq $MDSCOUNT); do
21422 dev=$(mdsdevname $idx)
21423 do_facet mds${idx} \
21424 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21425 grep ${fid} && rc=$idx
21429 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
21430 error "Fail to rename foo1 to foo2"
21431 if [ $rc -eq 0 ]; then
21432 for idx in $(seq $MDSCOUNT); do
21433 dev=$(mdsdevname $idx)
21434 do_facet mds${idx} \
21435 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
21436 grep ${fid} && rc=$idx
21440 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
21442 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
21443 error "Fail to link to $DIR/$tdir/dir1/foo2"
21444 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
21445 error "Fail to rename foo2 to foo0"
21446 unlink $DIR/$tdir/dir1/foo0 ||
21447 error "Fail to unlink $DIR/$tdir/dir1/foo0"
21448 rm -rf $DIR/$tdir/dir0 ||
21449 error "Fail to rm $DIR/$tdir/dir0"
21451 for idx in $(seq $MDSCOUNT); do
21452 dev=$(mdsdevname $idx)
21456 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
21458 start mds${idx} $dev $MDS_MOUNT_OPTS ||
21459 error "mount mds$idx failed"
21460 df $MOUNT > /dev/null 2>&1
21462 # e2fsck should not return error
21464 error "e2fsck detected error on MDT${idx}: rc=$rc"
21467 run_test 804 "verify agent entry for remote entry"
21470 do_facet $SINGLEMDS zfs set quota=$old $fsset
21471 unlinkmany $DIR/$tdir/f- 1000000
21476 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
21477 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
21478 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
21479 skip "netfree not implemented before 0.7"
21480 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
21481 skip "Need MDS version at least 2.10.57"
21488 local pref="osd-zfs.lustre-MDT0000."
21490 # limit available space on MDS dataset to meet nospace issue
21491 # quickly. then ZFS 0.7.2 can use reserved space if asked
21492 # properly (using netfree flag in osd_declare_destroy()
21493 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
21494 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
21496 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
21497 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
21498 let "usedkb=usedkb-freekb"
21499 let "freekb=freekb/2"
21500 if let "freekb > 5000"; then
21503 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
21504 trap cleanup_805 EXIT
21506 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
21507 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
21508 rm -rf $DIR/$tdir || error "not able to remove"
21509 do_facet $SINGLEMDS zfs set quota=$old $fsset
21512 run_test 805 "ZFS can remove from full fs"
21518 local size=$($LFS getsom -s $file)
21519 local expect=$(stat -c %s $file)
21521 [[ $size == $expect ]] ||
21522 error "$file expected size: $expect, got: $size"
21524 local blocks=$($LFS getsom -b $file)
21525 expect=$(stat -c %b $file)
21526 [[ $blocks == $expect ]] ||
21527 error "$file expected blocks: $expect, got: $blocks"
21532 local size=$($LFS getsom -s $1)
21535 [[ $size == $expect ]] ||
21536 error "$file expected size: $expect, got: $size"
21540 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21541 skip "Need MDS version at least 2.11.52"
21545 touch $DIR/$tfile || error "touch $tfile failed"
21547 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21548 save_lustre_params client "llite.*.xattr_cache" > $save
21549 lctl set_param llite.*.xattr_cache=0
21550 stack_trap "restore_lustre_params < $save" EXIT
21552 # single-threaded write
21553 echo "Test SOM for single-threaded write"
21554 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
21555 error "write $tfile failed"
21556 check_lsom_size $DIR/$tfile $bs
21559 local size=$(($num * $bs))
21563 echo "Test SOM for single client multi-threaded($num) write"
21564 $TRUNCATE $DIR/$tfile 0
21565 for ((i = 0; i < $num; i++)); do
21566 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21568 offset=$((offset + $bs))
21570 for (( i=0; i < $num; i++ )); do
21573 check_lsom_size $DIR/$tfile $size
21575 $TRUNCATE $DIR/$tfile 0
21576 for ((i = 0; i < $num; i++)); do
21577 offset=$((offset - $bs))
21578 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21581 for (( i=0; i < $num; i++ )); do
21584 check_lsom_size $DIR/$tfile $size
21586 # multi-client writes
21587 num=$(get_node_count ${CLIENTS//,/ })
21588 size=$(($num * $bs))
21592 echo "Test SOM for multi-client ($num) writes"
21593 $TRUNCATE $DIR/$tfile 0
21594 for client in ${CLIENTS//,/ }; do
21595 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21598 offset=$((offset + $bs))
21600 for (( i=0; i < $num; i++ )); do
21603 check_lsom_size $DIR/$tfile $offset
21606 $TRUNCATE $DIR/$tfile 0
21607 for client in ${CLIENTS//,/ }; do
21608 offset=$((offset - $bs))
21609 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21613 for (( i=0; i < $num; i++ )); do
21616 check_lsom_size $DIR/$tfile $size
21619 echo "Test SOM for truncate"
21620 $TRUNCATE $DIR/$tfile 1048576
21621 check_lsom_size $DIR/$tfile 1048576
21622 $TRUNCATE $DIR/$tfile 1234
21623 check_lsom_size $DIR/$tfile 1234
21625 # verify SOM blocks count
21626 echo "Verify SOM block count"
21627 $TRUNCATE $DIR/$tfile 0
21628 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
21629 error "failed to write file $tfile"
21630 check_lsom_data $DIR/$tfile
21632 run_test 806 "Verify Lazy Size on MDS"
21635 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21636 skip "Need MDS version at least 2.11.52"
21638 # Registration step
21639 changelog_register || error "changelog_register failed"
21640 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
21641 changelog_users $SINGLEMDS | grep -q $cl_user ||
21642 error "User $cl_user not found in changelog_users"
21644 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21645 save_lustre_params client "llite.*.xattr_cache" > $save
21646 lctl set_param llite.*.xattr_cache=0
21647 stack_trap "restore_lustre_params < $save" EXIT
21649 rm -rf $DIR/$tdir || error "rm $tdir failed"
21650 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
21651 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
21652 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
21653 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
21654 error "truncate $tdir/trunc failed"
21657 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
21658 error "write $tfile failed"
21660 # multi-client wirtes
21661 local num=$(get_node_count ${CLIENTS//,/ })
21665 echo "Test SOM for multi-client ($num) writes"
21666 touch $DIR/$tfile || error "touch $tfile failed"
21667 $TRUNCATE $DIR/$tfile 0
21668 for client in ${CLIENTS//,/ }; do
21669 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21672 offset=$((offset + $bs))
21674 for (( i=0; i < $num; i++ )); do
21679 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
21680 check_lsom_data $DIR/$tdir/trunc
21681 check_lsom_data $DIR/$tdir/single_dd
21682 check_lsom_data $DIR/$tfile
21685 # Deregistration step
21686 changelog_deregister || error "changelog_deregister failed"
21688 run_test 807 "verify LSOM syncing tool"
21690 check_som_nologged()
21692 local lines=$($LFS changelog $FSNAME-MDT0000 |
21693 grep 'x=trusted.som' | wc -l)
21694 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
21698 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
21699 skip "Need MDS version at least 2.11.55"
21701 # Registration step
21702 changelog_register || error "changelog_register failed"
21704 touch $DIR/$tfile || error "touch $tfile failed"
21707 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
21708 error "write $tfile failed"
21711 $TRUNCATE $DIR/$tfile 1234
21714 $TRUNCATE $DIR/$tfile 1048576
21717 # Deregistration step
21718 changelog_deregister || error "changelog_deregister failed"
21720 run_test 808 "Check trusted.som xattr not logged in Changelogs"
21725 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
21729 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
21730 skip "Need MDS version at least 2.11.56"
21732 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
21733 error "failed to create DoM-only file $DIR/$tfile"
21734 touch $DIR/$tfile || error "touch $tfile failed"
21735 check_som_nodata $DIR/$tfile
21737 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
21738 error "write $tfile failed"
21739 check_som_nodata $DIR/$tfile
21741 $TRUNCATE $DIR/$tfile 1234
21742 check_som_nodata $DIR/$tfile
21744 $TRUNCATE $DIR/$tfile 4097
21745 check_som_nodata $DIR/$file
21747 run_test 809 "Verify no SOM xattr store for DoM-only files"
21750 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21751 $GSS && skip_env "could not run with gss"
21754 stack_trap "set_checksums $ORIG_CSUM" EXIT
21755 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
21760 for csum in $CKSUM_TYPES; do
21761 #define OBD_FAIL_OSC_NO_GRANT 0x411
21762 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
21763 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
21765 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
21766 before=$(md5sum $DIR/$tfile)
21767 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
21768 after=$(md5sum $DIR/$tfile)
21769 [ "$before" == "$after" ] ||
21770 error "$csum: $before != $after bs=$1 seek=$2"
21774 run_test 810 "partial page writes on ZFS (LU-11663)"
21777 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
21778 skip "OST < 2.12.51 doesn't support this fail_loc"
21779 [ "$SHARED_KEY" = true ] &&
21780 skip "OSC connections never go IDLE with Shared-Keys enabled"
21782 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21783 # ensure ost1 is connected
21784 stat $DIR/$tfile >/dev/null || error "can't stat"
21785 wait_osc_import_state client ost1 FULL
21786 # no locks, no reqs to let the connection idle
21787 cancel_lru_locks osc
21789 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
21790 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
21791 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
21792 wait_osc_import_state client ost1 CONNECTING
21793 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
21795 stat $DIR/$tfile >/dev/null || error "can't stat file"
21797 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
21801 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
21802 echo -n y >> $DIR/$tfile
21803 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
21804 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
21806 run_test 814 "sparse cp works as expected (LU-12361)"
21810 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
21811 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
21813 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
21816 local ost1_imp=$(get_osc_import_name client ost1)
21817 local imp_name=$($LCTL list_param osc.$ost1_imp | head -n1 |
21820 [ "$SHARED_KEY" = true ] &&
21821 skip "OSC connections never go IDLE with Shared-Keys enabled"
21823 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21824 # ensure ost1 is connected
21825 stat $DIR/$tfile >/dev/null || error "can't stat"
21826 wait_osc_import_state client ost1 FULL
21827 # no locks, no reqs to let the connection idle
21828 cancel_lru_locks osc
21829 lru_resize_disable osc
21832 before=$($LCTL get_param -n \
21833 ldlm.namespaces.$imp_name.lru_size)
21835 wait_osc_import_state client ost1 IDLE
21836 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
21837 now=$($LCTL get_param -n \
21838 ldlm.namespaces.$imp_name.lru_size)
21839 [ $before == $now ] || error "lru_size changed $before != $now"
21841 run_test 816 "do not reset lru_resize on idle reconnect"
21845 exportfs -u localhost:$DIR/nfsexp
21850 systemctl restart nfs-server.service || skip "failed to restart nfsd"
21852 mkdir -p $DIR/nfsexp
21853 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
21854 error "failed to export nfs"
21856 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
21857 stack_trap cleanup_817 EXIT
21859 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
21860 error "failed to mount nfs to $tmpdir"
21862 cp /bin/true $tmpdir
21863 $DIR/nfsexp/true || error "failed to execute 'true' command"
21865 run_test 817 "nfsd won't cache write lock for exec file"
21868 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21869 cancel_lru_locks osc
21870 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
21871 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
21872 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
21875 run_test 819a "too big niobuf in read"
21878 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
21879 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
21880 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21881 cancel_lru_locks osc
21885 run_test 819b "too big niobuf in write"
21889 $LFS setstripe -c1 -i0 $DIR/$tfile
21890 $LFS setstripe -c1 -i1 $DIR/$tfile
21892 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
21893 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
21894 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
21895 error "start $SINGLEMDS failed"
21898 run_test 818 "unlink with failed llog"
21901 # tests that do cleanup/setup should be run at the end
21905 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21908 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
21909 $LCTL set_param fail_loc=0x903
21911 cancel_lru_locks MGC
21913 FAIL_ON_ERROR=true cleanup
21914 FAIL_ON_ERROR=true setup
21916 run_test 900 "umount should not race with any mgc requeue thread"
21920 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
21921 skip "client does not have LU-13377 fix"
21922 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
21923 $LCTL set_param fail_loc=0x1415
21924 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21925 cancel_lru_locks osc
21928 run_test 902 "test short write doesn't hang lustre"
21931 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
21932 check_and_cleanup_lustre
21933 if [ "$I_MOUNTED" != "yes" ]; then
21934 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true