2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: LU-9693 LU-6493 LU-9693 3561 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 45 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054 LU-10199
16 ALWAYS_EXCEPT=" 407 253 312 56xb $ALWAYS_EXCEPT"
18 # Check Grants after these tests
19 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
23 if [ -r /etc/SuSE-release ]
25 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
26 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
28 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
35 if is_sles11; then # LU-4341
36 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
39 SRCDIR=$(cd $(dirname $0); echo $PWD)
40 export PATH=$PATH:/sbin
46 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
47 CREATETEST=${CREATETEST:-createtest}
49 LFIND=${LFIND:-"$LFS find"}
50 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
52 OPENFILE=${OPENFILE:-openfile}
53 OPENUNLINK=${OPENUNLINK:-openunlink}
54 export MULTIOP=${MULTIOP:-multiop}
55 READS=${READS:-"reads"}
56 MUNLINK=${MUNLINK:-munlink}
57 SOCKETSERVER=${SOCKETSERVER:-socketserver}
58 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
59 MEMHOG=${MEMHOG:-memhog}
60 DIRECTIO=${DIRECTIO:-directio}
61 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
63 CHECK_GRANT=${CHECK_GRANT:-"yes"}
64 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
65 export PARALLEL=${PARALLEL:-"no"}
67 export NAME=${NAME:-local}
74 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
75 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
76 . $LUSTRE/tests/test-framework.sh
78 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
82 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
84 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
85 # bug number for skipped test: LU-1957
86 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
88 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
95 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
96 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
105 check_swap_layouts_support()
107 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
108 { skip "Does not support layout lock."; return 0; }
112 check_and_setup_lustre
116 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
117 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
118 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
120 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
121 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
122 rm -rf $DIR/[Rdfs][0-9]*
124 # $RUNAS_ID may get set incorrectly somewhere else
125 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
127 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
131 if [ "${ONLY}" = "MOUNT" ] ; then
132 echo "Lustre is up, please go on"
136 echo "preparing for tests involving mounts"
137 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
139 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
140 echo # add a newline after mke2fs.
144 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
145 lctl set_param debug=-1 2> /dev/null || true
148 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
150 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
152 run_test 0a "touch; rm ====================="
155 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
156 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
158 run_test 0b "chmod 0755 $DIR ============================="
161 $LCTL get_param mdc.*.import | grep "state: FULL" ||
162 error "import not FULL"
163 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
166 run_test 0c "check import proc"
169 test_mkdir $DIR/$tdir
170 test_mkdir $DIR/$tdir/d2
171 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
172 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
175 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
177 run_test 1 "mkdir; remkdir; rmdir"
180 test_mkdir $DIR/$tdir
181 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
182 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
184 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
186 run_test 2 "mkdir; touch; rmdir; check file"
189 test_mkdir $DIR/$tdir
190 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
191 touch $DIR/$tdir/$tfile
192 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
194 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
196 run_test 3 "mkdir; touch; rmdir; check dir"
198 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
200 test_mkdir -i 1 $DIR/$tdir
202 touch $DIR/$tdir/$tfile ||
203 error "Create file under remote directory failed"
206 error "Expect error removing in-use dir $DIR/$tdir"
208 test -d $DIR/$tdir || error "Remote directory disappeared"
210 rm -rf $DIR/$tdir || error "remove remote dir error"
212 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
215 test_mkdir $DIR/$tdir
216 test_mkdir $DIR/$tdir/d2
217 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
218 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
219 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
221 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
224 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
225 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
226 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
227 error "$tfile does not have perm 0666 or UID $UID"
228 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
230 error "$tfile should be 0666 and owned by UID $UID"
232 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
235 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
237 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
238 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
239 error "$tfile should be owned by UID $RUNAS_ID"
240 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
241 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
242 error "$tfile should be owned by UID $RUNAS_ID"
244 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
247 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
249 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
250 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
251 error "$tfile should be owned by GID $UID"
252 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
253 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
254 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
256 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
259 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
260 test_mkdir $DIR/$tdir
261 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
262 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
263 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
264 test_mkdir $DIR/$tdir/d/subdir
265 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
266 error "$tdir/d/subdir should be GID $RUNAS_GID"
267 if [[ $MDSCOUNT -gt 1 ]]; then
268 # check remote dir sgid inherite
269 $LFS mkdir -i 0 $DIR/$tdir.local ||
270 error "mkdir $tdir.local failed"
271 chmod g+s $DIR/$tdir.local ||
272 error "chmod $tdir.local failed"
273 chgrp $RUNAS_GID $DIR/$tdir.local ||
274 error "chgrp $tdir.local failed"
275 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
276 error "mkdir $tdir.remote failed"
277 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
278 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
279 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
280 error "$tdir.remote should be mode 02755"
283 run_test 6g "verify new dir in sgid dir inherits group"
285 test_6h() { # bug 7331
286 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
287 touch $DIR/$tfile || error "touch failed"
288 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
289 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
290 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
291 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
292 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
294 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
297 test_mkdir $DIR/$tdir
298 $MCREATE $DIR/$tdir/$tfile
299 chmod 0666 $DIR/$tdir/$tfile
300 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
301 error "$tdir/$tfile should be mode 0666"
303 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
306 if [ ! -d $DIR/$tdir ]; then
307 test_mkdir $DIR/$tdir
309 $MCREATE $DIR/$tdir/$tfile
310 echo -n foo > $DIR/$tdir/$tfile
311 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
312 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
314 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
317 test_mkdir $DIR/$tdir
318 touch $DIR/$tdir/$tfile
319 chmod 0666 $DIR/$tdir/$tfile
320 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
321 error "$tfile mode not 0666"
323 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
326 test_mkdir $DIR/$tdir
327 test_mkdir $DIR/$tdir/d2
328 test_mkdir $DIR/$tdir/d2/d3
329 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
331 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
334 test_mkdir $DIR/$tdir
335 test_mkdir $DIR/$tdir/d2
336 touch $DIR/$tdir/d2/$tfile
337 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
338 error "$tdir/d2/$tfile not a file"
340 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
343 test_mkdir $DIR/$tdir
344 test_mkdir $DIR/$tdir/d2
345 chmod 0666 $DIR/$tdir/d2
346 chmod 0705 $DIR/$tdir/d2
347 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
348 error "$tdir/d2 mode not 0705"
350 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
353 test_mkdir $DIR/$tdir
354 touch $DIR/$tdir/$tfile
355 chmod 0666 $DIR/$tdir/$tfile
356 chmod 0654 $DIR/$tdir/$tfile
357 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
358 error "$tdir/d2 mode not 0654"
360 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
363 test_mkdir $DIR/$tdir
364 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
366 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
367 error "$tdir/$tfile size not 0 after truncate"
369 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
372 test_mkdir $DIR/$tdir
373 touch $DIR/$tdir/$tfile
375 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
377 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
380 test_mkdir $DIR/$tdir
381 touch $DIR/$tdir/$tfile
382 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
383 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
384 error "$tdir/${tfile_2} not a file after rename"
385 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
387 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
390 test_mkdir $DIR/$tdir
391 touch $DIR/$tdir/$tfile
392 rm -rf $DIR/$tdir/$tfile
393 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
395 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
398 test_mkdir $DIR/$tdir
399 touch $DIR/$tdir/$tfile
400 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
402 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
403 error "$tdir/l-exist not a symlink"
404 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
405 error "$tdir/l-exist not referencing a file"
406 rm -f $DIR/$tdir/l-exist
407 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
409 run_test 17a "symlinks: create, remove (real)"
412 test_mkdir $DIR/$tdir
413 ln -s no-such-file $DIR/$tdir/l-dangle
415 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
416 error "$tdir/l-dangle not referencing no-such-file"
417 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
418 error "$tdir/l-dangle not referencing non-existent file"
419 rm -f $DIR/$tdir/l-dangle
420 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
422 run_test 17b "symlinks: create, remove (dangling)"
424 test_17c() { # bug 3440 - don't save failed open RPC for replay
425 test_mkdir $DIR/$tdir
426 ln -s foo $DIR/$tdir/$tfile
427 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
429 run_test 17c "symlinks: open dangling (should return error)"
432 test_mkdir $DIR/$tdir
433 ln -s foo $DIR/$tdir/$tfile
434 touch $DIR/$tdir/$tfile || error "creating to new symlink"
436 run_test 17d "symlinks: create dangling"
439 test_mkdir $DIR/$tdir
440 local foo=$DIR/$tdir/$tfile
441 ln -s $foo $foo || error "create symlink failed"
442 ls -l $foo || error "ls -l failed"
443 ls $foo && error "ls not failed" || true
445 run_test 17e "symlinks: create recursive symlink (should return error)"
448 test_mkdir $DIR/$tdir
449 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
454 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
457 run_test 17f "symlinks: long and very long symlink name"
459 # str_repeat(S, N) generate a string that is string S repeated N times
464 while [ $((n -= 1)) -ge 0 ]; do
470 # Long symlinks and LU-2241
472 test_mkdir $DIR/$tdir
473 local TESTS="59 60 61 4094 4095"
475 # Fix for inode size boundary in 2.1.4
476 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
479 # Patch not applied to 2.2 or 2.3 branches
480 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
481 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
484 # skip long symlink name for rhel6.5.
485 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
486 grep -q '6.5' /etc/redhat-release &>/dev/null &&
487 TESTS="59 60 61 4062 4063"
490 local SYMNAME=$(str_repeat 'x' $i)
491 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
492 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
495 run_test 17g "symlinks: really long symlink name and inode boundaries"
497 test_17h() { #bug 17378
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
501 test_mkdir $DIR/$tdir
502 if [[ $MDSCOUNT -gt 1 ]]; then
503 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
507 $LFS setstripe -c -1 $DIR/$tdir
508 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
509 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
510 touch $DIR/$tdir/$tfile || true
512 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
514 test_17i() { #bug 20018
515 remote_mds_nodsh && skip "remote MDS with nodsh" && return
516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
517 test_mkdir -c1 $DIR/$tdir
518 local foo=$DIR/$tdir/$tfile
520 if [[ $MDSCOUNT -gt 1 ]]; then
521 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
525 ln -s $foo $foo || error "create symlink failed"
526 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
527 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
528 ls -l $foo && error "error not detected"
531 run_test 17i "don't panic on short symlink"
533 test_17k() { #bug 22301
534 [[ -z "$(which rsync 2>/dev/null)" ]] &&
535 skip "no rsync command" && return 0
536 rsync --help | grep -q xattr ||
537 skip_env "$(rsync --version | head -n1) does not support xattrs"
538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
539 test_mkdir $DIR/$tdir
540 test_mkdir $DIR/$tdir.new
541 touch $DIR/$tdir/$tfile
542 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
543 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
544 error "rsync failed with xattrs enabled"
546 run_test 17k "symlinks: rsync with xattrs enabled"
548 test_17l() { # LU-279
549 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
550 skip "no getfattr command" && return 0
551 test_mkdir $DIR/$tdir
552 touch $DIR/$tdir/$tfile
553 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
554 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
555 # -h to not follow symlinks. -m '' to list all the xattrs.
556 # grep to remove first line: '# file: $path'.
557 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
559 lgetxattr_size_check $path $xattr ||
560 error "lgetxattr_size_check $path $xattr failed"
564 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
568 local short_sym="0123456789"
569 local wdir=$DIR/$tdir
572 remote_mds_nodsh && skip "remote MDS with nodsh" && return
573 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
574 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
575 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
577 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
578 skip "ldiskfs only test" && return 0
580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
584 # create a long symlink file
585 for ((i = 0; i < 4; ++i)); do
586 long_sym=${long_sym}${long_sym}
589 echo "create 512 short and long symlink files under $wdir"
590 for ((i = 0; i < 256; ++i)); do
591 ln -sf ${long_sym}"a5a5" $wdir/long-$i
592 ln -sf ${short_sym}"a5a5" $wdir/short-$i
598 wait_delete_completed
600 echo "recreate the 512 symlink files with a shorter string"
601 for ((i = 0; i < 512; ++i)); do
602 # rewrite the symlink file with a shorter string
603 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
604 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
607 local mds_index=$(($($LFS getstripe -M $wdir) + 1))
608 local devname=$(mdsdevname $mds_index)
610 echo "stop and checking mds${mds_index}:"
611 # e2fsck should not return error
613 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
616 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
617 error "start mds${mds_index} failed"
618 df $MOUNT > /dev/null 2>&1
620 error "e2fsck detected error for short/long symlink: rc=$rc"
622 run_test 17m "run e2fsck against MDT which contains short/long symlink"
624 check_fs_consistency_17n() {
628 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
629 # so it only check MDT1/MDT2 instead of all of MDTs.
630 for mdt_index in 1 2; do
631 local devname=$(mdsdevname $mdt_index)
632 # e2fsck should not return error
634 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
637 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
638 error "mount mds$mdt_index failed"
639 df $MOUNT > /dev/null 2>&1
647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
648 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
649 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
650 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
652 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
653 skip "ldiskfs only test" && return 0
655 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
659 test_mkdir $DIR/$tdir
660 for ((i=0; i<10; i++)); do
661 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
662 error "create remote dir error $i"
663 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
664 error "create files under remote dir failed $i"
667 check_fs_consistency_17n ||
668 error "e2fsck report error after create files under remote dir"
670 for ((i = 0; i < 10; i++)); do
671 rm -rf $DIR/$tdir/remote_dir_${i} ||
672 error "destroy remote dir error $i"
675 check_fs_consistency_17n ||
676 error "e2fsck report error after unlink files under remote dir"
678 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
679 skip "lustre < 2.4.50 does not support migrate mv " && return
681 for ((i = 0; i < 10; i++)); do
682 mkdir -p $DIR/$tdir/remote_dir_${i}
683 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
684 error "create files under remote dir failed $i"
685 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
686 error "migrate remote dir error $i"
688 check_fs_consistency_17n || error "e2fsck report error after migration"
690 for ((i = 0; i < 10; i++)); do
691 rm -rf $DIR/$tdir/remote_dir_${i} ||
692 error "destroy remote dir error $i"
695 check_fs_consistency_17n || error "e2fsck report error after unlink"
697 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
700 remote_mds_nodsh && skip "remote MDS with nodsh" && return
701 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
702 skip "Need MDS version at least 2.3.64" && return
704 local wdir=$DIR/${tdir}o
710 mdt_index=$($LFS getstripe -M $wdir/$tfile)
711 mdt_index=$((mdt_index + 1))
714 #fail mds will wait the failover finish then set
715 #following fail_loc to avoid interfer the recovery process.
718 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
719 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
720 ls -l $wdir/$tfile && rc=1
721 do_facet mds${mdt_index} lctl set_param fail_loc=0
722 [[ $rc -eq 0 ]] || error "stat file should fail"
724 run_test 17o "stat file with incompat LMA feature"
727 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
728 ls $DIR || error "Failed to ls $DIR: $?"
730 run_test 18 "touch .../f ; ls ... =============================="
736 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
738 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
741 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
743 run_test 19b "ls -l .../f19 (should return error) =============="
746 [ $RUNAS_ID -eq $UID ] &&
747 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
748 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
750 run_test 19c "$RUNAS touch .../f19 (should return error) =="
753 cat $DIR/f19 && error || true
755 run_test 19d "cat .../f19 (should return error) =============="
764 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
766 run_test 20 "touch .../f ; ls -l ..."
769 test_mkdir $DIR/$tdir
770 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
771 ln -s dangle $DIR/$tdir/link
772 echo foo >> $DIR/$tdir/link
773 cat $DIR/$tdir/dangle
774 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
775 $CHECKSTAT -f -t file $DIR/$tdir/link ||
776 error "$tdir/link not linked to a file"
778 run_test 21 "write to dangling link"
781 local wdir=$DIR/$tdir
783 chown $RUNAS_ID:$RUNAS_GID $wdir
784 (cd $wdir || error "cd $wdir failed";
785 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
787 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
788 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
789 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
790 error "checkstat -u failed"
792 run_test 22 "unpack tar archive as non-root user"
796 test_mkdir $DIR/$tdir
797 local file=$DIR/$tdir/$tfile
799 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
800 openfile -f O_CREAT:O_EXCL $file &&
801 error "$file recreate succeeded" || true
803 run_test 23a "O_CREAT|O_EXCL in subdir"
805 test_23b() { # bug 18988
806 test_mkdir $DIR/$tdir
807 local file=$DIR/$tdir/$tfile
810 echo foo > $file || error "write filed"
811 echo bar >> $file || error "append filed"
812 $CHECKSTAT -s 8 $file || error "wrong size"
815 run_test 23b "O_APPEND check"
819 echo '-- same directory rename'
820 test_mkdir $DIR/$tdir
821 touch $DIR/$tdir/$tfile.1
822 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
823 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
825 run_test 24a "rename file to non-existent target"
828 test_mkdir $DIR/$tdir
829 touch $DIR/$tdir/$tfile.{1,2}
830 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
831 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
832 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
834 run_test 24b "rename file to existing target"
837 test_mkdir $DIR/$tdir
838 test_mkdir $DIR/$tdir/d$testnum.1
839 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
840 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
841 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
843 run_test 24c "rename directory to non-existent target"
846 test_mkdir -c1 $DIR/$tdir
847 test_mkdir -c1 $DIR/$tdir/d$testnum.1
848 test_mkdir -c1 $DIR/$tdir/d$testnum.2
849 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
850 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
851 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
853 run_test 24d "rename directory to existing target"
856 echo '-- cross directory renames --'
860 mv $DIR/R5a/f $DIR/R5b/g
861 $CHECKSTAT -a $DIR/R5a/f || error
862 $CHECKSTAT -t file $DIR/R5b/g || error
864 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
869 touch $DIR/R6a/f $DIR/R6b/g
870 mv $DIR/R6a/f $DIR/R6b/g
871 $CHECKSTAT -a $DIR/R6a/f || error
872 $CHECKSTAT -t file $DIR/R6b/g || error
874 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
879 test_mkdir $DIR/R7a/d
880 mv $DIR/R7a/d $DIR/R7b/e
881 $CHECKSTAT -a $DIR/R7a/d || error
882 $CHECKSTAT -t dir $DIR/R7b/e || error
884 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
887 test_mkdir -c1 $DIR/R8a
888 test_mkdir -c1 $DIR/R8b
889 test_mkdir -c1 $DIR/R8a/d
890 test_mkdir -c1 $DIR/R8b/e
891 mrename $DIR/R8a/d $DIR/R8b/e
892 $CHECKSTAT -a $DIR/R8a/d || error
893 $CHECKSTAT -t dir $DIR/R8b/e || error
895 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
898 echo "-- rename error cases"
902 mrename $DIR/R9/f $DIR/R9/a
903 $CHECKSTAT -t file $DIR/R9/f || error
904 $CHECKSTAT -t dir $DIR/R9/a || error
905 $CHECKSTAT -a $DIR/R9/a/f || error
907 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
911 mrename $DIR/R10/f $DIR/R10/g
912 $CHECKSTAT -t dir $DIR/R10 || error
913 $CHECKSTAT -a $DIR/R10/f || error
914 $CHECKSTAT -a $DIR/R10/g || error
916 run_test 24j "source does not exist ============================"
920 test_mkdir $DIR/R11a/d
922 mv $DIR/R11a/f $DIR/R11a/d
923 $CHECKSTAT -a $DIR/R11a/f || error
924 $CHECKSTAT -t file $DIR/R11a/d/f || error
926 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
928 # bug 2429 - rename foo foo foo creates invalid file
931 $MULTIOP $f OcNs || error
933 run_test 24l "Renaming a file to itself ========================"
937 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
938 # on ext3 this does not remove either the source or target files
939 # though the "expected" operation would be to remove the source
940 $CHECKSTAT -t file ${f} || error "${f} missing"
941 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
943 run_test 24m "Renaming a file to a hard link to itself ========="
947 # this stats the old file after it was renamed, so it should fail
951 $CHECKSTAT ${f}.rename
954 run_test 24n "Statting the old file after renaming (Posix rename 2)"
957 test_mkdir $DIR/$tdir
958 rename_many -s random -v -n 10 $DIR/$tdir
960 run_test 24o "rename of files during htree split"
965 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
966 mrename $DIR/R12a $DIR/R12b
967 $CHECKSTAT -a $DIR/R12a || error
968 $CHECKSTAT -t dir $DIR/R12b || error
969 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
970 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
972 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
974 cleanup_multiop_pause() {
980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
983 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
984 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
987 trap cleanup_multiop_pause EXIT
988 mrename $DIR/R13a $DIR/R13b
989 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
990 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
991 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
992 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
993 cleanup_multiop_pause
994 wait $MULTIPID || error "multiop close failed"
996 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
998 test_24r() { #bug 3789
1000 test_mkdir $DIR/R14a/b
1001 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1002 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1003 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1005 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1008 test_mkdir $DIR/R15a
1009 test_mkdir $DIR/R15a/b
1010 test_mkdir $DIR/R15a/b/c
1011 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1012 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1013 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1015 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1017 test_mkdir $DIR/R16a
1018 test_mkdir $DIR/R16a/b
1019 test_mkdir $DIR/R16a/b/c
1020 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1021 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1022 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1024 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1026 test_24u() { # bug12192
1027 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1028 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1030 run_test 24u "create stripe file"
1034 size=$(getconf PAGE_SIZE 2>/dev/null)
1035 echo -n ${size:-4096}
1038 simple_cleanup_common() {
1041 [ -z "$DIR" -o -z "$tdir" ] && return 0
1043 local start=$SECONDS
1046 wait_delete_completed
1047 echo "cleanup time $((SECONDS - start))"
1051 max_pages_per_rpc() {
1052 local mdtname="$(printf "MDT%04x" ${1:-0})"
1053 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1058 local nrfiles=${COUNT:-100000}
1059 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1060 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1062 local fname="$DIR/$tdir/$tfile"
1063 test_mkdir "$(dirname $fname)"
1064 # assume MDT0000 has the fewest inodes
1065 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1066 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1067 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1069 trap simple_cleanup_common EXIT
1071 createmany -m "$fname" $nrfiles
1073 cancel_lru_locks mdc
1074 lctl set_param mdc.*.stats clear
1076 # was previously test_24D: LU-6101
1077 # readdir() returns correct number of entries after cursor reload
1078 local num_ls=$(ls $DIR/$tdir | wc -l)
1079 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1080 local num_all=$(ls -a $DIR/$tdir | wc -l)
1081 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1082 $num_all -ne $((nrfiles + 2)) ]; then
1083 error "Expected $nrfiles files, got $num_ls " \
1084 "($num_uniq unique $num_all .&..)"
1086 # LU-5 large readdir
1087 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1088 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1089 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1090 # take into account of overhead in lu_dirpage header and end mark in
1091 # each page, plus one in rpc_num calculation.
1092 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1093 local page_entries=$((($(page_size) - 24) / dirent_size))
1094 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1095 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1096 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1097 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1098 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1099 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1100 error "large readdir doesn't take effect: " \
1101 "$mds_readpage should be about $rpc_max"
1103 simple_cleanup_common
1105 run_test 24v "list large directory (test hash collision, b=17560)"
1107 test_24w() { # bug21506
1109 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1110 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1111 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1112 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1113 [[ "$SZ1" -eq "$SZ2" ]] ||
1114 error "Error reading at the end of the file $tfile"
1116 run_test 24w "Reading a file larger than 4Gb"
1119 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1121 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1122 skip "Need MDS version at least 2.7.56" && return
1124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1126 local remote_dir=$DIR/$tdir/remote_dir
1128 test_mkdir $DIR/$tdir
1129 $LFS mkdir -i $MDTIDX $remote_dir ||
1130 error "create remote directory failed"
1132 test_mkdir $DIR/$tdir/src_dir
1133 touch $DIR/$tdir/src_file
1134 test_mkdir $remote_dir/tgt_dir
1135 touch $remote_dir/tgt_file
1137 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1138 error "rename dir cross MDT failed!"
1140 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1141 error "rename file cross MDT failed!"
1143 touch $DIR/$tdir/ln_file
1144 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1145 error "ln file cross MDT failed"
1147 rm -rf $DIR/$tdir || error "Can not delete directories"
1149 run_test 24x "cross MDT rename/link"
1152 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1154 local remote_dir=$DIR/$tdir/remote_dir
1157 test_mkdir $DIR/$tdir
1158 $LFS mkdir -i $mdtidx $remote_dir ||
1159 error "create remote directory failed"
1161 test_mkdir $remote_dir/src_dir
1162 touch $remote_dir/src_file
1163 test_mkdir $remote_dir/tgt_dir
1164 touch $remote_dir/tgt_file
1166 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1167 error "rename subdir in the same remote dir failed!"
1169 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1170 error "rename files in the same remote dir failed!"
1172 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1173 error "link files in the same remote dir failed!"
1175 rm -rf $DIR/$tdir || error "Can not delete directories"
1177 run_test 24y "rename/link on the same dir should succeed"
1179 test_24A() { # LU-3182
1183 test_mkdir $DIR/$tdir
1184 trap simple_cleanup_common EXIT
1185 createmany -m $DIR/$tdir/$tfile $NFILES
1186 local t=$(ls $DIR/$tdir | wc -l)
1187 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1188 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1189 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1190 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1193 simple_cleanup_common || error "Can not delete directories"
1195 run_test 24A "readdir() returns correct number of entries."
1197 test_24B() { # LU-4805
1198 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1201 test_mkdir $DIR/$tdir
1202 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1203 error "create striped dir failed"
1205 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1206 [ $count -eq 2 ] || error "Expected 2, got $count"
1208 touch $DIR/$tdir/striped_dir/a
1210 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1211 [ $count -eq 3 ] || error "Expected 3, got $count"
1213 touch $DIR/$tdir/striped_dir/.f
1215 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1216 [ $count -eq 4 ] || error "Expected 4, got $count"
1218 rm -rf $DIR/$tdir || error "Can not delete directories"
1220 run_test 24B "readdir for striped dir return correct number of entries"
1223 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1229 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1230 error "create striped dir failed"
1232 cd $DIR/$tdir/d0/striped_dir
1234 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1235 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1236 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1238 [ "$d0_ino" = "$parent_ino" ] ||
1239 error ".. wrong, expect $d0_ino, get $parent_ino"
1241 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1242 error "mv striped dir failed"
1244 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1246 [ "$d1_ino" = "$parent_ino" ] ||
1247 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1249 run_test 24C "check .. in striped dir"
1252 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1256 mkdir $DIR/$tdir/src_dir
1257 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1258 error "create remote source failed"
1260 touch $DIR/$tdir/src_dir/src_child/a
1262 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1263 error "create remote target dir failed"
1265 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1266 error "create remote target child failed"
1268 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1269 error "rename dir cross MDT failed!"
1273 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1274 error "src_child still exists after rename"
1276 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1277 error "missing file(a) after rename"
1279 rm -rf $DIR/$tdir || error "Can not delete directories"
1281 run_test 24E "cross MDT rename/link"
1284 echo '== symlink sanity ============================================='
1288 touch $DIR/s25/foo || error
1290 run_test 25a "create file in symlinked directory ==============="
1293 [ ! -d $DIR/d25 ] && test_25a
1294 $CHECKSTAT -t file $DIR/s25/foo || error
1296 run_test 25b "lookup file in symlinked directory ==============="
1300 test_mkdir $DIR/d26/d26-2
1301 ln -s d26/d26-2 $DIR/s26
1302 touch $DIR/s26/foo || error
1304 run_test 26a "multiple component symlink ======================="
1307 test_mkdir -p $DIR/$tdir/d26-2
1308 ln -s $tdir/d26-2/foo $DIR/s26-2
1309 touch $DIR/s26-2 || error
1311 run_test 26b "multiple component symlink at end of lookup ======"
1314 test_mkdir $DIR/d26.2
1315 touch $DIR/d26.2/foo
1316 ln -s d26.2 $DIR/s26.2-1
1317 ln -s s26.2-1 $DIR/s26.2-2
1318 ln -s s26.2-2 $DIR/s26.2-3
1319 chmod 0666 $DIR/s26.2-3/foo
1321 run_test 26c "chain of symlinks"
1323 # recursive symlinks (bug 439)
1325 ln -s d26-3/foo $DIR/d26-3
1327 run_test 26d "create multiple component recursive symlink"
1330 [ ! -h $DIR/d26-3 ] && test_26d
1333 run_test 26e "unlink multiple component recursive symlink"
1335 # recursive symlinks (bug 7022)
1337 test_mkdir $DIR/$tdir
1338 test_mkdir $DIR/$tdir/$tfile
1339 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1340 test_mkdir -p lndir/bar1
1341 test_mkdir $DIR/$tdir/$tfile/$tfile
1342 cd $tfile || error "cd $tfile failed"
1343 ln -s .. dotdot || error "ln dotdot failed"
1344 ln -s dotdot/lndir lndir || error "ln lndir failed"
1345 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1346 output=`ls $tfile/$tfile/lndir/bar1`
1347 [ "$output" = bar1 ] && error "unexpected output"
1348 rm -r $tfile || error "rm $tfile failed"
1349 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1351 run_test 26f "rm -r of a directory which has recursive symlink"
1354 test_mkdir $DIR/$tdir
1355 $LFS getstripe $DIR/$tdir
1356 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1357 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1358 cp /etc/hosts $DIR/$tdir/$tfile || error
1360 run_test 27a "one stripe file"
1363 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1364 test_mkdir $DIR/$tdir
1365 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1366 $LFS getstripe -c $DIR/$tdir/$tfile
1367 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1368 error "two-stripe file doesn't have two stripes"
1370 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1372 run_test 27b "create and write to two stripe file"
1375 test_mkdir $DIR/$tdir
1376 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1377 error "setstripe failed"
1378 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1379 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1381 run_test 27d "create file with default settings"
1384 # LU-5839 adds check for existed layout before setting it
1385 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1386 skip "Need MDS version at least 2.7.56" && return
1387 test_mkdir $DIR/$tdir
1388 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1389 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1390 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1392 run_test 27e "setstripe existing file (should return error)"
1395 test_mkdir $DIR/$tdir
1396 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1397 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1398 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1399 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1400 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1401 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1403 run_test 27f "setstripe with bad stripe size (should return error)"
1406 test_mkdir $DIR/$tdir
1407 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1408 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1409 error "$DIR/$tdir/$tfile has object"
1411 run_test 27g "$LFS getstripe with no objects"
1414 test_mkdir $DIR/$tdir
1415 touch $DIR/$tdir/$tfile || error "touch failed"
1416 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1417 error "missing objects"
1419 run_test 27i "$LFS getstripe with some objects"
1422 test_mkdir $DIR/$tdir
1423 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1424 error "setstripe failed" || true
1426 run_test 27j "setstripe with bad stripe offset (should return error)"
1428 test_27k() { # bug 2844
1429 test_mkdir $DIR/$tdir
1430 local file=$DIR/$tdir/$tfile
1431 local ll_max_blksize=$((4 * 1024 * 1024))
1432 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1433 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1434 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1435 dd if=/dev/zero of=$file bs=4k count=1
1436 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1437 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1439 run_test 27k "limit i_blksize for broken user apps"
1442 mcreate $DIR/$tfile || error "creating file"
1443 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1444 error "setstripe should have failed" || true
1446 run_test 27l "check setstripe permissions (should return error)"
1449 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1451 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1453 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1454 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1457 trap simple_cleanup_common EXIT
1458 test_mkdir $DIR/$tdir
1459 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1460 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1461 error "dd should fill OST0"
1463 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1465 [ $i -gt 256 ] && break
1468 touch $DIR/$tdir/$tfile.$i
1469 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1470 awk '{print $1}'| grep -w "0") ] &&
1471 error "OST0 was full but new created file still use it"
1473 touch $DIR/$tdir/$tfile.$i
1474 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1475 awk '{print $1}'| grep -w "0") ] &&
1476 error "OST0 was full but new created file still use it"
1477 simple_cleanup_common
1479 run_test 27m "create file while OST0 was full"
1482 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1483 head -n 1 | awk '{ print $1 * 2 }')
1487 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1488 # if the OST isn't full anymore.
1490 local OSTIDX=${1:-""}
1492 local list=$(comma_list $(osts_nodes))
1493 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1495 do_nodes $list lctl set_param fail_loc=0
1496 sync # initiate all OST_DESTROYs from MDS to OST
1500 exhaust_precreations() {
1503 local FAILIDX=${3:-$OSTIDX}
1504 local ofacet=ost$((OSTIDX + 1))
1506 test_mkdir -p -c1 $DIR/$tdir
1507 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1508 local mfacet=mds$((mdtidx + 1))
1509 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1511 local OST=$(ostname_from_index $OSTIDX)
1514 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1515 local last_id=$(do_facet $mfacet lctl get_param -n \
1516 osc.$mdtosc_proc1.prealloc_last_id)
1517 local next_id=$(do_facet $mfacet lctl get_param -n \
1518 osc.$mdtosc_proc1.prealloc_next_id)
1520 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1521 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1523 test_mkdir -p $DIR/$tdir/${OST}
1524 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1525 #define OBD_FAIL_OST_ENOSPC 0x215
1526 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1527 echo "Creating to objid $last_id on ost $OST..."
1528 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1529 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1530 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1534 exhaust_all_precreations() {
1536 for (( i=0; i < OSTCOUNT; i++ )) ; do
1537 exhaust_precreations $i $1 -1
1542 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1544 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1545 remote_ost_nodsh && skip "remote OST with nodsh" && return
1548 rm -f $DIR/$tdir/$tfile
1549 exhaust_precreations 0 0x80000215
1550 $LFS setstripe -c -1 $DIR/$tdir
1551 touch $DIR/$tdir/$tfile || error
1552 $LFS getstripe $DIR/$tdir/$tfile
1555 run_test 27n "create file with some full OSTs"
1558 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1560 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1561 remote_ost_nodsh && skip "remote OST with nodsh" && return
1564 rm -f $DIR/$tdir/$tfile
1565 exhaust_all_precreations 0x215
1567 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1572 run_test 27o "create file with all full OSTs (should error)"
1575 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1578 remote_ost_nodsh && skip "remote OST with nodsh" && return
1581 rm -f $DIR/$tdir/$tfile
1582 test_mkdir $DIR/$tdir
1584 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1585 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1586 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1588 exhaust_precreations 0 0x80000215
1589 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1590 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1591 $LFS getstripe $DIR/$tdir/$tfile
1595 run_test 27p "append to a truncated file with some full OSTs"
1598 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1600 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1601 remote_ost_nodsh && skip "remote OST with nodsh" && return
1604 rm -f $DIR/$tdir/$tfile
1606 test_mkdir $DIR/$tdir
1607 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1608 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1609 error "truncate $DIR/$tdir/$tfile failed"
1610 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1612 exhaust_all_precreations 0x215
1614 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1615 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1619 run_test 27q "append to truncated file with all OSTs full (should error)"
1622 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1625 remote_ost_nodsh && skip "remote OST with nodsh" && return
1628 rm -f $DIR/$tdir/$tfile
1629 exhaust_precreations 0 0x80000215
1631 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error
1635 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1637 test_27s() { # bug 10725
1638 test_mkdir $DIR/$tdir
1639 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1640 local stripe_count=0
1641 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1642 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1643 error "stripe width >= 2^32 succeeded" || true
1646 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1648 test_27t() { # bug 10864
1653 $WLFS getstripe $tfile
1656 run_test 27t "check that utils parse path correctly"
1658 test_27u() { # bug 4900
1659 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1660 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1662 local list=$(comma_list $(mdts_nodes))
1664 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1665 do_nodes $list $LCTL set_param fail_loc=0x139
1666 test_mkdir -p $DIR/$tdir
1667 trap simple_cleanup_common EXIT
1668 createmany -o $DIR/$tdir/t- 1000
1669 do_nodes $list $LCTL set_param fail_loc=0
1671 TLOG=$TMP/$tfile.getstripe
1672 $LFS getstripe $DIR/$tdir > $TLOG
1673 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1674 unlinkmany $DIR/$tdir/t- 1000
1676 [[ $OBJS -gt 0 ]] &&
1677 error "$OBJS objects created on OST-0. See $TLOG" ||
1680 run_test 27u "skip object creation on OSC w/o objects"
1682 test_27v() { # bug 4900
1683 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1684 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1685 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1686 remote_ost_nodsh && skip "remote OST with nodsh" && return
1688 exhaust_all_precreations 0x215
1691 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1693 touch $DIR/$tdir/$tfile
1694 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1696 for (( i=1; i < OSTCOUNT; i++ )); do
1697 do_facet ost$i lctl set_param fail_loc=0x705
1699 local START=`date +%s`
1700 createmany -o $DIR/$tdir/$tfile 32
1702 local FINISH=`date +%s`
1703 local TIMEOUT=`lctl get_param -n timeout`
1704 local PROCESS=$((FINISH - START))
1705 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1706 error "$FINISH - $START >= $TIMEOUT / 2"
1707 sleep $((TIMEOUT / 2 - PROCESS))
1710 run_test 27v "skip object creation on slow OST"
1712 test_27w() { # bug 10997
1713 test_mkdir $DIR/$tdir
1714 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1715 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1716 error "stripe size $size != 65536" || true
1717 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1718 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1720 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1723 [[ $OSTCOUNT -lt 2 ]] &&
1724 skip_env "skipping multiple stripe count/offset test" && return
1726 test_mkdir $DIR/$tdir
1727 for i in $(seq 1 $OSTCOUNT); do
1729 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1730 error "setstripe -c $i -i $offset failed"
1731 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1732 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1733 [ $count -ne $i ] && error "stripe count $count != $i" || true
1734 [ $index -ne $offset ] &&
1735 error "stripe offset $index != $offset" || true
1738 run_test 27wa "check $LFS setstripe -c -i options"
1741 remote_ost_nodsh && skip "remote OST with nodsh" && return
1742 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1744 OFFSET=$(($OSTCOUNT - 1))
1746 local OST=$(ostname_from_index $OSTIDX)
1748 test_mkdir $DIR/$tdir
1749 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1750 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1752 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1753 for i in $(seq 0 $OFFSET); do
1754 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1755 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1756 error "OST0 was degraded but new created file still use it"
1758 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1760 run_test 27x "create files while OST0 is degraded"
1763 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1764 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1765 remote_ost_nodsh && skip "remote OST with nodsh" && return
1766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1768 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1769 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1770 osc.$mdtosc.prealloc_last_id)
1771 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1772 osc.$mdtosc.prealloc_next_id)
1773 local fcount=$((last_id - next_id))
1774 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1775 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1777 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1778 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1779 local OST_DEACTIVE_IDX=-1
1784 for OSC in $MDS_OSCS; do
1785 OST=$(osc_to_ost $OSC)
1786 OSTIDX=$(index_from_ostuuid $OST)
1787 if [ $OST_DEACTIVE_IDX == -1 ]; then
1788 OST_DEACTIVE_IDX=$OSTIDX
1790 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1791 echo $OSC "is Deactivated:"
1792 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1796 OSTIDX=$(index_from_ostuuid $OST)
1797 test_mkdir $DIR/$tdir
1798 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1800 for OSC in $MDS_OSCS; do
1801 OST=$(osc_to_ost $OSC)
1802 OSTIDX=$(index_from_ostuuid $OST)
1803 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1804 echo $OST "is degraded:"
1805 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1806 obdfilter.$OST.degraded=1
1811 createmany -o $DIR/$tdir/$tfile $fcount
1813 for OSC in $MDS_OSCS; do
1814 OST=$(osc_to_ost $OSC)
1815 OSTIDX=$(index_from_ostuuid $OST)
1816 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1817 echo $OST "is recovered from degraded:"
1818 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1819 obdfilter.$OST.degraded=0
1821 do_facet $SINGLEMDS lctl --device %$OSC activate
1825 # all osp devices get activated, hence -1 stripe count restored
1826 local stripe_count=0
1828 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1829 # devices get activated.
1831 $LFS setstripe -c -1 $DIR/$tfile
1832 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1834 [ $stripe_count -ne $OSTCOUNT ] &&
1835 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1838 run_test 27y "create files while OST0 is degraded and the rest inactive"
1844 lmm_count=$($GETSTRIPE -c $1)
1845 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1846 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1848 local old_ifs="$IFS"
1850 fid=($($LFS path2fid $1))
1853 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1854 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1856 # compare lmm_seq and lu_fid->f_seq
1857 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1858 # compare lmm_object_id and lu_fid->oid
1859 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1861 # check the trusted.fid attribute of the OST objects of the file
1862 local have_obdidx=false
1864 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1865 # skip lines up to and including "obdidx"
1866 [ -z "$obdidx" ] && break
1867 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1868 $have_obdidx || continue
1870 local ost=$((obdidx + 1))
1871 local dev=$(ostdevname $ost)
1874 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1876 seq=$(echo $seq | sed -e "s/^0x//g")
1877 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1878 oid_hex=$(echo $oid)
1880 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1882 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1886 # Don't unmount/remount the OSTs if we don't need to do that.
1887 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1888 # update too, until that use mount/ll_decode_filter_fid/mount.
1889 # Re-enable when debugfs will understand new filter_fid.
1891 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
1892 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1893 $dev 2>/dev/null" | grep "parent=")
1895 if [ -z "$ff" ]; then
1897 mount_fstype ost$ost
1898 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1899 $(facet_mntpt ost$ost)/$obj_file)
1900 unmount_fstype ost$ost
1901 start ost$ost $dev $OST_MOUNT_OPTS
1905 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1907 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1909 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1910 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1912 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
1913 # stripe_size=1048576 component_id=1 component_start=0 \
1914 # component_end=33554432
1915 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
1916 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
1917 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
1919 if grep -q 'stripe=' <<<$ff; then
1920 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
1922 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1923 # into f_ver in this case. See comment on ff_parent.
1924 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
1927 # compare lmm_seq and filter_fid->ff_parent.f_seq
1928 [ $ff_pseq = $lmm_seq ] ||
1929 error "FF parent SEQ $ff_pseq != $lmm_seq"
1930 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1931 [ $ff_poid = $lmm_oid ] ||
1932 error "FF parent OID $ff_poid != $lmm_oid"
1933 (($ff_pstripe == $stripe_nr)) ||
1934 error "FF stripe $ff_pstripe != $stripe_nr"
1936 stripe_nr=$((stripe_nr + 1))
1937 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
1939 if grep -q 'stripe_count=' <<<$ff; then
1940 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
1941 -e 's/ .*//' <<<$ff)
1942 [ $lmm_count = $ff_scnt ] ||
1943 error "FF stripe count $lmm_count != $ff_scnt"
1949 remote_ost_nodsh && skip "remote OST with nodsh" && return
1950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1951 test_mkdir $DIR/$tdir
1953 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1954 { error "setstripe -c -1 failed"; return 1; }
1955 # We need to send a write to every object to get parent FID info set.
1956 # This _should_ also work for setattr, but does not currently.
1957 # touch $DIR/$tdir/$tfile-1 ||
1958 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1959 { error "dd $tfile-1 failed"; return 2; }
1960 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1961 { error "setstripe -c -1 failed"; return 3; }
1962 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1963 { error "dd $tfile-2 failed"; return 4; }
1965 # make sure write RPCs have been sent to OSTs
1968 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1969 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1971 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1973 test_27A() { # b=19102
1974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1975 local restore_size=$($GETSTRIPE -S $MOUNT)
1976 local restore_count=$($GETSTRIPE -c $MOUNT)
1977 local restore_offset=$($GETSTRIPE -i $MOUNT)
1978 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1979 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1980 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1981 local default_size=$($GETSTRIPE -S $MOUNT)
1982 local default_offset=$($GETSTRIPE -i $MOUNT)
1983 local dsize=$((1024 * 1024))
1984 [ $default_size -eq $dsize ] ||
1985 error "stripe size $default_size != $dsize"
1986 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1987 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1989 run_test 27A "check filesystem-wide default LOV EA values"
1991 test_27B() { # LU-2523
1992 test_mkdir $DIR/$tdir
1993 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1995 # open f1 with O_LOV_DELAY_CREATE
1997 # call setstripe ioctl on open file descriptor for f1
1999 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2003 # open f1 with O_LOV_DELAY_CREATE
2005 # call setstripe ioctl on open file descriptor for f1
2007 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2009 # Allow multiop to fail in imitation of NFS's busted semantics.
2012 run_test 27B "call setstripe on open unlinked file/rename victim"
2014 test_27C() { #LU-2871
2015 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2023 test_mkdir $DIR/$tdir
2025 for i in $(seq 0 $((OSTCOUNT - 1))); do
2026 # set stripe across all OSTs starting from OST$i
2027 $SETSTRIPE -i $i -c -1 $tfile$i
2028 # get striping information
2029 ost_idx=($($GETSTRIPE $tfile$i |
2030 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2034 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2035 error "${#ost_idx[@]} != $OSTCOUNT"
2037 for index in $(seq 0 $((OSTCOUNT - 1))); do
2039 for j in $(echo ${ost_idx[@]}); do
2040 if [ $index -eq $j ]; then
2046 error "Can not find $index in ${ost_idx[@]}"
2050 run_test 27C "check full striping across all OSTs"
2053 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2054 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2055 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2056 local POOL=${POOL:-testpool}
2058 local last_ost=$(($OSTCOUNT - 1))
2060 local ost_list=$(seq $first_ost $ost_step $last_ost)
2061 local ost_range="$first_ost $last_ost $ost_step"
2063 if ! combined_mgs_mds ; then
2067 test_mkdir $DIR/$tdir
2068 pool_add $POOL || error "pool_add failed"
2069 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2072 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2074 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2075 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2076 skip27D += "-s 30,31"
2077 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2078 error "llapi_layout_test failed"
2080 destroy_test_pools || error "destroy test pools failed"
2082 if ! combined_mgs_mds ; then
2086 run_test 27D "validate llapi_layout API"
2088 # Verify that default_easize is increased from its initial value after
2089 # accessing a widely striped file.
2091 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2092 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2093 skip "client does not have LU-3338 fix" && return
2095 # 72 bytes is the minimum space required to store striping
2096 # information for a file striped across one OST:
2097 # (sizeof(struct lov_user_md_v3) +
2098 # sizeof(struct lov_user_ost_data_v1))
2100 $LCTL set_param -n llite.*.default_easize $min_easize ||
2101 error "lctl set_param failed"
2102 local easize=$($LCTL get_param -n llite.*.default_easize)
2104 [ $easize -eq $min_easize ] ||
2105 error "failed to set default_easize"
2107 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2108 error "setstripe failed"
2112 easize=$($LCTL get_param -n llite.*.default_easize)
2114 [ $easize -gt $min_easize ] ||
2115 error "default_easize not updated"
2117 run_test 27E "check that default extended attribute size properly increases"
2119 test_27F() { # LU-5346/LU-7975
2120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2121 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2122 skip "Need MDS version at least 2.8.51" && return
2123 remote_ost_nodsh && skip "remote OST with nodsh" && return
2125 test_mkdir $DIR/$tdir
2127 $SETSTRIPE -c 2 $DIR/$tdir
2129 # stop all OSTs to reproduce situation for LU-7975 ticket
2130 for num in $(seq $OSTCOUNT); do
2134 # open/create f0 with O_LOV_DELAY_CREATE
2135 # truncate f0 to a non-0 size
2137 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2139 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2140 # open/write it again to force delayed layout creation
2141 cat /etc/hosts > $DIR/$tdir/f0 &
2145 for num in $(seq $OSTCOUNT); do
2146 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2147 error "ost$num failed to start"
2150 wait $catpid || error "cat failed"
2152 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2153 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2156 run_test 27F "Client resend delayed layout creation with non-zero size"
2158 # createtest also checks that device nodes are created and
2159 # then visible correctly (#2091)
2160 test_28() { # bug 2091
2162 $CREATETEST $DIR/d28/ct || error
2164 run_test 28 "create/mknod/mkdir with bad file types ============"
2167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2168 sync; sleep 1; sync # flush out any dirty pages from previous tests
2175 declare -i LOCKCOUNTORIG=0
2176 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2177 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2179 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2181 declare -i LOCKUNUSEDCOUNTORIG=0
2182 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2183 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2190 declare -i LOCKCOUNTCURRENT=0
2191 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2192 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2195 declare -i LOCKUNUSEDCOUNTCURRENT=0
2196 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2197 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2200 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2201 $LCTL set_param -n ldlm.dump_namespaces ""
2202 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2203 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2204 log "dumped log to $TMP/test_29.dk (bug 5793)"
2207 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2208 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2209 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2210 log "dumped log to $TMP/test_29.dk (bug 5793)"
2214 run_test 29 "IT_GETATTR regression ============================"
2216 test_30a() { # was test_30
2217 cp $(which ls) $DIR || cp /bin/ls $DIR
2221 run_test 30a "execute binary from Lustre (execve) =============="
2224 cp `which ls` $DIR || cp /bin/ls $DIR
2226 $RUNAS $DIR/ls / || error
2229 run_test 30b "execute binary from Lustre as non-root ==========="
2231 test_30c() { # b=22376
2232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2233 cp `which ls` $DIR || cp /bin/ls $DIR
2235 cancel_lru_locks mdc
2236 cancel_lru_locks osc
2237 $RUNAS $DIR/ls / || error
2240 run_test 30c "execute binary from Lustre without read perms ===="
2243 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2244 $CHECKSTAT -a $DIR/f31 || error
2246 run_test 31a "open-unlink file =================================="
2249 touch $DIR/f31 || error
2250 ln $DIR/f31 $DIR/f31b || error
2251 $MULTIOP $DIR/f31b Ouc || error
2252 $CHECKSTAT -t file $DIR/f31 || error
2254 run_test 31b "unlink file with multiple links while open ======="
2257 touch $DIR/f31 || error
2258 ln $DIR/f31 $DIR/f31c || error
2259 multiop_bg_pause $DIR/f31 O_uc || return 1
2261 $MULTIOP $DIR/f31c Ouc
2262 kill -USR1 $MULTIPID
2265 run_test 31c "open-unlink file with multiple links ============="
2268 opendirunlink $DIR/d31d $DIR/d31d || error
2269 $CHECKSTAT -a $DIR/d31d || error
2271 run_test 31d "remove of open directory ========================="
2273 test_31e() { # bug 2904
2274 openfilleddirunlink $DIR/d31e || error
2276 run_test 31e "remove of open non-empty directory ==============="
2278 test_31f() { # bug 4554
2279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2281 test_mkdir $DIR/d31f
2282 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2283 cp /etc/hosts $DIR/d31f
2285 $GETSTRIPE $DIR/d31f/hosts
2286 multiop_bg_pause $DIR/d31f D_c || return 1
2289 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2290 test_mkdir $DIR/d31f
2291 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2292 cp /etc/hosts $DIR/d31f
2294 $GETSTRIPE $DIR/d31f/hosts
2295 multiop_bg_pause $DIR/d31f D_c || return 1
2298 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2299 wait $MULTIPID || error "first opendir $MULTIPID failed"
2303 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2304 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2307 run_test 31f "remove of open directory with open-unlink file ==="
2310 echo "-- cross directory link --"
2311 test_mkdir -c1 $DIR/${tdir}ga
2312 test_mkdir -c1 $DIR/${tdir}gb
2313 touch $DIR/${tdir}ga/f
2314 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2315 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2316 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2317 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2318 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2320 run_test 31g "cross directory link==============="
2323 echo "-- cross directory link --"
2324 test_mkdir -c1 $DIR/${tdir}
2325 test_mkdir -c1 $DIR/${tdir}/dir
2326 touch $DIR/${tdir}/f
2327 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2328 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2329 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2330 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2331 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2333 run_test 31h "cross directory link under child==============="
2336 echo "-- cross directory link --"
2337 test_mkdir -c1 $DIR/$tdir
2338 test_mkdir -c1 $DIR/$tdir/dir
2339 touch $DIR/$tdir/dir/f
2340 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2341 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2342 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2343 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2344 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2346 run_test 31i "cross directory link under parent==============="
2349 test_mkdir -c1 -p $DIR/$tdir
2350 test_mkdir -c1 -p $DIR/$tdir/dir1
2351 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2352 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2353 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2354 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2357 run_test 31j "link for directory==============="
2360 test_mkdir -c1 -p $DIR/$tdir
2362 touch $DIR/$tdir/exist
2363 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2364 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2365 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2366 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2367 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2368 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2369 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2372 run_test 31k "link to file: the same, non-existing, dir==============="
2378 touch $DIR/d31m2/exist
2379 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2380 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2381 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2382 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2383 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2384 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2387 run_test 31m "link to file: the same, non-existing, dir==============="
2390 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2391 nlink=$(stat --format=%h $DIR/$tfile)
2392 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2394 local cmd="exec $fd<$DIR/$tfile"
2397 trap "eval $cmd" EXIT
2398 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2399 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2400 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2401 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2402 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2405 run_test 31n "check link count of unlinked file"
2408 local TEMPNAME=$(mktemp $1_XXXXXX)
2409 mlink $TEMPNAME $1 2> /dev/null &&
2410 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2414 test_31o() { # LU-2901
2415 test_mkdir $DIR/$tdir
2416 for LOOP in $(seq 100); do
2417 rm -f $DIR/$tdir/$tfile*
2418 for THREAD in $(seq 8); do
2419 link_one $DIR/$tdir/$tfile.$LOOP &
2422 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2423 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2424 error "$LINKS duplicate links to $tfile.$LOOP" &&
2428 run_test 31o "duplicate hard links with same filename"
2431 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2433 test_mkdir $DIR/$tdir
2434 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2435 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2437 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2438 error "open unlink test1 failed"
2439 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2440 error "open unlink test2 failed"
2442 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2443 error "test1 still exists"
2444 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2445 error "test2 still exists"
2447 run_test 31p "remove of open striped directory"
2449 cleanup_test32_mount() {
2452 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2453 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2454 losetup -d $loopdev || true
2460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2461 echo "== more mountpoints and symlinks ================="
2462 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2463 trap cleanup_test32_mount EXIT
2464 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2465 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2466 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2467 cleanup_test32_mount
2469 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2473 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2474 trap cleanup_test32_mount EXIT
2475 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2476 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2477 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2478 cleanup_test32_mount
2480 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2484 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2485 trap cleanup_test32_mount EXIT
2486 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2487 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2488 test_mkdir -p $DIR/$tdir/d2/test_dir
2489 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2490 cleanup_test32_mount
2492 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2496 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2497 trap cleanup_test32_mount EXIT
2498 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2499 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2500 test_mkdir -p $DIR/$tdir/d2/test_dir
2501 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2502 cleanup_test32_mount
2504 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2508 test_mkdir -p $DIR/$tdir/tmp
2509 local tmp_dir=$DIR/$tdir/tmp
2510 ln -s $DIR/$tdir $tmp_dir/symlink11
2511 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2512 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2513 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2515 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2519 test_mkdir -p $DIR/$tdir/tmp
2520 local tmp_dir=$DIR/$tdir/tmp
2521 ln -s $DIR/$tdir $tmp_dir/symlink11
2522 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2523 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2524 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2526 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2529 local tmp_dir=$DIR/$tdir/tmp
2530 test_mkdir -p $tmp_dir
2531 test_mkdir $DIR/${tdir}2
2532 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2533 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2534 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2535 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2536 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2537 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2539 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2542 rm -fr $DIR/$tdir $DIR/${tdir}2
2543 tmp_dir=$DIR/$tdir/tmp
2544 test_mkdir -p $tmp_dir
2545 test_mkdir $DIR/${tdir}2
2546 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2547 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2548 ls $tmp_dir/symlink12 || error "listing symlink12"
2549 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2551 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2555 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2556 trap cleanup_test32_mount EXIT
2557 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2558 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2559 touch $DIR/$tdir/test_file
2560 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2561 cleanup_test32_mount
2563 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2566 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2567 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2568 trap cleanup_test32_mount EXIT
2569 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2570 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2571 touch $DIR/$tdir/test_file
2572 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2573 cleanup_test32_mount
2575 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2580 trap cleanup_test32_mount EXIT
2581 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2582 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2583 test_mkdir -p $DIR/$tdir/d2
2584 touch $DIR/$tdir/d2/test_file || error
2585 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2586 cleanup_test32_mount
2588 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2593 trap cleanup_test32_mount EXIT
2594 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2595 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2596 test_mkdir -p $DIR/$tdir/d2
2597 touch $DIR/$tdir/d2/test_file
2598 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2599 cleanup_test32_mount
2601 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2605 test_mkdir -p $DIR/d32m/tmp
2606 TMP_DIR=$DIR/d32m/tmp
2607 ln -s $DIR $TMP_DIR/symlink11
2608 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2609 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2610 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2612 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2616 test_mkdir -p $DIR/d32n/tmp
2617 TMP_DIR=$DIR/d32n/tmp
2618 ln -s $DIR $TMP_DIR/symlink11
2619 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2620 ls -l $DIR/d32n/tmp/symlink11 || error
2621 ls -l $DIR/d32n/symlink01 || error
2623 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2627 test_mkdir -p $DIR/d32o/tmp
2628 TMP_DIR=$DIR/d32o/tmp
2629 ln -s $DIR/$tfile $TMP_DIR/symlink12
2630 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2631 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2632 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2633 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2634 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2636 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2646 test_mkdir -p $DIR/d32p/tmp
2648 TMP_DIR=$DIR/d32p/tmp
2650 ln -s $DIR/$tfile $TMP_DIR/symlink12
2652 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2654 cat $DIR/d32p/tmp/symlink12 || error
2656 cat $DIR/d32p/symlink02 || error
2659 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2663 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2664 trap cleanup_test32_mount EXIT
2665 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2666 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2667 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2668 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2669 cleanup_test32_mount
2671 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2675 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2676 trap cleanup_test32_mount EXIT
2677 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2678 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2679 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2680 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2681 cleanup_test32_mount
2683 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2688 chmod 444 $DIR/$tfile
2689 chown $RUNAS_ID $DIR/$tfile
2691 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2694 run_test 33aa "write file with mode 444 (should return error)"
2698 test_mkdir $DIR/$tdir
2699 chown $RUNAS_ID $DIR/$tdir
2700 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2701 error "$RUNAS create $tdir/$tfile failed"
2702 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2703 error "open RDWR" || true
2705 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2709 test_mkdir $DIR/$tdir
2710 chown $RUNAS_ID $DIR/$tdir
2711 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2713 run_test 33b "test open file with malformed flags (No panic)"
2716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2722 remote_ost_nodsh && skip "remote OST with nodsh" && return
2725 test_mkdir $DIR/$tdir
2726 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2729 for ostnum in $(seq $OSTCOUNT); do
2730 # test-framework's OST numbering is one-based, while Lustre's
2732 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2733 # Parsing llobdstat's output sucks; we could grep the /proc
2734 # path, but that's likely to not be as portable as using the
2735 # llobdstat utility. So we parse lctl output instead.
2736 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2737 obdfilter/$ostname/stats |
2738 awk '/^write_bytes/ {print $7}' )
2739 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2740 if (( ${write_bytes:-0} > 0 ))
2747 $all_zeros || return 0
2750 echo foo > $DIR/$tdir/bar
2754 # Total up write_bytes after writing. We'd better find non-zeros.
2755 for ostnum in $(seq $OSTCOUNT); do
2756 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2757 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2758 obdfilter/$ostname/stats |
2759 awk '/^write_bytes/ {print $7}' )
2760 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2761 if (( ${write_bytes:-0} > 0 ))
2770 for ostnum in $(seq $OSTCOUNT); do
2771 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2772 echo "Check that write_bytes is present in obdfilter/*/stats:"
2773 do_facet ost$ostnum lctl get_param -n \
2774 obdfilter/$ostname/stats
2776 error "OST not keeping write_bytes stats (b22312)"
2779 run_test 33c "test llobdstat and write_bytes"
2782 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2785 local remote_dir=$DIR/$tdir/remote_dir
2787 test_mkdir $DIR/$tdir
2788 $LFS mkdir -i $MDTIDX $remote_dir ||
2789 error "create remote directory failed"
2791 touch $remote_dir/$tfile
2792 chmod 444 $remote_dir/$tfile
2793 chown $RUNAS_ID $remote_dir/$tfile
2795 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2797 chown $RUNAS_ID $remote_dir
2798 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2799 error "create" || true
2800 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2801 error "open RDWR" || true
2802 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2804 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2807 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2811 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2812 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2813 mkdir $DIR/$tdir/local_dir
2815 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2816 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2817 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2819 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2820 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2822 rmdir $DIR/$tdir/* || error "rmdir failed"
2825 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2826 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2827 mkdir $DIR/$tdir/local_dir
2829 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2830 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2831 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2833 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2834 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2836 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2839 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2840 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2841 mkdir $DIR/$tdir/local_dir
2843 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2844 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2845 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2847 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2848 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2850 run_test 33e "mkdir and striped directory should have same mode"
2854 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2858 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2859 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2862 chmod go+rwx $DIR/$tdir
2863 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2864 trap cleanup_33f EXIT
2866 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2867 error "cannot create striped directory"
2869 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2870 error "cannot create files in striped directory"
2872 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2873 error "cannot remove files in striped directory"
2875 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2876 error "cannot remove striped directory"
2880 run_test 33f "nonroot user can create, access, and remove a striped directory"
2883 mkdir -p $DIR/$tdir/dir2
2885 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2887 [[ $err =~ "exists" ]] || error "Not exists error"
2889 run_test 33g "nonroot user create already existing root created file"
2891 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2894 $MCREATE $DIR/f34 || error
2895 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2896 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2897 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2898 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2900 run_test 34a "truncate file that has not been opened ==========="
2903 [ ! -f $DIR/f34 ] && test_34a
2904 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2905 $OPENFILE -f O_RDONLY $DIR/f34
2906 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2907 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2909 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2912 [ ! -f $DIR/f34 ] && test_34a
2913 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2914 $OPENFILE -f O_RDWR $DIR/f34
2915 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2916 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2918 run_test 34c "O_RDWR opening file-with-size works =============="
2921 [ ! -f $DIR/f34 ] && test_34a
2922 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2923 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2926 run_test 34d "write to sparse file ============================="
2930 $MCREATE $DIR/f34e || error
2931 $TRUNCATE $DIR/f34e 1000 || error
2932 $CHECKSTAT -s 1000 $DIR/f34e || error
2933 $OPENFILE -f O_RDWR $DIR/f34e
2934 $CHECKSTAT -s 1000 $DIR/f34e || error
2936 run_test 34e "create objects, some with size and some without =="
2938 test_34f() { # bug 6242, 6243
2939 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2942 $MCREATE $DIR/f34f || error
2943 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2944 dd if=$DIR/f34f of=$TMP/f34f
2945 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2946 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2947 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2948 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2949 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2951 run_test 34f "read from a file with no objects until EOF ======="
2954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2955 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2956 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2957 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2958 cancel_lru_locks osc
2959 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2960 error "wrong size after lock cancel"
2962 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2963 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2964 error "expanding truncate failed"
2965 cancel_lru_locks osc
2966 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2967 error "wrong expanded size after lock cancel"
2969 run_test 34g "truncate long file ==============================="
2972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2976 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2977 sync # Flush the cache so that multiop below does not block on cache
2978 # flush when getting the group lock
2979 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2982 # Since just timed wait is not good enough, let's do a sync write
2983 # that way we are sure enough time for a roundtrip + processing
2984 # passed + 2 seconds of extra margin.
2985 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2989 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2990 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2994 local nsz=`stat -c %s $DIR/$tfile`
2995 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2997 run_test 34h "ftruncate file under grouplock should not block"
3000 cp /bin/sh $DIR/f35a
3002 chown $RUNAS_ID $DIR/f35a
3003 $RUNAS $DIR/f35a && error || true
3006 run_test 35a "exec file with mode 444 (should return and not leak)"
3010 utime $DIR/f36 || error
3012 run_test 36a "MDS utime check (mknod, utime)"
3016 utime $DIR/f36 || error
3018 run_test 36b "OST utime check (open, utime)"
3023 chown $RUNAS_ID $DIR/d36
3024 $RUNAS utime $DIR/d36/f36 || error
3026 run_test 36c "non-root MDS utime check (mknod, utime)"
3029 [ ! -d $DIR/d36 ] && test_36c
3030 echo "" > $DIR/d36/f36
3031 $RUNAS utime $DIR/d36/f36 || error
3033 run_test 36d "non-root OST utime check (open, utime)"
3036 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3037 test_mkdir $DIR/$tdir
3038 touch $DIR/$tdir/$tfile
3039 $RUNAS utime $DIR/$tdir/$tfile &&
3040 error "utime worked, expected failure" || true
3042 run_test 36e "utime on non-owned file (should return error)"
3046 local LANG_SAVE=$LANG
3047 local LC_LANG_SAVE=$LC_LANG
3048 export LANG=C LC_LANG=C # for date language
3050 DATESTR="Dec 20 2000"
3051 test_mkdir $DIR/$tdir
3052 lctl set_param fail_loc=$fl
3054 cp /etc/hosts $DIR/$tdir/$tfile
3055 sync & # write RPC generated with "current" inode timestamp, but delayed
3057 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3058 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3059 cancel_lru_locks osc
3060 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3062 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3063 echo "BEFORE: $LS_BEFORE" && \
3064 echo "AFTER : $LS_AFTER" && \
3065 echo "WANT : $DATESTR" && \
3066 error "$DIR/$tdir/$tfile timestamps changed" || true
3068 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3073 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3074 subr_36fh "0x80000214"
3076 run_test 36f "utime on file racing with OST BRW write =========="
3079 remote_ost_nodsh && skip "remote OST with nodsh" && return
3080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3085 test_mkdir $DIR/$tdir
3086 fmd_max_age=$(do_facet ost1 \
3087 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3090 fmd_before=$(do_facet ost1 \
3091 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3092 touch $DIR/$tdir/$tfile
3093 sleep $((fmd_max_age + 12))
3094 fmd_after=$(do_facet ost1 \
3095 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3097 echo "fmd_before: $fmd_before"
3098 echo "fmd_after: $fmd_after"
3099 [[ $fmd_after -gt $fmd_before ]] &&
3100 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3101 error "fmd didn't expire after ping" || true
3103 run_test 36g "filter mod data cache expiry ====================="
3106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3107 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3108 subr_36fh "0x80000227"
3110 run_test 36h "utime on file racing with OST BRW write =========="
3113 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3115 test_mkdir $DIR/$tdir
3116 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3118 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3119 local new_mtime=$((mtime + 200))
3121 #change Modify time of striped dir
3122 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3123 error "change mtime failed"
3125 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3127 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3129 run_test 36i "change mtime on striped directory"
3131 # test_37 - duplicate with tests 32q 32r
3134 local file=$DIR/$tfile
3136 openfile -f O_DIRECTORY $file
3139 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3140 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3142 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3144 test_39a() { # was test_39
3146 touch $DIR/${tfile}2
3147 # ls -l $DIR/$tfile $DIR/${tfile}2
3148 # ls -lu $DIR/$tfile $DIR/${tfile}2
3149 # ls -lc $DIR/$tfile $DIR/${tfile}2
3151 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3152 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3154 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3156 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3158 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3159 error "O_TRUNC didn't change timestamps"
3162 run_test 39a "mtime changed on create"
3165 test_mkdir -c1 $DIR/$tdir
3166 cp -p /etc/passwd $DIR/$tdir/fopen
3167 cp -p /etc/passwd $DIR/$tdir/flink
3168 cp -p /etc/passwd $DIR/$tdir/funlink
3169 cp -p /etc/passwd $DIR/$tdir/frename
3170 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3173 echo "aaaaaa" >> $DIR/$tdir/fopen
3174 echo "aaaaaa" >> $DIR/$tdir/flink
3175 echo "aaaaaa" >> $DIR/$tdir/funlink
3176 echo "aaaaaa" >> $DIR/$tdir/frename
3178 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3179 local link_new=`stat -c %Y $DIR/$tdir/flink`
3180 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3181 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3183 cat $DIR/$tdir/fopen > /dev/null
3184 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3185 rm -f $DIR/$tdir/funlink2
3186 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3188 for (( i=0; i < 2; i++ )) ; do
3189 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3190 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3191 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3192 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3194 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3195 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3196 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3197 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3199 cancel_lru_locks osc
3200 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3203 run_test 39b "mtime change on open, link, unlink, rename ======"
3205 # this should be set to past
3206 TEST_39_MTIME=`date -d "1 year ago" +%s`
3212 local mtime0=`stat -c %Y $DIR1/$tfile`
3214 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3215 local mtime1=`stat -c %Y $DIR1/$tfile`
3216 [ "$mtime1" = $TEST_39_MTIME ] || \
3217 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3220 echo hello >> $DIR1/$tfile
3222 local mtime2=`stat -c %Y $DIR1/$tfile`
3223 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3224 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3226 mv $DIR1/$tfile $DIR1/$tfile-1
3228 for (( i=0; i < 2; i++ )) ; do
3229 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3230 [ "$mtime2" = "$mtime3" ] || \
3231 error "mtime ($mtime2) changed (to $mtime3) on rename"
3233 cancel_lru_locks osc
3234 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3237 run_test 39c "mtime change on rename ==========================="
3241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3244 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3246 for (( i=0; i < 2; i++ )) ; do
3247 local mtime=`stat -c %Y $DIR1/$tfile`
3248 [ $mtime = $TEST_39_MTIME ] || \
3249 error "mtime($mtime) is not set to $TEST_39_MTIME"
3251 cancel_lru_locks osc
3252 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3255 run_test 39d "create, utime, stat =============================="
3259 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3261 local mtime1=`stat -c %Y $DIR1/$tfile`
3263 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3265 for (( i=0; i < 2; i++ )) ; do
3266 local mtime2=`stat -c %Y $DIR1/$tfile`
3267 [ $mtime2 = $TEST_39_MTIME ] || \
3268 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3270 cancel_lru_locks osc
3271 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3274 run_test 39e "create, stat, utime, stat ========================"
3278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3280 mtime1=`stat -c %Y $DIR1/$tfile`
3283 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3285 for (( i=0; i < 2; i++ )) ; do
3286 local mtime2=`stat -c %Y $DIR1/$tfile`
3287 [ $mtime2 = $TEST_39_MTIME ] || \
3288 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3290 cancel_lru_locks osc
3291 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3294 run_test 39f "create, stat, sleep, utime, stat ================="
3298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3299 echo hello >> $DIR1/$tfile
3300 local mtime1=`stat -c %Y $DIR1/$tfile`
3303 chmod o+r $DIR1/$tfile
3305 for (( i=0; i < 2; i++ )) ; do
3306 local mtime2=`stat -c %Y $DIR1/$tfile`
3307 [ "$mtime1" = "$mtime2" ] || \
3308 error "lost mtime: $mtime2, should be $mtime1"
3310 cancel_lru_locks osc
3311 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3314 run_test 39g "write, chmod, stat ==============================="
3318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3323 echo hello >> $DIR1/$tfile
3324 local mtime1=`stat -c %Y $DIR1/$tfile`
3326 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3328 if [ "$d1" != "$d2" ]; then
3329 echo "write and touch not within one second"
3331 for (( i=0; i < 2; i++ )) ; do
3332 local mtime2=`stat -c %Y $DIR1/$tfile`
3333 [ "$mtime2" = $TEST_39_MTIME ] || \
3334 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3336 cancel_lru_locks osc
3337 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3341 run_test 39h "write, utime within one second, stat ============="
3344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3348 echo hello >> $DIR1/$tfile
3349 local mtime1=`stat -c %Y $DIR1/$tfile`
3351 mv $DIR1/$tfile $DIR1/$tfile-1
3353 for (( i=0; i < 2; i++ )) ; do
3354 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3356 [ "$mtime1" = "$mtime2" ] || \
3357 error "lost mtime: $mtime2, should be $mtime1"
3359 cancel_lru_locks osc
3360 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3363 run_test 39i "write, rename, stat =============================="
3366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3367 start_full_debug_logging
3371 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3372 lctl set_param fail_loc=0x80000412
3373 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3374 error "multiop failed"
3376 local mtime1=`stat -c %Y $DIR1/$tfile`
3378 mv $DIR1/$tfile $DIR1/$tfile-1
3380 kill -USR1 $multipid
3381 wait $multipid || error "multiop close failed"
3383 for (( i=0; i < 2; i++ )) ; do
3384 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3385 [ "$mtime1" = "$mtime2" ] ||
3386 error "mtime is lost on close: $mtime2, " \
3389 cancel_lru_locks osc
3390 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3392 lctl set_param fail_loc=0
3393 stop_full_debug_logging
3395 run_test 39j "write, rename, close, stat ======================="
3398 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3402 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3404 local mtime1=`stat -c %Y $DIR1/$tfile`
3406 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3408 kill -USR1 $multipid
3409 wait $multipid || error "multiop close failed"
3411 for (( i=0; i < 2; i++ )) ; do
3412 local mtime2=`stat -c %Y $DIR1/$tfile`
3414 [ "$mtime2" = $TEST_39_MTIME ] || \
3415 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3417 cancel_lru_locks osc
3418 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3421 run_test 39k "write, utime, close, stat ========================"
3423 # this should be set to future
3424 TEST_39_ATIME=`date -d "1 year" +%s`
3427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3428 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3429 local atime_diff=$(do_facet $SINGLEMDS \
3430 lctl get_param -n mdd.*MDT0000*.atime_diff)
3434 # test setting directory atime to future
3435 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3436 local atime=$(stat -c %X $DIR/$tdir)
3437 [ "$atime" = $TEST_39_ATIME ] ||
3438 error "atime is not set to future: $atime, $TEST_39_ATIME"
3440 # test setting directory atime from future to now
3441 local now=$(date +%s)
3442 touch -a -d @$now $DIR/$tdir
3444 atime=$(stat -c %X $DIR/$tdir)
3445 [ "$atime" -eq "$now" ] ||
3446 error "atime is not updated from future: $atime, $now"
3448 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3451 # test setting directory atime when now > dir atime + atime_diff
3452 local d1=$(date +%s)
3454 local d2=$(date +%s)
3455 cancel_lru_locks mdc
3456 atime=$(stat -c %X $DIR/$tdir)
3457 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3458 error "atime is not updated : $atime, should be $d2"
3460 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3463 # test not setting directory atime when now < dir atime + atime_diff
3465 cancel_lru_locks mdc
3466 atime=$(stat -c %X $DIR/$tdir)
3467 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3468 error "atime is updated to $atime, should remain $d1<atime<$d2"
3470 do_facet $SINGLEMDS \
3471 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3473 run_test 39l "directory atime update ==========================="
3476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3479 local far_past_mtime=$(date -d "May 29 1953" +%s)
3480 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3482 touch -m -d @$far_past_mtime $DIR1/$tfile
3483 touch -a -d @$far_past_atime $DIR1/$tfile
3485 for (( i=0; i < 2; i++ )) ; do
3486 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3487 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3488 error "atime or mtime set incorrectly"
3490 cancel_lru_locks osc
3491 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3494 run_test 39m "test atime and mtime before 1970"
3496 test_39n() { # LU-3832
3497 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3498 local atime_diff=$(do_facet $SINGLEMDS \
3499 lctl get_param -n mdd.*MDT0000*.atime_diff)
3504 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3507 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3508 atime0=$(stat -c %X $DIR/$tfile)
3511 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3512 atime1=$(stat -c %X $DIR/$tfile)
3515 cancel_lru_locks mdc
3516 cancel_lru_locks osc
3517 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3518 atime2=$(stat -c %X $DIR/$tfile)
3520 do_facet $SINGLEMDS \
3521 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3523 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3524 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3526 run_test 39n "check that O_NOATIME is honored"
3529 TESTDIR=$DIR/$tdir/$tfile
3530 [ -e $TESTDIR ] && rm -rf $TESTDIR
3537 links2=$(stat -c %h .)
3538 [ $(($links1 + 2)) != $links2 ] &&
3539 error "wrong links count $(($links1 + 2)) != $links2"
3541 links3=$(stat -c %h .)
3542 [ $(($links1 + 1)) != $links3 ] &&
3543 error "wrong links count $links1 != $links3"
3546 run_test 39o "directory cached attributes updated after create"
3549 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3551 TESTDIR=$DIR/$tdir/$tdir
3552 [ -e $TESTDIR ] && rm -rf $TESTDIR
3553 test_mkdir -p $TESTDIR
3557 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3558 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3560 links2=$(stat -c %h .)
3561 [ $(($links1 + 2)) != $links2 ] &&
3562 error "wrong links count $(($links1 + 2)) != $links2"
3564 links3=$(stat -c %h .)
3565 [ $(($links1 + 1)) != $links3 ] &&
3566 error "wrong links count $links1 != $links3"
3569 run_test 39p "remote directory cached attributes updated after create ========"
3572 test_39q() { # LU-8041
3573 local testdir=$DIR/$tdir
3575 multiop_bg_pause $testdir D_c || error "multiop failed"
3577 cancel_lru_locks mdc
3578 kill -USR1 $multipid
3579 local atime=$(stat -c %X $testdir)
3580 [ "$atime" -ne 0 ] || error "atime is zero"
3582 run_test 39q "close won't zero out atime"
3585 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3586 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3587 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3588 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3589 error "$tfile is not 4096 bytes in size"
3591 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3595 small_write $DIR/f41 18
3597 run_test 41 "test small file write + fstat ====================="
3599 count_ost_writes() {
3600 lctl get_param -n ${OSC}.*.stats |
3601 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3602 END { printf("%0.0f", writes) }'
3609 BG_DIRTY_RATIO_SAVE=10
3610 MAX_BG_DIRTY_RATIO=25
3614 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3615 # dirty_ratio, dirty_background_ratio
3616 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3617 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3618 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3619 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3621 # if file not here, we are a 2.4 kernel
3622 kill -CONT `pidof kupdated`
3627 # setup the trap first, so someone cannot exit the test at the
3628 # exact wrong time and mess up a machine
3629 trap start_writeback EXIT
3630 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3631 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3632 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3633 sysctl -w vm.dirty_writeback_centisecs=0
3634 sysctl -w vm.dirty_writeback_centisecs=0
3635 # save and increase /proc/sys/vm/dirty_ratio
3636 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3637 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3638 # save and increase /proc/sys/vm/dirty_background_ratio
3639 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3640 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3642 # if file not here, we are a 2.4 kernel
3643 kill -STOP `pidof kupdated`
3647 # ensure that all stripes have some grant before we test client-side cache
3649 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3650 dd if=/dev/zero of=$i bs=4k count=1
3655 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3656 # file truncation, and file removal.
3658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3660 cancel_lru_locks $OSC
3662 sync; sleep 1; sync # just to be safe
3663 BEFOREWRITES=`count_ost_writes`
3664 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3665 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3666 AFTERWRITES=`count_ost_writes`
3667 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3668 error "$BEFOREWRITES < $AFTERWRITES"
3671 run_test 42a "ensure that we don't flush on close"
3674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3676 cancel_lru_locks $OSC
3679 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3680 BEFOREWRITES=$(count_ost_writes)
3681 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3682 AFTERWRITES=$(count_ost_writes)
3683 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3684 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3686 BEFOREWRITES=$(count_ost_writes)
3687 sync || error "sync: $?"
3688 AFTERWRITES=$(count_ost_writes)
3689 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3690 error "$BEFOREWRITES < $AFTERWRITES on sync"
3692 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3696 run_test 42b "test destroy of file with cached dirty data ======"
3698 # if these tests just want to test the effect of truncation,
3699 # they have to be very careful. consider:
3700 # - the first open gets a {0,EOF}PR lock
3701 # - the first write conflicts and gets a {0, count-1}PW
3702 # - the rest of the writes are under {count,EOF}PW
3703 # - the open for truncate tries to match a {0,EOF}PR
3704 # for the filesize and cancels the PWs.
3705 # any number of fixes (don't get {0,EOF} on open, match
3706 # composite locks, do smarter file size management) fix
3707 # this, but for now we want these tests to verify that
3708 # the cancellation with truncate intent works, so we
3709 # start the file with a full-file pw lock to match against
3710 # until the truncate.
3715 cancel_lru_locks $OSC
3717 # prime the file with 0,EOF PW to match
3721 # now the real test..
3722 dd if=/dev/zero of=$file bs=1024 count=100
3723 BEFOREWRITES=`count_ost_writes`
3724 $TRUNCATE $file $offset
3725 cancel_lru_locks $OSC
3726 AFTERWRITES=`count_ost_writes`
3731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3733 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3734 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3737 run_test 42c "test partial truncate of file with cached dirty data"
3740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3742 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3743 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3746 run_test 42d "test complete truncate of file with cached dirty data"
3748 test_42e() { # bug22074
3749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3750 local TDIR=$DIR/${tdir}e
3751 local pagesz=$(page_size)
3752 local pages=16 # hardcoded 16 pages, don't change it.
3753 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3754 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3758 test_mkdir $DIR/${tdir}e
3759 $SETSTRIPE -c 1 $TDIR
3760 createmany -o $TDIR/f $files
3762 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3764 # we assume that with $OSTCOUNT files, at least one of them will
3765 # be allocated on OST0.
3766 warmup_files=$((OSTCOUNT * max_dirty_mb))
3767 createmany -o $TDIR/w $warmup_files
3769 # write a large amount of data into one file and sync, to get good
3770 # avail_grant number from OST.
3771 for ((i=0; i<$warmup_files; i++)); do
3772 idx=$($GETSTRIPE -i $TDIR/w$i)
3773 [ $idx -ne 0 ] && continue
3774 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3777 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3779 $LCTL get_param $proc_osc0/cur_dirty_bytes
3780 $LCTL get_param $proc_osc0/cur_grant_bytes
3782 # create as much dirty pages as we can while not to trigger the actual
3783 # RPCs directly. but depends on the env, VFS may trigger flush during this
3784 # period, hopefully we are good.
3785 for ((i=0; i<$warmup_files; i++)); do
3786 idx=$($GETSTRIPE -i $TDIR/w$i)
3787 [ $idx -ne 0 ] && continue
3788 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3790 $LCTL get_param $proc_osc0/cur_dirty_bytes
3791 $LCTL get_param $proc_osc0/cur_grant_bytes
3793 # perform the real test
3794 $LCTL set_param $proc_osc0/rpc_stats 0
3795 for ((;i<$files; i++)); do
3796 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3797 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3800 $LCTL get_param $proc_osc0/rpc_stats
3803 local have_ppr=false
3804 $LCTL get_param $proc_osc0/rpc_stats |
3805 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3806 # skip lines until we are at the RPC histogram data
3807 [ "$PPR" == "pages" ] && have_ppr=true && continue
3808 $have_ppr || continue
3810 # we only want the percent stat for < 16 pages
3811 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3813 percent=$((percent + WPCT))
3814 if [[ $percent -gt 15 ]]; then
3815 error "less than 16-pages write RPCs" \
3822 run_test 42e "verify sub-RPC writes are not done synchronously"
3824 test_43A() { # was test_43
3825 test_mkdir $DIR/$tdir
3826 cp -p /bin/ls $DIR/$tdir/$tfile
3827 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3829 # give multiop a chance to open
3832 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3835 run_test 43A "execution of file opened for write should return -ETXTBSY"
3838 test_mkdir $DIR/$tdir
3839 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3840 cp -p multiop $DIR/$tdir/multiop
3841 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3842 error "multiop open $TMP/$tfile.junk failed"
3843 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
3845 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3846 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3847 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3849 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3853 test_mkdir $DIR/$tdir
3854 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3855 cp -p multiop $DIR/$tdir/multiop
3856 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3857 error "multiop open $TMP/$tfile.junk failed"
3858 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
3860 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3861 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3862 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3864 run_test 43b "truncate of file being executed should return -ETXTBSY"
3867 local testdir="$DIR/$tdir"
3870 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3871 ( cd $testdir && md5sum -c )
3873 run_test 43c "md5sum of copy into lustre"
3875 test_44A() { # was test_44
3876 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3877 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3878 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3880 run_test 44A "zero length read from a sparse stripe"
3883 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3885 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3886 [[ $nstripe -gt $OSTCOUNT ]] &&
3887 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3889 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3891 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3892 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3896 OFFSETS="0 $((stride/2)) $((stride-1))"
3897 for offset in $OFFSETS; do
3898 for i in $(seq 0 $((nstripe-1))); do
3899 local GLOBALOFFSETS=""
3901 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3902 local myfn=$DIR/d44a-$size
3903 echo "--------writing $myfn at $size"
3904 ll_sparseness_write $myfn $size ||
3905 error "ll_sparseness_write"
3906 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3907 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3908 error "ll_sparseness_verify $GLOBALOFFSETS"
3910 for j in $(seq 0 $((nstripe-1))); do
3912 size=$((((j + $nstripe )*$stride + $offset)))
3913 ll_sparseness_write $myfn $size ||
3914 error "ll_sparseness_write"
3915 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3917 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3918 error "ll_sparseness_verify $GLOBALOFFSETS"
3923 run_test 44a "test sparse pwrite ==============================="
3927 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
3933 before=`dirty_osc_total`
3934 echo executing "\"$*\""
3936 after=`dirty_osc_total`
3937 echo before $before, after $after
3940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3942 # Obtain grants from OST if it supports it
3943 echo blah > ${f}_grant
3946 do_dirty_record "echo blah > $f"
3947 [[ $before -eq $after ]] && error "write wasn't cached"
3948 do_dirty_record "> $f"
3949 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3950 do_dirty_record "echo blah > $f"
3951 [[ $before -eq $after ]] && error "write wasn't cached"
3952 do_dirty_record "sync"
3953 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3954 do_dirty_record "echo blah > $f"
3955 [[ $before -eq $after ]] && error "write wasn't cached"
3956 do_dirty_record "cancel_lru_locks osc"
3957 [[ $before -gt $after ]] ||
3958 error "lock cancellation didn't lower dirty count"
3961 run_test 45 "osc io page accounting ============================"
3963 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3964 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3965 # objects offset and an assert hit when an rpc was built with 1023's mapped
3966 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3972 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3974 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3975 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3979 run_test 46 "dirtying a previously written page ================"
3981 # test_47 is removed "Device nodes check" is moved to test_28
3983 test_48a() { # bug 2399
3984 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3985 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3986 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3988 test_mkdir $DIR/$tdir
3990 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3991 test_mkdir $DIR/$tdir
3992 touch foo || error "'touch foo' failed after recreating cwd"
3994 touch .foo || error "'touch .foo' failed after recreating cwd"
3996 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3997 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3998 cd . || error "'cd .' failed after recreating cwd"
3999 mkdir . && error "'mkdir .' worked after recreating cwd"
4000 rmdir . && error "'rmdir .' worked after recreating cwd"
4001 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4002 cd .. || error "'cd ..' failed after recreating cwd"
4004 run_test 48a "Access renamed working dir (should return errors)="
4006 test_48b() { # bug 2399
4008 test_mkdir $DIR/$tdir
4010 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4011 touch foo && error "'touch foo' worked after removing cwd"
4012 mkdir foo && error "'mkdir foo' worked after removing cwd"
4013 touch .foo && error "'touch .foo' worked after removing cwd"
4014 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4015 ls . > /dev/null && error "'ls .' worked after removing cwd"
4016 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4017 mkdir . && error "'mkdir .' worked after removing cwd"
4018 rmdir . && error "'rmdir .' worked after removing cwd"
4019 ln -s . foo && error "'ln -s .' worked after removing cwd"
4020 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4022 run_test 48b "Access removed working dir (should return errors)="
4024 test_48c() { # bug 2350
4025 #lctl set_param debug=-1
4028 test_mkdir -p $DIR/$tdir/dir
4030 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4031 $TRACE touch foo && error "touch foo worked after removing cwd"
4032 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4033 touch .foo && error "touch .foo worked after removing cwd"
4034 mkdir .foo && error "mkdir .foo worked after removing cwd"
4035 $TRACE ls . && error "'ls .' worked after removing cwd"
4036 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4037 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4038 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4039 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4040 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4042 run_test 48c "Access removed working subdir (should return errors)"
4044 test_48d() { # bug 2350
4045 #lctl set_param debug=-1
4048 test_mkdir -p $DIR/$tdir/dir
4050 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4051 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4052 $TRACE touch foo && error "'touch foo' worked after removing parent"
4053 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4054 touch .foo && error "'touch .foo' worked after removing parent"
4055 mkdir .foo && error "mkdir .foo worked after removing parent"
4056 $TRACE ls . && error "'ls .' worked after removing parent"
4057 $TRACE ls .. && error "'ls ..' worked after removing parent"
4058 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4059 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4060 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4063 run_test 48d "Access removed parent subdir (should return errors)"
4065 test_48e() { # bug 4134
4066 #lctl set_param debug=-1
4069 test_mkdir -p $DIR/$tdir/dir
4071 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4072 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4073 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4074 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4075 # On a buggy kernel addition of "touch foo" after cd .. will
4076 # produce kernel oops in lookup_hash_it
4077 touch ../foo && error "'cd ..' worked after recreate parent"
4079 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4081 run_test 48e "Access to recreated parent subdir (should return errors)"
4083 test_49() { # LU-1030
4084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4085 remote_ost_nodsh && skip "remote OST with nodsh" && return
4086 # get ost1 size - lustre-OST0000
4087 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4089 # write 800M at maximum
4090 [[ $ost1_size -lt 2 ]] && ost1_size=2
4091 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4093 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4094 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4097 # change max_pages_per_rpc while writing the file
4098 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4099 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4100 # loop until dd process exits
4101 while ps ax -opid | grep -wq $dd_pid; do
4102 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4103 sleep $((RANDOM % 5 + 1))
4105 # restore original max_pages_per_rpc
4106 $LCTL set_param $osc1_mppc=$orig_mppc
4107 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4109 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4113 test_mkdir $DIR/$tdir
4115 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4117 run_test 50 "special situations: /proc symlinks ==============="
4119 test_51a() { # was test_51
4120 # bug 1516 - create an empty entry right after ".." then split dir
4121 test_mkdir -c1 $DIR/$tdir
4122 touch $DIR/$tdir/foo
4123 $MCREATE $DIR/$tdir/bar
4125 createmany -m $DIR/$tdir/longfile 201
4127 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4128 $MCREATE $DIR/$tdir/longfile$FNUM
4133 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4135 run_test 51a "special situations: split htree with empty entry =="
4137 cleanup_print_lfs_df () {
4144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4145 local dir=$DIR/$tdir
4147 local nrdirs=$((65536 + 100))
4149 # cleanup the directory
4156 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4157 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4158 [[ $numfree -lt $nrdirs ]] &&
4159 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4162 # need to check free space for the directories as well
4163 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4164 numfree=$(( blkfree / $(fs_inode_ksize) ))
4165 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4168 trap cleanup_print_lfs_df EXIT
4171 createmany -d $dir/d $nrdirs || {
4172 unlinkmany $dir/d $nrdirs
4173 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4177 nrdirs=$(ls -U $dir | wc -l)
4179 # unlink all but 100 subdirectories, then check it still works
4181 local delete=$((nrdirs - left))
4186 # for ldiskfs the nlink count should be 1, but this is OSD specific
4187 # and so this is listed for informational purposes only
4188 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4189 unlinkmany -d $dir/d $delete ||
4190 error "unlink of first $delete subdirs failed"
4192 echo "nlink between: $(stat -c %h $dir)"
4193 local found=$(ls -U $dir | wc -l)
4194 [ $found -ne $left ] &&
4195 error "can't find subdirs: found only $found, expected $left"
4197 unlinkmany -d $dir/d $delete $left ||
4198 error "unlink of second $left subdirs failed"
4199 # regardless of whether the backing filesystem tracks nlink accurately
4200 # or not, the nlink count shouldn't be more than "." and ".." here
4201 local after=$(stat -c %h $dir)
4202 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4203 echo "nlink after: $after"
4205 cleanup_print_lfs_df
4207 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4211 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4212 test_mkdir $DIR/$tdir
4213 createmany -o $DIR/$tdir/t- 1000
4214 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4215 for N in $(seq 0 $((OSTCOUNT - 1))); do
4216 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4217 END { printf("%0.0f", objs) }' $TMP/$tfile)
4218 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4219 '($1 == '$N') { objs += 1 } \
4220 END { printf("%0.0f", objs) }')
4221 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4223 unlinkmany $DIR/$tdir/t- 1000
4226 for N in $(seq 1 $((OSTCOUNT - 1))); do
4227 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4228 error "OST $N has less objects vs OST $NLAST" \
4229 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4230 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4231 error "OST $N has less objects vs OST $NLAST" \
4232 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4234 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4235 error "OST $N has less #0 objects vs OST $NLAST" \
4236 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4237 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4238 error "OST $N has less #0 objects vs OST $NLAST" \
4239 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4244 run_test 51d "check object distribution"
4247 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4248 skip "ldiskfs only test"
4252 test_mkdir -c1 $DIR/$tdir
4253 test_mkdir -c1 $DIR/$tdir/d0
4255 touch $DIR/$tdir/d0/foo
4256 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4257 error "file exceed 65000 nlink limit!"
4258 unlinkmany $DIR/$tdir/d0/f- 65001
4261 run_test 51e "check file nlink limit"
4264 test_mkdir $DIR/$tdir
4267 local ulimit_old=$(ulimit -n)
4268 local spare=20 # number of spare fd's for scripts/libraries, etc.
4269 local mdt=$(lfs getstripe -M $DIR/$tdir)
4270 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4272 echo "MDT$mdt numfree=$numfree, max=$max"
4273 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4274 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4275 while ! ulimit -n $((numfree + spare)); do
4276 numfree=$((numfree * 3 / 4))
4278 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4280 echo "left ulimit at $ulimit_old"
4283 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4284 unlinkmany $DIR/$tdir/f $numfree
4285 error "create+open $numfree files in $DIR/$tdir failed"
4287 ulimit -n $ulimit_old
4289 # if createmany exits at 120s there will be fewer than $numfree files
4290 unlinkmany $DIR/$tdir/f $numfree || true
4292 run_test 51f "check many open files limit"
4295 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4296 test_mkdir $DIR/$tdir
4297 touch $DIR/$tdir/foo
4298 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4299 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4300 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4301 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4302 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4304 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4305 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4306 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4308 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4309 cp -r $DIR/$tdir $TMP/
4310 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4312 run_test 52a "append-only flag test (should return errors)"
4315 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4316 test_mkdir $DIR/$tdir
4317 touch $DIR/$tdir/foo
4318 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4319 cat test > $DIR/$tdir/foo && error "cat test worked"
4320 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4321 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4322 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4324 echo foo >> $DIR/$tdir/foo && error "echo worked"
4325 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4326 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4327 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4328 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4330 chattr -i $DIR/$tdir/foo || error "chattr failed"
4332 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4334 run_test 52b "immutable flag test (should return errors) ======="
4337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4338 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4339 remote_ost_nodsh && skip "remote OST with nodsh" && return
4352 local support_last_seq=true
4354 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4355 support_last_seq=false
4358 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4360 for value in $(do_facet $SINGLEMDS \
4361 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4362 param=$(echo ${value[0]} | cut -d "=" -f1)
4363 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4365 if $support_last_seq; then
4366 param_seq=$(echo $param |
4367 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4368 mds_last_seq=$(do_facet $SINGLEMDS \
4369 $LCTL get_param -n $param_seq)
4371 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4373 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4374 node=$(facet_active_host ost$((ostnum+1)))
4375 param="obdfilter.$ostname.last_id"
4376 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4377 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4378 ost_last_id=$ost_last
4380 if $support_last_seq; then
4381 ost_last_id=$(echo $ost_last |
4382 awk -F':' '{print $2}' |
4384 ost_last_seq=$(echo $ost_last |
4385 awk -F':' '{print $1}')
4386 [[ $ost_last_seq = $mds_last_seq ]] || continue
4389 if [[ $ost_last_id != $mds_last ]]; then
4390 error "$ost_last_id != $mds_last"
4397 $found || error "can not match last_seq/last_id for $mdtosc"
4400 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4403 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4405 $SOCKETSERVER $DIR/socket ||
4406 error "$SOCKETSERVER $DIR/socket failed: $?"
4407 $SOCKETCLIENT $DIR/socket ||
4408 error "$SOCKETCLIENT $DIR/socket failed: $?"
4409 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4411 run_test 54a "unix domain socket test =========================="
4417 dd if=/dev/zero of=$f bs=$(page_size) count=1
4419 run_test 54b "char device works in lustre ======================"
4422 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4423 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4424 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4426 for i in $(seq 3 7); do
4427 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4436 loopdev="$DIR/loop54c"
4439 $UMOUNT $DIR/$tdir || rc=$?
4440 losetup -d $loopdev || true
4441 losetup -d $LOOPDEV || true
4442 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4448 loopdev="$DIR/loop54c"
4451 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4452 trap cleanup_54c EXIT
4453 mknod $loopdev b 7 $LOOPNUM
4454 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4455 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4456 losetup $loopdev $DIR/$tfile ||
4457 error "can't set up $loopdev for $DIR/$tfile"
4458 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4459 test_mkdir $DIR/$tdir
4460 mount -t ext2 $loopdev $DIR/$tdir ||
4461 error "error mounting $loopdev on $DIR/$tdir"
4462 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4465 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4469 run_test 54c "block device works in lustre ====================="
4475 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4477 run_test 54d "fifo device works in lustre ======================"
4482 cp -aL /dev/console $f
4483 echo $string > $f || error "echo $string to $f failed"
4485 run_test 54e "console/tty device works in lustre ======================"
4487 #The test_55 used to be iopen test and it was removed by bz#24037.
4488 #run_test 55 "check iopen_connect_dentry() ======================"
4490 test_56a() { # was test_56
4493 test_mkdir -p $DIR/$tdir/dir
4495 NUMFILESx2=$(($NUMFILES * 2))
4496 for i in $(seq 1 $NUMFILES); do
4497 touch $DIR/$tdir/file$i
4498 touch $DIR/$tdir/dir/file$i
4501 # test lfs getstripe with --recursive
4502 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4503 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4504 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4505 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4506 [[ $FILENUM -eq $NUMFILES ]] ||
4507 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4508 echo "$GETSTRIPE --recursive passed."
4510 # test lfs getstripe with file instead of dir
4511 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4512 [[ $FILENUM -eq 1 ]] ||
4513 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4514 echo "$GETSTRIPE file1 passed."
4516 #test lfs getstripe with --verbose
4517 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4518 grep -c lmm_magic) -eq $NUMFILES ]] ||
4519 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4520 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4521 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4523 #test lfs getstripe with -v prints lmm_fid
4524 [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
4525 error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
4526 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
4527 error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
4528 echo "$GETSTRIPE --verbose passed."
4530 #check for FID information
4531 local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
4532 local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
4533 awk '/lmm_fid: / { print $2 }')
4534 local fid3=$($LFS path2fid $DIR/$tdir/file1)
4535 [ "$fid1" != "$fid2" ] &&
4536 error "getstripe --fid $fid1 != getstripe --verbose $fid2"
4537 [ "$fid1" != "$fid3" ] &&
4538 error "getstripe --fid $fid1 != lfs path2fid $fid3"
4539 echo "$GETSTRIPE --fid passed."
4541 #test lfs getstripe with --obd
4542 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4543 grep -q "unknown obduuid" ||
4544 error "$GETSTRIPE --obd wrong_uuid should return error message"
4546 [[ $OSTCOUNT -lt 2 ]] &&
4547 skip_env "skipping other $GETSTRIPE --obd test" && return
4550 OBDUUID=$(ostuuid_from_index $OSTIDX)
4551 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4552 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4553 [[ $FOUND -eq $FILENUM ]] ||
4554 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4555 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4556 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4557 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4558 error "$GETSTRIPE --obd: should not show file on other obd"
4559 echo "$GETSTRIPE --obd passed"
4561 run_test 56a "check $GETSTRIPE"
4564 test_mkdir $DIR/$tdir
4566 for i in $(seq 1 $NUMDIRS); do
4567 test_mkdir $DIR/$tdir/dir$i
4570 # test lfs getdirstripe default mode is non-recursion, which is
4571 # different from lfs getstripe
4572 dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
4573 [[ $dircnt -eq 1 ]] ||
4574 error "$LFS getdirstripe: found $dircnt, not 1"
4575 dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
4576 grep -c lmv_stripe_count)
4577 [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
4578 error "$LFS getdirstripe --recursive: found $dircnt, \
4579 not $((NUMDIRS + 1))"
4581 run_test 56b "check $LFS getdirstripe"
4585 local ost_name=$(ostname_from_index $ost_idx)
4587 local old_status=$(ost_dev_status $ost_idx)
4588 [[ -z "$old_status" ]] ||
4589 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4591 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4594 local new_status=$(ost_dev_status $ost_idx)
4595 [[ "$new_status" = "D" ]] ||
4596 error "OST $ost_name is in status of '$new_status', not 'D'"
4598 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4601 new_status=$(ost_dev_status $ost_idx)
4602 [[ -z "$new_status" ]] ||
4603 error "OST $ost_name is in status of '$new_status', not ''"
4605 run_test 56c "check 'lfs df' showing device status"
4610 local LOCAL_NUMFILES="$1"
4611 local LOCAL_NUMDIRS="$2"
4612 local MKDIR_PARAMS="$3"
4613 local DIR_STRIPE_PARAMS="$4"
4615 if [ ! -d "$TDIR" ] ; then
4616 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4617 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4618 for i in `seq 1 $LOCAL_NUMFILES` ; do
4621 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4622 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4623 for j in `seq 1 $LOCAL_NUMFILES` ; do
4624 touch $TDIR/dir$i/file$j
4630 setup_56_special() {
4634 if [ ! -e "$TDIR/loop1b" ] ; then
4635 for i in `seq 1 $LOCAL_NUMFILES` ; do
4636 mknod $TDIR/loop${i}b b 7 $i
4637 mknod $TDIR/null${i}c c 1 3
4638 ln -s $TDIR/file1 $TDIR/link${i}l
4640 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4641 mknod $TDIR/dir$i/loop${i}b b 7 $i
4642 mknod $TDIR/dir$i/null${i}c c 1 3
4643 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4652 setup_56 $NUMFILES $NUMDIRS
4654 EXPECTED=$(($NUMDIRS + 2))
4655 # test lfs find with -name
4656 for i in $(seq 1 $NUMFILES) ; do
4657 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4658 [ $NUMS -eq $EXPECTED ] ||
4659 error "lfs find -name \"*$i\" $TDIR wrong: "\
4660 "found $NUMS, expected $EXPECTED"
4663 run_test 56g "check lfs find -name ============================="
4669 setup_56 $NUMFILES $NUMDIRS
4671 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4672 # test lfs find with ! -name
4673 for i in $(seq 1 $NUMFILES) ; do
4674 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4675 [ $NUMS -eq $EXPECTED ] ||
4676 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4677 "found $NUMS, expected $EXPECTED"
4680 run_test 56h "check lfs find ! -name"
4684 test_mkdir $DIR/$tdir
4685 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4686 CMD="$LFIND -ost $UUID $DIR/$tdir"
4688 [ -z "$OUT" ] || error "'$CMD' returned directory '$OUT'"
4690 run_test 56i "check 'lfs find -ost UUID' skips directories"
4694 setup_56_special $NUMFILES $NUMDIRS
4696 EXPECTED=$((NUMDIRS + 1))
4697 CMD="$LFIND -type d $TDIR"
4698 NUMS=$($CMD | wc -l)
4699 [ $NUMS -eq $EXPECTED ] ||
4700 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4702 run_test 56j "check lfs find -type d ============================="
4706 setup_56_special $NUMFILES $NUMDIRS
4708 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4709 CMD="$LFIND -type f $TDIR"
4710 NUMS=$($CMD | wc -l)
4711 [ $NUMS -eq $EXPECTED ] ||
4712 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4714 run_test 56k "check lfs find -type f ============================="
4718 setup_56_special $NUMFILES $NUMDIRS
4720 EXPECTED=$((NUMDIRS + NUMFILES))
4721 CMD="$LFIND -type b $TDIR"
4722 NUMS=$($CMD | wc -l)
4723 [ $NUMS -eq $EXPECTED ] ||
4724 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4726 run_test 56l "check lfs find -type b ============================="
4730 setup_56_special $NUMFILES $NUMDIRS
4732 EXPECTED=$((NUMDIRS + NUMFILES))
4733 CMD="$LFIND -type c $TDIR"
4734 NUMS=$($CMD | wc -l)
4735 [ $NUMS -eq $EXPECTED ] ||
4736 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4738 run_test 56m "check lfs find -type c ============================="
4742 setup_56_special $NUMFILES $NUMDIRS
4744 EXPECTED=$((NUMDIRS + NUMFILES))
4745 CMD="$LFIND -type l $TDIR"
4746 NUMS=$($CMD | wc -l)
4747 [ $NUMS -eq $EXPECTED ] ||
4748 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4750 run_test 56n "check lfs find -type l ============================="
4754 setup_56 $NUMFILES $NUMDIRS
4755 utime $TDIR/file1 > /dev/null || error "utime (1)"
4756 utime $TDIR/file2 > /dev/null || error "utime (2)"
4757 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4758 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4759 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4760 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4763 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4764 [ $NUMS -eq $EXPECTED ] || \
4765 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4768 CMD="$LFIND -mtime 0 $TDIR"
4769 NUMS=$($CMD | wc -l)
4770 [ $NUMS -eq $EXPECTED ] ||
4771 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4773 run_test 56o "check lfs find -mtime for old files =========================="
4776 [ $RUNAS_ID -eq $UID ] &&
4777 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4780 setup_56 $NUMFILES $NUMDIRS
4782 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4784 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4785 NUMS=$($CMD | wc -l)
4786 [ $NUMS -eq $EXPECTED ] || \
4787 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4789 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4790 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4791 NUMS=$($CMD | wc -l)
4792 [ $NUMS -eq $EXPECTED ] || \
4793 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4795 run_test 56p "check lfs find -uid and ! -uid ==============================="
4798 [ $RUNAS_ID -eq $UID ] &&
4799 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4802 setup_56 $NUMFILES $NUMDIRS
4804 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4807 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4808 NUMS=$($CMD | wc -l)
4809 [ $NUMS -eq $EXPECTED ] ||
4810 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4812 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4813 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4814 NUMS=$($CMD | wc -l)
4815 [ $NUMS -eq $EXPECTED ] ||
4816 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4818 run_test 56q "check lfs find -gid and ! -gid ==============================="
4822 setup_56 $NUMFILES $NUMDIRS
4825 CMD="$LFIND -size 0 -type f $TDIR"
4826 NUMS=$($CMD | wc -l)
4827 [ $NUMS -eq $EXPECTED ] ||
4828 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4830 CMD="$LFIND ! -size 0 -type f $TDIR"
4831 NUMS=$($CMD | wc -l)
4832 [ $NUMS -eq $EXPECTED ] ||
4833 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4834 echo "test" > $TDIR/$tfile
4835 echo "test2" > $TDIR/$tfile.2 && sync
4837 CMD="$LFIND -size 5 -type f $TDIR"
4838 NUMS=$($CMD | wc -l)
4839 [ $NUMS -eq $EXPECTED ] ||
4840 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4842 CMD="$LFIND -size +5 -type f $TDIR"
4843 NUMS=$($CMD | wc -l)
4844 [ $NUMS -eq $EXPECTED ] ||
4845 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4847 CMD="$LFIND -size +0 -type f $TDIR"
4848 NUMS=$($CMD | wc -l)
4849 [ $NUMS -eq $EXPECTED ] ||
4850 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4852 CMD="$LFIND ! -size -5 -type f $TDIR"
4853 NUMS=$($CMD | wc -l)
4854 [ $NUMS -eq $EXPECTED ] ||
4855 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4857 CMD="$LFIND -size -5 -type f $TDIR"
4858 NUMS=$($CMD | wc -l)
4859 [ $NUMS -eq $EXPECTED ] ||
4860 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4862 run_test 56r "check lfs find -size works =========================="
4864 test_56s() { # LU-611
4869 for i in $(seq 1 $NUMDIRS); do
4870 $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile
4873 CMD="$LFIND -c $OSTCOUNT $TDIR"
4874 NUMS=$($CMD | wc -l)
4875 [ $NUMS -eq $EXPECTED ] || {
4877 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4881 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4882 if [[ $OSTCOUNT -gt 1 ]]; then
4883 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4887 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4891 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4892 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4893 NUMS=$($CMD | wc -l)
4894 [ $NUMS -eq $EXPECTED ] || {
4896 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4899 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4900 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4901 NUMS=$($CMD | wc -l)
4902 [ $NUMS -eq $EXPECTED ] || {
4904 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4908 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4909 NUMS=$($CMD | wc -l)
4910 [ $NUMS -eq $EXPECTED ] || {
4912 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4915 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4916 NUMS=$($CMD | wc -l)
4917 [ $NUMS -eq $EXPECTED ] || {
4919 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4923 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4924 NUMS=$($CMD | wc -l)
4925 [ $NUMS -eq $EXPECTED ] || {
4927 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4930 run_test 56s "check lfs find -stripe-count works"
4932 test_56t() { # LU-611
4937 for i in $(seq 1 $NUMDIRS); do
4938 $SETSTRIPE -S 4M $TDIR/dir$i/$tfile
4941 CMD="$LFIND -S 4M $TDIR"
4942 NUMS=$($CMD | wc -l)
4943 [ $NUMS -eq $EXPECTED ] || {
4945 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4949 setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
4951 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4953 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4954 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4955 NUMS=$($CMD | wc -l)
4956 [ $NUMS -eq $EXPECTED ] ||
4957 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4959 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4960 NUMS=$($CMD | wc -l)
4961 [ $NUMS -eq $EXPECTED ] ||
4962 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4964 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4965 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4966 NUMS=$($CMD | wc -l)
4967 [ $NUMS -eq $EXPECTED ] ||
4968 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4970 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4971 NUMS=$($CMD | wc -l)
4972 [ $NUMS -eq $EXPECTED ] ||
4973 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4976 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4977 NUMS=$($CMD | wc -l)
4978 [ $NUMS -eq $EXPECTED ] ||
4979 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4981 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4982 NUMS=$($CMD | wc -l)
4983 [ $NUMS -eq $EXPECTED ] ||
4984 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4987 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4988 NUMS=$($CMD | wc -l)
4989 [ $NUMS -eq $EXPECTED ] ||
4990 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4992 run_test 56t "check lfs find -stripe-size works"
4994 test_56u() { # LU-611
4996 setup_56 $NUMFILES $NUMDIRS "-i 0"
4998 if [[ $OSTCOUNT -gt 1 ]]; then
4999 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
5005 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
5006 CMD="$LFIND -stripe-index 0 -type f $TDIR"
5007 NUMS=$($CMD | wc -l)
5008 [ $NUMS -eq $EXPECTED ] ||
5009 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5012 CMD="$LFIND -stripe-index 1 -type f $TDIR"
5013 NUMS=$($CMD | wc -l)
5014 [ $NUMS -eq $EXPECTED ] ||
5015 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5017 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
5018 NUMS=$($CMD | wc -l)
5019 [ $NUMS -eq $EXPECTED ] ||
5020 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5023 # This should produce an error and not return any files
5024 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
5025 NUMS=$($CMD 2>/dev/null | wc -l)
5026 [ $NUMS -eq $EXPECTED ] ||
5027 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5029 if [[ $OSTCOUNT -gt 1 ]]; then
5030 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
5031 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
5032 NUMS=$($CMD | wc -l)
5033 [ $NUMS -eq $EXPECTED ] ||
5034 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5037 run_test 56u "check lfs find -stripe-index works"
5044 setup_56 $NUMFILES $NUMDIRS
5046 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
5047 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
5049 for file in $($LFIND -mdt $UUID $TDIR); do
5050 file_mdt_idx=$($GETSTRIPE -M $file)
5051 [ $file_mdt_idx -eq $MDT_IDX ] ||
5052 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
5055 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5058 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5062 rm -rf $TDIR || error "remove $TDIR failed"
5063 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5066 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
5067 error "$GETSTRIPE -S -d $TDIR failed"
5068 stripe_size=${stripe_size%% *}
5070 local file_size=$((stripe_size * OSTCOUNT))
5071 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5072 local required_space=$((file_num * file_size))
5074 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5076 [[ $free_space -le $((required_space / 1024)) ]] &&
5077 skip_env "need $required_space bytes, have $free_space KB" &&
5081 local dd_count=$((file_size / dd_bs))
5083 # write data into the files
5087 for i in $(seq 1 $NUMFILES); do
5089 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5090 error "write data into $file failed"
5092 for i in $(seq 1 $NUMDIRS); do
5093 for j in $(seq 1 $NUMFILES); do
5094 file=$TDIR/dir$i/file$j
5095 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5096 error "write data into $file failed"
5100 # $LFS_MIGRATE will fail if hard link migration is unsupported
5101 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5102 createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 ||
5103 error "creating links to $TDIR/dir1/file1 failed"
5107 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5110 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
5112 eval $cmd || error "$cmd failed"
5114 check_stripe_count $TDIR/file1 $expected
5116 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5118 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5119 # OST 1 if it is on OST 0. This file is small enough to
5120 # be on only one stripe.
5121 file=$TDIR/migr_1_ost
5122 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5123 error "write data into $file failed"
5124 local obdidx=$($LFS getstripe -i $file)
5125 local oldmd5=$(md5sum $file)
5127 [[ $obdidx -eq 0 ]] && newobdidx=1
5128 cmd="$LFS migrate -i $newobdidx $file"
5130 eval $cmd || error "$cmd failed"
5131 local realobdix=$($LFS getstripe -i $file)
5132 local newmd5=$(md5sum $file)
5133 [[ $newobdidx -ne $realobdix ]] &&
5134 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
5135 [[ "$oldmd5" != "$newmd5" ]] &&
5136 error "md5sum differ: $oldmd5, $newmd5"
5140 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
5142 eval $cmd || error "$cmd failed"
5144 for j in $(seq 1 $NUMFILES); do
5145 check_stripe_count $TDIR/dir1/file$j $expected
5148 # lfs_migrate works with lfs find
5149 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
5150 $LFS_MIGRATE -y -c $expected"
5152 eval $cmd || error "$cmd failed"
5154 for i in $(seq 2 $NUMFILES); do
5155 check_stripe_count $TDIR/file$i $expected
5157 for i in $(seq 2 $NUMDIRS); do
5158 for j in $(seq 1 $NUMFILES); do
5159 check_stripe_count $TDIR/dir$i/file$j $expected
5163 run_test 56w "check lfs_migrate -c stripe_count works"
5166 check_swap_layouts_support && return 0
5167 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5169 local dir0=$DIR/$tdir
5170 local ref1=/etc/passwd
5171 local file1=$dir0/file1
5173 test_mkdir $dir0 || error "creating dir $dir0"
5174 $LFS setstripe -c 2 $file1
5176 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5177 stripe=$($LFS getstripe -c $file1)
5178 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5179 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5184 run_test 56x "lfs migration support"
5187 check_swap_layouts_support && return 0
5188 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5190 local dir0=$DIR/$tdir/$testnum
5193 local ref1=/etc/passwd
5194 local file1=$dir0/file1
5196 $LFS setstripe -c 2 $file1
5198 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5199 local stripe=$($LFS getstripe -c $file1)
5200 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5201 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5206 run_test 56xa "lfs migration --block support"
5208 check_migrate_links() {
5210 local file1="$dir/file1"
5213 local total_count=$(($begin + $count - 1))
5214 local symlink_count=10
5217 if [ ! -f "$file1" ]; then
5218 echo -n "creating initial file..."
5219 $LFS setstripe -c 1 -S "512k" "$file1" ||
5220 error "cannot setstripe initial file"
5223 echo -n "creating symlinks..."
5224 for s in $(seq 1 $symlink_count); do
5225 ln -s "$file1" "$dir/slink$s" ||
5226 error "cannot create symlinks"
5230 echo -n "creating nonlinked files..."
5231 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5232 error "cannot create nonlinked files"
5237 if [ ! -f "$dir/file$total_count" ]; then
5238 echo -n "creating hard links $begin:$total_count..."
5239 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5240 /dev/null || error "cannot create hard links"
5244 echo -n "checking number of hard links listed in xattrs..."
5245 local fid=$($LFS getstripe -F "$file1")
5246 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5249 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5250 echo "hard link list has unexpected size, skipping test"
5253 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5254 error "link names should exceed xattrs size"
5257 echo -n "migrating files..."
5258 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5260 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5263 # make sure all links have been properly migrated
5264 echo -n "verifying files..."
5265 fid=$($LFS getstripe -F "$file1") ||
5266 error "cannot get fid for file $file1"
5267 for i in $(seq 2 $total_count); do
5268 local fid2=$($LFS getstripe -F $dir/file$i)
5269 [ "$fid2" == "$fid" ] ||
5270 error "migrated hard link has mismatched FID"
5273 # make sure hard links were properly detected, and migration was
5274 # performed only once for the entire link set; nonlinked files should
5276 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5277 local expected=$(($uniq_count + 1))
5278 [ "$actual" -eq "$expected" ] ||
5279 error "hard links individually migrated ($actual != $expected)"
5281 # make sure the correct number of hard links are present
5282 local hardlinks=$(stat -c '%h' "$file1")
5283 [ $hardlinks -eq $total_count ] ||
5284 error "num hard links $hardlinks != $total_count"
5291 local dir0="$DIR/$tdir"
5293 test_mkdir "$dir0" || error "cannot create dir $dir0"
5295 echo "testing lfs migrate mode when all links fit within xattrs"
5296 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 2 99
5298 echo "testing rsync mode when all links fit within xattrs"
5299 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 2 99
5301 echo "testing lfs migrate mode when all links do not fit within xattrs"
5302 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 101 100
5304 echo "testing rsync mode when all links do not fit within xattrs"
5305 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 101 100
5310 run_test 56xb "lfs migration hard link support"
5313 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5314 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5318 local dir0=$DIR/$tdir/$testnum
5320 local f1=$dir0/file1
5321 local f2=$dir0/file2
5323 touch $f1 || error "creating std file $f1"
5324 $MULTIOP $f2 H2c || error "creating released file $f2"
5326 # a directory can be raid0, so ask only for files
5327 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5328 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5330 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5331 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5333 # only files can be released, so no need to force file search
5334 res=$($LFIND $dir0 -L released)
5335 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5337 res=$($LFIND $dir0 \! -L released)
5338 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5341 run_test 56y "lfs find -L raid0|released"
5343 test_56z() { # LU-4824
5344 # This checks to make sure 'lfs find' continues after errors
5345 # There are two classes of errors that should be caught:
5346 # - If multiple paths are provided, all should be searched even if one
5348 # - If errors are encountered during the search, it should not terminate
5351 test_mkdir $DIR/$tdir
5352 for i in d{0..9}; do
5353 test_mkdir $DIR/$tdir/$i
5355 touch $DIR/$tdir/d{0..9}/$tfile
5356 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5357 error "$LFS find did not return an error"
5358 # Make a directory unsearchable. This should NOT be the last entry in
5359 # directory order. Arbitrarily pick the 6th entry
5360 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5361 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5362 # The user should be able to see 10 directories and 9 files
5363 [ $count == 19 ] || error "$LFS find did not continue after error"
5365 run_test 56z "lfs find should continue after an error"
5367 test_56aa() { # LU-5937
5368 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5371 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5373 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5374 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5376 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5378 run_test 56aa "lfs find --size under striped dir"
5381 # Create composite files with one component
5382 TDIR=$DIR/$tdir/1Mfiles
5383 setup_56 5 1 "--component-end 1M"
5384 # Create composite files with three components
5385 TDIR=$DIR/$tdir/2Mfiles
5386 setup_56 5 2 "-E 2M -E 4M -E 6M"
5388 # Create non-composite files
5389 createmany -o $TDIR/${tfile}- 10
5391 local nfiles=$($LFIND --component-end 1M --type f $TDIR | wc -l)
5392 [[ $nfiles == 10 ]] ||
5393 error "lfs find -E 1M found $nfiles != 10 files"
5395 nfiles=$($LFIND ! -E 1M --type f $TDIR | wc -l)
5396 [[ $nfiles == 25 ]] ||
5397 error "lfs find ! -E 1M found $nfiles != 25 files"
5399 # All files have a component that starts at 0
5400 local nfiles=$($LFIND --component-start 0 --type f $TDIR | wc -l)
5401 [[ $nfiles == 35 ]] ||
5402 error "lfs find --component-start 0 found $nfiles != 35 files"
5404 nfiles=$($LFIND --component-start 2M --type f $TDIR | wc -l)
5405 [[ $nfiles == 15 ]] ||
5406 error "$LFIND --component-start 2M found $nfiles != 15 files"
5408 # All files created here have a componenet that does not starts at 2M
5409 nfiles=$($LFIND ! --component-start 2M --type f $TDIR | wc -l)
5410 [[ $nfiles == 35 ]] ||
5411 error "$LFIND ! --component-start 2M found $nfiles != 35 files"
5413 # Find files with a specified number of components
5414 local nfiles=$($LFIND --component-count 3 --type f $TDIR | wc -l)
5415 [[ $nfiles == 15 ]] ||
5416 error "lfs find --component-count 3 found $nfiles != 15 files"
5418 # Remember non-composite files have a component count of zero
5419 local nfiles=$($LFIND --component-count 0 --type f $TDIR | wc -l)
5420 [[ $nfiles == 10 ]] ||
5421 error "lfs find --component-count 0 found $nfiles != 10 files"
5423 nfiles=$($LFIND ! --component-count 3 --type f $TDIR | wc -l)
5424 [[ $nfiles == 20 ]] ||
5425 error "$LFIND ! --component-count 3 found $nfiles != 20 files"
5427 # All files have a flag called "init"
5428 local nfiles=$($LFIND --component-flags init --type f $TDIR | wc -l)
5429 [[ $nfiles == 35 ]] ||
5430 error "$LFIND --component-flags init found $nfiles != 35 files"
5432 # Multi-component files will have a component not initialized
5433 local nfiles=$($LFIND ! --component-flags init --type f $TDIR | wc -l)
5434 [[ $nfiles == 15 ]] ||
5435 error "$LFIND !--component-flags init found $nfiles != 15 files"
5440 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
5443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5444 # note test will not do anything if MDS is not local
5445 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5446 skip "ldiskfs only test"
5450 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5451 local MNTDEV="osd*.*MDT*.mntdev"
5452 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5453 [ -z "$DEV" ] && error "can't access $MNTDEV"
5454 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5455 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5456 error "can't access $DEV"
5457 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5458 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5462 run_test 57a "verify MDS filesystem created with large inodes =="
5465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5466 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5467 skip "ldiskfs only test"
5471 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5472 local dir=$DIR/$tdir
5476 local FILEN=$dir/f$FILECOUNT
5478 rm -rf $dir || error "removing $dir"
5480 local mdtidx=$($LFS getstripe -M $dir)
5481 local mdtname=MDT$(printf %04x $mdtidx)
5482 local facet=mds$((mdtidx + 1))
5484 echo "mcreating $FILECOUNT files"
5485 createmany -m $dir/f 1 $FILECOUNT || \
5486 error "creating files in $dir"
5488 # verify that files do not have EAs yet
5489 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5490 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5494 df $dir #make sure we get new statfs data
5495 local MDSFREE=$(do_facet $facet \
5496 lctl get_param -n osd*.*$mdtname.kbytesfree)
5497 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5498 echo "opening files to create objects/EAs"
5500 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5501 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5504 # verify that files have EAs now
5505 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5506 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5508 sleep 1 #make sure we get new statfs data
5510 local MDSFREE2=$(do_facet $facet \
5511 lctl get_param -n osd*.*$mdtname.kbytesfree)
5512 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5513 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5514 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5515 error "MDC before $MDCFREE != after $MDCFREE2"
5517 echo "MDC before $MDCFREE != after $MDCFREE2"
5518 echo "unable to confirm if MDS has large inodes"
5523 run_test 57b "default LOV EAs are stored inside large inodes ==="
5526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5527 [ -z "$(which wiretest 2>/dev/null)" ] &&
5528 skip_env "could not find wiretest" && return
5531 run_test 58 "verify cross-platform wire constants =============="
5534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5535 echo "touch 130 files"
5536 createmany -o $DIR/f59- 130
5538 unlinkmany $DIR/f59- 130
5540 # wait for commitment of removal
5541 wait_delete_completed
5543 run_test 59 "verify cancellation of llog records async ========="
5545 TEST60_HEAD="test_60 run $RANDOM"
5547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5548 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5549 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5550 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5551 skip_env "missing subtest run-llog.sh" && return
5553 log "$TEST60_HEAD - from kernel mode"
5554 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5555 do_facet mgs "sh run-llog.sh" || error "run-llog.sh failed"
5556 do_facet mgs $LCTL dk > $TMP/$tfile
5558 # LU-6388: test llog_reader
5559 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5560 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5561 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5562 skip_env "missing llog_reader" && return
5563 local fstype=$(facet_fstype mgs)
5564 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5565 skip_env "Only for ldiskfs or zfs type mgs" && return
5567 local mntpt=$(facet_mntpt mgs)
5568 local mgsdev=$(mgsdevname 1)
5580 #get fid and record list
5581 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5583 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5585 #remount mgs as ldiskfs or zfs type
5586 stop mgs || error "stop mgs failed"
5587 mount_fstype mgs || error "remount mgs failed"
5588 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5591 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5592 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5597 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5599 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5601 echo "obj_file is $obj_file"
5602 do_facet mgs $llog_reader $obj_file
5604 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5605 awk '{ print $3 }' | sed -e "s/^type=//g")
5606 if [ $rec_type != $rec ]; then
5607 echo "FAILED test_60a wrong record type $rec_type," \
5613 #check obj path if record type is LLOG_LOGID_MAGIC
5614 if [ "$rec" == "1064553b" ]; then
5615 path=$(do_facet mgs $llog_reader $obj_file |
5616 grep "path=" | awk '{ print $NF }' |
5617 sed -e "s/^path=//g")
5618 if [ $obj_file != $mntpt/$path ]; then
5619 echo "FAILED test_60a wrong obj path" \
5620 "$montpt/$path, should be $obj_file"
5627 #restart mgs before "error", otherwise it will block the next test
5628 stop mgs || error "stop mgs failed"
5629 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5630 $pass || error "test failed, see FAILED test_60a messages for specifics"
5632 run_test 60a "llog_test run from kernel module and test llog_reader"
5635 # test old logid format
5636 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5637 do_facet mgs $LCTL dl | grep MGS
5638 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5639 error "old llog_print failed"
5642 # test new logid format
5643 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5644 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5645 error "new llog_print failed"
5648 run_test 60aa "llog_print works with FIDs and simple names"
5650 test_60b() { # bug 6411
5651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5653 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5665 [[ $LLOG_COUNT -gt 100 ]] &&
5666 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5668 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5672 echo "create 5000 files"
5673 createmany -o $DIR/f60c- 5000
5674 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5675 lctl set_param fail_loc=0x80000137
5676 unlinkmany $DIR/f60c- 5000
5677 lctl set_param fail_loc=0
5679 run_test 60c "unlink file when mds full"
5682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5683 SAVEPRINTK=$(lctl get_param -n printk)
5685 # verify "lctl mark" is even working"
5686 MESSAGE="test message ID $RANDOM $$"
5687 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5688 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5690 lctl set_param printk=0 || error "set lnet.printk failed"
5691 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5692 MESSAGE="new test message ID $RANDOM $$"
5693 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5694 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5695 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5697 lctl set_param -n printk="$SAVEPRINTK"
5699 run_test 60d "test printk console message masking"
5702 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5703 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5705 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5706 do_facet mds1 lctl set_param fail_loc=0x15b
5709 run_test 60e "no space while new llog is being created"
5712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5714 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5715 cancel_lru_locks osc
5716 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5719 run_test 61 "mmap() writes don't make sync hang ================"
5721 # bug 2330 - insufficient obd_match error checking causes LBUG
5723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5726 cancel_lru_locks osc
5727 lctl set_param fail_loc=0x405
5728 cat $f && error "cat succeeded, expect -EIO"
5729 lctl set_param fail_loc=0
5731 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5732 # match every page all of the time.
5733 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5735 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5736 # Though this test is irrelevant anymore, it helped to reveal some
5737 # other grant bugs (LU-4482), let's keep it.
5738 test_63a() { # was test_63
5739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5740 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5741 for i in `seq 10` ; do
5742 dd if=/dev/zero of=$DIR/f63 bs=8k &
5748 rm -f $DIR/f63 || true
5750 run_test 63a "Verify oig_wait interruption does not crash ======="
5752 # bug 2248 - async write errors didn't return to application on sync
5753 # bug 3677 - async write errors left page locked
5755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5757 lctl set_param debug=-1
5759 # ensure we have a grant to do async writes
5760 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5763 sync # sync lest earlier test intercept the fail_loc
5765 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5766 lctl set_param fail_loc=0x80000406
5767 $MULTIOP $DIR/$tfile Owy && \
5768 error "sync didn't return ENOMEM"
5769 sync; sleep 2; sync # do a real sync this time to flush page
5770 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5771 error "locked page left in cache after async error" || true
5774 run_test 63b "async write errors should be returned to fsync ==="
5777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5779 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5781 run_test 64a "verify filter grant calculations (in kernel) ====="
5784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5785 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5787 run_test 64b "check out-of-space detection on client"
5790 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5792 run_test 64c "verify grant shrink"
5794 # bug 1414 - set/get directories' stripe info
5796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5797 test_mkdir $DIR/$tdir
5799 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5801 run_test 65a "directory with no stripe info"
5804 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5805 test_mkdir $DIR/$tdir
5806 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5808 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5811 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5813 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5816 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5817 [ $OSTCOUNT -lt 2 ] && skip "need at least 2 OSTs" && return
5818 test_mkdir $DIR/$tdir
5819 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
5821 $LFS setstripe -S $((stripesize * 4)) -i 1 \
5822 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5824 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5826 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5829 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5830 test_mkdir $DIR/$tdir
5831 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5832 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5834 if [[ $STRIPECOUNT -le 0 ]]; then
5836 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5837 #LOV_MAX_STRIPE_COUNT is 2000
5838 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5840 sc=$(($STRIPECOUNT - 1))
5842 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5843 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5844 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5845 error "lverify failed"
5847 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5851 test_mkdir $DIR/$tdir
5853 $SETSTRIPE $DIR/$tdir || error "setstripe"
5854 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5855 error "no stripe info failed"
5857 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5859 run_test 65e "directory setstripe defaults"
5862 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5863 test_mkdir $DIR/${tdir}f
5864 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5866 run_test 65f "dir setstripe permission (should return error) ==="
5869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5870 test_mkdir $DIR/$tdir
5871 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5873 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5874 error "setstripe -S failed"
5875 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
5876 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
5877 error "delete default stripe failed"
5879 run_test 65g "directory setstripe -d"
5882 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5883 test_mkdir $DIR/$tdir
5884 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5886 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5887 error "setstripe -S failed"
5888 test_mkdir $DIR/$tdir/dd1
5889 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5890 error "stripe info inherit failed"
5892 run_test 65h "directory stripe info inherit ===================="
5894 test_65i() { # bug6367
5895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5896 $SETSTRIPE -S 65536 -c -1 $MOUNT
5898 run_test 65i "set non-default striping on root directory (bug 6367)="
5900 test_65ia() { # bug12836
5901 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5902 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5904 run_test 65ia "getstripe on -1 default directory striping"
5906 test_65ib() { # bug12836
5907 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5908 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5910 run_test 65ib "getstripe -v on -1 default directory striping"
5912 test_65ic() { # bug12836
5913 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5914 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5916 run_test 65ic "new find on -1 default directory striping"
5918 test_65j() { # bug6367
5919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5921 # if we aren't already remounting for each test, do so for this test
5922 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5923 cleanup || error "failed to unmount"
5926 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5928 run_test 65j "set default striping on root directory (bug 6367)="
5930 test_65k() { # bug11679
5931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5932 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5933 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5935 local disable_precreate=true
5936 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
5937 disable_precreate=false
5939 echo "Check OST status: "
5940 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
5941 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
5943 for OSC in $MDS_OSCS; do
5944 echo $OSC "is active"
5945 do_facet $SINGLEMDS lctl --device %$OSC activate
5948 for INACTIVE_OSC in $MDS_OSCS; do
5949 local ost=$(osc_to_ost $INACTIVE_OSC)
5950 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
5951 lov.*md*.target_obd |
5952 awk -F: /$ost/'{ print $1 }' | head -n 1)
5955 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
5956 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
5958 echo "Deactivate: " $INACTIVE_OSC
5959 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5961 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
5962 osp.$ost*MDT0000.create_count")
5963 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
5964 osp.$ost*MDT0000.max_create_count")
5965 $disable_precreate &&
5966 do_facet $SINGLEMDS "lctl set_param -n \
5967 osp.$ost*MDT0000.max_create_count=0"
5969 for idx in $(seq 0 $((OSTCOUNT - 1))); do
5970 [ -f $DIR/$tdir/$idx ] && continue
5971 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
5972 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
5973 error "setstripe $idx should succeed"
5974 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
5976 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
5979 do_facet $SINGLEMDS "lctl set_param -n \
5980 osp.$ost*MDT0000.max_create_count=$max_count"
5981 do_facet $SINGLEMDS "lctl set_param -n \
5982 osp.$ost*MDT0000.create_count=$count"
5983 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5984 echo $INACTIVE_OSC "is Activate"
5986 wait_osc_import_state mds ost$ostnum FULL
5989 run_test 65k "validate manual striping works properly with deactivated OSCs"
5991 test_65l() { # bug 12836
5992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5993 test_mkdir -p $DIR/$tdir/test_dir
5994 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5995 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5997 run_test 65l "lfs find on -1 stripe dir ========================"
6000 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
6003 run_test 65m "normal user can't set filesystem default stripe"
6005 # bug 2543 - update blocks count on client
6007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6009 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6010 sync; sync_all_data; sync; sync_all_data
6011 cancel_lru_locks osc
6012 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6013 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6015 run_test 66 "update inode blocks count on client ==============="
6018 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6022 swapon -s | awk '($1 == "'$1'") { print $4 }'
6025 # bug5265, obdfilter oa2dentry return -ENOENT
6026 # #define OBD_FAIL_SRV_ENOENT 0x217
6028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6029 remote_ost_nodsh && skip "remote OST with nodsh" && return
6032 $SETSTRIPE -c 1 -i 0 $f
6034 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6036 do_facet ost1 lctl set_param fail_loc=0x217
6037 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6038 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6040 do_facet ost1 lctl set_param fail_loc=0
6041 $DIRECTIO write $f 0 2 || error "write error"
6043 cancel_lru_locks osc
6044 $DIRECTIO read $f 0 1 || error "read error"
6046 do_facet ost1 lctl set_param fail_loc=0x217
6047 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6049 do_facet ost1 lctl set_param fail_loc=0
6052 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6055 test_mkdir $DIR/$tdir
6056 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6057 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6059 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6061 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6063 [ "$RUNAS_ID" = "$UID" ] &&
6064 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6066 # Check that testing environment is properly set up. Skip if not
6067 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
6068 skip_env "User $RUNAS_ID does not exist - skipping"
6072 chmod 777 $DIR/$tfile
6073 chmod ug+s $DIR/$tfile
6074 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6075 error "$RUNAS dd $DIR/$tfile failed"
6076 # See if we are still setuid/sgid
6077 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6078 error "S/gid is not dropped on write"
6079 # Now test that MDS is updated too
6080 cancel_lru_locks mdc
6081 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6082 error "S/gid is not dropped on MDS"
6085 run_test 72a "Test that remove suid works properly (bug5695) ===="
6087 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6090 [ "$RUNAS_ID" = "$UID" ] && \
6091 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6092 [ "$RUNAS_ID" -eq 0 ] && \
6093 skip_env "RUNAS_ID = 0 -- skipping" && return
6095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6096 # Check that testing environment is properly set up. Skip if not
6097 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
6098 skip_env "User $RUNAS_ID does not exist - skipping"
6101 touch $DIR/${tfile}-f{g,u}
6102 test_mkdir $DIR/${tfile}-dg
6103 test_mkdir $DIR/${tfile}-du
6104 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6105 chmod g+s $DIR/${tfile}-{f,d}g
6106 chmod u+s $DIR/${tfile}-{f,d}u
6107 for perm in 777 2777 4777; do
6108 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6109 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6110 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6111 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6115 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6117 # bug 3462 - multiple simultaneous MDC requests
6119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6120 test_mkdir $DIR/d73-1
6121 test_mkdir $DIR/d73-2
6122 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6125 lctl set_param fail_loc=0x80000129
6126 $MULTIOP $DIR/d73-1/f73-2 Oc &
6128 lctl set_param fail_loc=0
6130 $MULTIOP $DIR/d73-2/f73-3 Oc &
6134 wait $pid1 || return 1
6138 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6139 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6140 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6144 run_test 73 "multiple MDC requests (should not deadlock)"
6146 test_74a() { # bug 6149, 6184
6147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6148 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6150 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6151 # will spin in a tight reconnection loop
6153 $LCTL set_param fail_loc=0x8000030e
6154 # get any lock that won't be difficult - lookup works.
6156 $LCTL set_param fail_loc=0
6160 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6162 test_74b() { # bug 13310
6163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6164 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6166 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6167 # will spin in a tight reconnection loop
6168 $LCTL set_param fail_loc=0x8000030e
6169 # get a "difficult" lock
6171 $LCTL set_param fail_loc=0
6175 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6179 #define OBD_FAIL_LDLM_NEW_LOCK
6180 $LCTL set_param fail_loc=0x319
6181 touch $DIR/$tfile && error "touch successful"
6182 $LCTL set_param fail_loc=0
6185 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6188 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6191 test_76() { # Now for bug 20433, added originally in bug 1443
6192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6193 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6194 cancel_lru_locks osc
6195 BEFORE_INODES=$(num_inodes)
6196 echo "before inodes: $BEFORE_INODES"
6198 [ "$SLOW" = "no" ] && COUNT=100
6199 for i in $(seq $COUNT); do
6203 cancel_lru_locks osc
6204 AFTER_INODES=$(num_inodes)
6205 echo "after inodes: $AFTER_INODES"
6207 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6209 AFTER_INODES=$(num_inodes)
6211 echo "wait $wait seconds inodes: $AFTER_INODES"
6212 if [ $wait -gt 30 ]; then
6213 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6217 run_test 76 "confirm clients recycle inodes properly ===="
6223 # Note: in sptlrpc modes which enable its own bulk checksum, the
6224 # original crc32_le bulk checksum will be automatically disabled,
6225 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6226 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6227 # In this case set_checksums() will not be no-op, because sptlrpc
6228 # bulk checksum will be enabled all through the test.
6230 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6231 lctl set_param -n osc.*.checksums $1
6235 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6236 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6237 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6238 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6241 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6242 log "set checksum type to $1"
6245 F77_TMP=$TMP/f77-temp
6248 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6249 error "error writing to $F77_TMP"
6252 test_77a() { # bug 10889
6253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6254 $GSS && skip "could not run with gss" && return
6255 [ ! -f $F77_TMP ] && setup_f77
6257 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6261 run_test 77a "normal checksum read/write operation"
6263 test_77b() { # bug 10889
6264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6265 $GSS && skip "could not run with gss" && return
6266 [ ! -f $F77_TMP ] && setup_f77
6267 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6268 $LCTL set_param fail_loc=0x80000409
6271 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6272 error "dd error: $?"
6273 $LCTL set_param fail_loc=0
6275 for algo in $CKSUM_TYPES; do
6276 cancel_lru_locks osc
6277 set_checksum_type $algo
6278 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6279 $LCTL set_param fail_loc=0x80000408
6280 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6281 $LCTL set_param fail_loc=0
6284 set_checksum_type $ORIG_CSUM_TYPE
6287 run_test 77b "checksum error on client write, read"
6292 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6294 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6295 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6296 $check_ost && [ -n $ost_file_prefix ] &&
6297 do_facet ost1 rm -f ${ost_file_prefix}\*
6301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6302 $GSS && skip "could not run with gss" && return
6305 local osc_file_prefix
6307 local check_ost=false
6308 local ost_file_prefix
6314 # ensure corruption will occur on first OSS/OST
6315 $LFS setstripe -i 0 $DIR/$tfile
6317 [ ! -f $F77_TMP ] && setup_f77
6318 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6319 error "dd write error: $?"
6320 fid=$($LFS path2fid $DIR/$tfile)
6322 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6325 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6326 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6328 echo "OSS do not support bulk pages dump upon error"
6331 osc_file_prefix=$($LCTL get_param -n debug_path)
6332 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6334 trap cleanup_77c EXIT
6337 # enable bulk pages dump upon error on Client
6338 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6339 # enable bulk pages dump upon error on OSS
6341 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6343 # flush Client cache to allow next read to reach OSS
6344 cancel_lru_locks osc
6346 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6347 $LCTL set_param fail_loc=0x80000408
6348 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6349 $LCTL set_param fail_loc=0
6353 # check cksum dump on Client
6354 osc_file=$(ls ${osc_file_prefix}*)
6355 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6356 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6357 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6358 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6359 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6361 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6362 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6363 error "dump content does not match on Client"
6365 $check_ost || skip "No need to check cksum dump on OSS"
6367 # check cksum dump on OSS
6368 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6369 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6370 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6371 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6372 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6373 error "dump content does not match on OSS"
6377 run_test 77c "checksum error on client read with debug"
6379 test_77d() { # bug 10889
6380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6381 $GSS && skip "could not run with gss" && return
6382 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6383 $LCTL set_param fail_loc=0x80000409
6385 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6386 error "direct write: rc=$?"
6387 $LCTL set_param fail_loc=0
6390 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6391 $LCTL set_param fail_loc=0x80000408
6393 cancel_lru_locks osc
6394 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6395 error "direct read: rc=$?"
6396 $LCTL set_param fail_loc=0
6399 run_test 77d "checksum error on OST direct write, read"
6401 test_77f() { # bug 10889
6402 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6403 $GSS && skip "could not run with gss" && return
6405 for algo in $CKSUM_TYPES; do
6406 cancel_lru_locks osc
6407 set_checksum_type $algo
6408 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6409 $LCTL set_param fail_loc=0x409
6410 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6411 error "direct write succeeded"
6412 $LCTL set_param fail_loc=0
6414 set_checksum_type $ORIG_CSUM_TYPE
6417 run_test 77f "repeat checksum error on write (expect error)"
6419 test_77g() { # bug 10889
6420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6421 $GSS && skip "could not run with gss" && return
6422 remote_ost_nodsh && skip "remote OST with nodsh" && return
6424 [ ! -f $F77_TMP ] && setup_f77
6426 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6427 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6428 do_facet ost1 lctl set_param fail_loc=0x8000021a
6430 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6431 error "write error: rc=$?"
6432 do_facet ost1 lctl set_param fail_loc=0
6435 cancel_lru_locks osc
6436 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6437 do_facet ost1 lctl set_param fail_loc=0x8000021b
6439 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6440 do_facet ost1 lctl set_param fail_loc=0
6443 run_test 77g "checksum error on OST write, read"
6445 test_77j() { # bug 13805
6446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6447 $GSS && skip "could not run with gss" && return
6448 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6449 lctl set_param fail_loc=0x40c
6450 remount_client $MOUNT
6451 lctl set_param fail_loc=0
6452 # wait async osc connect to finish and reflect updated state value
6454 for (( i=0; i < OSTCOUNT; i++ )) ; do
6455 wait_osc_import_state client ost$((i+1)) FULL
6458 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6459 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6460 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6461 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6463 remount_client $MOUNT
6465 run_test 77j "client only supporting ADLER32"
6467 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6476 test_78() { # bug 10901
6477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6478 remote_ost || { skip_env "local OST" && return; }
6481 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6482 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6483 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6484 echo "MemTotal: $MEMTOTAL"
6486 # reserve 256MB of memory for the kernel and other running processes,
6487 # and then take 1/2 of the remaining memory for the read/write buffers.
6488 if [ $MEMTOTAL -gt 512 ] ;then
6489 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6491 # for those poor memory-starved high-end clusters...
6492 MEMTOTAL=$((MEMTOTAL / 2))
6494 echo "Mem to use for directio: $MEMTOTAL"
6496 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6497 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6498 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6499 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6501 echo "Smallest OST: $SMALLESTOST"
6502 [[ $SMALLESTOST -lt 10240 ]] &&
6503 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6505 trap cleanup_test_78 EXIT
6507 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6508 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6510 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6511 echo "File size: $F78SIZE"
6512 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6513 for i in $(seq 1 $NSEQ); do
6514 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6515 echo directIO rdwr round $i of $NSEQ
6516 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6521 run_test 78 "handle large O_DIRECT writes correctly ============"
6523 test_79() { # bug 12743
6524 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6525 wait_delete_completed
6527 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6528 BKFREE=$(calc_osc_kbytes kbytesfree)
6529 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6531 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6532 DFTOTAL=`echo $STRING | cut -d, -f1`
6533 DFUSED=`echo $STRING | cut -d, -f2`
6534 DFAVAIL=`echo $STRING | cut -d, -f3`
6535 DFFREE=$(($DFTOTAL - $DFUSED))
6537 ALLOWANCE=$((64 * $OSTCOUNT))
6539 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6540 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6541 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6543 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6544 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6545 error "df free($DFFREE) mismatch OST free($BKFREE)"
6547 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6548 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6549 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6552 run_test 79 "df report consistency check ======================="
6554 test_80() { # bug 10718
6555 remote_ost_nodsh && skip "remote OST with nodsh" && return
6556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6557 # relax strong synchronous semantics for slow backends like ZFS
6558 local soc="obdfilter.*.sync_on_lock_cancel"
6559 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6561 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6562 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6563 facet_active_host $host; done | sort -u)
6564 do_nodes $hosts lctl set_param $soc=never
6567 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6569 local BEFORE=`date +%s`
6570 cancel_lru_locks osc
6571 local AFTER=`date +%s`
6572 local DIFF=$((AFTER-BEFORE))
6573 if [ $DIFF -gt 1 ] ; then
6574 error "elapsed for 1M@1T = $DIFF"
6577 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6581 run_test 80 "Page eviction is equally fast at high offsets too ===="
6583 test_81a() { # LU-456
6584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6585 remote_ost_nodsh && skip "remote OST with nodsh" && return
6586 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6587 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6588 do_facet ost1 lctl set_param fail_loc=0x80000228
6590 # write should trigger a retry and success
6591 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6592 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6594 if [ $RC -ne 0 ] ; then
6595 error "write should success, but failed for $RC"
6598 run_test 81a "OST should retry write when get -ENOSPC ==============="
6600 test_81b() { # LU-456
6601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6602 remote_ost_nodsh && skip "remote OST with nodsh" && return
6603 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6604 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6605 do_facet ost1 lctl set_param fail_loc=0x228
6607 # write should retry several times and return -ENOSPC finally
6608 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6609 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6612 if [ $RC -ne $ENOSPC ] ; then
6613 error "dd should fail for -ENOSPC, but succeed."
6616 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6618 test_82() { # LU-1031
6619 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6623 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6625 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6627 kill -USR1 $MULTIPID2
6629 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6630 error "First grouplock does not block second one"
6632 echo "Second grouplock blocks first one"
6634 kill -USR1 $MULTIPID1
6638 run_test 82 "Basic grouplock test"
6641 local sfile="/boot/System.map-$(uname -r)"
6642 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6643 $LCTL set_param fail_loc=0x140d
6644 cp $sfile $DIR/$tfile || error "write failed"
6645 diff -c $sfile $DIR/$tfile || error "files are different"
6646 $LCTL set_param fail_loc=0
6649 run_test 83 "Short write in ptask ==============================="
6652 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6654 test_mkdir $DIR/$tdir.cvsroot
6655 chown $RUNAS_ID $DIR/$tdir.cvsroot
6658 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
6661 # some versions of cvs import exit(1) when asked to import links or
6662 # files they can't read. ignore those files.
6663 local toignore=$(find . -type l -printf '-I %f\n' -o \
6664 ! -perm /4 -printf '-I %f\n')
6665 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
6666 $tdir.reposname vtag rtag
6669 test_mkdir $DIR/$tdir.reposname
6670 chown $RUNAS_ID $DIR/$tdir.reposname
6671 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
6673 cd $DIR/$tdir.reposname
6675 $RUNAS cvs add -m 'addmsg' foo99
6677 $RUNAS cvs commit -m 'nomsg' foo99
6678 rm -fr $DIR/$tdir.cvsroot
6680 run_test 99 "cvs strange file/directory operations"
6683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6684 [[ "$NETTYPE" =~ tcp ]] ||
6685 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
6688 remote_ost_nodsh && skip "remote OST with nodsh" && return
6689 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6691 { skip "useless for local single node setup" && return; }
6693 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6694 [ "$PROT" != "tcp" ] && continue
6695 RPORT=$(echo $REMOTE | cut -d: -f2)
6696 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6699 LPORT=`echo $LOCAL | cut -d: -f2`
6700 if [ $LPORT -ge 1024 ]; then
6701 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6703 error_exit "local: $LPORT > 1024, remote: $RPORT"
6706 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6708 run_test 100 "check local port using privileged port ==========="
6710 function get_named_value()
6719 echo $line | sed "s/^$tag[ ]*//"
6726 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6727 awk '/^max_cached_mb/ { print $2 }')
6730 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6736 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
6740 local cache_limit=32
6742 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6743 trap cleanup_101a EXIT
6744 $LCTL set_param -n llite.*.read_ahead_stats 0
6745 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6748 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6750 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6751 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6754 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6755 get_named_value 'read but discarded' | cut -d" " -f1); do
6756 discard=$(($discard + $s))
6760 if [[ $(($discard * 10)) -gt $nreads ]]; then
6761 $LCTL get_param osc.*-osc*.rpc_stats
6762 $LCTL get_param llite.*.read_ahead_stats
6763 error "too many ($discard) discarded pages"
6765 rm -f $DIR/$tfile || true
6767 run_test 101a "check read-ahead for random reads"
6770 test_mkdir $DIR/$tdir
6771 local STRIPE_SIZE=$1
6772 local FILE_LENGTH=$2
6775 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6777 local list=$(comma_list $(osts_nodes))
6778 set_osd_param $list '' read_cache_enable 0
6779 set_osd_param $list '' writethrough_cache_enable 0
6781 trap cleanup_test101bc EXIT
6782 # prepare the read-ahead file
6783 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6785 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6786 count=$FILE_SIZE_MB 2> /dev/null
6790 cleanup_test101bc() {
6795 local list=$(comma_list $(osts_nodes))
6796 set_osd_param $list '' read_cache_enable 1
6797 set_osd_param $list '' writethrough_cache_enable 1
6801 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6806 local STRIPE_SIZE=$2
6807 local FILE_LENGTH=$3
6808 local RA_INC=1048576
6809 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6810 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6811 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6812 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6813 get_named_value 'read but discarded' |
6814 cut -d" " -f1 | calc_total)
6815 if [[ $DISCARD -gt $discard_limit ]]; then
6816 $LCTL get_param llite.*.read_ahead_stats
6817 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6819 echo "Read-ahead success for size ${READ_SIZE}"
6824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6825 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6826 local STRIPE_SIZE=1048576
6827 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6828 if [ $SLOW == "yes" ]; then
6829 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6831 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6834 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6836 # prepare the read-ahead file
6837 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6838 cancel_lru_locks osc
6839 for BIDX in 2 4 8 16 32 64 128 256
6841 local BSIZE=$((BIDX*4096))
6842 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6843 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6844 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6845 $LCTL set_param -n llite.*.read_ahead_stats 0
6846 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6847 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6848 cancel_lru_locks osc
6849 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6854 run_test 101b "check stride-io mode read-ahead ================="
6857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6858 local STRIPE_SIZE=1048576
6859 local FILE_LENGTH=$((STRIPE_SIZE*100))
6863 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6865 cancel_lru_locks osc
6866 $LCTL set_param osc.*.rpc_stats 0
6867 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6868 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6869 local stats=$($LCTL get_param -n $osc_rpc_stats)
6870 local lines=$(echo "$stats" | awk 'END {print NR;}')
6873 if [ $lines -le 20 ]; then
6876 for size in 1 2 4 8; do
6877 local rpc=$(echo "$stats" |
6878 awk '($1 == "'$size':") {print $2; exit; }')
6880 error "Small $((size*4))k read IO $rpc !"
6882 echo "$osc_rpc_stats check passed!"
6887 run_test 101c "check stripe_size aligned read-ahead ================="
6890 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6891 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6896 local file=$DIR/$tfile
6897 local sz_MB=${FILESIZE_101d:-500}
6898 local ra_MB=${READAHEAD_MB:-40}
6900 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6901 [ $free_MB -lt $sz_MB ] &&
6902 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6904 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6905 $SETSTRIPE -c -1 $file || error "setstripe failed"
6907 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6908 echo Cancel LRU locks on lustre client to flush the client cache
6909 cancel_lru_locks osc
6911 echo Disable read-ahead
6912 local old_READAHEAD=$(set_read_ahead 0)
6914 echo Reading the test file $file with read-ahead disabled
6915 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6917 echo Cancel LRU locks on lustre client to flush the client cache
6918 cancel_lru_locks osc
6919 echo Enable read-ahead with ${ra_MB}MB
6920 set_read_ahead $ra_MB
6922 echo Reading the test file $file with read-ahead enabled
6923 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6925 echo "read-ahead disabled time read $raOFF"
6926 echo "read-ahead enabled time read $raON"
6928 set_read_ahead $old_READAHEAD
6930 wait_delete_completed
6932 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6933 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6935 run_test 101d "file read with and without read-ahead enabled"
6938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6939 local file=$DIR/$tfile
6940 local size_KB=500 #KB
6944 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6945 local need_KB=$((count * size_KB))
6946 [[ $free_KB -le $need_KB ]] &&
6947 skip_env "Need free space $need_KB, have $free_KB" && return
6949 echo "Creating $count ${size_KB}K test files"
6950 for ((i = 0; i < $count; i++)); do
6951 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6954 echo "Cancel LRU locks on lustre client to flush the client cache"
6955 cancel_lru_locks $OSC
6957 echo "Reset readahead stats"
6958 $LCTL set_param -n llite.*.read_ahead_stats 0
6960 for ((i = 0; i < $count; i++)); do
6961 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6964 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6965 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6967 for ((i = 0; i < $count; i++)); do
6968 rm -rf $file.$i 2>/dev/null
6971 #10000 means 20% reads are missing in readahead
6972 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6974 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6977 which iozone || { skip "no iozone installed" && return; }
6979 local old_debug=$($LCTL get_param debug)
6980 old_debug=${old_debug#*=}
6981 $LCTL set_param debug="reada mmap"
6983 # create a test file
6984 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
6986 echo Cancel LRU locks on lustre client to flush the client cache
6987 cancel_lru_locks osc
6989 echo Reset readahead stats
6990 $LCTL set_param -n llite.*.read_ahead_stats 0
6992 echo mmap read the file with small block size
6993 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
6996 echo checking missing pages
6997 $LCTL get_param llite.*.read_ahead_stats
6998 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6999 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7001 $LCTL set_param debug="$old_debug"
7002 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7005 run_test 101f "check mmap read performance"
7007 test_101g_brw_size_test() {
7009 local pages=$((mb * 1048576 / $(page_size)))
7011 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7012 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7013 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7014 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7018 $LCTL set_param -n osc.*.rpc_stats=0
7020 # 10 RPCs should be enough for the test
7022 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
7023 { error "dd write ${mb} MB blocks failed"; return 3; }
7024 cancel_lru_locks osc
7025 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
7026 { error "dd write ${mb} MB blocks failed"; return 4; }
7028 # calculate number of full-sized read and write RPCs
7029 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7030 sed -n '/pages per rpc/,/^$/p' |
7031 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7032 END { print reads,writes }'))
7033 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7035 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7043 local osts=$(get_facets OST)
7044 local list=$(comma_list $(osts_nodes))
7045 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7046 local brw_size="obdfilter.*.brw_size"
7047 local ostver=$(lustre_version_code ost1)
7048 local cliver=$(lustre_version_code client)
7050 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7052 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7053 if [ $ostver -ge $(version_code 2.8.52) -o \
7054 \( $ostver -ge $(version_code 2.7.17) -a \
7055 $ostver -lt $(version_code 2.7.50) \) ] &&
7056 [ $cliver -ge $(version_code 2.8.52) -o \
7057 \( $cliver -ge $(version_code 2.7.17) -a \
7058 $cliver -lt $(version_code 2.7.50) \) ]; then
7059 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7060 if [[ $orig_mb -lt 16 ]]; then
7061 save_lustre_params $osts "$brw_size" > $p
7062 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7063 error "set 16MB RPC size failed"
7065 echo "remount client to enable new RPC size"
7066 remount_client $MOUNT || error "remount_client failed"
7069 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7070 # should be able to set brw_size=12, but no rpc_stats for that
7071 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7074 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7076 if [[ $orig_mb -lt 16 ]]; then
7077 restore_lustre_params < $p
7078 remount_client $MOUNT || error "remount_client restore failed"
7081 rm -f $p $DIR/$tfile
7083 run_test 101g "Big bulk(4/16 MiB) readahead"
7086 test_mkdir $DIR/$tdir
7087 chown $RUNAS_ID $DIR/$tdir
7090 STRIPE_COUNT=$OSTCOUNT
7091 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7093 trap cleanup_test102 EXIT
7095 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7097 for num in 1 2 3 4; do
7098 for count in $(seq 1 $STRIPE_COUNT); do
7099 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7100 local size=`expr $STRIPE_SIZE \* $num`
7101 local file=file"$num-$idx-$count"
7102 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7108 $1 tar cf $TMP/f102.tar $tdir --xattrs
7114 rm -rf $DIR/d0.sanity/d102
7118 local testfile=$DIR/$tfile
7122 [ "$UID" != 0 ] && skip_env "must run as root" && return
7123 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7124 skip_env "must have user_xattr" && return
7126 [ -z "$(which setfattr 2>/dev/null)" ] &&
7127 skip_env "could not find setfattr" && return
7129 echo "set/get xattr..."
7130 setfattr -n trusted.name1 -v value1 $testfile ||
7131 error "setfattr -n trusted.name1=value1 $testfile failed"
7132 getfattr -n trusted.name1 $testfile 2> /dev/null |
7133 grep "trusted.name1=.value1" ||
7134 error "$testfile missing trusted.name1=value1"
7136 setfattr -n user.author1 -v author1 $testfile ||
7137 error "setfattr -n user.author1=author1 $testfile failed"
7138 getfattr -n user.author1 $testfile 2> /dev/null |
7139 grep "user.author1=.author1" ||
7140 error "$testfile missing trusted.author1=author1"
7143 setfattr -n trusted.name2 -v value2 $testfile ||
7144 error "$testfile unable to set trusted.name2"
7145 setfattr -n trusted.name3 -v value3 $testfile ||
7146 error "$testfile unable to set trusted.name3"
7147 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7148 grep "trusted.name" | wc -l) -eq 3 ] ||
7149 error "$testfile missing 3 trusted.name xattrs"
7151 setfattr -n user.author2 -v author2 $testfile ||
7152 error "$testfile unable to set user.author2"
7153 setfattr -n user.author3 -v author3 $testfile ||
7154 error "$testfile unable to set user.author3"
7155 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7156 grep "user.author" | wc -l) -eq 3 ] ||
7157 error "$testfile missing 3 user.author xattrs"
7159 echo "remove xattr..."
7160 setfattr -x trusted.name1 $testfile ||
7161 error "$testfile error deleting trusted.name1"
7162 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7163 error "$testfile did not delete trusted.name1 xattr"
7165 setfattr -x user.author1 $testfile ||
7166 error "$testfile error deleting user.author1"
7167 echo "set lustre special xattr ..."
7168 $LFS setstripe -c1 $testfile
7169 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7170 awk -F "=" '/trusted.lov/ { print $2 }' )
7171 setfattr -n "trusted.lov" -v $lovea $testfile ||
7172 error "$testfile doesn't ignore setting trusted.lov again"
7173 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7174 error "$testfile allow setting invalid trusted.lov"
7177 run_test 102a "user xattr test =================================="
7180 [ -z "$(which setfattr 2>/dev/null)" ] &&
7181 skip_env "could not find setfattr" && return
7183 # b10930: get/set/list trusted.lov xattr
7184 echo "get/set/list trusted.lov xattr ..."
7185 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7186 local testfile=$DIR/$tfile
7187 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7188 error "setstripe failed"
7189 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7190 error "getstripe failed"
7191 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7192 error "can't get trusted.lov from $testfile"
7194 local testfile2=${testfile}2
7195 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7196 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7199 setfattr -n trusted.lov -v $value $testfile2
7200 local stripe_size=$($GETSTRIPE -S $testfile2)
7201 local stripe_count=$($GETSTRIPE -c $testfile2)
7202 [[ $stripe_size -eq 65536 ]] ||
7203 error "stripe size $stripe_size != 65536"
7204 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7205 error "stripe count $stripe_count != $STRIPECOUNT"
7208 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7211 [ -z "$(which setfattr 2>/dev/null)" ] &&
7212 skip_env "could not find setfattr" && return
7214 # b10930: get/set/list lustre.lov xattr
7215 echo "get/set/list lustre.lov xattr ..."
7216 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7217 test_mkdir $DIR/$tdir
7218 chown $RUNAS_ID $DIR/$tdir
7219 local testfile=$DIR/$tdir/$tfile
7220 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7221 error "setstripe failed"
7222 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7223 error "getstripe failed"
7224 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7225 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7227 local testfile2=${testfile}2
7228 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7229 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7231 $RUNAS $MCREATE $testfile2
7232 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7233 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7234 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7235 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7236 [ $stripe_count -eq $STRIPECOUNT ] ||
7237 error "stripe count $stripe_count != $STRIPECOUNT"
7239 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7241 compare_stripe_info1() {
7242 local stripe_index_all_zero=true
7244 for num in 1 2 3 4; do
7245 for count in $(seq 1 $STRIPE_COUNT); do
7246 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7247 local size=$((STRIPE_SIZE * num))
7248 local file=file"$num-$offset-$count"
7249 stripe_size=$($LFS getstripe -S $PWD/$file)
7250 [[ $stripe_size -ne $size ]] &&
7251 error "$file: size $stripe_size != $size"
7252 stripe_count=$($LFS getstripe -c $PWD/$file)
7253 # allow fewer stripes to be created, ORI-601
7254 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7255 error "$file: count $stripe_count != $count"
7256 stripe_index=$($LFS getstripe -i $PWD/$file)
7257 [[ $stripe_index -ne 0 ]] &&
7258 stripe_index_all_zero=false
7262 $stripe_index_all_zero &&
7263 error "all files are being extracted starting from OST index 0"
7267 have_xattrs_include() {
7268 tar --help | grep -q xattrs-include &&
7269 echo --xattrs-include="lustre.*"
7273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7274 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7275 XINC=$(have_xattrs_include)
7277 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7279 compare_stripe_info1
7281 run_test 102d "tar restore stripe info from tarfile,not keep osts"
7284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7285 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7286 XINC=$(have_xattrs_include)
7288 test_mkdir $DIR/$tdir.restore
7290 tar cf - --xattrs $tdir | tar xf - \
7291 -C $DIR/$tdir.restore --xattrs $XINC
7292 cd $DIR/$tdir.restore/$tdir
7293 compare_stripe_info1
7295 run_test 102f "tar copy files, not keep osts"
7298 local xsize=${1:-1024} # in bytes
7299 local file=$DIR/$tfile
7301 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7302 skip "must have user_xattr" && return 0
7303 [ -z "$(which setfattr 2>/dev/null)" ] &&
7304 skip_env "could not find setfattr" && return 0
7305 [ -z "$(which getfattr 2>/dev/null)" ] &&
7306 skip_env "could not find getfattr" && return 0
7310 local value="$(generate_string $xsize)"
7312 local xbig=trusted.big
7313 log "save $xbig on $file"
7314 setfattr -n $xbig -v $value $file ||
7315 error "saving $xbig on $file failed"
7317 local orig=$(get_xattr_value $xbig $file)
7318 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7320 local xsml=trusted.sml
7321 log "save $xsml on $file"
7322 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7324 local new=$(get_xattr_value $xbig $file)
7325 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7327 log "grow $xsml on $file"
7328 setfattr -n $xsml -v "$value" $file ||
7329 error "growing $xsml on $file failed"
7331 new=$(get_xattr_value $xbig $file)
7332 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7333 log "$xbig still valid after growing $xsml"
7338 test_102h() { # bug 15777
7341 run_test 102h "grow xattr from inside inode to external block"
7344 large_xattr_enabled || { skip "large_xattr disabled" && return; }
7345 grow_xattr $(max_xattr_size)
7347 run_test 102ha "grow xattr from inside inode to external inode"
7349 test_102i() { # bug 17038
7350 [ -z "$(which getfattr 2>/dev/null)" ] &&
7351 skip "could not find getfattr" && return
7353 ln -s $DIR/$tfile $DIR/${tfile}link
7354 getfattr -n trusted.lov $DIR/$tfile ||
7355 error "lgetxattr on $DIR/$tfile failed"
7356 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7357 grep -i "no such attr" ||
7358 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7359 rm -f $DIR/$tfile $DIR/${tfile}link
7361 run_test 102i "lgetxattr test on symbolic link ============"
7364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7365 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7366 XINC=$(have_xattrs_include)
7367 setup_test102 "$RUNAS"
7368 chown $RUNAS_ID $DIR/$tdir
7369 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7371 compare_stripe_info1 "$RUNAS"
7373 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7376 [ -z "$(which setfattr 2>/dev/null)" ] &&
7377 skip "could not find setfattr" && return
7379 # b22187 just check that does not crash for regular file.
7380 setfattr -n trusted.lov $DIR/$tfile
7381 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
7382 local test_kdir=$DIR/$tdir
7383 test_mkdir $test_kdir
7384 local default_size=$($LFS getstripe -S $test_kdir)
7385 local default_count=$($LFS getstripe -c $test_kdir)
7386 local default_offset=$($LFS getstripe -i $test_kdir)
7387 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7388 error 'dir setstripe failed'
7389 setfattr -n trusted.lov $test_kdir
7390 local stripe_size=$($LFS getstripe -S $test_kdir)
7391 local stripe_count=$($LFS getstripe -c $test_kdir)
7392 local stripe_offset=$($LFS getstripe -i $test_kdir)
7393 [ $stripe_size -eq $default_size ] ||
7394 error "stripe size $stripe_size != $default_size"
7395 [ $stripe_count -eq $default_count ] ||
7396 error "stripe count $stripe_count != $default_count"
7397 [ $stripe_offset -eq $default_offset ] ||
7398 error "stripe offset $stripe_offset != $default_offset"
7399 rm -rf $DIR/$tfile $test_kdir
7401 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7404 [ -z "$(which getfattr 2>/dev/null)" ] &&
7405 skip "could not find getfattr" && return
7407 # LU-532 trusted. xattr is invisible to non-root
7408 local testfile=$DIR/$tfile
7412 echo "listxattr as user..."
7413 chown $RUNAS_ID $testfile
7414 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7415 grep -q "trusted" &&
7416 error "$testfile trusted xattrs are user visible"
7420 run_test 102l "listxattr size test =================================="
7422 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7423 local path=$DIR/$tfile
7426 listxattr_size_check $path || error "listattr_size_check $path failed"
7428 run_test 102m "Ensure listxattr fails on small bufffer ========"
7432 getxattr() { # getxattr path name
7433 # Return the base64 encoding of the value of xattr name on path.
7437 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7439 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7441 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7443 getfattr --absolute-names --encoding=base64 --name=$name $path |
7444 awk -F= -v name=$name '$1 == name {
7445 print substr($0, index($0, "=") + 1);
7449 test_102n() { # LU-4101 mdt: protect internal xattrs
7450 [ -z "$(which setfattr 2>/dev/null)" ] &&
7451 skip "could not find setfattr" && return
7452 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7454 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7458 local file0=$DIR/$tfile.0
7459 local file1=$DIR/$tfile.1
7460 local xattr0=$TMP/$tfile.0
7461 local xattr1=$TMP/$tfile.1
7462 local namelist="lov lma lmv link fid version som hsm"
7466 rm -rf $file0 $file1 $xattr0 $xattr1
7469 # Get 'before' xattrs of $file1.
7470 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7472 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7473 namelist+=" lfsck_namespace"
7474 for name in $namelist; do
7475 # Try to copy xattr from $file0 to $file1.
7476 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7478 setfattr --name=trusted.$name --value="$value" $file1 ||
7479 error "setxattr 'trusted.$name' failed"
7481 # Try to set a garbage xattr.
7482 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7484 if [[ x$name == "xlov" ]]; then
7485 setfattr --name=trusted.lov --value="$value" $file1 &&
7486 error "setxattr invalid 'trusted.lov' success"
7488 setfattr --name=trusted.$name --value="$value" $file1 ||
7489 error "setxattr invalid 'trusted.$name' failed"
7492 # Try to remove the xattr from $file1. We don't care if this
7493 # appears to succeed or fail, we just don't want there to be
7494 # any changes or crashes.
7495 setfattr --remove=$trusted.$name $file1 2> /dev/null
7498 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7501 # Try to copy xattr from $file0 to $file1.
7502 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7504 setfattr --name=trusted.$name --value="$value" $file1 ||
7505 error "setxattr 'trusted.$name' failed"
7507 # Try to set a garbage xattr.
7508 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7510 setfattr --name=trusted.$name --value="$value" $file1 ||
7511 error "setxattr 'trusted.$name' failed"
7513 # Try to remove the xattr from $file1. We don't care if this
7514 # appears to succeed or fail, we just don't want there to be
7515 # any changes or crashes.
7516 setfattr --remove=$trusted.$name $file1 2> /dev/null
7519 # Get 'after' xattrs of file1.
7520 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7522 if ! diff $xattr0 $xattr1; then
7523 error "before and after xattrs of '$file1' differ"
7526 rm -rf $file0 $file1 $xattr0 $xattr1
7530 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7532 test_102p() { # LU-4703 setxattr did not check ownership
7533 local testfile=$DIR/$tfile
7535 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7536 skip "MDS needs to be at least 2.5.56" && return
7540 echo "setfacl as user..."
7541 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7542 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7544 echo "setfattr as user..."
7545 setfacl -m "u:$RUNAS_ID:---" $testfile
7546 $RUNAS setfattr -x system.posix_acl_access $testfile
7547 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7549 run_test 102p "check setxattr(2) correctly fails without permission"
7552 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7553 skip "MDS needs to be at least 2.6.92" && return
7554 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7556 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7559 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7560 skip "MDS needs to be at least 2.6.93" && return
7561 touch $DIR/$tfile || error "touch"
7562 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7563 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7564 rm $DIR/$tfile || error "rm"
7567 mkdir -p $DIR/$tdir || error "mkdir"
7568 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7569 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7570 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7571 error "$testfile error deleting user.author1"
7572 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7573 grep "user.$(basename $tdir)" &&
7574 error "$tdir did not delete user.$(basename $tdir)"
7575 rmdir $DIR/$tdir || error "rmdir"
7578 test_mkdir $DIR/$tdir
7579 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7580 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7581 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7582 error "$testfile error deleting user.author1"
7583 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7584 grep "user.$(basename $tdir)" &&
7585 error "$tdir did not delete user.$(basename $tdir)"
7586 rmdir $DIR/$tdir || error "rm striped dir"
7588 run_test 102r "set EAs with empty values"
7592 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7597 [ "$UID" != 0 ] && skip_env "must run as root" && return
7598 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7599 skip "must have acl enabled" && return
7600 [ -z "$(which setfacl 2>/dev/null)" ] &&
7601 skip_env "could not find setfacl" && return
7602 $GSS && skip "could not run under gss" && return
7603 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7605 gpasswd -a daemon bin # LU-5641
7606 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7608 declare -a identity_old
7610 for num in $(seq $MDSCOUNT); do
7611 switch_identity $num true || identity_old[$num]=$?
7619 echo "performing cp ..."
7620 run_acl_subtest cp || error "run_acl_subtest cp failed"
7621 echo "performing getfacl-noacl..."
7622 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7623 echo "performing misc..."
7624 run_acl_subtest misc || error "misc test failed"
7625 echo "performing permissions..."
7626 run_acl_subtest permissions || error "permissions failed"
7627 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7628 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7629 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7630 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7632 echo "performing permissions xattr..."
7633 run_acl_subtest permissions_xattr ||
7634 error "permissions_xattr failed"
7636 echo "performing setfacl..."
7637 run_acl_subtest setfacl || error "setfacl test failed"
7639 # inheritance test got from HP
7640 echo "performing inheritance..."
7641 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7642 chmod +x make-tree || error "chmod +x failed"
7643 run_acl_subtest inheritance || error "inheritance test failed"
7646 echo "LU-974 ignore umask when acl is enabled..."
7647 run_acl_subtest 974 || error "LU-974 umask test failed"
7648 if [ $MDSCOUNT -ge 2 ]; then
7649 run_acl_subtest 974_remote ||
7650 error "LU-974 umask test failed under remote dir"
7653 echo "LU-2561 newly created file is same size as directory..."
7654 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7655 run_acl_subtest 2561 || error "LU-2561 test failed"
7657 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7660 run_acl_subtest 4924 || error "LU-4924 test failed"
7665 for num in $(seq $MDSCOUNT); do
7666 if [ "${identity_old[$num]}" = 1 ]; then
7667 switch_identity $num false || identity_old[$num]=$?
7671 run_test 103a "acl test ========================================="
7675 cp -rp $DIR/$tdir $DIR/$tdir.bak
7677 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7678 error "$DIR/$tdir shouldn't contain default ACL"
7679 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7680 error "$DIR/$tdir.bak shouldn't contain default ACL"
7683 run_test 103c "'cp -rp' won't set empty acl"
7686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7688 lfs df || error "lfs df failed"
7689 lfs df -ih || error "lfs df -ih failed"
7690 lfs df -h $DIR || error "lfs df -h $DIR failed"
7691 lfs df -i $DIR || error "lfs df -i $DIR failed"
7692 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7693 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7695 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7696 lctl --device %$OSC deactivate
7697 lfs df || error "lfs df with deactivated OSC failed"
7698 lctl --device %$OSC activate
7699 # wait the osc back to normal
7700 wait_osc_import_state client ost FULL
7702 lfs df || error "lfs df with reactivated OSC failed"
7705 run_test 104a "lfs df [-ih] [path] test ========================="
7708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7709 [ $RUNAS_ID -eq $UID ] &&
7710 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7712 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7713 grep "Permission denied" | wc -l)))
7714 if [ $denied_cnt -ne 0 ]; then
7715 error "lfs check servers test failed"
7718 run_test 104b "$RUNAS lfs check servers test ===================="
7721 # doesn't work on 2.4 kernels
7723 if $(flock_is_enabled); then
7724 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7726 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7730 run_test 105a "flock when mounted without -o flock test ========"
7734 if $(flock_is_enabled); then
7735 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7737 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7741 run_test 105b "fcntl when mounted without -o flock test ========"
7745 if $(flock_is_enabled); then
7746 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7748 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7752 run_test 105c "lockf when mounted without -o flock test"
7754 test_105d() { # bug 15924
7755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7756 test_mkdir $DIR/$tdir
7757 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7758 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7759 $LCTL set_param fail_loc=0x80000315
7760 flocks_test 2 $DIR/$tdir
7762 run_test 105d "flock race (should not freeze) ========"
7764 test_105e() { # bug 22660 && 22040
7765 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7767 flocks_test 3 $DIR/$tfile
7769 run_test 105e "Two conflicting flocks from same process"
7771 test_106() { #bug 10921
7772 test_mkdir $DIR/$tdir
7773 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7774 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7776 run_test 106 "attempt exec of dir followed by chown of that dir"
7779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7786 local save_pattern=$(sysctl -n kernel.core_pattern)
7787 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7788 sysctl -w kernel.core_pattern=$file
7789 sysctl -w kernel.core_uses_pid=0
7797 kill -s 11 $SLEEPPID
7799 if [ -e $file ]; then
7800 size=`stat -c%s $file`
7801 [ $size -eq 0 ] && error "Fail to create core file $file"
7803 error "Fail to create core file $file"
7806 sysctl -w kernel.core_pattern=$save_pattern
7807 sysctl -w kernel.core_uses_pid=$save_uses_pid
7810 run_test 107 "Coredump on SIG"
7813 test_mkdir $DIR/$tdir
7814 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
7815 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
7816 error "mkdir with 256 char should fail, but did not"
7817 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7818 error "create with 255 char failed"
7819 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7820 error "create with 256 char should fail, but did not"
7825 run_test 110 "filename length checking"
7828 # Purpose: To verify dynamic thread (OSS) creation.
7831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7832 remote_ost_nodsh && skip "remote OST with nodsh" && return
7834 # Lustre does not stop service threads once they are started.
7835 # Reset number of running threads to default.
7840 local save_params="$TMP/sanity-$TESTNAME.parameters"
7842 # Get ll_ost_io count before I/O
7843 OSTIO_pre=$(do_facet ost1 \
7844 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
7845 # Exit if lustre is not running (ll_ost_io not running).
7846 [ -z "$OSTIO_pre" ] && error "no OSS threads"
7848 echo "Starting with $OSTIO_pre threads"
7849 local thread_max=$((OSTIO_pre * 2))
7850 local rpc_in_flight=$((thread_max * 2))
7851 # Number of I/O Process proposed to be started.
7853 local facets=$(get_facets OST)
7855 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
7856 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
7858 # Set in_flight to $rpc_in_flight
7859 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
7860 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
7861 nfiles=${rpc_in_flight}
7862 # Set ost thread_max to $thread_max
7863 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
7865 # 5 Minutes should be sufficient for max number of OSS
7866 # threads(thread_max) to be created.
7870 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
7871 test_mkdir $DIR/$tdir
7872 for i in $(seq $nfiles); do
7873 local file=$DIR/$tdir/${tfile}-$i
7874 $LFS setstripe -c -1 -i 0 $file
7875 ($WTL $file $timeout)&
7878 # I/O Started - Wait for thread_started to reach thread_max or report
7879 # error if thread_started is more than thread_max.
7880 echo "Waiting for thread_started to reach thread_max"
7881 local thread_started=0
7882 local end_time=$((SECONDS + timeout))
7884 while [ $SECONDS -le $end_time ] ; do
7886 # Get ost i/o thread_started count.
7887 thread_started=$(do_facet ost1 \
7889 ost.OSS.ost_io.threads_started | cut -d= -f2")
7890 # Break out if thread_started is equal/greater than thread_max
7891 if [[ $thread_started -ge $thread_max ]]; then
7892 echo ll_ost_io thread_started $thread_started, \
7893 equal/greater than thread_max $thread_max
7899 # Cleanup - We have the numbers, Kill i/o jobs if running.
7900 jobcount=($(jobs -p))
7901 for i in $(seq 0 $((${#jobcount[@]}-1)))
7903 kill -9 ${jobcount[$i]}
7904 if [ $? -ne 0 ] ; then
7906 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
7910 # Cleanup files left by WTL binary.
7911 for i in $(seq $nfiles); do
7912 local file=$DIR/$tdir/${tfile}-$i
7914 if [ $? -ne 0 ] ; then
7915 echo "Warning: Failed to delete file $file"
7919 restore_lustre_params <$save_params
7920 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
7922 # Error out if no new thread has started or Thread started is greater
7924 if [[ $thread_started -le $OSTIO_pre ||
7925 $thread_started -gt $thread_max ]]; then
7926 error "ll_ost_io: thread_started $thread_started" \
7927 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
7928 "No new thread started or thread started greater " \
7932 run_test 115 "verify dynamic thread creation===================="
7935 wait_delete_completed
7936 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7937 echo "OST kbytes available: ${AVAIL[@]}"
7942 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7943 #echo OST $i: ${AVAIL[i]}kb
7944 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7948 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7953 echo "Min free space: OST $MINI: $MINV"
7954 echo "Max free space: OST $MAXI: $MAXV"
7957 test_116a() { # was previously test_116()
7958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7959 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7961 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7963 echo -n "Free space priority "
7964 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7969 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7970 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7972 trap simple_cleanup_common EXIT
7975 # Check if we need to generate uneven OSTs
7976 test_mkdir -p $DIR/$tdir/OST${MINI}
7977 local FILL=$((MINV / 4))
7978 local DIFF=$((MAXV - MINV))
7979 local DIFF2=$((DIFF * 100 / MINV))
7981 local threshold=$(do_facet $SINGLEMDS \
7982 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7983 threshold=${threshold%%%}
7984 echo -n "Check for uneven OSTs: "
7985 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7987 if [[ $DIFF2 -gt $threshold ]]; then
7989 echo "Don't need to fill OST$MINI"
7991 # generate uneven OSTs. Write 2% over the QOS threshold value
7993 DIFF=$((threshold - DIFF2 + 2))
7994 DIFF2=$((MINV * DIFF / 100))
7995 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
7996 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7997 error "setstripe failed"
7998 DIFF=$((DIFF2 / 2048))
8000 while [ $i -lt $DIFF ]; do
8002 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8003 bs=2M count=1 2>/dev/null
8012 DIFF=$((MAXV - MINV))
8013 DIFF2=$((DIFF * 100 / MINV))
8014 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8015 if [ $DIFF2 -gt $threshold ]; then
8018 echo "failed - QOS mode won't be used"
8019 skip "QOS imbalance criteria not met"
8020 simple_cleanup_common
8029 # now fill using QOS
8030 $SETSTRIPE -c 1 $DIR/$tdir
8031 FILL=$((FILL / 200))
8032 if [ $FILL -gt 600 ]; then
8035 echo "writing $FILL files to QOS-assigned OSTs"
8037 while [ $i -lt $FILL ]; do
8039 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8043 echo "wrote $i 200k files"
8047 echo "Note: free space may not be updated, so measurements might be off"
8049 DIFF2=$((MAXV - MINV))
8050 echo "free space delta: orig $DIFF final $DIFF2"
8051 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8052 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8053 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8054 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8055 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8056 if [[ $DIFF -gt 0 ]]; then
8057 FILL=$((DIFF2 * 100 / DIFF - 100))
8058 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8061 # Figure out which files were written where
8062 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8063 awk '/'$MINI1': / {print $2; exit}')
8065 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8066 echo "$MINC files created on smaller OST $MINI1"
8067 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8068 awk '/'$MAXI1': / {print $2; exit}')
8070 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8071 echo "$MAXC files created on larger OST $MAXI1"
8072 if [[ $MINC -gt 0 ]]; then
8073 FILL=$((MAXC * 100 / MINC - 100))
8074 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8076 [[ $MAXC -gt $MINC ]] ||
8077 error_ignore LU-9 "stripe QOS didn't balance free space"
8078 simple_cleanup_common
8080 run_test 116a "stripe QOS: free space balance ==================="
8082 test_116b() { # LU-2093
8083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8084 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8086 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8087 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8088 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8089 [ -z "$old_rr" ] && skip "no QOS" && return 0
8090 do_facet $SINGLEMDS lctl set_param \
8091 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8093 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8094 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8095 do_facet $SINGLEMDS lctl set_param fail_loc=0
8097 do_facet $SINGLEMDS lctl set_param \
8098 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8100 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8102 test_117() # bug 10891
8104 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8105 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8106 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8107 lctl set_param fail_loc=0x21e
8108 > $DIR/$tfile || error "truncate failed"
8109 lctl set_param fail_loc=0
8110 echo "Truncate succeeded."
8113 run_test 117 "verify osd extend =========="
8115 NO_SLOW_RESENDCOUNT=4
8116 export OLD_RESENDCOUNT=""
8117 set_resend_count () {
8118 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8119 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8120 lctl set_param -n $PROC_RESENDCOUNT $1
8121 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8124 # for reduce test_118* time (b=14842)
8125 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8127 # Reset async IO behavior after error case
8129 FILE=$DIR/reset_async
8131 # Ensure all OSCs are cleared
8132 $SETSTRIPE -c -1 $FILE
8133 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8138 test_118a() #bug 11710
8140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8143 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8144 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8145 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8147 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8148 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8153 run_test 118a "verify O_SYNC works =========="
8157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8158 remote_ost_nodsh && skip "remote OST with nodsh" && return
8162 #define OBD_FAIL_SRV_ENOENT 0x217
8163 set_nodes_failloc "$(osts_nodes)" 0x217
8164 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8166 set_nodes_failloc "$(osts_nodes)" 0
8167 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8168 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8171 if [[ $RC -eq 0 ]]; then
8172 error "Must return error due to dropped pages, rc=$RC"
8176 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8177 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8181 echo "Dirty pages not leaked on ENOENT"
8183 # Due to the above error the OSC will issue all RPCs syncronously
8184 # until a subsequent RPC completes successfully without error.
8185 $MULTIOP $DIR/$tfile Ow4096yc
8190 run_test 118b "Reclaim dirty pages on fatal error =========="
8194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8196 # for 118c, restore the original resend count, LU-1940
8197 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8198 set_resend_count $OLD_RESENDCOUNT
8199 remote_ost_nodsh && skip "remote OST with nodsh" && return
8203 #define OBD_FAIL_OST_EROFS 0x216
8204 set_nodes_failloc "$(osts_nodes)" 0x216
8206 # multiop should block due to fsync until pages are written
8207 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8211 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8212 error "Multiop failed to block on fsync, pid=$MULTIPID"
8215 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8217 if [[ $WRITEBACK -eq 0 ]]; then
8218 error "No page in writeback, writeback=$WRITEBACK"
8221 set_nodes_failloc "$(osts_nodes)" 0
8224 if [[ $RC -ne 0 ]]; then
8225 error "Multiop fsync failed, rc=$RC"
8228 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8229 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8231 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8232 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8236 echo "Dirty pages flushed via fsync on EROFS"
8239 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8241 # continue to use small resend count to reduce test_118* time (b=14842)
8242 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8247 remote_ost_nodsh && skip "remote OST with nodsh" && return
8251 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8252 set_nodes_failloc "$(osts_nodes)" 0x214
8253 # multiop should block due to fsync until pages are written
8254 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8258 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8259 error "Multiop failed to block on fsync, pid=$MULTIPID"
8262 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8264 if [[ $WRITEBACK -eq 0 ]]; then
8265 error "No page in writeback, writeback=$WRITEBACK"
8268 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8269 set_nodes_failloc "$(osts_nodes)" 0
8271 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8272 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8274 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8275 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8279 echo "Dirty pages gaurenteed flushed via fsync"
8282 run_test 118d "Fsync validation inject a delay of the bulk =========="
8285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8288 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8289 lctl set_param fail_loc=0x8000040a
8291 # Should simulate EINVAL error which is fatal
8292 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8294 if [[ $RC -eq 0 ]]; then
8295 error "Must return error due to dropped pages, rc=$RC"
8298 lctl set_param fail_loc=0x0
8300 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8301 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8302 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8304 if [[ $LOCKED -ne 0 ]]; then
8305 error "Locked pages remain in cache, locked=$LOCKED"
8308 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8309 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8313 echo "No pages locked after fsync"
8318 run_test 118f "Simulate unrecoverable OSC side error =========="
8321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8324 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8325 lctl set_param fail_loc=0x406
8327 # simulate local -ENOMEM
8328 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8331 lctl set_param fail_loc=0
8332 if [[ $RC -eq 0 ]]; then
8333 error "Must return error due to dropped pages, rc=$RC"
8336 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8337 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8338 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8340 if [[ $LOCKED -ne 0 ]]; then
8341 error "Locked pages remain in cache, locked=$LOCKED"
8344 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8345 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8349 echo "No pages locked after fsync"
8354 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8358 remote_ost_nodsh && skip "remote OST with nodsh" && return
8362 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8363 set_nodes_failloc "$(osts_nodes)" 0x20e
8364 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8365 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8368 set_nodes_failloc "$(osts_nodes)" 0
8369 if [[ $RC -eq 0 ]]; then
8370 error "Must return error due to dropped pages, rc=$RC"
8373 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8374 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8375 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8377 if [[ $LOCKED -ne 0 ]]; then
8378 error "Locked pages remain in cache, locked=$LOCKED"
8381 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8382 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8386 echo "No pages locked after fsync"
8390 run_test 118h "Verify timeout in handling recoverables errors =========="
8392 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8396 remote_ost_nodsh && skip "remote OST with nodsh" && return
8400 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8401 set_nodes_failloc "$(osts_nodes)" 0x20e
8403 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8404 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8407 set_nodes_failloc "$(osts_nodes)" 0
8411 if [[ $RC -ne 0 ]]; then
8412 error "got error, but should be not, rc=$RC"
8415 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8416 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8417 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8418 if [[ $LOCKED -ne 0 ]]; then
8419 error "Locked pages remain in cache, locked=$LOCKED"
8422 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8423 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8427 echo "No pages locked after fsync"
8431 run_test 118i "Fix error before timeout in recoverable error =========="
8433 [ "$SLOW" = "no" ] && set_resend_count 4
8436 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8437 remote_ost_nodsh && skip "remote OST with nodsh" && return
8441 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8442 set_nodes_failloc "$(osts_nodes)" 0x220
8444 # return -EIO from OST
8445 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8447 set_nodes_failloc "$(osts_nodes)" 0x0
8448 if [[ $RC -eq 0 ]]; then
8449 error "Must return error due to dropped pages, rc=$RC"
8452 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8453 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8454 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8455 if [[ $LOCKED -ne 0 ]]; then
8456 error "Locked pages remain in cache, locked=$LOCKED"
8459 # in recoverable error on OST we want resend and stay until it finished
8460 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8461 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8465 echo "No pages locked after fsync"
8469 run_test 118j "Simulate unrecoverable OST side error =========="
8473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8474 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8476 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8477 set_nodes_failloc "$(osts_nodes)" 0x20e
8478 test_mkdir $DIR/$tdir
8480 for ((i=0;i<10;i++)); do
8481 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8482 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8489 set_nodes_failloc "$(osts_nodes)" 0
8492 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8498 test_mkdir $DIR/$tdir
8499 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8502 run_test 118l "fsync dir"
8504 test_118m() # LU-3066
8506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8507 test_mkdir $DIR/$tdir
8508 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8511 run_test 118m "fdatasync dir ========="
8513 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8521 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8523 # Sleep to avoid a cached response.
8524 #define OBD_STATFS_CACHE_SECONDS 1
8527 # Inject a 10 second delay in the OST_STATFS handler.
8528 #define OBD_FAIL_OST_STATFS_DELAY 0x242
8529 set_nodes_failloc "$(osts_nodes)" 0x242
8532 stat --file-system $MOUNT > /dev/null
8535 set_nodes_failloc "$(osts_nodes)" 0
8537 if ((end - begin > 20)); then
8538 error "statfs took $((end - begin)) seconds, expected 10"
8541 run_test 118n "statfs() sends OST_STATFS requests in parallel"
8543 test_119a() # bug 11737
8545 BSIZE=$((512 * 1024))
8546 directio write $DIR/$tfile 0 1 $BSIZE
8547 # We ask to read two blocks, which is more than a file size.
8548 # directio will indicate an error when requested and actual
8549 # sizes aren't equeal (a normal situation in this case) and
8550 # print actual read amount.
8551 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8552 if [ "$NOB" != "$BSIZE" ]; then
8553 error "read $NOB bytes instead of $BSIZE"
8557 run_test 119a "Short directIO read must return actual read amount"
8559 test_119b() # bug 11737
8561 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8563 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8564 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8566 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8567 error "direct read failed"
8570 run_test 119b "Sparse directIO read must return actual read amount"
8572 test_119c() # bug 13099
8575 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8576 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8579 run_test 119c "Testing for direct read hitting hole"
8581 test_119d() # bug 15950
8583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8584 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8585 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8587 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8588 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8589 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8590 lctl set_param fail_loc=0x40d
8591 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8594 cat $DIR/$tfile > /dev/null &
8595 lctl set_param fail_loc=0
8598 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8600 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8601 error "the read rpcs have not completed in 2s"
8603 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8605 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8609 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8610 test_mkdir $DIR/$tdir
8611 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8612 { skip "no early lock cancel on server"; return 0; }
8614 lru_resize_disable mdc
8615 lru_resize_disable osc
8616 cancel_lru_locks mdc
8617 # asynchronous object destroy at MDT could cause bl ast to client
8618 cancel_lru_locks osc
8620 stat $DIR/$tdir > /dev/null
8621 can1=$(do_facet $SINGLEMDS \
8622 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8623 awk '/ldlm_cancel/ {print $2}')
8624 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8625 awk '/ldlm_bl_callback/ {print $2}')
8626 test_mkdir -c1 $DIR/$tdir/d1
8627 can2=$(do_facet $SINGLEMDS \
8628 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8629 awk '/ldlm_cancel/ {print $2}')
8630 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8631 awk '/ldlm_bl_callback/ {print $2}')
8632 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8633 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8634 lru_resize_enable mdc
8635 lru_resize_enable osc
8637 run_test 120a "Early Lock Cancel: mkdir test"
8640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8641 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8642 test_mkdir $DIR/$tdir
8643 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8644 { skip "no early lock cancel on server"; return 0; }
8645 lru_resize_disable mdc
8646 lru_resize_disable osc
8647 cancel_lru_locks mdc
8648 stat $DIR/$tdir > /dev/null
8649 can1=$(do_facet $SINGLEMDS \
8650 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8651 awk '/ldlm_cancel/ {print $2}')
8652 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8653 awk '/ldlm_bl_callback/ {print $2}')
8655 can2=$(do_facet $SINGLEMDS \
8656 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8657 awk '/ldlm_cancel/ {print $2}')
8658 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8659 awk '/ldlm_bl_callback/ {print $2}')
8660 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8661 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8662 lru_resize_enable mdc
8663 lru_resize_enable osc
8665 run_test 120b "Early Lock Cancel: create test"
8668 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8669 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8670 test_mkdir -c1 $DIR/$tdir
8671 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8672 { skip "no early lock cancel on server"; return 0; }
8673 lru_resize_disable mdc
8674 lru_resize_disable osc
8675 test_mkdir -c1 $DIR/$tdir/d1
8676 test_mkdir -c1 $DIR/$tdir/d2
8677 touch $DIR/$tdir/d1/f1
8678 cancel_lru_locks mdc
8679 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8680 can1=$(do_facet $SINGLEMDS \
8681 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8682 awk '/ldlm_cancel/ {print $2}')
8683 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8684 awk '/ldlm_bl_callback/ {print $2}')
8685 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8686 can2=$(do_facet $SINGLEMDS \
8687 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8688 awk '/ldlm_cancel/ {print $2}')
8689 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8690 awk '/ldlm_bl_callback/ {print $2}')
8691 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8692 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8693 lru_resize_enable mdc
8694 lru_resize_enable osc
8696 run_test 120c "Early Lock Cancel: link test"
8699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8700 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8701 test_mkdir -c1 $DIR/$tdir
8702 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8703 { skip "no early lock cancel on server"; return 0; }
8704 lru_resize_disable mdc
8705 lru_resize_disable osc
8707 cancel_lru_locks mdc
8708 stat $DIR/$tdir > /dev/null
8709 can1=$(do_facet $SINGLEMDS \
8710 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8711 awk '/ldlm_cancel/ {print $2}')
8712 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8713 awk '/ldlm_bl_callback/ {print $2}')
8714 chmod a+x $DIR/$tdir
8715 can2=$(do_facet $SINGLEMDS \
8716 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8717 awk '/ldlm_cancel/ {print $2}')
8718 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8719 awk '/ldlm_bl_callback/ {print $2}')
8720 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8721 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8722 lru_resize_enable mdc
8723 lru_resize_enable osc
8725 run_test 120d "Early Lock Cancel: setattr test"
8728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8729 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8730 { skip "no early lock cancel on server"; return 0; }
8731 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8732 local dlmtrace_set=false
8734 test_mkdir -c1 $DIR/$tdir
8735 lru_resize_disable mdc
8736 lru_resize_disable osc
8737 ! $LCTL get_param debug | grep -q dlmtrace &&
8738 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8739 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8740 cancel_lru_locks mdc
8741 cancel_lru_locks osc
8742 dd if=$DIR/$tdir/f1 of=/dev/null
8743 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8744 # XXX client can not do early lock cancel of OST lock
8745 # during unlink (LU-4206), so cancel osc lock now.
8747 cancel_lru_locks osc
8748 can1=$(do_facet $SINGLEMDS \
8749 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8750 awk '/ldlm_cancel/ {print $2}')
8751 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8752 awk '/ldlm_bl_callback/ {print $2}')
8753 unlink $DIR/$tdir/f1
8755 can2=$(do_facet $SINGLEMDS \
8756 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8757 awk '/ldlm_cancel/ {print $2}')
8758 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8759 awk '/ldlm_bl_callback/ {print $2}')
8760 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8761 $LCTL dk $TMP/cancel.debug.txt
8762 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8763 $LCTL dk $TMP/blocking.debug.txt
8764 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8765 lru_resize_enable mdc
8766 lru_resize_enable osc
8768 run_test 120e "Early Lock Cancel: unlink test"
8771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8772 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8773 { skip "no early lock cancel on server"; return 0; }
8774 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8775 test_mkdir -c1 $DIR/$tdir
8776 lru_resize_disable mdc
8777 lru_resize_disable osc
8778 test_mkdir -c1 $DIR/$tdir/d1
8779 test_mkdir -c1 $DIR/$tdir/d2
8780 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8781 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8782 cancel_lru_locks mdc
8783 cancel_lru_locks osc
8784 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8785 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8786 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8787 # XXX client can not do early lock cancel of OST lock
8788 # during rename (LU-4206), so cancel osc lock now.
8790 cancel_lru_locks osc
8791 can1=$(do_facet $SINGLEMDS \
8792 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8793 awk '/ldlm_cancel/ {print $2}')
8794 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8795 awk '/ldlm_bl_callback/ {print $2}')
8796 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8798 can2=$(do_facet $SINGLEMDS \
8799 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8800 awk '/ldlm_cancel/ {print $2}')
8801 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8802 awk '/ldlm_bl_callback/ {print $2}')
8803 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8804 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8805 lru_resize_enable mdc
8806 lru_resize_enable osc
8808 run_test 120f "Early Lock Cancel: rename test"
8811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8812 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8813 { skip "no early lock cancel on server"; return 0; }
8814 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8815 lru_resize_disable mdc
8816 lru_resize_disable osc
8818 echo create $count files
8819 test_mkdir $DIR/$tdir
8820 cancel_lru_locks mdc
8821 cancel_lru_locks osc
8824 can0=$(do_facet $SINGLEMDS \
8825 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8826 awk '/ldlm_cancel/ {print $2}')
8827 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8828 awk '/ldlm_bl_callback/ {print $2}')
8829 createmany -o $DIR/$tdir/f $count
8831 can1=$(do_facet $SINGLEMDS \
8832 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8833 awk '/ldlm_cancel/ {print $2}')
8834 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8835 awk '/ldlm_bl_callback/ {print $2}')
8837 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8838 echo rm $count files
8841 can2=$(do_facet $SINGLEMDS \
8842 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8843 awk '/ldlm_cancel/ {print $2}')
8844 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8845 awk '/ldlm_bl_callback/ {print $2}')
8847 echo total: $count removes in $((t2-t1))
8848 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8850 # wait for commitment of removal
8851 lru_resize_enable mdc
8852 lru_resize_enable osc
8854 run_test 120g "Early Lock Cancel: performance test"
8856 test_121() { #bug #10589
8857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8859 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8860 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8861 lctl set_param fail_loc=0x310
8862 cancel_lru_locks osc > /dev/null
8863 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8864 lctl set_param fail_loc=0
8865 [[ $reads -eq $writes ]] ||
8866 error "read $reads blocks, must be $writes blocks"
8868 run_test 121 "read cancel race ========="
8870 test_123a() { # was test 123, statahead(bug 11401)
8871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8873 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
8874 log "testing UP system. Performance may be lower than expected."
8879 test_mkdir $DIR/$tdir
8880 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8881 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8883 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8884 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8886 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8887 lctl set_param -n llite.*.statahead_max 0
8888 lctl get_param llite.*.statahead_max
8889 cancel_lru_locks mdc
8890 cancel_lru_locks osc
8892 time ls -l $DIR/$tdir | wc -l
8894 delta=$((etime - stime))
8895 log "ls $i files without statahead: $delta sec"
8896 lctl set_param llite.*.statahead_max=$max
8898 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8899 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8900 cancel_lru_locks mdc
8901 cancel_lru_locks osc
8903 time ls -l $DIR/$tdir | wc -l
8905 delta_sa=$((etime - stime))
8906 log "ls $i files with statahead: $delta_sa sec"
8907 lctl get_param -n llite.*.statahead_stats
8908 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8910 [[ $swrong -lt $ewrong ]] &&
8911 log "statahead was stopped, maybe too many locks held!"
8912 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8914 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8915 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8916 lctl set_param -n llite.*.statahead_max 0
8917 lctl get_param llite.*.statahead_max
8918 cancel_lru_locks mdc
8919 cancel_lru_locks osc
8921 time ls -l $DIR/$tdir | wc -l
8923 delta=$((etime - stime))
8924 log "ls $i files again without statahead: $delta sec"
8925 lctl set_param llite.*.statahead_max=$max
8926 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8927 if [ $SLOWOK -eq 0 ]; then
8928 error "ls $i files is slower with statahead!"
8930 log "ls $i files is slower with statahead!"
8936 [ $delta -gt 20 ] && break
8937 [ $delta -gt 8 ] && MULT=$((50 / delta))
8938 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8946 delta=$((etime - stime))
8947 log "rm -r $DIR/$tdir/: $delta seconds"
8949 lctl get_param -n llite.*.statahead_stats
8951 run_test 123a "verify statahead work"
8953 test_123b () { # statahead(bug 15027)
8954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8955 test_mkdir $DIR/$tdir
8956 createmany -o $DIR/$tdir/$tfile-%d 1000
8958 cancel_lru_locks mdc
8959 cancel_lru_locks osc
8961 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8962 lctl set_param fail_loc=0x80000803
8963 ls -lR $DIR/$tdir > /dev/null
8965 lctl set_param fail_loc=0x0
8966 lctl get_param -n llite.*.statahead_stats
8971 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8975 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
8976 { skip "no lru resize on server"; return 0; }
8978 test_mkdir $DIR/$tdir
8980 log "create $NR files at $DIR/$tdir"
8981 createmany -o $DIR/$tdir/f $NR ||
8982 error "failed to create $NR files in $DIR/$tdir"
8984 cancel_lru_locks mdc
8985 ls -l $DIR/$tdir > /dev/null
8989 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8990 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8991 LRU_SIZE=$($LCTL get_param -n $PARAM)
8992 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8993 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8995 log "NS=$(basename $NSDIR)"
9000 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9001 skip "Not enough cached locks created!"
9008 # We know that lru resize allows one client to hold $LIMIT locks
9009 # for 10h. After that locks begin to be killed by client.
9011 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9013 if [ $LIMIT -lt $LRU_SIZE ]; then
9014 skip "Limit is too small $LIMIT"
9018 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9019 # killing locks. Some time was spent for creating locks. This means
9020 # that up to the moment of sleep finish we must have killed some of
9021 # them (10-100 locks). This depends on how fast ther were created.
9022 # Many of them were touched in almost the same moment and thus will
9023 # be killed in groups.
9024 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9026 # Use $LRU_SIZE_B here to take into account real number of locks
9027 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9028 local LRU_SIZE_B=$LRU_SIZE
9030 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9031 log "OLD_LVF=$OLD_LVF"
9032 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9034 # Let's make sure that we really have some margin. Client checks
9035 # cached locks every 10 sec.
9037 log "Sleep ${SLEEP} sec"
9039 while ((SEC<$SLEEP)); do
9043 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9047 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9048 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9050 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9051 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9052 unlinkmany $DIR/$tdir/f $NR
9056 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9057 log "unlink $NR files at $DIR/$tdir"
9058 unlinkmany $DIR/$tdir/f $NR
9060 run_test 124a "lru resize ======================================="
9062 get_max_pool_limit()
9064 local limit=$($LCTL get_param \
9065 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9068 if [[ $l -gt $max ]]; then
9076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9077 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9078 { skip "no lru resize on server"; return 0; }
9080 LIMIT=$(get_max_pool_limit)
9082 NR=$(($(default_lru_size)*20))
9083 if [[ $NR -gt $LIMIT ]]; then
9084 log "Limit lock number by $LIMIT locks"
9088 IFree=$(mdsrate_inodes_available)
9089 if [ $IFree -lt $NR ]; then
9090 log "Limit lock number by $IFree inodes"
9094 lru_resize_disable mdc
9095 test_mkdir -p $DIR/$tdir/disable_lru_resize
9097 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9098 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9099 cancel_lru_locks mdc
9102 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9105 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9108 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9112 nolruresize_delta=$((etime-stime))
9113 log "ls -la time: $nolruresize_delta seconds"
9114 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9115 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9117 lru_resize_enable mdc
9118 test_mkdir -p $DIR/$tdir/enable_lru_resize
9120 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9121 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9122 cancel_lru_locks mdc
9125 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9128 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9131 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9135 lruresize_delta=$((etime-stime))
9136 log "ls -la time: $lruresize_delta seconds"
9137 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9139 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9140 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9141 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9142 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9144 log "lru resize performs the same with no lru resize"
9146 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9148 run_test 124b "lru resize (performance test) ======================="
9151 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9152 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9153 { skip "no lru resize on server"; return 0; }
9155 # cache ununsed locks on client
9157 cancel_lru_locks mdc
9158 test_mkdir $DIR/$tdir
9159 createmany -o $DIR/$tdir/f $nr ||
9160 error "failed to create $nr files in $DIR/$tdir"
9161 ls -l $DIR/$tdir > /dev/null
9163 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9164 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9165 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9166 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9167 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9169 # set lru_max_age to 1 sec
9170 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9171 echo "sleep $((recalc_p * 2)) seconds..."
9172 sleep $((recalc_p * 2))
9174 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9175 # restore lru_max_age
9176 $LCTL set_param -n $nsdir.lru_max_age $max_age
9177 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9178 unlinkmany $DIR/$tdir/f $nr
9180 run_test 124c "LRUR cancel very aged locks"
9182 test_125() { # 13358
9183 $LCTL get_param -n llite.*.client_type | grep -q local ||
9184 { skip "must run as local client"; return; }
9185 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
9186 { skip "must have acl enabled"; return; }
9187 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9188 test_mkdir $DIR/$tdir
9189 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
9190 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
9191 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
9193 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9195 test_126() { # bug 12829/13455
9196 $LCTL get_param -n llite.*.client_type | grep -q local ||
9197 { skip "must run as local client"; return; }
9198 [ "$UID" != 0 ] && skip_env "$TESTNAME (must run as root)" && return
9199 $GSS && skip "must run as gss disabled" && return
9201 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9202 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9204 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9206 run_test 126 "check that the fsgid provided by the client is taken into account"
9208 test_127a() { # bug 15521
9209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9210 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9211 $LCTL set_param osc.*.stats=0
9212 FSIZE=$((2048 * 1024))
9213 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9214 cancel_lru_locks osc
9215 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9217 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9218 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9219 echo "got $COUNT $NAME"
9220 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9221 eval $NAME=$COUNT || error "Wrong proc format"
9224 read_bytes|write_bytes)
9225 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9226 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9227 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9228 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9229 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9230 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9231 error "sumsquare is too small: $SUMSQ"
9232 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9233 error "sumsquare is too big: $SUMSQ"
9237 done < $DIR/${tfile}.tmp
9239 #check that we actually got some stats
9240 [ "$read_bytes" ] || error "Missing read_bytes stats"
9241 [ "$write_bytes" ] || error "Missing write_bytes stats"
9242 [ "$read_bytes" != 0 ] || error "no read done"
9243 [ "$write_bytes" != 0 ] || error "no write done"
9245 run_test 127a "verify the client stats are sane"
9247 test_127b() { # bug LU-333
9248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9249 $LCTL set_param llite.*.stats=0
9250 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9251 # perform 2 reads and writes so MAX is different from SUM.
9252 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9253 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9254 cancel_lru_locks osc
9255 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9256 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9258 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9259 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9260 echo "got $COUNT $NAME"
9261 eval $NAME=$COUNT || error "Wrong proc format"
9265 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9266 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9267 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9268 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9271 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9272 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9273 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9274 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9278 done < $TMP/${tfile}.tmp
9280 #check that we actually got some stats
9281 [ "$read_bytes" ] || error "Missing read_bytes stats"
9282 [ "$write_bytes" ] || error "Missing write_bytes stats"
9283 [ "$read_bytes" != 0 ] || error "no read done"
9284 [ "$write_bytes" != 0 ] || error "no write done"
9286 rm -f $TMP/${tfile}.tmp
9288 run_test 127b "verify the llite client stats are sane"
9290 test_128() { # bug 15212
9292 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9297 result=$(grep error $TMP/$tfile.log)
9298 rm -f $DIR/$tfile $TMP/$tfile.log
9300 error "consecutive find's under interactive lfs failed"
9302 run_test 128 "interactive lfs for 2 consecutive find's"
9309 local ldproc=/proc/fs/ldiskfs
9310 local facets=$(get_facets MDS)
9312 for facet in ${facets//,/ }; do
9313 canondev=$(ldiskfs_canon \
9314 *.$(convert_facet2label $facet).mntdev $facet)
9315 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9316 ldproc=/sys/fs/ldiskfs
9317 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9318 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9323 local facets=$(get_facets MDS)
9324 for facet in ${facets//,/ }; do
9325 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9331 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9332 { skip "Need MDS version with at least 2.5.56"; return 0; }
9334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9335 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9336 skip "ldiskfs only test"
9339 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9342 local has_warning=false
9347 # block size of mds1
9348 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9349 set_dir_limits $maxsize $maxsize
9350 local dirsize=$(stat -c%s "$DIR/$tdir")
9352 while [[ $dirsize -le $maxsize ]]; do
9353 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9355 if ! $has_warning; then
9356 check_mds_dmesg '"is approaching"' && has_warning=true
9359 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9360 # EFBIG for previous versions included in ldiskfs series
9361 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9363 echo "return code $rc received as expected"
9365 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9366 error_exit "create failed w/o dir size limit"
9368 check_mds_dmesg '"has reached"' ||
9369 error_exit "reached message should be output"
9371 [ $has_warning = "false" ] &&
9372 error_exit "warning message should be output"
9374 dirsize=$(stat -c%s "$DIR/$tdir")
9376 [[ $dirsize -ge $maxsize ]] && return 0
9377 error_exit "current dir size $dirsize, " \
9378 "previous limit $maxsize"
9379 elif [ $rc -ne 0 ]; then
9381 error_exit "return $rc received instead of expected " \
9382 "$EFBIG or $ENOSPC, files in dir $dirsize"
9384 nfiles=$((nfiles + 1))
9385 dirsize=$(stat -c%s "$DIR/$tdir")
9389 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9391 run_test 129 "test directory size limit ========================"
9400 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9401 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9404 trap cleanup_130 EXIT RETURN
9406 local fm_file=$DIR/$tfile
9407 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9408 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9409 error "dd failed for $fm_file"
9411 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9412 filefrag -ves $fm_file
9414 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9415 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9416 [ $RC != 0 ] && error "filefrag $fm_file failed"
9418 filefrag_op=$(filefrag -ve $fm_file |
9419 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9420 lun=$($GETSTRIPE -i $fm_file)
9422 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9425 for line in $filefrag_op
9427 frag_lun=`echo $line | cut -d: -f5`
9428 ext_len=`echo $line | cut -d: -f4`
9429 if (( $frag_lun != $lun )); then
9431 error "FIEMAP on 1-stripe file($fm_file) failed"
9434 (( tot_len += ext_len ))
9437 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9439 error "FIEMAP on 1-stripe file($fm_file) failed;"
9445 echo "FIEMAP on single striped file succeeded"
9447 run_test 130a "FIEMAP (1-stripe file)"
9450 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9452 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9453 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9456 trap cleanup_130 EXIT RETURN
9458 local fm_file=$DIR/$tfile
9459 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9460 error "setstripe on $fm_file"
9461 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9462 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9464 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9465 error "dd failed on $fm_file"
9467 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9468 filefrag_op=$(filefrag -ve $fm_file |
9469 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9471 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9472 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9477 for line in $filefrag_op
9479 frag_lun=$(echo $line | cut -d: -f5 |
9480 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9481 ext_len=$(echo $line | cut -d: -f4)
9482 if (( $frag_lun != $last_lun )); then
9483 if (( tot_len != 1024 )); then
9485 error "FIEMAP on $fm_file failed; returned " \
9486 "len $tot_len for OST $last_lun instead of 1024"
9493 (( tot_len += ext_len ))
9496 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9498 error "FIEMAP on $fm_file failed; returned wrong number of " \
9499 "luns or wrong len for OST $last_lun"
9505 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9507 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9510 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9512 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9513 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9516 trap cleanup_130 EXIT RETURN
9518 local fm_file=$DIR/$tfile
9519 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9520 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9521 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9523 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9524 error "dd failed on $fm_file"
9526 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9527 filefrag_op=$(filefrag -ve $fm_file |
9528 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9530 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9531 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9536 for line in $filefrag_op
9538 frag_lun=$(echo $line | cut -d: -f5 |
9539 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9540 ext_len=$(echo $line | cut -d: -f4)
9541 if (( $frag_lun != $last_lun )); then
9542 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9543 if (( logical != 512 )); then
9545 error "FIEMAP on $fm_file failed; returned " \
9546 "logical start for lun $logical instead of 512"
9549 if (( tot_len != 512 )); then
9551 error "FIEMAP on $fm_file failed; returned " \
9552 "len $tot_len for OST $last_lun instead of 1024"
9559 (( tot_len += ext_len ))
9562 if (( num_luns != 2 || tot_len != 512 )); then
9564 error "FIEMAP on $fm_file failed; returned wrong number of " \
9565 "luns or wrong len for OST $last_lun"
9571 echo "FIEMAP on 2-stripe file with hole succeeded"
9573 run_test 130c "FIEMAP (2-stripe file with hole)"
9576 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9578 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9579 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9582 trap cleanup_130 EXIT RETURN
9584 local fm_file=$DIR/$tfile
9585 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9586 error "setstripe on $fm_file"
9587 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9588 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9590 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
9591 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
9592 error "dd failed on $fm_file"
9594 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9595 filefrag_op=$(filefrag -ve $fm_file |
9596 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9598 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9599 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9604 for line in $filefrag_op
9606 frag_lun=$(echo $line | cut -d: -f5 |
9607 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9608 ext_len=$(echo $line | cut -d: -f4)
9609 if (( $frag_lun != $last_lun )); then
9610 if (( tot_len != 1024 )); then
9612 error "FIEMAP on $fm_file failed; returned " \
9613 "len $tot_len for OST $last_lun instead of 1024"
9620 (( tot_len += ext_len ))
9623 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
9625 error "FIEMAP on $fm_file failed; returned wrong number of " \
9626 "luns or wrong len for OST $last_lun"
9632 echo "FIEMAP on N-stripe file succeeded"
9634 run_test 130d "FIEMAP (N-stripe file)"
9637 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9639 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9640 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9642 trap cleanup_130 EXIT RETURN
9644 local fm_file=$DIR/$tfile
9645 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9646 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9647 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9650 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9651 for ((i = 0; i < $NUM_BLKS; i++))
9653 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9656 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9657 filefrag_op=$(filefrag -ve $fm_file |
9658 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9660 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9661 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9666 for line in $filefrag_op
9668 frag_lun=$(echo $line | cut -d: -f5 |
9669 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9670 ext_len=$(echo $line | cut -d: -f4)
9671 if (( $frag_lun != $last_lun )); then
9672 if (( tot_len != $EXPECTED_LEN )); then
9674 error "FIEMAP on $fm_file failed; returned " \
9675 "len $tot_len for OST $last_lun instead " \
9683 (( tot_len += ext_len ))
9686 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9688 error "FIEMAP on $fm_file failed; returned wrong number " \
9689 "of luns or wrong len for OST $last_lun"
9695 echo "FIEMAP with continuation calls succeeded"
9697 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9699 # Test for writev/readv
9701 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
9702 error "writev test failed"
9703 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
9704 error "readv failed"
9707 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9710 local fsize=$((524288 + 1048576 + 1572864))
9711 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
9712 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9713 error "append writev test failed"
9715 ((fsize += 1572864 + 1048576))
9716 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
9717 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9718 error "append writev test failed"
9721 run_test 131b "test append writev"
9724 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9727 run_test 131c "test read/write on file w/o objects"
9730 rwv -f $DIR/$tfile -w -n 1 1572864
9731 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9732 if [ "$NOB" != 1572864 ]; then
9733 error "Short read filed: read $NOB bytes instead of 1572864"
9737 run_test 131d "test short read"
9740 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9741 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9742 error "read hitting hole failed"
9745 run_test 131e "test read hitting hole"
9754 mds*) res=$(do_facet $facet \
9755 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9757 ost*) res=$(do_facet $facet \
9758 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9760 *) error "Wrong facet '$facet'" ;;
9763 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9764 # if the argument $3 is zero, it means any stat increment is ok.
9765 if [[ $want -gt 0 ]]; then
9766 local count=$(echo $res | awk '{ print $2 }')
9767 [[ $count -ne $want ]] &&
9768 error "The $op counter on $facet is $count, not $want"
9773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9774 remote_ost_nodsh && skip "remote OST with nodsh" && return
9775 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9777 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9778 { skip "MDS doesn't support rename stats"; return; }
9779 local testdir=$DIR/${tdir}/stats_testdir
9780 mkdir -p $DIR/${tdir}
9783 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9784 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9786 # verify mdt stats first.
9787 mkdir ${testdir} || error "mkdir failed"
9788 check_stats $SINGLEMDS "mkdir" 1
9789 touch ${testdir}/${tfile} || error "touch failed"
9790 check_stats $SINGLEMDS "open" 1
9791 check_stats $SINGLEMDS "close" 1
9792 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
9793 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
9794 check_stats $SINGLEMDS "mknod" 2
9796 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
9797 check_stats $SINGLEMDS "unlink" 1
9798 rm -f ${testdir}/${tfile} || error "file remove failed"
9799 check_stats $SINGLEMDS "unlink" 2
9801 # remove working dir and check mdt stats again.
9802 rmdir ${testdir} || error "rmdir failed"
9803 check_stats $SINGLEMDS "rmdir" 1
9805 local testdir1=$DIR/${tdir}/stats_testdir1
9807 mkdir -p ${testdir1}
9808 touch ${testdir1}/test1
9809 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9810 check_stats $SINGLEMDS "crossdir_rename" 1
9812 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9813 check_stats $SINGLEMDS "samedir_rename" 1
9817 run_test 133a "Verifying MDT stats ========================================"
9820 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9821 remote_ost_nodsh && skip "remote OST with nodsh" && return
9822 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9823 local testdir=$DIR/${tdir}/stats_testdir
9824 mkdir -p ${testdir} || error "mkdir failed"
9825 touch ${testdir}/${tfile} || error "touch failed"
9826 cancel_lru_locks mdc
9829 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9830 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9832 # extra mdt stats verification.
9833 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9834 check_stats $SINGLEMDS "setattr" 1
9835 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9836 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9838 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9839 check_stats $SINGLEMDS "getattr" 1
9841 $LFS df || error "lfs failed"
9842 check_stats $SINGLEMDS "statfs" 1
9846 run_test 133b "Verifying extra MDT stats =================================="
9849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9850 remote_ost_nodsh && skip "remote OST with nodsh" && return
9851 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9852 local testdir=$DIR/$tdir/stats_testdir
9853 test_mkdir -p $testdir
9855 # verify obdfilter stats.
9856 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
9858 cancel_lru_locks osc
9859 wait_delete_completed
9862 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9863 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9865 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
9868 cancel_lru_locks osc
9869 check_stats ost1 "write" 1
9871 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
9872 check_stats ost1 "read" 1
9874 > $testdir/$tfile || error "truncate failed"
9875 check_stats ost1 "punch" 1
9877 rm -f $testdir/$tfile || error "file remove failed"
9878 wait_delete_completed
9879 check_stats ost1 "destroy" 1
9883 run_test 133c "Verifying OST stats ========================================"
9890 while [ $value -ge 2 ]; do
9895 if [ $orig -gt $order ]; then
9903 local size=('K' 'M' 'G' 'T');
9905 local size_string=$value
9907 while [ $value -ge 1024 ]; do
9908 if [ $i -gt 3 ]; then
9909 #T is the biggest unit we get here, if that is bigger,
9911 size_string=${value}T
9914 value=$((value >> 10))
9915 if [ $value -lt 1024 ]; then
9916 size_string=${value}${size[$i]}
9927 local context=${2:-.}
9928 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9930 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9936 remote_ost_nodsh && skip "remote OST with nodsh" && return
9937 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9938 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9939 { skip "MDS doesn't support rename stats"; return; }
9941 local testdir1=$DIR/${tdir}/stats_testdir1
9942 local testdir2=$DIR/${tdir}/stats_testdir2
9944 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9946 mkdir -p ${testdir1} || error "mkdir failed"
9947 mkdir -p ${testdir2} || error "mkdir failed"
9949 createmany -o $testdir1/test 512 || error "createmany failed"
9951 # check samedir rename size
9952 mv ${testdir1}/test0 ${testdir1}/test_0
9954 local testdir1_size=$(ls -l $DIR/${tdir} |
9955 awk '/stats_testdir1/ {print $5}')
9956 local testdir2_size=$(ls -l $DIR/${tdir} |
9957 awk '/stats_testdir2/ {print $5}')
9959 testdir1_size=$(order_2 $testdir1_size)
9960 testdir2_size=$(order_2 $testdir2_size)
9962 testdir1_size=$(size_in_KMGT $testdir1_size)
9963 testdir2_size=$(size_in_KMGT $testdir2_size)
9965 echo "source rename dir size: ${testdir1_size}"
9966 echo "target rename dir size: ${testdir2_size}"
9968 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9969 eval $cmd || error "$cmd failed"
9970 local samedir=$($cmd | grep 'same_dir')
9971 local same_sample=$(get_rename_size $testdir1_size)
9972 [ -z "$samedir" ] && error "samedir_rename_size count error"
9973 [[ $same_sample -eq 1 ]] ||
9974 error "samedir_rename_size error $same_sample"
9975 echo "Check same dir rename stats success"
9977 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9979 # check crossdir rename size
9980 mv ${testdir1}/test_0 ${testdir2}/test_0
9982 testdir1_size=$(ls -l $DIR/${tdir} |
9983 awk '/stats_testdir1/ {print $5}')
9984 testdir2_size=$(ls -l $DIR/${tdir} |
9985 awk '/stats_testdir2/ {print $5}')
9987 testdir1_size=$(order_2 $testdir1_size)
9988 testdir2_size=$(order_2 $testdir2_size)
9990 testdir1_size=$(size_in_KMGT $testdir1_size)
9991 testdir2_size=$(size_in_KMGT $testdir2_size)
9993 echo "source rename dir size: ${testdir1_size}"
9994 echo "target rename dir size: ${testdir2_size}"
9996 eval $cmd || error "$cmd failed"
9997 local crossdir=$($cmd | grep 'crossdir')
9998 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9999 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10000 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10001 [[ $src_sample -eq 1 ]] ||
10002 error "crossdir_rename_size error $src_sample"
10003 [[ $tgt_sample -eq 1 ]] ||
10004 error "crossdir_rename_size error $tgt_sample"
10005 echo "Check cross dir rename stats success"
10006 rm -rf $DIR/${tdir}
10008 run_test 133d "Verifying rename_stats ========================================"
10011 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10012 remote_ost_nodsh && skip "remote OST with nodsh" && return
10013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10014 local testdir=$DIR/${tdir}/stats_testdir
10015 local ctr f0 f1 bs=32768 count=42 sum
10017 mkdir -p ${testdir} || error "mkdir failed"
10019 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10021 for ctr in {write,read}_bytes; do
10023 cancel_lru_locks osc
10025 do_facet ost1 $LCTL set_param -n \
10026 "obdfilter.*.exports.clear=clear"
10028 if [ $ctr = write_bytes ]; then
10030 f1=${testdir}/${tfile}
10032 f0=${testdir}/${tfile}
10036 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10039 cancel_lru_locks osc
10041 sum=$(do_facet ost1 $LCTL get_param \
10042 "obdfilter.*.exports.*.stats" |
10043 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10044 $1 == ctr { sum += $7 }
10045 END { printf("%0.0f", sum) }')
10047 if ((sum != bs * count)); then
10048 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10052 rm -rf $DIR/${tdir}
10054 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10056 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10059 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10060 remote_ost_nodsh && skip "remote OST with nodsh" && return
10061 # First without trusting modes.
10062 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10063 echo "proc_dirs='$proc_dirs'"
10064 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10065 find $proc_dirs -exec cat '{}' \; &> /dev/null
10067 # Second verifying readability.
10068 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10070 # eventually, this can also be replaced with "lctl get_param -R",
10071 # but not until that option is always available on the server
10073 for facet in mds1 ost1; do
10074 local facet_proc_dirs=$(do_facet $facet \
10075 \\\ls -d $proc_regexp 2>/dev/null)
10076 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10077 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10078 do_facet $facet find $facet_proc_dirs \
10079 ! -name req_history \
10080 -exec cat '{}' \\\; &> /dev/null
10082 do_facet $facet find $facet_proc_dirs \
10083 ! -name req_history \
10085 -exec cat '{}' \\\; &> /dev/null ||
10086 error "proc file read failed"
10089 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
10092 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10093 remote_ost_nodsh && skip "remote OST with nodsh" && return
10094 # Second verifying writability.
10095 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10096 echo "proc_dirs='$proc_dirs'"
10097 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10099 -ignore_readdir_race \
10101 -not -name force_lbug \
10102 -not -name changelog_mask \
10103 -exec badarea_io '{}' \; ||
10104 error "find $proc_dirs failed"
10107 for facet in mds1 ost1; do
10108 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10109 skip "Too old lustre on $facet" && continue
10110 local facet_proc_dirs=$(do_facet $facet \
10111 \\\ls -d $proc_regexp 2> /dev/null)
10112 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10113 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10114 do_facet $facet find $facet_proc_dirs \
10115 -ignore_readdir_race \
10117 -not -name force_lbug \
10118 -not -name changelog_mask \
10119 -exec badarea_io '{}' \\\; ||
10120 error "$facet find $facet_proc_dirs failed"
10123 # remount the FS in case writes/reads /proc break the FS
10124 cleanup || error "failed to unmount"
10125 setup || error "failed to setup"
10128 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
10131 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10132 remote_ost_nodsh && skip "remote OST with nodsh" && return
10133 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10134 skip "Need MDS version at least 2.9.54" && return
10137 for facet in client mds1 ost1; do
10138 local facet_proc_dirs=$(do_facet $facet \
10139 \\\ls -d $proc_regexp 2> /dev/null)
10140 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10141 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10142 # Get the list of files that are missing the terminating newline
10143 local missing=($(do_facet $facet \
10144 find ${facet_proc_dirs} -type f \| \
10145 while read F\; do \
10146 awk -v FS='\v' -v RS='\v\v' \
10147 "'END { if(NR>0 && \
10148 \\\$NF !~ /.*\\\n\$/) \
10149 print FILENAME}'" \
10152 [ ${#missing[*]} -eq 0 ] ||
10153 error "files do not end with newline: ${missing[*]}"
10156 run_test 133h "Proc files should end with newlines"
10159 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10160 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10161 skip "Need MDS version at least 2.7.54" && return
10163 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10164 cancel_lru_locks mdc
10166 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10167 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10168 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10171 createmany -o $DIR/$tdir/f $nr ||
10172 error "failed to create $nr files in $DIR/$tdir"
10173 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10175 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10176 do_facet mds1 $LCTL set_param fail_loc=0x327
10177 do_facet mds1 $LCTL set_param fail_val=500
10180 echo "sleep 10 seconds ..."
10182 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10184 do_facet mds1 $LCTL set_param fail_loc=0
10185 do_facet mds1 $LCTL set_param fail_val=0
10186 [ $lck_cnt -lt $unused ] ||
10187 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10190 unlinkmany $DIR/$tdir/f $nr
10192 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10195 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10196 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10197 skip "Need MDS version at least 2.7.54" && return
10199 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10200 cancel_lru_locks mdc
10202 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10203 ldlm.lock_reclaim_threshold_mb)
10204 # disable reclaim temporarily
10205 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10207 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10208 do_facet mds1 $LCTL set_param fail_loc=0x328
10209 do_facet mds1 $LCTL set_param fail_val=500
10211 $LCTL set_param debug=+trace
10214 createmany -o $DIR/$tdir/f $nr &
10215 local create_pid=$!
10217 echo "Sleep $TIMEOUT seconds ..."
10219 if ! ps -p $create_pid > /dev/null 2>&1; then
10220 do_facet mds1 $LCTL set_param fail_loc=0
10221 do_facet mds1 $LCTL set_param fail_val=0
10222 do_facet mds1 $LCTL set_param \
10223 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10224 error "createmany finished incorrectly!"
10226 do_facet mds1 $LCTL set_param fail_loc=0
10227 do_facet mds1 $LCTL set_param fail_val=0
10228 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10229 wait $create_pid || return 1
10231 unlinkmany $DIR/$tdir/f $nr
10233 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10235 test_140() { #bug-17379
10236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10237 test_mkdir $DIR/$tdir
10238 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10239 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10241 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10242 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10244 while i=$((i + 1)); do
10246 cd $i || error "Changing to $i"
10247 ln -s ../stat stat || error "Creating stat symlink"
10248 # Read the symlink until ELOOP present,
10249 # not LBUGing the system is considered success,
10250 # we didn't overrun the stack.
10251 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10252 if [ $ret -ne 0 ]; then
10253 if [ $ret -eq 40 ]; then
10256 error "Open stat symlink"
10262 echo "The symlink depth = $i"
10263 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10264 error "Invalid symlink depth"
10266 # Test recursive symlink
10267 ln -s symlink_self symlink_self
10268 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10269 echo "open symlink_self returns $ret"
10270 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10272 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10276 local TF="$TMP/$tfile"
10278 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10280 cancel_lru_locks $OSC
10281 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10282 remount_client $MOUNT
10284 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10287 $TRUNCATE $DIR/$tfile 6000
10288 cancel_lru_locks $OSC
10289 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10292 echo "12345" >>$DIR/$tfile
10293 cancel_lru_locks $OSC
10294 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10297 echo "12345" >>$DIR/$tfile
10298 cancel_lru_locks $OSC
10299 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10304 run_test 150 "truncate/append tests"
10306 #LU-2902 roc_hit was not able to read all values from lproc
10307 function roc_hit_init() {
10308 local list=$(comma_list $(osts_nodes))
10309 local dir=$DIR/$tdir-check
10310 local file=$dir/$tfile
10316 #use setstripe to do a write to every ost
10317 for i in $(seq 0 $((OSTCOUNT-1))); do
10318 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10319 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10320 idx=$(printf %04x $i)
10321 BEFORE=$(get_osd_param $list *OST*$idx stats |
10322 awk '$1 == "cache_access" {sum += $7}
10323 END { printf("%0.0f", sum) }')
10325 cancel_lru_locks osc
10326 cat $file >/dev/null
10328 AFTER=$(get_osd_param $list *OST*$idx stats |
10329 awk '$1 == "cache_access" {sum += $7}
10330 END { printf("%0.0f", sum) }')
10332 echo BEFORE:$BEFORE AFTER:$AFTER
10333 if ! let "AFTER - BEFORE == 4"; then
10335 error "roc_hit is not safe to use"
10343 function roc_hit() {
10344 local list=$(comma_list $(osts_nodes))
10345 echo $(get_osd_param $list '' stats |
10346 awk '$1 == "cache_hit" {sum += $7}
10347 END { printf("%0.0f", sum) }')
10350 function set_cache() {
10353 if [ "$2" == "off" ]; then
10356 local list=$(comma_list $(osts_nodes))
10357 set_osd_param $list '' $1_cache_enable $on
10359 cancel_lru_locks osc
10363 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10364 remote_ost_nodsh && skip "remote OST with nodsh" && return
10367 local list=$(comma_list $(osts_nodes))
10369 # check whether obdfilter is cache capable at all
10370 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10371 echo "not cache-capable obdfilter"
10375 # check cache is enabled on all obdfilters
10376 if get_osd_param $list '' read_cache_enable | grep 0; then
10377 echo "oss cache is disabled"
10381 set_osd_param $list '' writethrough_cache_enable 1
10383 # check write cache is enabled on all obdfilters
10384 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10385 echo "oss write cache is NOT enabled"
10391 #define OBD_FAIL_OBD_NO_LRU 0x609
10392 do_nodes $list $LCTL set_param fail_loc=0x609
10394 # pages should be in the case right after write
10395 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10398 local BEFORE=$(roc_hit)
10399 cancel_lru_locks osc
10400 cat $DIR/$tfile >/dev/null
10401 local AFTER=$(roc_hit)
10403 do_nodes $list $LCTL set_param fail_loc=0
10405 if ! let "AFTER - BEFORE == CPAGES"; then
10406 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10409 # the following read invalidates the cache
10410 cancel_lru_locks osc
10411 set_osd_param $list '' read_cache_enable 0
10412 cat $DIR/$tfile >/dev/null
10414 # now data shouldn't be found in the cache
10416 cancel_lru_locks osc
10417 cat $DIR/$tfile >/dev/null
10419 if let "AFTER - BEFORE != 0"; then
10420 error "IN CACHE: before: $BEFORE, after: $AFTER"
10423 set_osd_param $list '' read_cache_enable 1
10426 run_test 151 "test cache on oss and controls ==============================="
10429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10430 local TF="$TMP/$tfile"
10432 # simulate ENOMEM during write
10433 #define OBD_FAIL_OST_NOMEM 0x226
10434 lctl set_param fail_loc=0x80000226
10435 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10437 sync || error "sync failed"
10438 lctl set_param fail_loc=0
10440 # discard client's cache
10441 cancel_lru_locks osc
10443 # simulate ENOMEM during read
10444 lctl set_param fail_loc=0x80000226
10445 cmp $TF $DIR/$tfile || error "cmp failed"
10446 lctl set_param fail_loc=0
10450 run_test 152 "test read/write with enomem ============================"
10453 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10455 run_test 153 "test if fdatasync does not crash ======================="
10457 dot_lustre_fid_permission_check() {
10459 local ffid=$MOUNT/.lustre/fid/$fid
10462 echo "stat fid $fid"
10463 stat $ffid > /dev/null || error "stat $ffid failed."
10464 echo "touch fid $fid"
10465 touch $ffid || error "touch $ffid failed."
10466 echo "write to fid $fid"
10467 cat /etc/hosts > $ffid || error "write $ffid failed."
10468 echo "read fid $fid"
10469 diff /etc/hosts $ffid || error "read $ffid failed."
10470 echo "append write to fid $fid"
10471 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10472 echo "rename fid $fid"
10473 mv $ffid $test_dir/$tfile.1 &&
10474 error "rename $ffid to $tfile.1 should fail."
10475 touch $test_dir/$tfile.1
10476 mv $test_dir/$tfile.1 $ffid &&
10477 error "rename $tfile.1 to $ffid should fail."
10478 rm -f $test_dir/$tfile.1
10479 echo "truncate fid $fid"
10480 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10481 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10482 echo "link fid $fid"
10483 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10485 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10486 echo "setfacl fid $fid"
10487 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10488 echo "getfacl fid $fid"
10489 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10491 echo "unlink fid $fid"
10492 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10493 echo "mknod fid $fid"
10494 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10496 fid=[0xf00000400:0x1:0x0]
10497 ffid=$MOUNT/.lustre/fid/$fid
10499 echo "stat non-exist fid $fid"
10500 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10501 echo "write to non-exist fid $fid"
10502 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10503 echo "link new fid $fid"
10504 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10506 mkdir -p $test_dir/$tdir
10507 touch $test_dir/$tdir/$tfile
10508 fid=$($LFS path2fid $test_dir/$tdir)
10511 error "error: could not get fid for $test_dir/$dir/$tfile."
10513 ffid=$MOUNT/.lustre/fid/$fid
10516 ls $ffid > /dev/null || error "ls $ffid failed."
10517 echo "touch $fid/$tfile.1"
10518 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10520 echo "touch $MOUNT/.lustre/fid/$tfile"
10521 touch $MOUNT/.lustre/fid/$tfile && \
10522 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10524 echo "setxattr to $MOUNT/.lustre/fid"
10525 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10527 echo "listxattr for $MOUNT/.lustre/fid"
10528 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10530 echo "delxattr from $MOUNT/.lustre/fid"
10531 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10533 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10534 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10535 error "touch invalid fid should fail."
10537 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10538 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10539 error "touch non-normal fid should fail."
10541 echo "rename $tdir to $MOUNT/.lustre/fid"
10542 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10543 error "rename to $MOUNT/.lustre/fid should fail."
10545 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10547 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10548 local new_obf_mode=777
10550 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10551 chmod $new_obf_mode $DIR/.lustre/fid ||
10552 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10554 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10555 [ $obf_mode -eq $new_obf_mode ] ||
10556 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10558 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10559 chmod $old_obf_mode $DIR/.lustre/fid ||
10560 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10563 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10564 fid=$($LFS path2fid $test_dir/$tfile-2)
10566 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10568 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10569 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10570 error "create lov data thru .lustre failed"
10572 echo "cp /etc/passwd $test_dir/$tfile-2"
10573 cp /etc/passwd $test_dir/$tfile-2 ||
10574 error "copy to $test_dir/$tfile-2 failed."
10575 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10576 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10577 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10579 rm -rf $test_dir/tfile.lnk
10580 rm -rf $test_dir/$tfile-2
10584 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10585 skip "Need MDS version at least 2.4.1" && return
10587 local tf=$DIR/$tfile
10590 local fid=$($LFS path2fid $tf)
10591 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10593 # check that we get the same pathname back
10594 local found=$($LFS fid2path $MOUNT "$fid")
10595 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10596 [ "$found" == "$tf" ] ||
10597 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10599 run_test 154A "lfs path2fid and fid2path basic checks"
10602 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10603 skip "Need MDS version at least 2.4.1" && return
10605 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10606 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10607 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10608 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10610 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10611 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10613 # check that we get the same pathname
10614 echo "PFID: $PFID, name: $name"
10615 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10616 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10617 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10618 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10620 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10622 run_test 154B "verify the ll_decode_linkea tool"
10625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10626 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10627 { skip "Need MDS version at least 2.2.51"; return 0; }
10628 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10629 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10631 cp /etc/hosts $DIR/$tfile
10633 fid=$($LFS path2fid $DIR/$tfile)
10635 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10637 dot_lustre_fid_permission_check "$fid" $DIR ||
10638 error "dot lustre permission check $fid failed"
10640 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10642 touch $MOUNT/.lustre/file &&
10643 error "creation is not allowed under .lustre"
10645 mkdir $MOUNT/.lustre/dir &&
10646 error "mkdir is not allowed under .lustre"
10650 run_test 154a "Open-by-FID"
10653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10654 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10655 { skip "Need MDS version at least 2.2.51"; return 0; }
10656 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10658 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10660 local remote_dir=$DIR/$tdir/remote_dir
10664 mkdir -p $DIR/$tdir
10665 $LFS mkdir -i $MDTIDX $remote_dir ||
10666 error "create remote directory failed"
10668 cp /etc/hosts $remote_dir/$tfile
10670 fid=$($LFS path2fid $remote_dir/$tfile)
10672 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10674 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10675 error "dot lustre permission check $fid failed"
10678 run_test 154b "Open-by-FID for remote directory"
10681 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10682 skip "Need MDS version at least 2.4.1" && return
10684 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10685 local FID1=$($LFS path2fid $DIR/$tfile.1)
10686 local FID2=$($LFS path2fid $DIR/$tfile.2)
10687 local FID3=$($LFS path2fid $DIR/$tfile.3)
10690 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10691 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10692 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10694 [ "$FID" = "${!want}" ] ||
10695 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10699 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10701 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10702 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10706 run_test 154c "lfs path2fid and fid2path multiple arguments"
10709 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10710 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10711 skip "Need MDS version at least 2.5.53" && return
10713 if remote_mds; then
10714 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10718 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10725 local fid=$($LFS path2fid $DIR/$tfile)
10728 cmd="exec $fd<$DIR/$tfile"
10730 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10731 echo "$fid_list" | grep "$fid"
10734 cmd="exec $fd>/dev/null"
10736 if [ $rc -ne 0 ]; then
10737 error "FID $fid not found in open files list $fid_list"
10740 run_test 154d "Verify open file fid"
10744 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10745 skip "Need MDS version at least 2.6.50" && return
10747 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10748 error ".lustre returned by readdir"
10751 run_test 154e ".lustre is not returned by readdir"
10754 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10755 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10756 test_mkdir -p -c1 $DIR/$tdir/d
10757 # test dirs inherit from its stripe
10758 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10759 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10760 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10761 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10764 # get fid of parents
10765 local FID0=$($LFS path2fid $DIR/$tdir/d)
10766 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10767 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10768 local FID3=$($LFS path2fid $DIR)
10770 # check that path2fid --parents returns expected <parent_fid>/name
10771 # 1) test for a directory (single parent)
10772 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10773 [ "$parent" == "$FID0/foo1" ] ||
10774 error "expected parent: $FID0/foo1, got: $parent"
10776 # 2) test for a file with nlink > 1 (multiple parents)
10777 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10778 echo "$parent" | grep -F "$FID1/$tfile" ||
10779 error "$FID1/$tfile not returned in parent list"
10780 echo "$parent" | grep -F "$FID2/link" ||
10781 error "$FID2/link not returned in parent list"
10783 # 3) get parent by fid
10784 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10785 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10786 echo "$parent" | grep -F "$FID1/$tfile" ||
10787 error "$FID1/$tfile not returned in parent list (by fid)"
10788 echo "$parent" | grep -F "$FID2/link" ||
10789 error "$FID2/link not returned in parent list (by fid)"
10791 # 4) test for entry in root directory
10792 parent=$($LFS path2fid --parents $DIR/f)
10793 echo "$parent" | grep -F "$FID3/f" ||
10794 error "$FID3/f not returned in parent list"
10796 # 5) test it on root directory
10797 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10798 error "$MOUNT should not have parents"
10800 # enable xattr caching and check that linkea is correctly updated
10801 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10802 save_lustre_params client "llite.*.xattr_cache" > $save
10803 lctl set_param llite.*.xattr_cache 1
10805 # 6.1) linkea update on rename
10806 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10808 # get parents by fid
10809 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10810 # foo1 should no longer be returned in parent list
10811 echo "$parent" | grep -F "$FID1" &&
10812 error "$FID1 should no longer be in parent list"
10813 # the new path should appear
10814 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10815 error "$FID2/$tfile.moved is not in parent list"
10817 # 6.2) linkea update on unlink
10818 rm -f $DIR/$tdir/d/foo2/link
10819 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10820 # foo2/link should no longer be returned in parent list
10821 echo "$parent" | grep -F "$FID2/link" &&
10822 error "$FID2/link should no longer be in parent list"
10826 restore_lustre_params < $save
10829 run_test 154f "get parent fids by reading link ea"
10833 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
10834 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
10835 { skip "Need MDS version at least 2.6.92"; return 0; }
10836 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10838 mkdir -p $DIR/$tdir
10839 llapi_fid_test -d $DIR/$tdir
10841 run_test 154g "various llapi FID tests"
10843 test_155_small_load() {
10844 local temp=$TMP/$tfile
10845 local file=$DIR/$tfile
10847 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10848 error "dd of=$temp bs=6096 count=1 failed"
10850 cancel_lru_locks $OSC
10851 cmp $temp $file || error "$temp $file differ"
10853 $TRUNCATE $temp 6000
10854 $TRUNCATE $file 6000
10855 cmp $temp $file || error "$temp $file differ (truncate1)"
10857 echo "12345" >>$temp
10858 echo "12345" >>$file
10859 cmp $temp $file || error "$temp $file differ (append1)"
10861 echo "12345" >>$temp
10862 echo "12345" >>$file
10863 cmp $temp $file || error "$temp $file differ (append2)"
10869 test_155_big_load() {
10870 remote_ost_nodsh && skip "remote OST with nodsh" && return
10871 local temp=$TMP/$tfile
10872 local file=$DIR/$tfile
10875 local cache_size=$(do_facet ost$((MAXI+1)) \
10876 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10877 local large_file_size=$((cache_size * 2))
10879 echo "OSS cache size: $cache_size KB"
10880 echo "Large file size: $large_file_size KB"
10882 [ $MAXV -le $large_file_size ] && \
10883 skip_env "max available OST size needs > $large_file_size KB" && \
10886 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10888 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10889 error "dd of=$temp bs=$large_file_size count=1k failed"
10892 cancel_lru_locks osc
10893 cmp $temp $file || error "$temp $file differ"
10899 save_writethrough() {
10900 local facets=$(get_facets OST)
10902 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
10903 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
10907 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10908 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10909 save_writethrough $p
10912 set_cache writethrough on
10913 test_155_small_load
10914 restore_lustre_params < $p
10917 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10921 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10922 save_writethrough $p
10925 set_cache writethrough off
10926 test_155_small_load
10927 restore_lustre_params < $p
10930 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10934 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10935 save_writethrough $p
10938 set_cache writethrough on
10939 test_155_small_load
10940 restore_lustre_params < $p
10943 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10946 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10947 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10948 save_writethrough $p
10951 set_cache writethrough off
10952 test_155_small_load
10953 restore_lustre_params < $p
10956 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10960 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10961 save_writethrough $p
10964 set_cache writethrough on
10966 restore_lustre_params < $p
10969 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10973 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10974 save_writethrough $p
10977 set_cache writethrough off
10979 restore_lustre_params < $p
10982 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10985 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10986 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10987 save_writethrough $p
10990 set_cache writethrough on
10992 restore_lustre_params < $p
10995 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10998 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10999 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11000 save_writethrough $p
11003 set_cache writethrough off
11005 restore_lustre_params < $p
11008 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11011 remote_ost_nodsh && skip "remote OST with nodsh" && return
11012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11016 local file="$DIR/$tfile"
11017 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11019 [ "$(facet_fstype ost1)" = "zfs" -a \
11020 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11021 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
11024 save_writethrough $p
11027 log "Turn on read and write cache"
11029 set_cache writethrough on
11031 log "Write data and read it back."
11032 log "Read should be satisfied from the cache."
11033 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11035 cancel_lru_locks osc
11036 cat $file >/dev/null
11038 if ! let "AFTER - BEFORE == CPAGES"; then
11039 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11041 log "cache hits:: before: $BEFORE, after: $AFTER"
11044 log "Read again; it should be satisfied from the cache."
11046 cancel_lru_locks osc
11047 cat $file >/dev/null
11049 if ! let "AFTER - BEFORE == CPAGES"; then
11050 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11052 log "cache hits:: before: $BEFORE, after: $AFTER"
11055 log "Turn off the read cache and turn on the write cache"
11057 set_cache writethrough on
11059 log "Read again; it should be satisfied from the cache."
11061 cancel_lru_locks osc
11062 cat $file >/dev/null
11064 if ! let "AFTER - BEFORE == CPAGES"; then
11065 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11067 log "cache hits:: before: $BEFORE, after: $AFTER"
11070 log "Read again; it should not be satisfied from the cache."
11072 cancel_lru_locks osc
11073 cat $file >/dev/null
11075 if ! let "AFTER - BEFORE == 0"; then
11076 error "IN CACHE: before: $BEFORE, after: $AFTER"
11078 log "cache hits:: before: $BEFORE, after: $AFTER"
11081 log "Write data and read it back."
11082 log "Read should be satisfied from the cache."
11083 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11085 cancel_lru_locks osc
11086 cat $file >/dev/null
11088 if ! let "AFTER - BEFORE == CPAGES"; then
11089 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11091 log "cache hits:: before: $BEFORE, after: $AFTER"
11094 log "Read again; it should not be satisfied from the cache."
11096 cancel_lru_locks osc
11097 cat $file >/dev/null
11099 if ! let "AFTER - BEFORE == 0"; then
11100 error "IN CACHE: before: $BEFORE, after: $AFTER"
11102 log "cache hits:: before: $BEFORE, after: $AFTER"
11105 log "Turn off read and write cache"
11107 set_cache writethrough off
11109 log "Write data and read it back"
11110 log "It should not be satisfied from the cache."
11112 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11113 cancel_lru_locks osc
11115 cat $file >/dev/null
11117 if ! let "AFTER - BEFORE == 0"; then
11118 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11120 log "cache hits:: before: $BEFORE, after: $AFTER"
11123 log "Turn on the read cache and turn off the write cache"
11125 set_cache writethrough off
11127 log "Write data and read it back"
11128 log "It should not be satisfied from the cache."
11130 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11132 cancel_lru_locks osc
11133 cat $file >/dev/null
11135 if ! let "AFTER - BEFORE == 0"; then
11136 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11138 log "cache hits:: before: $BEFORE, after: $AFTER"
11141 log "Read again; it should be satisfied from the cache."
11143 cancel_lru_locks osc
11144 cat $file >/dev/null
11146 if ! let "AFTER - BEFORE == CPAGES"; then
11147 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11149 log "cache hits:: before: $BEFORE, after: $AFTER"
11152 restore_lustre_params < $p
11155 run_test 156 "Verification of tunables"
11158 cleanup_changelog () {
11160 echo "Deregistering changelog client $CL_USER"
11161 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11165 if [[ $MDSCOUNT -gt 1 ]]; then
11166 error_ignore bz17935 $*
11174 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11176 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11178 if [ $MASK -eq 1 ]; then
11179 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11181 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11185 changelog_extract_field() {
11189 local identifier=$4
11191 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11192 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11198 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11199 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11200 { skip "Need MDS version at least 2.2.0"; return; }
11202 local CL_USERS="mdd.$MDT0.changelog_users"
11203 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11204 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11205 changelog_register -n)
11206 echo "Registered as changelog user $CL_USER"
11207 trap cleanup_changelog EXIT
11208 $GET_CL_USERS | grep -q $CL_USER ||
11209 error "User $CL_USER not found in changelog_users"
11212 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11213 touch $DIR/$tdir/pics/2008/zachy/timestamp
11214 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11215 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11216 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11217 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11218 rm $DIR/$tdir/pics/desktop.jpg
11220 $LFS changelog $MDT0 | tail -5
11222 echo "verifying changelog mask"
11223 changelog_chmask "MKDIR"
11224 changelog_chmask "CLOSE"
11226 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11227 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11229 changelog_chmask "MKDIR"
11230 changelog_chmask "CLOSE"
11232 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11233 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11235 $LFS changelog $MDT0
11236 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11237 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11238 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11239 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11242 echo "verifying target fid"
11243 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11244 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11245 [ "$fidc" == "$fidf" ] ||
11246 err17935 "fid in changelog $fidc != file fid $fidf"
11247 echo "verifying parent fid"
11248 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11249 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11250 [ "$fidc" == "$fidf" ] ||
11251 err17935 "pfid in changelog $fidc != dir fid $fidf"
11253 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11254 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11255 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11256 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11257 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11258 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11260 MIN_REC=$($GET_CL_USERS |
11261 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11262 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11263 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11264 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11265 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11267 # LU-3446 changelog index reset on MDT restart
11268 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11269 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11270 $LFS changelog_clear $MDT0 $CL_USER 0
11271 stop $SINGLEMDS || error "Fail to stop MDT."
11272 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11273 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11274 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11275 [ $CUR_REC1 == $CUR_REC2 ] ||
11276 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11278 echo "verifying user deregister"
11280 $GET_CL_USERS | grep -q $CL_USER &&
11281 error "User $CL_USER still in changelog_users"
11283 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11284 if [ $CL_USER -eq 0 ]; then
11285 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11286 touch $DIR/$tdir/chloe
11287 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11288 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11289 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11291 echo "$CL_USER other changelog users; can't verify off"
11294 run_test 160a "changelog sanity"
11296 test_160b() { # LU-3587
11297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11298 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11299 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11300 { skip "Need MDS version at least 2.2.0"; return; }
11302 local CL_USERS="mdd.$MDT0.changelog_users"
11303 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11304 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11305 changelog_register -n)
11306 echo "Registered as changelog user $CL_USER"
11307 trap cleanup_changelog EXIT
11308 $GET_CL_USERS | grep -q $CL_USER ||
11309 error "User $CL_USER not found in changelog_users"
11311 local LONGNAME1=$(str_repeat a 255)
11312 local LONGNAME2=$(str_repeat b 255)
11315 echo "creating very long named file"
11316 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11317 echo "moving very long named file"
11318 mv $LONGNAME1 $LONGNAME2
11320 $LFS changelog $MDT0 | grep RENME
11324 run_test 160b "Verify that very long rename doesn't crash in changelog"
11327 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11330 local server_version=$(lustre_version_code $SINGLEMDS)
11332 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11333 [[ $server_version -gt $(version_code 2.5.1) &&
11334 $server_version -lt $(version_code 2.5.50) ]] ||
11335 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11338 # Registration step
11339 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11340 changelog_register -n)
11341 trap cleanup_changelog EXIT
11344 mkdir -p $DIR/$tdir
11345 $MCREATE $DIR/$tdir/foo_160c
11346 changelog_chmask "TRUNC"
11347 $TRUNCATE $DIR/$tdir/foo_160c 200
11348 changelog_chmask "TRUNC"
11349 $TRUNCATE $DIR/$tdir/foo_160c 199
11350 $LFS changelog $MDT0
11351 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11352 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11353 $LFS changelog_clear $MDT0 $CL_USER 0
11355 # Deregistration step
11358 run_test 160c "verify that changelog log catch the truncate event"
11361 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11362 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11364 local server_version=$(lustre_version_code mds1)
11365 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11367 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11368 { skip "Need MDS version at least 2.7.60+"; return; }
11369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11371 # Registration step
11372 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11373 changelog_register -n)
11375 trap cleanup_changelog EXIT
11376 mkdir -p $DIR/$tdir/migrate_dir
11377 $LFS changelog_clear $MDT0 $CL_USER 0
11379 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11380 $LFS changelog $MDT0
11381 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11382 $LFS changelog_clear $MDT0 $CL_USER 0
11383 [ $MIGRATES -eq 1 ] ||
11384 error "MIGRATE changelog mask count $MIGRATES != 1"
11386 # Deregistration step
11389 run_test 160d "verify that changelog log catch the migrate event"
11392 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11395 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11396 changelog_register -n)
11397 echo "Registered as changelog user $CL_USER"
11398 trap cleanup_changelog EXIT
11400 # Delete a future user (expect fail)
11401 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11404 if [ $rc -eq 0 ]; then
11405 error "Deleted non-existant user cl77"
11406 elif [ $rc -ne 2 ]; then
11407 error "changelog_deregister failed with $rc, " \
11408 "expected 2 (ENOENT)"
11411 # Clear to a bad index (1 billion should be safe)
11412 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11415 if [ $rc -eq 0 ]; then
11416 error "Successfully cleared to invalid CL index"
11417 elif [ $rc -ne 22 ]; then
11418 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11421 run_test 160e "changelog negative testing"
11425 do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
11426 echo "Deregistering changelog client $CL_USER"
11427 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11428 echo "Deregistering changelog client $CL_USER2"
11429 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER2
11430 restore_lustre_params < $save_params
11435 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11436 # should be set by default
11438 local CL_USERS="mdd.$MDT0.changelog_users"
11439 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11440 local save_params="$TMP/sanity-$TESTNAME.parameters"
11442 save_lustre_params $SINGLEMDS \
11443 "mdd.$MDT0.changelog_max_idle_time" > $save_params
11444 save_lustre_params $SINGLEMDS \
11445 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11446 save_lustre_params $SINGLEMDS \
11447 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11449 trap cleanup_160f EXIT
11452 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11453 changelog_register -n)
11454 echo "Registered as changelog user $CL_USER"
11455 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11456 changelog_register -n)
11457 echo "Registered as changelog user $CL_USER2"
11458 $GET_CL_USERS | grep -q $CL_USER ||
11459 error "User $CL_USER not found in changelog_users"
11460 $GET_CL_USERS | grep -q $CL_USER2 ||
11461 error "User $CL_USER2 not found in changelog_users"
11463 # generate some changelogs to accumulate
11464 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11465 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11466 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11467 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11469 # check changelogs have been generated
11470 nbcl=$($LFS changelog $MDT0 | wc -l)
11471 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11473 do_facet $SINGLEMDS $LCTL set_param \
11474 mdd.$MDT0.changelog_max_idle_time=10
11475 do_facet $SINGLEMDS $LCTL set_param \
11476 mdd.$MDT0.changelog_min_gc_interval=2
11477 do_facet $SINGLEMDS $LCTL set_param \
11478 mdd.$MDT0.changelog_min_free_cat_entries=3
11480 # simulate changelog catalog almost full
11481 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11482 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11483 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11486 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11487 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 2))
11488 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11489 echo "verifying user clear: $(( $USER_REC1 + 2 )) == $USER_REC2"
11490 [ $USER_REC2 == $(($USER_REC1 + 2)) ] ||
11491 error "user index expected $(($USER_REC1 + 2)) is $USER_REC2"
11494 # generate one more changelog to trigger fail_loc
11495 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11497 # ensure gc thread is done
11498 wait_update_facet $SINGLEMDS \
11499 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11501 # check user still registered
11502 $GET_CL_USERS | grep -q $CL_USER ||
11503 error "User $CL_USER not found in changelog_users"
11504 # check user2 unregistered
11505 $GET_CL_USERS | grep -q $CL_USER2 &&
11506 error "User $CL_USER2 still found in changelog_users"
11508 # check changelogs are present and starting at $USER_REC2 + 1
11509 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11510 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11511 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11512 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11516 run_test 160f "changelog garbage collect (timestamped users)"
11519 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11520 # should be set by default
11522 local CL_USERS="mdd.$MDT0.changelog_users"
11523 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11524 local save_params="$TMP/sanity-$TESTNAME.parameters"
11526 save_lustre_params $SINGLEMDS \
11527 "mdd.$MDT0.changelog_max_idle_indexes" > $save_params
11528 save_lustre_params $SINGLEMDS \
11529 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11530 save_lustre_params $SINGLEMDS \
11531 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11533 trap cleanup_160f EXIT
11535 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
11536 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1314
11539 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11540 changelog_register -n)
11541 echo "Registered as changelog user $CL_USER"
11542 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11543 changelog_register -n)
11544 echo "Registered as changelog user $CL_USER2"
11545 $GET_CL_USERS | grep -q $CL_USER ||
11546 error "User $CL_USER not found in changelog_users"
11547 $GET_CL_USERS | grep -q $CL_USER2 ||
11548 error "User $CL_USER2 not found in changelog_users"
11550 # generate some changelogs to accumulate
11551 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11552 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11553 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11554 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11556 # check changelogs have been generated
11557 nbcl=$($LFS changelog $MDT0 | wc -l)
11558 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11560 do_facet $SINGLEMDS $LCTL set_param \
11561 mdd.$MDT0.changelog_max_idle_indexes=$((nbcl - 1))
11562 do_facet $SINGLEMDS $LCTL set_param \
11563 mdd.$MDT0.changelog_min_gc_interval=2
11564 do_facet $SINGLEMDS $LCTL set_param \
11565 mdd.$MDT0.changelog_min_free_cat_entries=3
11567 # simulate changelog catalog almost full
11568 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11569 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11570 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11572 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11573 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 3))
11574 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11575 echo "verifying user clear: $(( $USER_REC1 + 3 )) == $USER_REC2"
11576 [ $USER_REC2 == $(($USER_REC1 + 3)) ] ||
11577 error "user index expected $(($USER_REC1 + 3)) is $USER_REC2"
11579 # generate one more changelog to trigger fail_loc
11580 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11582 # ensure gc thread is done
11583 wait_update_facet $SINGLEMDS \
11584 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11586 # check user still registered
11587 $GET_CL_USERS | grep -q $CL_USER ||
11588 error "User $CL_USER not found in changelog_users"
11589 # check user2 unregistered
11590 $GET_CL_USERS | grep -q $CL_USER2 &&
11591 error "User $CL_USER2 still found in changelog_users"
11593 # check changelogs are present and starting at $USER_REC2 + 1
11594 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11595 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11596 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11597 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11601 run_test 160g "changelog garbage collect (old users)"
11604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11605 test_mkdir -c1 $DIR/$tdir
11606 cp /etc/hosts $DIR/$tdir/$tfile
11607 test_mkdir -c1 $DIR/$tdir/foo1
11608 test_mkdir -c1 $DIR/$tdir/foo2
11609 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11610 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11611 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11612 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11613 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11614 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11615 $LFS fid2path $DIR $FID
11616 err17935 "bad link ea"
11619 rm $DIR/$tdir/foo2/zachary
11621 rm $DIR/$tdir/foo2/thor
11623 rm $DIR/$tdir/$tfile
11625 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11626 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11628 $LFS fid2path $DIR $FID
11629 err17935 "bad link rename"
11631 rm $DIR/$tdir/foo2/maggie
11634 local longname=filename_avg_len_is_thirty_two_
11635 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11636 error "failed to hardlink many files"
11637 links=$($LFS fid2path $DIR $FID | wc -l)
11638 echo -n "${links}/1000 links in link EA"
11639 [[ $links -gt 60 ]] ||
11640 err17935 "expected at least 60 links in link EA"
11641 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11642 error "failed to unlink many hardlinks"
11644 run_test 161a "link ea sanity"
11647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11648 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11650 local remote_dir=$DIR/$tdir/remote_dir
11652 mkdir -p $DIR/$tdir
11653 $LFS mkdir -i $MDTIDX $remote_dir ||
11654 error "create remote directory failed"
11656 cp /etc/hosts $remote_dir/$tfile
11657 mkdir -p $remote_dir/foo1
11658 mkdir -p $remote_dir/foo2
11659 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11660 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11661 ln $remote_dir/$tfile $remote_dir/foo1/luna
11662 ln $remote_dir/$tfile $remote_dir/foo2/thor
11664 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11666 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11667 $LFS fid2path $DIR $FID
11668 err17935 "bad link ea"
11671 rm $remote_dir/foo2/zachary
11673 rm $remote_dir/foo2/thor
11675 rm $remote_dir/$tfile
11677 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11678 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11679 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11680 $LFS fid2path $DIR $FID
11681 err17935 "bad link rename"
11683 rm $remote_dir/foo2/maggie
11686 local longname=filename_avg_len_is_thirty_two_
11687 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11688 error "failed to hardlink many files"
11689 links=$($LFS fid2path $DIR $FID | wc -l)
11690 echo -n "${links}/1000 links in link EA"
11691 [[ ${links} -gt 60 ]] ||
11692 err17935 "expected at least 60 links in link EA"
11693 unlinkmany $remote_dir/foo2/$longname 1000 ||
11694 error "failed to unlink many hardlinks"
11696 run_test 161b "link ea sanity under remote directory"
11699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11701 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11702 skip "Need MDS version at least 2.1.5" && return
11704 # define CLF_RENAME_LAST 0x0001
11705 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11706 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11707 changelog_register -n)
11709 trap cleanup_changelog EXIT
11711 mkdir -p $DIR/$tdir
11712 touch $DIR/$tdir/foo_161c
11713 touch $DIR/$tdir/bar_161c
11714 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11715 $LFS changelog $MDT0 | grep RENME
11716 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11718 $LFS changelog_clear $MDT0 $CL_USER 0
11719 if [ x$flags != "x0x1" ]; then
11720 error "flag $flags is not 0x1"
11722 echo "rename overwrite a target having nlink = 1," \
11723 "changelog record has flags of $flags"
11725 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11726 touch $DIR/$tdir/foo_161c
11727 touch $DIR/$tdir/bar_161c
11728 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11729 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11730 $LFS changelog $MDT0 | grep RENME
11731 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11732 $LFS changelog_clear $MDT0 $CL_USER 0
11733 if [ x$flags != "x0x0" ]; then
11734 error "flag $flags is not 0x0"
11736 echo "rename overwrite a target having nlink > 1," \
11737 "changelog record has flags of $flags"
11739 # rename doesn't overwrite a target (changelog flag 0x0)
11740 touch $DIR/$tdir/foo_161c
11741 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11742 $LFS changelog $MDT0 | grep RENME
11743 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11744 $LFS changelog_clear $MDT0 $CL_USER 0
11745 if [ x$flags != "x0x0" ]; then
11746 error "flag $flags is not 0x0"
11748 echo "rename doesn't overwrite a target," \
11749 "changelog record has flags of $flags"
11751 # define CLF_UNLINK_LAST 0x0001
11752 # unlink a file having nlink = 1 (changelog flag 0x1)
11753 rm -f $DIR/$tdir/foo2_161c
11754 $LFS changelog $MDT0 | grep UNLNK
11755 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11756 $LFS changelog_clear $MDT0 $CL_USER 0
11757 if [ x$flags != "x0x1" ]; then
11758 error "flag $flags is not 0x1"
11760 echo "unlink a file having nlink = 1," \
11761 "changelog record has flags of $flags"
11763 # unlink a file having nlink > 1 (changelog flag 0x0)
11764 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11765 rm -f $DIR/$tdir/foobar_161c
11766 $LFS changelog $MDT0 | grep UNLNK
11767 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11768 $LFS changelog_clear $MDT0 $CL_USER 0
11769 if [ x$flags != "x0x0" ]; then
11770 error "flag $flags is not 0x0"
11772 echo "unlink a file having nlink > 1," \
11773 "changelog record has flags of $flags"
11776 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11783 # cleanup previous run
11784 rm -rf $DIR/$tdir/$tfile
11786 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11787 changelog_register -n)
11788 [[ $? -eq 0 ]] || error "changelog_register failed"
11790 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11791 # interfer with $MOUNT/.lustre/fid/ access
11793 [[ $? -eq 0 ]] || error "mkdir failed"
11795 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11796 $LCTL set_param fail_loc=0x8000140c
11798 $LCTL set_param fail_val=5
11801 echo foofoo > $DIR/$tdir/$tfile &
11804 # wait for create to be delayed
11808 [[ $? -eq 0 ]] || error "create should be blocked"
11810 local tempfile=$(mktemp)
11811 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11812 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11813 # some delay may occur during ChangeLog publishing and file read just
11814 # above, that could allow file write to happen finally
11815 [[ -s $tempfile ]] && echo "file should be empty"
11817 $LCTL set_param fail_loc=0
11820 [[ $? -eq 0 ]] || error "create failed"
11822 $LFS changelog_clear $MDT0 $user 0
11823 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11825 run_test 161d "create with concurrent .lustre/fid access"
11832 local path=$(${LFS} fid2path $*)
11833 # Remove the '//' indicating a remote directory
11834 path=$(echo $path | sed 's#//#/#g')
11837 if [ $RC -ne 0 ]; then
11838 err17935 "path looked up of $expected failed. Error $RC"
11840 elif [ "${path}" != "${expected}" ]; then
11841 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11844 echo "fid $fid resolves to path $path (expected $expected)"
11847 test_162a() { # was test_162
11848 # Make changes to filesystem
11849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11850 test_mkdir -p -c1 $DIR/$tdir/d2
11851 touch $DIR/$tdir/d2/$tfile
11852 touch $DIR/$tdir/d2/x1
11853 touch $DIR/$tdir/d2/x2
11854 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11855 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11857 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11858 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11859 error "check path $tdir/d2/$tfile failed"
11862 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11863 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11864 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11865 error "check path $tdir/d2/p/q/r/slink failed"
11867 # softlink to wrong file
11868 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11869 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11870 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11871 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11874 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11875 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11876 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11877 # fid2path dir/fsname should both work
11878 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11879 error "check path $tdir/d2/a/b/c/new_file failed"
11880 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11881 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11883 # hardlink count: check that there are 2 links
11884 # Doesnt work with CMD yet: 17935
11885 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11886 err17935 "expected 2 links"
11888 # hardlink indexing: remove the first link
11889 rm $DIR/$tdir/d2/p/q/r/hlink
11890 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11891 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11895 run_test 162a "path lookup sanity"
11898 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11899 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11902 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11903 error "create striped dir failed"
11905 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11906 tail -n 1 | awk '{print $2}')
11907 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11909 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11910 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11913 for ((i=0;i<5;i++)); do
11914 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11915 error "get fid for f$i failed"
11916 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11917 error "check path $tdir/striped_dir/f$i failed"
11919 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11920 error "get fid for d$i failed"
11921 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11922 error "check path $tdir/striped_dir/d$i failed"
11927 run_test 162b "striped directory path lookup sanity"
11929 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11931 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11932 skip "Need MDS version at least 2.7.51" && return
11933 test_mkdir $DIR/$tdir.local
11934 test_mkdir $DIR/$tdir.remote
11935 local lpath=$tdir.local
11936 local rpath=$tdir.remote
11938 for ((i = 0; i <= 101; i++)); do
11941 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11942 error "get fid for local directory $DIR/$lpath failed"
11943 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11944 error "check path for local directory $DIR/$lpath failed"
11947 test_mkdir $DIR/$rpath
11948 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11949 error "get fid for remote directory $DIR/$rpath failed"
11950 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11951 error "check path for remote directory $DIR/$rpath failed"
11956 run_test 162c "fid2path works with paths 100 or more directories deep"
11959 # do directio so as not to populate the page cache
11960 log "creating a 10 Mb file"
11961 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11962 log "starting reads"
11963 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11964 log "truncating the file"
11965 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11967 kill %+ || true # reads might have finished
11968 echo "wait until dd is finished"
11970 log "removing the temporary file"
11971 rm -rf $DIR/$tfile || error "tmp file removal failed"
11973 run_test 169 "parallel read and truncate should not deadlock"
11976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11977 $LCTL clear # bug 18514
11978 $LCTL debug_daemon start $TMP/${tfile}_log_good
11980 $LCTL debug_daemon stop
11981 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11982 error "sed failed to read log_good"
11984 $LCTL debug_daemon start $TMP/${tfile}_log_good
11986 $LCTL debug_daemon stop
11988 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11989 error "lctl df log_bad failed"
11991 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11992 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11994 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11995 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11997 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11998 error "bad_line good_line1 good_line2 are empty"
12000 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12001 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
12002 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12004 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
12005 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12006 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12008 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
12009 error "bad_line_new good_line_new are empty"
12011 local expected_good=$((good_line1 + good_line2*2))
12013 rm -f $TMP/${tfile}*
12014 # LU-231, short malformed line may not be counted into bad lines
12015 if [ $bad_line -ne $bad_line_new ] &&
12016 [ $bad_line -ne $((bad_line_new - 1)) ]; then
12017 error "expected $bad_line bad lines, but got $bad_line_new"
12021 if [ $expected_good -ne $good_line_new ]; then
12022 error "expected $expected_good good lines, but got $good_line_new"
12027 run_test 170 "test lctl df to handle corrupted log ====================="
12029 test_171() { # bug20592
12030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12031 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
12032 $LCTL set_param fail_loc=0x50e
12033 $LCTL set_param fail_val=3000
12034 multiop_bg_pause $DIR/$tfile O_s || true
12036 kill -USR1 $MULTIPID
12040 if dmesg | grep "recursive fault"; then
12041 error "caught a recursive fault"
12043 $LCTL set_param fail_loc=0
12046 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
12048 # it would be good to share it with obdfilter-survey/iokit-libecho code
12049 setup_obdecho_osc () {
12052 local obdfilter_name=$2
12053 echo "Creating new osc for $obdfilter_name on $ost_nid"
12054 # make sure we can find loopback nid
12055 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
12057 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
12058 ${obdfilter_name}_osc_UUID || rc=2; }
12059 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
12060 ${obdfilter_name}_UUID $ost_nid || rc=3; }
12064 cleanup_obdecho_osc () {
12065 local obdfilter_name=$1
12066 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
12067 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
12074 local pages=${3:-64}
12079 local obd_size=$(get_obd_size $node $OBD)
12080 local page_size=$(get_page_size $node)
12081 if [[ -n "$obd_size" ]]; then
12082 local new_count=$((obd_size / (pages * page_size / 1024)))
12083 [[ $new_count -ge $count ]] || count=$new_count
12086 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
12087 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
12089 if [ $rc -eq 0 ]; then
12090 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
12091 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
12093 echo "New object id is $id"
12094 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
12096 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
12097 "test_brw $count w v $pages $id" || rc=4; }
12098 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
12100 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
12101 "cleanup" || rc=5; }
12102 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
12103 "detach" || rc=6; }
12104 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
12109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12110 remote_ost_nodsh && skip "remote OST with nodsh" && return
12112 local rmmod_local=0
12114 if ! module_loaded obdecho; then
12115 load_module obdecho/obdecho
12119 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
12120 local host=$(lctl get_param -n osc.$osc.import |
12121 awk '/current_connection:/ {print $2}' )
12122 local target=$(lctl get_param -n osc.$osc.import |
12123 awk '/target:/ {print $2}' )
12124 target=${target%_UUID}
12126 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
12127 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
12128 [[ -n $target ]] && cleanup_obdecho_osc $target
12129 [ $rmmod_local -eq 1 ] && rmmod obdecho
12132 run_test 180a "test obdecho on osc"
12135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12136 remote_ost_nodsh && skip "remote OST with nodsh" && return
12138 local rmmod_remote=0
12140 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12141 rmmod_remote=true || error "failed to load module obdecho"
12142 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
12143 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12144 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12147 run_test 180b "test obdecho directly on obdfilter"
12149 test_180c() { # LU-2598
12150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12151 remote_ost_nodsh && skip "remote OST with nodsh" && return
12152 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12153 skip "Need MDS version at least 2.4.0" && return
12156 local rmmod_remote=false
12157 local pages=16384 # 64MB bulk I/O RPC size
12160 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12161 rmmod_remote=true || error "failed to load module obdecho"
12163 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
12165 if [ -n "$target" ]; then
12166 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12168 echo "there is no obdfilter target on ost1"
12171 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12174 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12176 test_181() { # bug 22177
12177 test_mkdir $DIR/$tdir
12178 # create enough files to index the directory
12179 createmany -o $DIR/$tdir/foobar 4000
12180 # print attributes for debug purpose
12183 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12185 # remove the files & current working dir
12186 unlinkmany $DIR/$tdir/foobar 4000
12188 kill -USR1 $MULTIPID
12190 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12193 run_test 181 "Test open-unlinked dir ========================"
12199 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12201 $LCTL set_param mdc.*.rpc_stats=clear
12203 for (( i = 0; i < $tcount; i++ )) ; do
12204 mkdir $DIR/$tdir/$i
12207 for (( i = 0; i < $tcount; i++ )) ; do
12208 createmany -o $DIR/$tdir/$i/f- $fcount &
12212 for (( i = 0; i < $tcount; i++ )) ; do
12213 unlinkmany $DIR/$tdir/$i/f- $fcount &
12217 $LCTL get_param mdc.*.rpc_stats
12221 run_test 182 "Test parallel modify metadata operations ================"
12223 test_183() { # LU-2275
12224 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12225 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12226 skip "Need MDS version at least 2.3.56" && return
12228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12229 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12230 echo aaa > $DIR/$tdir/$tfile
12232 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12233 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12235 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12236 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12238 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12240 # Flush negative dentry cache
12241 touch $DIR/$tdir/$tfile
12243 # We are not checking for any leaked references here, they'll
12244 # become evident next time we do cleanup with module unload.
12247 run_test 183 "No crash or request leak in case of strange dispositions ========"
12249 # test suite 184 is for LU-2016, LU-2017
12251 check_swap_layouts_support && return 0
12253 dir0=$DIR/$tdir/$testnum
12254 test_mkdir -p -c1 $dir0
12259 $SETSTRIPE -c1 $file1
12261 $SETSTRIPE -c2 $file2
12263 gen1=$($GETSTRIPE -g $file1)
12264 gen2=$($GETSTRIPE -g $file2)
12266 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12267 gen=$($GETSTRIPE -g $file1)
12268 [[ $gen1 != $gen ]] ||
12269 "Layout generation on $file1 does not change"
12270 gen=$($GETSTRIPE -g $file2)
12271 [[ $gen2 != $gen ]] ||
12272 "Layout generation on $file2 does not change"
12274 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12275 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12277 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
12279 run_test 184a "Basic layout swap"
12282 check_swap_layouts_support && return 0
12284 dir0=$DIR/$tdir/$testnum
12285 mkdir -p $dir0 || error "creating dir $dir0"
12292 $SETSTRIPE -c1 $file1
12293 $SETSTRIPE -c2 $file2
12294 $SETSTRIPE -c1 $file3
12295 chown $RUNAS_ID $file3
12296 gen1=$($GETSTRIPE -g $file1)
12297 gen2=$($GETSTRIPE -g $file2)
12299 $LFS swap_layouts $dir1 $dir2 &&
12300 error "swap of directories layouts should fail"
12301 $LFS swap_layouts $dir1 $file1 &&
12302 error "swap of directory and file layouts should fail"
12303 $RUNAS $LFS swap_layouts $file1 $file2 &&
12304 error "swap of file we cannot write should fail"
12305 $LFS swap_layouts $file1 $file3 &&
12306 error "swap of file with different owner should fail"
12307 /bin/true # to clear error code
12309 run_test 184b "Forbidden layout swap (will generate errors)"
12312 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12313 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12314 check_swap_layouts_support && return 0
12316 local dir0=$DIR/$tdir/$testnum
12317 mkdir -p $dir0 || error "creating dir $dir0"
12319 local ref1=$dir0/ref1
12320 local ref2=$dir0/ref2
12321 local file1=$dir0/file1
12322 local file2=$dir0/file2
12323 # create a file large enough for the concurrent test
12324 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12325 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12326 echo "ref file size: ref1($(stat -c %s $ref1))," \
12327 "ref2($(stat -c %s $ref2))"
12330 dd if=$ref1 of=$file1 bs=16k &
12333 # Make sure dd starts to copy file
12334 while [ ! -f $file1 ]; do sleep 0.1; done
12336 $LFS swap_layouts $file1 $file2
12339 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12340 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12342 # how many bytes copied before swapping layout
12343 local copied=$(stat -c %s $file2)
12344 local remaining=$(stat -c %s $ref1)
12345 remaining=$((remaining - copied))
12346 echo "Copied $copied bytes before swapping layout..."
12348 cmp -n $copied $file1 $ref2 | grep differ &&
12349 error "Content mismatch [0, $copied) of ref2 and file1"
12350 cmp -n $copied $file2 $ref1 ||
12351 error "Content mismatch [0, $copied) of ref1 and file2"
12352 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12353 error "Content mismatch [$copied, EOF) of ref1 and file1"
12356 rm -f $ref1 $ref2 $file1 $file2
12358 run_test 184c "Concurrent write and layout swap"
12361 check_swap_layouts_support && return 0
12362 [ -z "$(which getfattr 2>/dev/null)" ] &&
12363 skip "no getfattr command" && return 0
12365 local file1=$DIR/$tdir/$tfile-1
12366 local file2=$DIR/$tdir/$tfile-2
12367 local file3=$DIR/$tdir/$tfile-3
12371 mkdir -p $DIR/$tdir
12372 touch $file1 || error "create $file1 failed"
12373 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12374 error "create $file2 failed"
12375 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12376 error "create $file3 failed"
12377 lovea1=$(get_layout_param $file1)
12379 $LFS swap_layouts $file2 $file3 ||
12380 error "swap $file2 $file3 layouts failed"
12381 $LFS swap_layouts $file1 $file2 ||
12382 error "swap $file1 $file2 layouts failed"
12384 lovea2=$(get_layout_param $file2)
12387 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12389 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12390 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12392 run_test 184d "allow stripeless layouts swap"
12395 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12396 { skip "Need MDS version at least 2.6.94"; return 0; }
12397 check_swap_layouts_support && return 0
12398 [ -z "$(which getfattr 2>/dev/null)" ] &&
12399 skip "no getfattr command" && return 0
12401 local file1=$DIR/$tdir/$tfile-1
12402 local file2=$DIR/$tdir/$tfile-2
12403 local file3=$DIR/$tdir/$tfile-3
12406 mkdir -p $DIR/$tdir
12407 touch $file1 || error "create $file1 failed"
12408 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12409 error "create $file2 failed"
12410 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12411 error "create $file3 failed"
12413 $LFS swap_layouts $file1 $file2 ||
12414 error "swap $file1 $file2 layouts failed"
12416 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12417 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12419 echo 123 > $file1 || error "Should be able to write into $file1"
12421 $LFS swap_layouts $file1 $file3 ||
12422 error "swap $file1 $file3 layouts failed"
12424 echo 123 > $file1 || error "Should be able to write into $file1"
12426 rm -rf $file1 $file2 $file3
12428 run_test 184e "Recreate layout after stripeless layout swaps"
12430 test_185() { # LU-2441
12431 # LU-3553 - no volatile file support in old servers
12432 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12433 { skip "Need MDS version at least 2.3.60"; return 0; }
12435 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12436 touch $DIR/$tdir/spoo
12437 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12438 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12439 error "cannot create/write a volatile file"
12440 [ "$FILESET" == "" ] &&
12441 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12442 error "FID is still valid after close"
12444 multiop_bg_pause $DIR/$tdir vVw4096_c
12451 # assume that the next FID for this client is sequential, since stdout
12452 # is unfortunately eaten by multiop_bg_pause
12453 local n=$((${fidv[1]} + 1))
12454 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12455 if [ "$FILESET" == "" ]; then
12456 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12457 error "FID is missing before close"
12459 kill -USR1 $multi_pid
12460 # 1 second delay, so if mtime change we will see it
12462 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12463 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12465 run_test 185 "Volatile file support"
12468 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12469 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12470 skip "Need MDS version at least 2.3.0" && return
12472 local dir0=$DIR/$tdir/$testnum
12473 mkdir -p $dir0 || error "creating dir $dir0"
12475 local file=$dir0/file1
12476 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12477 local dv1=$($LFS data_version $file)
12478 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12479 local dv2=$($LFS data_version $file)
12480 [[ $dv1 != $dv2 ]] ||
12481 error "data version did not change on write $dv1 == $dv2"
12486 run_test 187a "Test data version change"
12489 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12490 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12491 skip "Need MDS version at least 2.3.0" && return
12493 local dir0=$DIR/$tdir/$testnum
12494 mkdir -p $dir0 || error "creating dir $dir0"
12496 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12497 [[ ${DV[0]} != ${DV[1]} ]] ||
12498 error "data version did not change on write"\
12499 " ${DV[0]} == ${DV[1]}"
12504 run_test 187b "Test data version change on volatile file"
12507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12508 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12509 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12511 local POOL=${POOL:-cea1}
12512 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12513 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12516 local last_ost=$(($OSTCOUNT - 1))
12518 local ost_list=$(seq $first_ost $ost_step $last_ost)
12519 local ost_range="$first_ost $last_ost $ost_step"
12520 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12521 local file_dir=$POOL_ROOT/file_tst
12522 local subdir=$test_path/subdir
12525 if ! combined_mgs_mds ; then
12530 # former test_200a test_200b
12531 pool_add $POOL || { rc=$? ; break; }
12532 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12533 # former test_200c test_200d
12534 mkdir -p $test_path
12535 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12536 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12538 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12539 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12540 || { rc=$? ; break; }
12541 # former test_200e test_200f
12542 local files=$((OSTCOUNT*3))
12543 pool_alloc_files $POOL $test_path $files "$ost_list" \
12544 || { rc=$? ; break; }
12545 pool_create_files $POOL $file_dir $files "$ost_list" \
12546 || { rc=$? ; break; }
12547 # former test_200g test_200h
12548 pool_lfs_df $POOL || { rc=$? ; break; }
12549 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12551 # former test_201a test_201b test_201c
12552 pool_remove_first_target $POOL || { rc=$? ; break; }
12554 local f=$test_path/$tfile
12555 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12556 pool_remove $POOL $f || { rc=$? ; break; }
12562 if ! combined_mgs_mds ; then
12567 run_test 200 "OST pools"
12569 # usage: default_attr <count | size | offset>
12571 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12574 # usage: check_default_stripe_attr
12575 check_default_stripe_attr() {
12576 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12579 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12581 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12585 error "unknown getstripe attr '$1'"
12588 [ $ACTUAL == $EXPECTED ] ||
12589 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12593 test_mkdir $DIR/$tdir
12594 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12596 check_default_stripe_attr --stripe-count
12597 check_default_stripe_attr --stripe-size
12598 check_default_stripe_attr --stripe-index
12600 run_test 204a "Print default stripe attributes"
12603 test_mkdir $DIR/$tdir
12604 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12606 check_default_stripe_attr --stripe-size
12607 check_default_stripe_attr --stripe-index
12609 run_test 204b "Print default stripe size and offset"
12612 test_mkdir $DIR/$tdir
12613 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12615 check_default_stripe_attr --stripe-count
12616 check_default_stripe_attr --stripe-index
12618 run_test 204c "Print default stripe count and offset"
12621 test_mkdir $DIR/$tdir
12622 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12624 check_default_stripe_attr --stripe-count
12625 check_default_stripe_attr --stripe-size
12627 run_test 204d "Print default stripe count and size"
12630 test_mkdir $DIR/$tdir
12631 $SETSTRIPE -d $DIR/$tdir
12633 check_default_stripe_attr --stripe-count --raw
12634 check_default_stripe_attr --stripe-size --raw
12635 check_default_stripe_attr --stripe-index --raw
12637 run_test 204e "Print raw stripe attributes"
12640 test_mkdir $DIR/$tdir
12641 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12643 check_default_stripe_attr --stripe-size --raw
12644 check_default_stripe_attr --stripe-index --raw
12646 run_test 204f "Print raw stripe size and offset"
12649 test_mkdir $DIR/$tdir
12650 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12652 check_default_stripe_attr --stripe-count --raw
12653 check_default_stripe_attr --stripe-index --raw
12655 run_test 204g "Print raw stripe count and offset"
12658 test_mkdir $DIR/$tdir
12659 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12661 check_default_stripe_attr --stripe-count --raw
12662 check_default_stripe_attr --stripe-size --raw
12664 run_test 204h "Print raw stripe count and size"
12666 # Figure out which job scheduler is being used, if any,
12667 # or use a fake one
12668 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12669 JOBENV=SLURM_JOB_ID
12670 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12672 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12674 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12675 JOBENV=LOADL_STEP_ID
12676 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12679 $LCTL list_param jobid_name > /dev/null 2>&1
12680 if [ $? -eq 0 ]; then
12687 verify_jobstats() {
12692 # we don't really need to clear the stats for this test to work, since each
12693 # command has a unique jobid, but it makes debugging easier if needed.
12694 # for facet in $facets; do
12695 # local dev=$(convert_facet2label $facet)
12696 # # clear old jobstats
12697 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12700 # use a new JobID for each test, or we might see an old one
12701 [ "$JOBENV" = "FAKE_JOBID" ] &&
12702 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12706 [ "$JOBENV" = "nodelocal" ] && {
12707 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12708 $LCTL set_param jobid_name=$FAKE_JOBID
12712 log "Test: ${cmd[*]}"
12713 log "Using JobID environment variable $JOBENV=$JOBVAL"
12715 if [ $JOBENV = "FAKE_JOBID" ]; then
12716 FAKE_JOBID=$JOBVAL ${cmd[*]}
12721 # all files are created on OST0000
12722 for facet in $facets; do
12723 local stats="*.$(convert_facet2label $facet).job_stats"
12724 if [ $(do_facet $facet lctl get_param $stats |
12725 grep -c $JOBVAL) -ne 1 ]; then
12726 do_facet $facet lctl get_param $stats
12727 error "No jobstats for $JOBVAL found on $facet::$stats"
12734 NEW_JOBENV=${1:-$OLD_JOBENV}
12735 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12736 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12741 do_facet $SINGLEMDS \
12742 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12743 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12747 test_205() { # Job stats
12748 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12749 { skip "Need MDS version with at least 2.7.1"; return 0; }
12751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12752 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12753 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12754 remote_ost_nodsh && skip "remote OST with nodsh" && return
12756 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12757 skip "Server doesn't support jobstats" && return 0
12758 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12760 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12761 if [ $OLD_JOBENV != $JOBENV ]; then
12762 jobstats_set $JOBENV
12763 trap cleanup_205 EXIT
12766 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12767 echo "Registered as changelog user $CL_USER"
12769 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12770 lctl get_param -n mdt.*.job_cleanup_interval)
12771 local interval_new=5
12772 do_facet $SINGLEMDS \
12773 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12774 local start=$SECONDS
12778 cmd="mkdir $DIR/$tdir"
12779 verify_jobstats "$cmd" "$SINGLEMDS"
12781 cmd="rmdir $DIR/$tdir"
12782 verify_jobstats "$cmd" "$SINGLEMDS"
12783 # mkdir on secondary MDT
12784 if [ $MDSCOUNT -gt 1 ]; then
12785 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12786 verify_jobstats "$cmd" "mds2"
12789 cmd="mknod $DIR/$tfile c 1 3"
12790 verify_jobstats "$cmd" "$SINGLEMDS"
12792 cmd="rm -f $DIR/$tfile"
12793 verify_jobstats "$cmd" "$SINGLEMDS"
12794 # create all files on OST0000 so verify_jobstats can find OST stats
12796 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12797 verify_jobstats "$cmd" "$SINGLEMDS"
12799 cmd="touch $DIR/$tfile"
12800 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12802 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12803 verify_jobstats "$cmd" "ost1"
12805 cancel_lru_locks osc
12806 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12807 verify_jobstats "$cmd" "ost1"
12809 cmd="$TRUNCATE $DIR/$tfile 0"
12810 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12812 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12813 verify_jobstats "$cmd" "$SINGLEMDS"
12814 # jobstats expiry - sleep until old stats should be expired
12815 local left=$((interval_new + 5 - (SECONDS - start)))
12816 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12817 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12819 cmd="mkdir $DIR/$tdir.expire"
12820 verify_jobstats "$cmd" "$SINGLEMDS"
12821 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12822 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12824 # Ensure that jobid are present in changelog (if supported by MDS)
12825 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12827 $LFS changelog $MDT0 | tail -9
12828 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12829 [ $jobids -eq 9 ] ||
12830 error "Wrong changelog jobid count $jobids != 9"
12834 jobstats_set $JOBENV
12836 $LFS changelog $MDT0 | tail -1
12837 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12838 [ $jobids -eq 0 ] ||
12839 error "Unexpected jobids when jobid_var=$JOBENV"
12844 run_test 205 "Verify job stats"
12846 # LU-1480, LU-1773 and LU-1657
12848 mkdir -p $DIR/$tdir
12849 $SETSTRIPE -c -1 $DIR/$tdir
12850 #define OBD_FAIL_LOV_INIT 0x1403
12851 $LCTL set_param fail_loc=0xa0001403
12852 $LCTL set_param fail_val=1
12853 touch $DIR/$tdir/$tfile || true
12855 run_test 206 "fail lov_init_raid0() doesn't lbug"
12858 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12859 local fsz=`stat -c %s $DIR/$tfile`
12860 cancel_lru_locks mdc
12862 # do not return layout in getattr intent
12863 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12864 $LCTL set_param fail_loc=0x170
12865 local sz=`stat -c %s $DIR/$tfile`
12867 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12871 run_test 207a "can refresh layout at glimpse"
12874 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12875 local cksum=`md5sum $DIR/$tfile`
12876 local fsz=`stat -c %s $DIR/$tfile`
12877 cancel_lru_locks mdc
12878 cancel_lru_locks osc
12880 # do not return layout in getattr intent
12881 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12882 $LCTL set_param fail_loc=0x171
12884 # it will refresh layout after the file is opened but before read issues
12885 echo checksum is "$cksum"
12886 echo "$cksum" |md5sum -c --quiet || error "file differs"
12890 run_test 207b "can refresh layout at open"
12893 # FIXME: in this test suite, only RD lease is used. This is okay
12894 # for now as only exclusive open is supported. After generic lease
12895 # is done, this test suite should be revised. - Jinshan
12897 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12898 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12899 { skip "Need MDS version at least 2.4.52"; return 0; }
12901 echo "==== test 1: verify get lease work"
12902 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12904 echo "==== test 2: verify lease can be broken by upcoming open"
12905 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12909 $MULTIOP $DIR/$tfile oO_RDONLY:c
12910 kill -USR1 $PID && wait $PID || error "break lease error"
12912 echo "==== test 3: verify lease can't be granted if an open already exists"
12913 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12917 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12918 kill -USR1 $PID && wait $PID || error "open file error"
12920 echo "==== test 4: lease can sustain over recovery"
12921 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12927 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12929 echo "==== test 5: lease broken can't be regained by replay"
12930 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12934 # open file to break lease and then recovery
12935 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12938 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12942 run_test 208 "Exclusive open"
12945 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12946 skip_env "must have disp_stripe" && return
12949 sync; sleep 5; sync;
12951 echo 3 > /proc/sys/vm/drop_caches
12952 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12954 # open/close 500 times
12955 for i in $(seq 500); do
12959 echo 3 > /proc/sys/vm/drop_caches
12960 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12962 echo "before: $req_before, after: $req_after"
12963 [ $((req_after - req_before)) -ge 300 ] &&
12964 error "open/close requests are not freed"
12967 run_test 209 "read-only open/close requests should be freed promptly"
12971 size=$((size % 8192 + 1))
12972 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12973 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12974 rm -f $DIR/f212 $DIR/f212.xyz
12976 run_test 212 "Sendfile test ============================================"
12979 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12980 cancel_lru_locks osc
12981 lctl set_param fail_loc=0x8000040f
12982 # generate a read lock
12983 cat $DIR/$tfile > /dev/null
12984 # write to the file, it will try to cancel the above read lock.
12985 cat /etc/hosts >> $DIR/$tfile
12987 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12989 test_214() { # for bug 20133
12990 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12991 for (( i=0; i < 340; i++ )) ; do
12992 touch $DIR/$tdir/d214c/a$i
12995 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12996 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12997 ls $DIR/d214c || error "ls $DIR/d214c failed"
12998 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12999 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
13001 run_test 214 "hash-indexed directory test - bug 20133"
13003 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
13004 create_lnet_proc_files() {
13005 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
13008 # counterpart of create_lnet_proc_files
13009 remove_lnet_proc_files() {
13010 rm -f $TMP/lnet_$1.sys
13013 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13014 # 3rd arg as regexp for body
13015 check_lnet_proc_stats() {
13016 local l=$(cat "$TMP/lnet_$1" |wc -l)
13017 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
13019 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
13022 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13023 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
13024 # optional and can be regexp for 2nd line (lnet.routes case)
13025 check_lnet_proc_entry() {
13026 local blp=2 # blp stands for 'position of 1st line of body'
13027 [ -z "$5" ] || blp=3 # lnet.routes case
13029 local l=$(cat "$TMP/lnet_$1" |wc -l)
13030 # subtracting one from $blp because the body can be empty
13031 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
13033 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
13034 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
13036 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
13037 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
13039 # bail out if any unexpected line happened
13040 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
13041 [ "$?" != 0 ] || error "$2 misformatted"
13044 test_215() { # for bugs 18102, 21079, 21517
13045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13046 local N='(0|[1-9][0-9]*)' # non-negative numeric
13047 local P='[1-9][0-9]*' # positive numeric
13048 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
13049 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
13050 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
13051 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
13053 local L1 # regexp for 1st line
13054 local L2 # regexp for 2nd line (optional)
13055 local BR # regexp for the rest (body)
13057 # lnet.stats should look as 11 space-separated non-negative numerics
13058 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
13059 create_lnet_proc_files "stats"
13060 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
13061 remove_lnet_proc_files "stats"
13063 # lnet.routes should look like this:
13064 # Routing disabled/enabled
13065 # net hops priority state router
13066 # where net is a string like tcp0, hops > 0, priority >= 0,
13067 # state is up/down,
13068 # router is a string like 192.168.1.1@tcp2
13069 L1="^Routing (disabled|enabled)$"
13070 L2="^net +hops +priority +state +router$"
13071 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
13072 create_lnet_proc_files "routes"
13073 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
13074 remove_lnet_proc_files "routes"
13076 # lnet.routers should look like this:
13077 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
13078 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
13079 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
13080 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
13081 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
13082 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
13083 create_lnet_proc_files "routers"
13084 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
13085 remove_lnet_proc_files "routers"
13087 # lnet.peers should look like this:
13088 # nid refs state last max rtr min tx min queue
13089 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
13090 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
13091 # numeric (0 or >0 or <0), queue >= 0.
13092 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
13093 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
13094 create_lnet_proc_files "peers"
13095 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
13096 remove_lnet_proc_files "peers"
13098 # lnet.buffers should look like this:
13099 # pages count credits min
13100 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
13101 L1="^pages +count +credits +min$"
13102 BR="^ +$N +$N +$I +$I$"
13103 create_lnet_proc_files "buffers"
13104 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
13105 remove_lnet_proc_files "buffers"
13107 # lnet.nis should look like this:
13108 # nid status alive refs peer rtr max tx min
13109 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
13110 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
13111 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
13112 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
13113 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
13114 create_lnet_proc_files "nis"
13115 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
13116 remove_lnet_proc_files "nis"
13118 # can we successfully write to lnet.stats?
13119 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
13121 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
13123 test_216() { # bug 20317
13124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13125 remote_ost_nodsh && skip "remote OST with nodsh" && return
13128 local facets=$(get_facets OST)
13129 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13131 save_lustre_params client "osc.*.contention_seconds" > $p
13132 save_lustre_params $facets \
13133 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13134 save_lustre_params $facets \
13135 "ldlm.namespaces.filter-*.contended_locks" >> $p
13136 save_lustre_params $facets \
13137 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13138 clear_stats osc.*.osc_stats
13140 # agressive lockless i/o settings
13141 do_nodes $(comma_list $(osts_nodes)) \
13142 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13143 ldlm.namespaces.filter-*.contended_locks=0 \
13144 ldlm.namespaces.filter-*.contention_seconds=60"
13145 lctl set_param -n osc.*.contention_seconds=60
13147 $DIRECTIO write $DIR/$tfile 0 10 4096
13148 $CHECKSTAT -s 40960 $DIR/$tfile
13150 # disable lockless i/o
13151 do_nodes $(comma_list $(osts_nodes)) \
13152 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13153 ldlm.namespaces.filter-*.contended_locks=32 \
13154 ldlm.namespaces.filter-*.contention_seconds=0"
13155 lctl set_param -n osc.*.contention_seconds=0
13156 clear_stats osc.*.osc_stats
13158 dd if=/dev/zero of=$DIR/$tfile count=0
13159 $CHECKSTAT -s 0 $DIR/$tfile
13161 restore_lustre_params <$p
13165 run_test 216 "check lockless direct write updates file size and kms correctly"
13167 test_217() { # bug 22430
13168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13172 for node in $(nodes_list); do
13173 nid=$(host_nids_address $node $NETTYPE)
13174 if [[ $nid = *-* ]] ; then
13175 echo "lctl ping $(h2nettype $nid)"
13176 lctl ping $(h2nettype $nid)
13178 echo "skipping $node (no hyphen detected)"
13182 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13185 # do directio so as not to populate the page cache
13186 log "creating a 10 Mb file"
13187 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13188 log "starting reads"
13189 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13190 log "truncating the file"
13191 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13193 kill %+ || true # reads might have finished
13194 echo "wait until dd is finished"
13196 log "removing the temporary file"
13197 rm -rf $DIR/$tfile || error "tmp file removal failed"
13199 run_test 218 "parallel read and truncate should not deadlock ======================="
13202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13203 # write one partial page
13204 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13205 # set no grant so vvp_io_commit_write will do sync write
13206 $LCTL set_param fail_loc=0x411
13207 # write a full page at the end of file
13208 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13210 $LCTL set_param fail_loc=0
13211 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13212 $LCTL set_param fail_loc=0x411
13213 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13216 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13217 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13219 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13221 test_220() { #LU-325
13222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13223 remote_ost_nodsh && skip "remote OST with nodsh" && return
13224 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13225 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13228 # create on MDT0000 so the last_id and next_id are correct
13230 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13234 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13235 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13236 osc.$mdtosc_proc1.prealloc_last_id)
13237 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13238 osc.$mdtosc_proc1.prealloc_next_id)
13242 if ! combined_mgs_mds ; then
13246 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13247 #define OBD_FAIL_OST_ENOINO 0x229
13248 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13249 create_pool $FSNAME.$TESTNAME || return 1
13250 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13252 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13254 MDSOBJS=$((last_id - next_id))
13255 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13257 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13258 echo "OST still has $count kbytes free"
13260 echo "create $MDSOBJS files @next_id..."
13261 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13263 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13264 osc.$mdtosc_proc1.prealloc_last_id)
13265 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13266 osc.$mdtosc_proc1.prealloc_next_id)
13268 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13273 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13274 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13276 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
13277 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
13278 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
13279 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
13280 echo "unlink $MDSOBJS files @$next_id..."
13281 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
13283 if ! combined_mgs_mds ; then
13287 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13291 dd if=`which date` of=$MOUNT/date oflag=sync
13292 chmod +x $MOUNT/date
13294 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13295 $LCTL set_param fail_loc=0x80001401
13297 $MOUNT/date > /dev/null
13300 run_test 221 "make sure fault and truncate race to not cause OOM"
13303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13305 test_mkdir $DIR/$tdir
13306 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13307 createmany -o $DIR/$tdir/$tfile 10
13308 cancel_lru_locks mdc
13309 cancel_lru_locks osc
13310 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13311 $LCTL set_param fail_loc=0x31a
13312 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13313 $LCTL set_param fail_loc=0
13316 run_test 222a "AGL for ls should not trigger CLIO lock failure"
13319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13321 test_mkdir $DIR/$tdir
13322 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13323 createmany -o $DIR/$tdir/$tfile 10
13324 cancel_lru_locks mdc
13325 cancel_lru_locks osc
13326 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13327 $LCTL set_param fail_loc=0x31a
13328 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13329 $LCTL set_param fail_loc=0
13331 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
13334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13336 test_mkdir $DIR/$tdir
13337 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13338 createmany -o $DIR/$tdir/$tfile 10
13339 cancel_lru_locks mdc
13340 cancel_lru_locks osc
13341 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13342 $LCTL set_param fail_loc=0x31b
13343 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13344 $LCTL set_param fail_loc=0
13347 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13349 test_224a() { # LU-1039, MRP-303
13350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13351 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13352 $LCTL set_param fail_loc=0x508
13353 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13354 $LCTL set_param fail_loc=0
13357 run_test 224a "Don't panic on bulk IO failure"
13359 test_224b() { # LU-1039, MRP-303
13360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13361 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13362 cancel_lru_locks osc
13363 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13364 $LCTL set_param fail_loc=0x515
13365 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13366 $LCTL set_param fail_loc=0
13369 run_test 224b "Don't panic on bulk IO failure"
13371 test_224c() { # LU-6441
13372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13373 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13375 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13376 save_writethrough $p
13377 set_cache writethrough on
13379 local pages_per_rpc=$($LCTL get_param \
13380 osc.*.max_pages_per_rpc)
13381 local at_max=$($LCTL get_param -n at_max)
13382 local timeout=$($LCTL get_param -n timeout)
13383 local test_at="$LCTL get_param -n at_max"
13384 local param_at="$FSNAME.sys.at_max"
13385 local test_timeout="$LCTL get_param -n timeout"
13386 local param_timeout="$FSNAME.sys.timeout"
13388 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13390 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13391 error "conf_param at_max=0 failed"
13392 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13393 error "conf_param timeout=5 failed"
13395 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13396 do_facet ost1 $LCTL set_param fail_loc=0x520
13397 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13398 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13400 do_facet ost1 $LCTL set_param fail_loc=0
13402 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13403 error "conf_param at_max=$at_max failed"
13404 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13405 $timeout || error "conf_param timeout=$timeout failed"
13407 $LCTL set_param -n $pages_per_rpc
13408 restore_lustre_params < $p
13411 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13413 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13415 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13416 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13417 if [ -z ${MDSSURVEY} ]; then
13418 skip_env "mds-survey not found" && return
13421 [ $MDSCOUNT -ge 2 ] &&
13422 skip "skipping now for more than one MDT" && return
13424 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13425 { skip "Need MDS version at least 2.2.51"; return; }
13427 local mds=$(facet_host $SINGLEMDS)
13428 local target=$(do_nodes $mds 'lctl dl' | \
13429 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13431 local cmd1="file_count=1000 thrhi=4"
13432 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13433 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13434 local cmd="$cmd1 $cmd2 $cmd3"
13436 rm -f ${TMP}/mds_survey*
13438 eval $cmd || error "mds-survey with zero-stripe failed"
13439 cat ${TMP}/mds_survey*
13440 rm -f ${TMP}/mds_survey*
13442 run_test 225a "Metadata survey sanity with zero-stripe"
13445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13446 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13447 if [ -z ${MDSSURVEY} ]; then
13448 skip_env "mds-survey not found" && return
13450 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13451 { skip "Need MDS version at least 2.2.51"; return; }
13453 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13454 skip_env "Need to mount OST to test" && return
13457 local mds=$(facet_host $SINGLEMDS)
13458 local target=$(do_nodes $mds 'lctl dl' | \
13459 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13461 local cmd1="file_count=1000 thrhi=4"
13462 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13463 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13464 local cmd="$cmd1 $cmd2 $cmd3"
13466 rm -f ${TMP}/mds_survey*
13468 eval $cmd || error "mds-survey with stripe_count failed"
13469 cat ${TMP}/mds_survey*
13470 rm -f ${TMP}/mds_survey*
13472 run_test 225b "Metadata survey sanity with stripe_count = 1"
13474 mcreate_path2fid () {
13480 local path=$DIR/$tdir/$name
13485 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13486 error "cannot create $desc"
13488 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13490 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13492 fid_path=$($LFS fid2path $MOUNT $fid)
13494 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13496 [ "$path" == "$fid_path" ] ||
13497 error "fid2path returned $fid_path, expected $path"
13499 echo "pass with $path and $fid"
13504 mkdir -p $DIR/$tdir
13506 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13507 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13508 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13509 mcreate_path2fid 0040666 0 0 dir "directory"
13510 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13511 mcreate_path2fid 0100666 0 0 file "regular file"
13512 mcreate_path2fid 0120666 0 0 link "symbolic link"
13513 mcreate_path2fid 0140666 0 0 sock "socket"
13515 run_test 226a "call path2fid and fid2path on files of all type"
13518 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13522 mkdir -p $DIR/$tdir
13523 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13524 error "create remote directory failed"
13525 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13526 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13527 "character special file (null)"
13528 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13529 "character special file (no device)"
13530 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13531 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13532 "block special file (loop)"
13533 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13534 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13535 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13537 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13539 # LU-1299 Executing or running ldd on a truncated executable does not
13540 # cause an out-of-memory condition.
13542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13543 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13544 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13545 chmod +x $MOUNT/date
13547 $MOUNT/date > /dev/null
13548 ldd $MOUNT/date > /dev/null
13551 run_test 227 "running truncated executable does not cause OOM"
13553 # LU-1512 try to reuse idle OI blocks
13555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13557 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13558 skip "ldiskfs only test" && return
13560 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13561 local myDIR=$DIR/$tdir
13564 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13565 $LCTL set_param fail_loc=0x80001002
13566 createmany -o $myDIR/t- 10000
13567 $LCTL set_param fail_loc=0
13568 # The guard is current the largest FID holder
13570 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13572 local IDX=$(($SEQ % 64))
13574 do_facet $SINGLEMDS sync
13575 # Make sure journal flushed.
13577 local blk1=$(do_facet $SINGLEMDS \
13578 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13579 grep Blockcount | awk '{print $4}')
13581 # Remove old files, some OI blocks will become idle.
13582 unlinkmany $myDIR/t- 10000
13583 # Create new files, idle OI blocks should be reused.
13584 createmany -o $myDIR/t- 2000
13585 do_facet $SINGLEMDS sync
13586 # Make sure journal flushed.
13588 local blk2=$(do_facet $SINGLEMDS \
13589 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13590 grep Blockcount | awk '{print $4}')
13592 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13594 run_test 228a "try to reuse idle OI blocks"
13597 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13598 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13599 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13600 skip "ldiskfs only test" && return
13602 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13603 local myDIR=$DIR/$tdir
13606 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13607 $LCTL set_param fail_loc=0x80001002
13608 createmany -o $myDIR/t- 10000
13609 $LCTL set_param fail_loc=0
13610 # The guard is current the largest FID holder
13612 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13614 local IDX=$(($SEQ % 64))
13616 do_facet $SINGLEMDS sync
13617 # Make sure journal flushed.
13619 local blk1=$(do_facet $SINGLEMDS \
13620 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13621 grep Blockcount | awk '{print $4}')
13623 # Remove old files, some OI blocks will become idle.
13624 unlinkmany $myDIR/t- 10000
13627 stop $SINGLEMDS || error "Fail to stop MDT."
13629 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13631 df $MOUNT || error "Fail to df."
13632 # Create new files, idle OI blocks should be reused.
13633 createmany -o $myDIR/t- 2000
13634 do_facet $SINGLEMDS sync
13635 # Make sure journal flushed.
13637 local blk2=$(do_facet $SINGLEMDS \
13638 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13639 grep Blockcount | awk '{print $4}')
13641 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13643 run_test 228b "idle OI blocks can be reused after MDT restart"
13647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13648 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13649 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13650 skip "ldiskfs only test" && return
13652 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13653 local myDIR=$DIR/$tdir
13656 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13657 $LCTL set_param fail_loc=0x80001002
13658 # 20000 files can guarantee there are index nodes in the OI file
13659 createmany -o $myDIR/t- 20000
13660 $LCTL set_param fail_loc=0
13661 # The guard is current the largest FID holder
13663 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13665 local IDX=$(($SEQ % 64))
13667 do_facet $SINGLEMDS sync
13668 # Make sure journal flushed.
13670 local blk1=$(do_facet $SINGLEMDS \
13671 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13672 grep Blockcount | awk '{print $4}')
13674 # Remove old files, some OI blocks will become idle.
13675 unlinkmany $myDIR/t- 20000
13677 # The OI file should become empty now
13679 # Create new files, idle OI blocks should be reused.
13680 createmany -o $myDIR/t- 2000
13681 do_facet $SINGLEMDS sync
13682 # Make sure journal flushed.
13684 local blk2=$(do_facet $SINGLEMDS \
13685 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13686 grep Blockcount | awk '{print $4}')
13688 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13690 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13692 test_229() { # LU-2482, LU-3448
13693 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13694 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13697 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13701 # Create a file with a released layout and stripe count 2.
13702 $MULTIOP $DIR/$tfile H2c ||
13703 error "failed to create file with released layout"
13705 $GETSTRIPE -v $DIR/$tfile
13707 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13708 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
13710 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13711 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13712 stat $DIR/$tfile || error "failed to stat released file"
13714 chown $RUNAS_ID $DIR/$tfile ||
13715 error "chown $RUNAS_ID $DIR/$tfile failed"
13717 chgrp $RUNAS_ID $DIR/$tfile ||
13718 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13720 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13721 rm $DIR/$tfile || error "failed to remove released file"
13723 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13727 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13730 test_mkdir $DIR/$tdir
13731 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13732 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13733 [ $mdt_idx -ne 0 ] &&
13734 error "create local directory on wrong MDT $mdt_idx"
13736 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13737 error "create remote directory failed"
13738 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13739 [ $mdt_idx -ne $MDTIDX ] &&
13740 error "create remote directory on wrong MDT $mdt_idx"
13742 createmany -o $DIR/$tdir/test_230/t- 10 ||
13743 error "create files on remote directory failed"
13744 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13745 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13746 rm -r $DIR/$tdir || error "unlink remote directory failed"
13748 run_test 230a "Create remote directory and files under the remote directory"
13751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13752 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13759 local migrate_dir=$DIR/$tdir/migrate_dir
13760 local other_dir=$DIR/$tdir/other_dir
13762 test_mkdir $DIR/$tdir
13763 test_mkdir -i0 -c1 $migrate_dir
13764 test_mkdir -i0 -c1 $other_dir
13765 for ((i=0; i<10; i++)); do
13766 mkdir -p $migrate_dir/dir_${i}
13767 createmany -o $migrate_dir/dir_${i}/f 10 ||
13768 error "create files under remote dir failed $i"
13771 cp /etc/passwd $migrate_dir/$tfile
13772 cp /etc/passwd $other_dir/$tfile
13773 chattr +SAD $migrate_dir
13774 chattr +SAD $migrate_dir/$tfile
13776 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13777 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13778 local old_dir_mode=$(stat -c%f $migrate_dir)
13779 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13781 mkdir -p $migrate_dir/dir_default_stripe2
13782 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13783 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13785 mkdir -p $other_dir
13786 ln $migrate_dir/$tfile $other_dir/luna
13787 ln $migrate_dir/$tfile $migrate_dir/sofia
13788 ln $other_dir/$tfile $migrate_dir/david
13789 ln -s $migrate_dir/$tfile $other_dir/zachary
13790 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13791 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13793 $LFS migrate -m $MDTIDX $migrate_dir ||
13794 error "fails on migrating remote dir to MDT1"
13796 echo "migratate to MDT1, then checking.."
13797 for ((i = 0; i < 10; i++)); do
13798 for file in $(find $migrate_dir/dir_${i}); do
13799 mdt_index=$($LFS getstripe -M $file)
13800 [ $mdt_index == $MDTIDX ] ||
13801 error "$file is not on MDT${MDTIDX}"
13805 # the multiple link file should still in MDT0
13806 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13807 [ $mdt_index == 0 ] ||
13808 error "$file is not on MDT${MDTIDX}"
13810 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13811 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13812 error " expect $old_dir_flag get $new_dir_flag"
13814 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13815 [ "$old_file_flag" = "$new_file_flag" ] ||
13816 error " expect $old_file_flag get $new_file_flag"
13818 local new_dir_mode=$(stat -c%f $migrate_dir)
13819 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13820 error "expect mode $old_dir_mode get $new_dir_mode"
13822 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13823 [ "$old_file_mode" = "$new_file_mode" ] ||
13824 error "expect mode $old_file_mode get $new_file_mode"
13826 diff /etc/passwd $migrate_dir/$tfile ||
13827 error "$tfile different after migration"
13829 diff /etc/passwd $other_dir/luna ||
13830 error "luna different after migration"
13832 diff /etc/passwd $migrate_dir/sofia ||
13833 error "sofia different after migration"
13835 diff /etc/passwd $migrate_dir/david ||
13836 error "david different after migration"
13838 diff /etc/passwd $other_dir/zachary ||
13839 error "zachary different after migration"
13841 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13842 error "${tfile}_ln different after migration"
13844 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13845 error "${tfile}_ln_other different after migration"
13847 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13848 [ $stripe_count = 2 ] ||
13849 error "dir strpe_count $d != 2 after migration."
13851 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13852 [ $stripe_count = 2 ] ||
13853 error "file strpe_count $d != 2 after migration."
13855 #migrate back to MDT0
13858 $LFS migrate -m $MDTIDX $migrate_dir ||
13859 error "fails on migrating remote dir to MDT0"
13861 echo "migrate back to MDT0, checking.."
13862 for file in $(find $migrate_dir); do
13863 mdt_index=$($LFS getstripe -M $file)
13864 [ $mdt_index == $MDTIDX ] ||
13865 error "$file is not on MDT${MDTIDX}"
13868 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13869 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13870 error " expect $old_dir_flag get $new_dir_flag"
13872 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13873 [ "$old_file_flag" = "$new_file_flag" ] ||
13874 error " expect $old_file_flag get $new_file_flag"
13876 local new_dir_mode=$(stat -c%f $migrate_dir)
13877 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13878 error "expect mode $old_dir_mode get $new_dir_mode"
13880 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13881 [ "$old_file_mode" = "$new_file_mode" ] ||
13882 error "expect mode $old_file_mode get $new_file_mode"
13884 diff /etc/passwd ${migrate_dir}/$tfile ||
13885 error "$tfile different after migration"
13887 diff /etc/passwd ${other_dir}/luna ||
13888 error "luna different after migration"
13890 diff /etc/passwd ${migrate_dir}/sofia ||
13891 error "sofia different after migration"
13893 diff /etc/passwd ${other_dir}/zachary ||
13894 error "zachary different after migration"
13896 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13897 error "${tfile}_ln different after migration"
13899 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13900 error "${tfile}_ln_other different after migration"
13902 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13903 [ $stripe_count = 2 ] ||
13904 error "dir strpe_count $d != 2 after migration."
13906 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13907 [ $stripe_count = 2 ] ||
13908 error "file strpe_count $d != 2 after migration."
13910 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13912 run_test 230b "migrate directory"
13915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13916 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13921 local migrate_dir=$DIR/$tdir/migrate_dir
13923 #If migrating directory fails in the middle, all entries of
13924 #the directory is still accessiable.
13925 test_mkdir $DIR/$tdir
13926 test_mkdir -i0 -c1 $migrate_dir
13928 createmany -o $migrate_dir/f 10 ||
13929 error "create files under ${migrate_dir} failed"
13931 #failed after migrating 5 entries
13932 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13933 do_facet mds1 lctl set_param fail_loc=0x20001801
13934 do_facet mds1 lctl set_param fail_val=5
13935 local t=$(ls $migrate_dir | wc -l)
13936 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13937 error "migrate should fail after 5 entries"
13939 mkdir $migrate_dir/dir &&
13940 error "mkdir succeeds under migrating directory"
13941 touch $migrate_dir/file &&
13942 error "touch file succeeds under migrating directory"
13944 local u=$(ls $migrate_dir | wc -l)
13945 [ "$u" == "$t" ] || error "$u != $t during migration"
13947 for file in $(find $migrate_dir); do
13948 stat $file || error "stat $file failed"
13951 do_facet mds1 lctl set_param fail_loc=0
13952 do_facet mds1 lctl set_param fail_val=0
13954 $LFS migrate -m $MDTIDX $migrate_dir ||
13955 error "migrate open files should failed with open files"
13957 echo "Finish migration, then checking.."
13958 for file in $(find $migrate_dir); do
13959 mdt_index=$($LFS getstripe -M $file)
13960 [ $mdt_index == $MDTIDX ] ||
13961 error "$file is not on MDT${MDTIDX}"
13964 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13966 run_test 230c "check directory accessiblity if migration is failed"
13969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13970 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13973 local migrate_dir=$DIR/$tdir/migrate_dir
13977 test_mkdir $DIR/$tdir
13978 test_mkdir -i0 -c1 $migrate_dir
13980 for ((i=0; i<100; i++)); do
13981 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13982 createmany -o $migrate_dir/dir_${i}/f 100 ||
13983 error "create files under remote dir failed $i"
13986 $LFS migrate -m $MDTIDX $migrate_dir ||
13987 error "migrate remote dir error"
13989 echo "Finish migration, then checking.."
13990 for file in $(find $migrate_dir); do
13991 mdt_index=$($LFS getstripe -M $file)
13992 [ $mdt_index == $MDTIDX ] ||
13993 error "$file is not on MDT${MDTIDX}"
13996 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13998 run_test 230d "check migrate big directory"
14001 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14002 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14008 mkdir -p $DIR/$tdir
14009 mkdir $DIR/$tdir/migrate_dir
14010 mkdir $DIR/$tdir/other_dir
14011 touch $DIR/$tdir/migrate_dir/a
14012 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
14013 ls $DIR/$tdir/other_dir
14015 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14016 error "migrate dir fails"
14018 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14019 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14021 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14022 [ $mdt_index == 0 ] || error "a is not on MDT0"
14024 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
14025 error "migrate dir fails"
14027 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
14028 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
14030 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14031 [ $mdt_index == 1 ] || error "a is not on MDT1"
14033 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
14034 [ $mdt_index == 1 ] || error "b is not on MDT1"
14036 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14037 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
14039 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
14041 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14043 run_test 230e "migrate mulitple local link files"
14046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14047 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14051 mkdir -p $DIR/$tdir
14052 mkdir $DIR/$tdir/migrate_dir
14053 $LFS mkdir -i1 $DIR/$tdir/other_dir
14054 touch $DIR/$tdir/migrate_dir/a
14055 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
14056 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
14057 ls $DIR/$tdir/other_dir
14059 # a should be migrated to MDT1, since no other links on MDT0
14060 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14061 error "#1 migrate dir fails"
14062 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14063 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14064 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14065 [ $mdt_index == 1 ] || error "a is not on MDT1"
14067 # a should stay on MDT1, because it is a mulitple link file
14068 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14069 error "#2 migrate dir fails"
14070 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14071 [ $mdt_index == 1 ] || error "a is not on MDT1"
14073 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14074 error "#3 migrate dir fails"
14076 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14077 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
14078 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
14080 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
14081 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
14083 # a should be migrated to MDT0, since no other links on MDT1
14084 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14085 error "#4 migrate dir fails"
14086 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14087 [ $mdt_index == 0 ] || error "a is not on MDT0"
14089 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14091 run_test 230f "migrate mulitple remote link files"
14094 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14095 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14097 mkdir -p $DIR/$tdir/migrate_dir
14099 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
14100 error "migrating dir to non-exist MDT succeeds"
14103 run_test 230g "migrate dir to non-exist MDT"
14106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14107 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14108 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
14109 skip "Need MDS version at least 2.7.64" && return
14112 mkdir -p $DIR/$tdir/migrate_dir
14114 $LFS migrate -m1 $DIR &&
14115 error "migrating mountpoint1 should fail"
14117 $LFS migrate -m1 $DIR/$tdir/.. &&
14118 error "migrating mountpoint2 should fail"
14120 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
14121 error "migrating $tdir fail"
14123 mdt_index=$($LFS getstripe -M $DIR/$tdir)
14124 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14126 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14127 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14130 run_test 230h "migrate .. and root"
14133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14134 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14136 mkdir -p $DIR/$tdir/migrate_dir
14138 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
14139 error "migration fails with a tailing slash"
14141 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14142 error "migration fails with two tailing slashes"
14144 run_test 230i "lfs migrate -m tolerates trailing slashes"
14148 # For simplicity this test assumes that max_pages_per_rpc
14149 # is the same across all OSCs
14150 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14151 local bulk_size=$((max_pages * 4096))
14152 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14155 mkdir -p $DIR/$tdir
14156 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14157 error "failed to set stripe with -S ${brw_size}M option"
14159 # clear the OSC stats
14160 $LCTL set_param osc.*.stats=0 &>/dev/null
14163 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14164 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14165 oflag=direct &>/dev/null || error "dd failed"
14167 sync; sleep 1; sync # just to be safe
14168 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14169 if [ x$nrpcs != "x1" ]; then
14170 $LCTL get_param osc.*.stats
14171 error "found $nrpcs ost_write RPCs, not 1 as expected"
14175 # Drop the OSC cache, otherwise we will read from it
14176 cancel_lru_locks osc
14178 # clear the OSC stats
14179 $LCTL set_param osc.*.stats=0 &>/dev/null
14181 # Client reads $bulk_size.
14182 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14183 iflag=direct &>/dev/null || error "dd failed"
14185 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14186 if [ x$nrpcs != "x1" ]; then
14187 $LCTL get_param osc.*.stats
14188 error "found $nrpcs ost_read RPCs, not 1 as expected"
14191 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14194 mkdir -p $DIR/$tdir
14196 for i in {0..1023}; do
14197 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14198 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14199 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14203 run_test 231b "must not assert on fully utilized OST request buffer"
14206 mkdir -p $DIR/$tdir
14207 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14209 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14210 do_facet ost1 $LCTL set_param fail_loc=0x31c
14212 # ignore dd failure
14213 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
14215 do_facet ost1 $LCTL set_param fail_loc=0
14216 umount_client $MOUNT || error "umount failed"
14217 mount_client $MOUNT || error "mount failed"
14218 stop ost1 || error "cannot stop ost1"
14219 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
14221 run_test 232a "failed lock should not block umount"
14224 mkdir -p $DIR/$tdir
14225 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14226 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
14228 cancel_lru_locks osc
14230 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14231 do_facet ost1 $LCTL set_param fail_loc=0x31c
14234 $LFS data_version $DIR/$tdir/$tfile || true
14236 do_facet ost1 $LCTL set_param fail_loc=0
14237 umount_client $MOUNT || error "umount failed"
14238 mount_client $MOUNT || error "mount failed"
14239 stop ost1 || error "cannot stop ost1"
14240 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
14242 run_test 232b "failed data version lock should not block umount"
14245 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14246 { skip "Need MDS version at least 2.3.64"; return; }
14247 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14249 local fid=$($LFS path2fid $MOUNT)
14250 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14251 error "cannot access $MOUNT using its FID '$fid'"
14253 run_test 233a "checking that OBF of the FS root succeeds"
14256 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14257 { skip "Need MDS version at least 2.5.90"; return; }
14258 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14260 local fid=$($LFS path2fid $MOUNT/.lustre)
14261 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14262 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14264 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14265 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14266 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14268 run_test 233b "checking that OBF of the FS .lustre succeeds"
14271 local p="$TMP/sanityN-$TESTNAME.parameters"
14272 save_lustre_params client "llite.*.xattr_cache" > $p
14273 lctl set_param llite.*.xattr_cache 1 ||
14274 { skip "xattr cache is not supported"; return 0; }
14276 mkdir -p $DIR/$tdir || error "mkdir failed"
14277 touch $DIR/$tdir/$tfile || error "touch failed"
14278 # OBD_FAIL_LLITE_XATTR_ENOMEM
14279 $LCTL set_param fail_loc=0x1405
14280 # output of the form: attr 2 4 44 3 fc13 x86_64
14281 V=($(IFS=".-" rpm -q attr))
14282 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
14283 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
14284 # attr pre-2.4.44-7 had a bug with rc
14285 # LU-3703 - SLES 11 and FC13 clients have older attr
14286 getfattr -n user.attr $DIR/$tdir/$tfile &&
14287 error "getfattr should have failed with ENOMEM"
14289 skip "LU-3703: attr version $(getfattr --version) too old"
14291 $LCTL set_param fail_loc=0x0
14294 restore_lustre_params < $p
14297 run_test 234 "xattr cache should not crash on ENOMEM"
14300 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14301 skip "Need MDS version at least 2.4.52" && return
14302 flock_deadlock $DIR/$tfile
14307 124) error "process hangs on a deadlock"
14309 *) error "error executing flock_deadlock $DIR/$tfile"
14313 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14317 check_swap_layouts_support && return 0
14318 test_mkdir -c1 $DIR/$tdir
14320 local ref1=/etc/passwd
14321 local ref2=/etc/group
14322 local file1=$DIR/$tdir/f1
14323 local file2=$DIR/$tdir/f2
14325 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14326 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14327 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14328 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14329 local fd=$(free_fd)
14330 local cmd="exec $fd<>$file2"
14333 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14334 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14337 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14342 run_test 236 "Layout swap on open unlinked file"
14344 # test to verify file handle related system calls
14345 # (name_to_handle_at/open_by_handle_at)
14346 # The new system calls are supported in glibc >= 2.14.
14349 echo "Test file_handle syscalls" > $DIR/$tfile ||
14350 error "write failed"
14351 check_fhandle_syscalls $DIR/$tfile ||
14352 error "check_fhandle_syscalls failed"
14354 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14356 # LU-4659 linkea consistency
14358 local server_version=$(lustre_version_code $SINGLEMDS)
14360 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14361 [[ $server_version -gt $(version_code 2.5.1) &&
14362 $server_version -lt $(version_code 2.5.50) ]] ||
14363 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14366 ln $DIR/$tfile $DIR/$tfile.lnk
14367 touch $DIR/$tfile.new
14368 mv $DIR/$tfile.new $DIR/$tfile
14369 local fid1=$($LFS path2fid $DIR/$tfile)
14370 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14371 local path1=$($LFS fid2path $FSNAME "$fid1")
14372 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14373 local path2=$($LFS fid2path $FSNAME "$fid2")
14374 [ $tfile.lnk == $path2 ] ||
14375 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14378 run_test 238 "Verify linkea consistency"
14381 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14382 skip "Need MDS version at least 2.5.60" && return
14383 local list=$(comma_list $(mdts_nodes))
14385 mkdir -p $DIR/$tdir
14386 createmany -o $DIR/$tdir/f- 5000
14387 unlinkmany $DIR/$tdir/f- 5000
14388 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
14389 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14390 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14391 osp.*MDT*.sync_in_flight" | calc_sum)
14392 [ "$changes" -eq 0 ] || error "$changes not synced"
14394 run_test 239 "osp_sync test"
14396 test_239a() { #LU-5297
14397 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14399 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14400 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14401 chgrp $RUNAS_GID $DIR/$tfile
14402 wait_delete_completed
14404 run_test 239a "process invalid osp sync record correctly"
14406 test_239b() { #LU-5297
14407 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14409 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14410 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14411 chgrp $RUNAS_GID $DIR/$tfile1
14412 wait_delete_completed
14413 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14415 chgrp $RUNAS_GID $DIR/$tfile2
14416 wait_delete_completed
14418 run_test 239b "process osp sync record with ENOMEM error correctly"
14421 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14422 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14424 mkdir -p $DIR/$tdir
14426 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14427 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14428 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14429 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14431 umount_client $MOUNT || error "umount failed"
14432 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14433 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14434 mount_client $MOUNT || error "failed to mount client"
14436 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14437 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14439 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14442 for LOOP in $(seq $1); do
14443 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14444 cancel_lru_locks $OSC || true
14449 for LOOP in $(seq $1); do
14450 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14451 iflag=direct 2>/dev/null
14455 test_241a() { # was test_241
14456 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14458 cancel_lru_locks $OSC
14459 test_241_bio 1000 &
14464 run_test 241a "bio vs dio"
14467 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14469 test_241_dio 1000 &
14474 run_test 241b "dio vs dio"
14477 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14478 mkdir -p $DIR/$tdir
14479 touch $DIR/$tdir/$tfile
14481 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14482 do_facet mds1 lctl set_param fail_loc=0x105
14483 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14485 do_facet mds1 lctl set_param fail_loc=0
14486 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14488 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14492 test_mkdir $DIR/$tdir
14493 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14495 run_test 243 "various group lock tests"
14499 test_mkdir $DIR/$tdir
14500 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14501 sendfile_grouplock $DIR/$tdir/$tfile || \
14502 error "sendfile+grouplock failed"
14505 run_test 244 "sendfile with group lock tests"
14508 local flagname="multi_mod_rpcs"
14509 local connect_data_name="max_mod_rpcs"
14512 # check if multiple modify RPCs flag is set
14513 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14514 grep "connect_flags:")
14517 echo "$out" | grep -qw $flagname
14518 if [ $? -ne 0 ]; then
14519 echo "connect flag $flagname is not set"
14523 # check if multiple modify RPCs data is set
14524 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14527 echo "$out" | grep -qw $connect_data_name ||
14528 error "import should have connect data $connect_data_name"
14530 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14532 test_246() { # LU-7371
14533 remote_ost_nodsh && skip "remote OST with nodsh" && return
14534 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14535 skip "Need OST version >= 2.7.62" && return 0
14536 do_facet ost1 $LCTL set_param fail_val=4095
14537 #define OBD_FAIL_OST_READ_SIZE 0x234
14538 do_facet ost1 $LCTL set_param fail_loc=0x234
14539 $LFS setstripe $DIR/$tfile -i 0 -c 1
14540 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14541 cancel_lru_locks $FSNAME-OST0000
14542 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14544 run_test 246 "Read file of size 4095 should return right length"
14550 umount_client $submount
14555 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14557 { skip "Fileset feature is not supported"; return; }
14559 local submount=${MOUNT}_$tdir
14562 mkdir -p $submount || error "mkdir $submount failed"
14563 FILESET="$FILESET/$tdir" mount_client $submount ||
14564 error "mount $submount failed"
14565 trap "cleanup_247 $submount" EXIT
14566 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14567 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14568 error "read $MOUNT/$tdir/$tfile failed"
14569 cleanup_247 $submount
14571 run_test 247a "mount subdir as fileset"
14574 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14575 { skip "Fileset feature is not supported"; return; }
14577 local submount=${MOUNT}_$tdir
14579 rm -rf $MOUNT/$tdir
14580 mkdir -p $submount || error "mkdir $submount failed"
14582 FILESET="$FILESET/$tdir" mount_client $submount &&
14583 error "mount $submount should fail"
14586 run_test 247b "mount subdir that dose not exist"
14589 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14590 { skip "Fileset feature is not supported"; return; }
14592 local submount=${MOUNT}_$tdir
14594 mkdir -p $MOUNT/$tdir/dir1
14595 mkdir -p $submount || error "mkdir $submount failed"
14596 trap "cleanup_247 $submount" EXIT
14597 FILESET="$FILESET/$tdir" mount_client $submount ||
14598 error "mount $submount failed"
14599 local fid=$($LFS path2fid $MOUNT/)
14600 $LFS fid2path $submount $fid && error "fid2path should fail"
14601 cleanup_247 $submount
14603 run_test 247c "running fid2path outside root"
14606 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14607 { skip "Fileset feature is not supported"; return; }
14609 local submount=${MOUNT}_$tdir
14611 mkdir -p $MOUNT/$tdir/dir1
14612 mkdir -p $submount || error "mkdir $submount failed"
14613 FILESET="$FILESET/$tdir" mount_client $submount ||
14614 error "mount $submount failed"
14615 trap "cleanup_247 $submount" EXIT
14616 local fid=$($LFS path2fid $submount/dir1)
14617 $LFS fid2path $submount $fid || error "fid2path should succeed"
14618 cleanup_247 $submount
14620 run_test 247d "running fid2path inside root"
14624 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14626 { skip "Fileset feature is not supported"; return; }
14628 local submount=${MOUNT}_$tdir
14631 mkdir -p $submount || error "mkdir $submount failed"
14632 FILESET="$FILESET/.." mount_client $submount &&
14633 error "mount $submount should fail"
14636 run_test 247e "mount .. as fileset"
14639 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14640 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14642 # create a large file for fast read verification
14643 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14645 # make sure the file is created correctly
14646 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14647 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14649 echo "Test 1: verify that fast read is 4 times faster on cache read"
14651 # small read with fast read enabled
14652 $LCTL set_param -n llite.*.fast_read=1
14653 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14654 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14655 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14656 # small read with fast read disabled
14657 $LCTL set_param -n llite.*.fast_read=0
14658 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14659 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14660 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14662 # verify that fast read is 4 times faster for cache read
14663 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14664 error_not_in_vm "fast read was not 4 times faster: " \
14665 "$t_fast vs $t_slow"
14667 echo "Test 2: verify the performance between big and small read"
14668 $LCTL set_param -n llite.*.fast_read=1
14670 # 1k non-cache read
14671 cancel_lru_locks osc
14672 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14673 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14674 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14676 # 1M non-cache read
14677 cancel_lru_locks osc
14678 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14679 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14680 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14682 # verify that big IO is not 4 times faster than small IO
14683 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14684 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14686 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14689 run_test 248 "fast read verification"
14691 test_249() { # LU-7890
14693 $SETSTRIPE -c 1 $DIR/$tfile
14695 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14696 skip "Need at least version 2.8.54"
14698 # Offset 2T == 4k * 512M
14699 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14700 error "dd to 2T offset failed"
14702 run_test 249 "Write above 2T file size"
14705 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14706 && skip "no 16TB file size limit on ZFS" && return
14708 $SETSTRIPE -c 1 $DIR/$tfile
14709 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14710 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14711 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14712 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14713 conv=notrunc,fsync && error "append succeeded"
14716 run_test 250 "Write above 16T limit"
14719 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14721 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14722 #Skip once - writing the first stripe will succeed
14723 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14724 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14725 error "short write happened"
14727 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14728 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14729 error "short read happened"
14733 run_test 251 "Handling short read and write correctly"
14743 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14744 remote_ost_nodsh && skip "remote OST with nodsh" && return
14745 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14746 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14747 skip "ldiskfs only test"
14751 # check lr_reader on OST0000
14753 dev=$(facet_device $tgt)
14754 out=$(do_facet $tgt $LR_READER $dev)
14755 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14757 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14758 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14759 error "Invalid uuid returned by $LR_READER on target $tgt"
14760 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14762 # check lr_reader -c on MDT0000
14764 dev=$(facet_device $tgt)
14765 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14766 echo "$LR_READER does not support additional options"
14769 out=$(do_facet $tgt $LR_READER -c $dev)
14770 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14772 num=$(echo "$out" | grep -c "mdtlov")
14773 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14774 error "Invalid number of mdtlov clients returned by $LR_READER"
14775 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14777 # check lr_reader -cr on MDT0000
14778 out=$(do_facet $tgt $LR_READER -cr $dev)
14779 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14781 echo "$out" | grep -q "^reply_data:$" ||
14782 error "$LR_READER should have returned 'reply_data' section"
14783 num=$(echo "$out" | grep -c "client_generation")
14784 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14786 run_test 252 "check lr_reader tool"
14788 test_253_fill_ost() {
14789 local size_mb #how many MB should we write to pass watermark
14790 local lwm=$3 #low watermark
14791 local free_10mb #10% of free space
14793 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14794 size_mb=$((free_kb / 1024 - lwm))
14795 free_10mb=$((free_kb / 10240))
14796 #If 10% of free space cross low watermark use it
14797 if (( free_10mb > size_mb )); then
14800 #At least we need to store 1.1 of difference between
14801 #free space and low watermark
14802 size_mb=$((size_mb + size_mb / 10))
14804 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14805 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14806 oflag=append conv=notrunc
14811 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14812 echo "OST still has $((free_kb / 1024)) mbytes free"
14819 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14820 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14821 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14823 local ost_name=$($LFS osts |
14824 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14826 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14827 do_facet $SINGLEMDS $LCTL get_param -n \
14828 osp.$mdtosc_proc1.reserved_mb_high ||
14829 { skip "remote MDS does not support reserved_mb_high" &&
14834 wait_delete_completed
14837 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14838 osp.$mdtosc_proc1.reserved_mb_high)
14839 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14840 osp.$mdtosc_proc1.reserved_mb_low)
14841 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14843 if ! combined_mgs_mds ; then
14846 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14847 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14848 error "Adding $ost_name to pool failed"
14850 # Wait for client to see a OST at pool
14851 wait_update $HOSTNAME "$LCTL get_param -n
14852 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14853 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14854 error "Client can not see the pool"
14855 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14856 error "Setstripe failed"
14858 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14859 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14860 echo "OST still has $((blocks/1024)) mbytes free"
14862 local new_lwm=$((blocks/1024-10))
14863 do_facet $SINGLEMDS $LCTL set_param \
14864 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14865 do_facet $SINGLEMDS $LCTL set_param \
14866 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14868 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14870 #First enospc could execute orphan deletion so repeat.
14871 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14873 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14874 osp.$mdtosc_proc1.prealloc_status)
14875 echo "prealloc_status $oa_status"
14877 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14878 error "File creation should fail"
14879 #object allocation was stopped, but we still able to append files
14880 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14881 error "Append failed"
14882 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14884 wait_delete_completed
14888 for i in $(seq 10 12); do
14889 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14890 error "File creation failed after rm";
14893 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14894 osp.$mdtosc_proc1.prealloc_status)
14895 echo "prealloc_status $oa_status"
14897 if (( oa_status != 0 )); then
14898 error "Object allocation still disable after rm"
14900 do_facet $SINGLEMDS $LCTL set_param \
14901 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14902 do_facet $SINGLEMDS $LCTL set_param \
14903 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14906 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14907 error "Remove $ost_name from pool failed"
14908 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14909 error "Pool destroy fialed"
14911 if ! combined_mgs_mds ; then
14915 run_test 253 "Check object allocation limit"
14920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14921 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14922 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14923 { skip "MDS does not support changelog_size" && return; }
14925 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14926 echo "Registered as changelog user $cl_user"
14928 $LFS changelog_clear $MDT0 $cl_user 0
14930 local size1=$(do_facet mds1 \
14931 $LCTL get_param -n mdd.$MDT0.changelog_size)
14932 echo "Changelog size $size1"
14935 $LFS mkdir -i 0 $DIR/$tdir
14937 mkdir -p $DIR/$tdir/pics/2008/zachy
14938 touch $DIR/$tdir/pics/2008/zachy/timestamp
14939 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
14940 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14941 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14942 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14943 rm $DIR/$tdir/pics/desktop.jpg
14945 local size2=$(do_facet mds1 \
14946 $LCTL get_param -n mdd.$MDT0.changelog_size)
14947 echo "Changelog size after work $size2"
14949 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14951 if (( size2 <= size1 )); then
14952 error "Changelog size after work should be greater than original"
14956 run_test 254 "Check changelog size"
14963 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
14964 awk -F: '{print $2}' | grep $type > /dev/null
14965 if [ $? -ne 0 ]; then
14975 lfs ladvise -a willread $file > /dev/null 2>&1
14976 if [ $? -eq 0 ]; then
14980 lfs ladvise -a willread $file 2>&1 |
14981 grep "Inappropriate ioctl for device" > /dev/null
14982 if [ $? -eq 0 ]; then
14989 bc <<<"scale=2; ($1 - $2) * 100 / $2"
14992 # run a random read IO workload
14993 # usage: random_read_iops <filename> <filesize> <iosize>
14994 random_read_iops() {
14997 local iosize=${3:-4096}
14999 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
15000 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
15003 drop_file_oss_cache() {
15007 $LFS ladvise -a dontneed $file 2>/dev/null ||
15008 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
15011 ladvise_willread_performance()
15014 local average_origin=0
15015 local average_cache=0
15016 local average_ladvise=0
15018 for ((i = 1; i <= $repeat; i++)); do
15019 echo "Iter $i/$repeat: reading without willread hint"
15020 cancel_lru_locks osc
15021 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15022 local speed_origin=$(random_read_iops $DIR/$tfile $size)
15023 echo "Iter $i/$repeat: uncached speed: $speed_origin"
15024 average_origin=$(bc <<<"$average_origin + $speed_origin")
15026 cancel_lru_locks osc
15027 local speed_cache=$(random_read_iops $DIR/$tfile $size)
15028 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
15029 average_cache=$(bc <<<"$average_cache + $speed_cache")
15031 cancel_lru_locks osc
15032 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15033 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
15034 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
15035 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
15036 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
15038 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
15039 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
15040 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
15042 speedup_cache=$(percent $average_cache $average_origin)
15043 speedup_ladvise=$(percent $average_ladvise $average_origin)
15045 echo "Average uncached read: $average_origin"
15046 echo "Average speedup with OSS cached read: " \
15047 "$average_cache = +$speedup_cache%"
15048 echo "Average speedup with ladvise willread: " \
15049 "$average_ladvise = +$speedup_ladvise%"
15051 local lowest_speedup=20
15052 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
15053 echo "Speedup with OSS cached read less than $lowest_speedup%," \
15054 "got $average_cache%. Skipping ladvise willread check."
15058 # the test won't work on ZFS until it supports 'ladvise dontneed', but
15059 # it is still good to run until then to exercise 'ladvise willread'
15060 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15061 [ "$(facet_fstype ost1)" = "zfs" ] &&
15062 echo "osd-zfs does not support dontneed or drop_caches" &&
15065 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
15066 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
15067 error_not_in_vm "Speedup with willread is less than " \
15068 "$lowest_speedup%, got $average_ladvise%"
15072 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15073 skip "lustre < 2.8.54 does not support ladvise " && return
15074 remote_ost_nodsh && skip "remote OST with nodsh" && return
15076 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
15078 ladvise_no_type willread $DIR/$tfile &&
15079 skip "willread ladvise is not supported" && return
15081 ladvise_no_ioctl $DIR/$tfile &&
15082 skip "ladvise ioctl is not supported" && return
15085 local size=$((size_mb * 1048576))
15086 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15087 error "dd to $DIR/$tfile failed"
15089 lfs ladvise -a willread $DIR/$tfile ||
15090 error "Ladvise failed with no range argument"
15092 lfs ladvise -a willread -s 0 $DIR/$tfile ||
15093 error "Ladvise failed with no -l or -e argument"
15095 lfs ladvise -a willread -e 1 $DIR/$tfile ||
15096 error "Ladvise failed with only -e argument"
15098 lfs ladvise -a willread -l 1 $DIR/$tfile ||
15099 error "Ladvise failed with only -l argument"
15101 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
15102 error "End offset should not be smaller than start offset"
15104 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
15105 error "End offset should not be equal to start offset"
15107 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
15108 error "Ladvise failed with overflowing -s argument"
15110 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
15111 error "Ladvise failed with overflowing -e argument"
15113 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
15114 error "Ladvise failed with overflowing -l argument"
15116 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
15117 error "Ladvise succeeded with conflicting -l and -e arguments"
15119 echo "Synchronous ladvise should wait"
15121 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
15122 do_nodes $(comma_list $(osts_nodes)) \
15123 $LCTL set_param fail_val=$delay fail_loc=0x237
15125 local start_ts=$SECONDS
15126 lfs ladvise -a willread $DIR/$tfile ||
15127 error "Ladvise failed with no range argument"
15128 local end_ts=$SECONDS
15129 local inteval_ts=$((end_ts - start_ts))
15131 if [ $inteval_ts -lt $(($delay - 1)) ]; then
15132 error "Synchronous advice didn't wait reply"
15135 echo "Asynchronous ladvise shouldn't wait"
15136 local start_ts=$SECONDS
15137 lfs ladvise -a willread -b $DIR/$tfile ||
15138 error "Ladvise failed with no range argument"
15139 local end_ts=$SECONDS
15140 local inteval_ts=$((end_ts - start_ts))
15142 if [ $inteval_ts -gt $(($delay / 2)) ]; then
15143 error "Asynchronous advice blocked"
15146 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
15147 ladvise_willread_performance
15149 run_test 255a "check 'lfs ladvise -a willread'"
15155 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
15159 remote_ost_nodsh && skip "remote OST with nodsh" && return
15161 lfs setstripe -c 1 -i 0 $DIR/$tfile
15163 ladvise_no_type dontneed $DIR/$tfile &&
15164 skip "dontneed ladvise is not supported" && return
15166 ladvise_no_ioctl $DIR/$tfile &&
15167 skip "ladvise ioctl is not supported" && return
15169 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15170 skip "lustre < 2.8.54 does not support ladvise" && return
15172 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15173 [ "$(facet_fstype ost1)" = "zfs" ] &&
15174 skip "zfs-osd does not support 'ladvise dontneed'" && return
15177 local size=$((size_mb * 1048576))
15178 # In order to prevent disturbance of other processes, only check 3/4
15179 # of the memory usage
15180 local kibibytes=$((size_mb * 1024 * 3 / 4))
15182 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15183 error "dd to $DIR/$tfile failed"
15185 local total=$(facet_meminfo ost1 MemTotal)
15186 echo "Total memory: $total KiB"
15188 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15189 local before_read=$(facet_meminfo ost1 Cached)
15190 echo "Cache used before read: $before_read KiB"
15192 lfs ladvise -a willread $DIR/$tfile ||
15193 error "Ladvise willread failed"
15194 local after_read=$(facet_meminfo ost1 Cached)
15195 echo "Cache used after read: $after_read KiB"
15197 lfs ladvise -a dontneed $DIR/$tfile ||
15198 error "Ladvise dontneed again failed"
15199 local no_read=$(facet_meminfo ost1 Cached)
15200 echo "Cache used after dontneed ladvise: $no_read KiB"
15202 if [ $total -lt $((before_read + kibibytes)) ]; then
15203 echo "Memory is too small, abort checking"
15207 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15208 error "Ladvise willread should use more memory" \
15209 "than $kibibytes KiB"
15212 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15213 error "Ladvise dontneed should release more memory" \
15214 "than $kibibytes KiB"
15217 run_test 255b "check 'lfs ladvise -a dontneed'"
15226 [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] &&
15227 skip "lustre < 2.10.53 does not support lockahead" && return
15229 test_mkdir -p $DIR/$tdir
15230 $SETSTRIPE -i 0 $DIR/$tdir
15232 #test 10 returns only success/failure
15234 lockahead_test -d $DIR/$tdir -t $i
15236 if [ $rc -eq 255 ]; then
15237 error "Ladvise test${i} failed, ${rc}"
15240 #test 11 counts lock enqueue requests, all others count new locks
15242 count=$(do_facet ost1 \
15243 $LCTL get_param -n ost.OSS.ost.stats)
15244 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
15246 lockahead_test -d $DIR/$tdir -t $i
15248 if [ $rc -eq 255 ]; then
15249 error "Ladvise test${i} failed, ${rc}"
15252 new_count=$(do_facet ost1 \
15253 $LCTL get_param -n ost.OSS.ost.stats)
15254 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
15255 awk '{ print $2 }')
15257 difference="$((new_count - count))"
15258 if [ $difference -ne $rc ]; then
15259 error "Ladvise test${i}, bad enqueue count, returned " \
15260 "${rc}, actual ${difference}"
15263 for i in $(seq 12 21); do
15264 # If we do not do this, we run the risk of having too many
15265 # locks and starting lock cancellation while we are checking
15267 cancel_lru_locks osc
15269 count=$($LCTL get_param -n \
15270 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15272 lockahead_test -d $DIR/$tdir -t $i
15274 if [ $rc -eq 255 ]; then
15275 error "Ladvise test ${i} failed, ${rc}"
15278 new_count=$($LCTL get_param -n \
15279 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15280 difference="$((new_count - count))"
15282 # Test 15 output is divided by 100 to map down to valid return
15283 if [ $i -eq 15 ]; then
15287 if [ $difference -ne $rc ]; then
15288 error "Ladvise test ${i}, bad lock count, returned " \
15289 "${rc}, actual ${difference}"
15293 #test 22 returns only success/failure
15295 lockahead_test -d $DIR/$tdir -t $i
15297 if [ $rc -eq 255 ]; then
15298 error "Ladvise test${i} failed, ${rc}"
15302 run_test 255c "suite of ladvise lockahead tests"
15309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15310 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15311 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
15312 skip "ldiskfs only test" && return
15314 mdt_dev=$(mdsdevname 1)
15316 cl_user=$(do_facet mds1 \
15317 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
15318 if [[ -n $cl_user ]]; then
15319 skip "active changelog user"
15323 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15324 echo "Registered as changelog user $cl_user"
15327 mkdir -p $DIR/$tdir
15329 $LFS changelog_clear $MDT0 $cl_user 0
15332 touch $DIR/$tdir/{1..10}
15335 stop mds1 || error "Fail to stop MDT."
15338 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
15340 #after mount new plainllog is used
15341 touch $DIR/$tdir/{11..19}
15343 local TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
15344 cat_sl=$(do_facet mds1 \
15345 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15346 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15347 do_facet mds1 rm $TEMP256FILE
15349 if (( cat_sl != 2 )); then
15350 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15351 error "Changelog catalog has wrong number of slots $cat_sl"
15354 $LFS changelog_clear $MDT0 $cl_user 0
15357 TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
15358 cat_sl=$(do_facet mds1 \
15359 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15360 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15361 do_facet mds1 rm $TEMP256FILE
15363 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15365 if (( cat_sl == 2 )); then
15366 error "Empty plain llog was not deleted from changelog catalog"
15368 if (( cat_sl != 1 )); then
15369 error "Active plain llog shouldn\`t be deleted from catalog"
15372 run_test 256 "Check llog delete for empty and not full state"
15375 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15376 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15377 skip "Need MDS version at least 2.8.55" && return
15379 test_mkdir $DIR/$tdir
15381 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15382 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15385 #define OBD_FAIL_MDS_XATTR_REP 0x161
15386 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15387 local facet=mds$((mdtidx + 1))
15388 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15389 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15391 stop $facet || error "stop MDS failed"
15392 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15393 error "start MDS fail"
15395 run_test 257 "xattr locks are not lost"
15397 # Verify we take the i_mutex when security requires it
15399 #define OBD_FAIL_IMUTEX_SEC 0x141c
15400 $LCTL set_param fail_loc=0x141c
15402 chmod u+s $DIR/$tfile
15403 chmod a+rwx $DIR/$tfile
15404 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15406 if [ $RC -ne 0 ]; then
15407 error "error, failed to take i_mutex, rc=$?"
15413 # Verify we do NOT take the i_mutex in the normal case
15415 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15416 $LCTL set_param fail_loc=0x141d
15419 chmod a+rw $DIR/$tfile
15420 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15422 if [ $RC -ne 0 ]; then
15423 error "error, took i_mutex unnecessarily, rc=$?"
15428 run_test 258b "verify i_mutex security behavior"
15431 #define OBD_FAIL_MDC_CLOSE 0x806
15432 $LCTL set_param fail_loc=0x80000806
15436 run_test 260 "Check mdc_close fail"
15438 ### Data-on-MDT sanity tests ###
15441 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15442 skip "Need MDS version at least 2.10.55" && return
15445 local dom=$DIR/$tdir/dom_file
15446 local tmp=$DIR/$tdir/tmp_file
15448 mkdir -p $DIR/$tdir
15450 # basic checks for DoM component creation
15451 $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
15452 error "Can set MDT layout to non-first entry"
15454 $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
15455 error "Can define multiple entries as MDT layout"
15457 $LFS setstripe -E 1M -L mdt $dom ||
15458 error "Can't create DoM layout"
15460 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
15461 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
15462 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
15464 local mdtidx=$($GETSTRIPE -M $dom)
15465 local mdtname=MDT$(printf %04x $mdtidx)
15466 local facet=mds$((mdtidx + 1))
15467 local space_check=1
15469 # Skip free space checks with ZFS
15470 if [ "$(facet_fstype $facet)" == "zfs" ]; then
15476 local mdtfree1=$(do_facet $facet \
15477 lctl get_param -n osd*.*$mdtname.kbytesfree)
15478 dd if=/dev/urandom of=$tmp bs=1024 count=100
15479 # check also direct IO along write
15480 dd if=$tmp of=$dom bs=102400 count=1 oflag=direct
15482 cmp $tmp $dom || error "file data is different"
15483 [ $(stat -c%s $dom) == 102400 ] || error "bad size after write"
15484 if [ $space_check == 1 ]; then
15485 local mdtfree2=$(do_facet $facet \
15486 lctl get_param -n osd*.*$mdtname.kbytesfree)
15487 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15488 error "MDT free space is wrong after write"
15492 $TRUNCATE $dom 10000
15493 [ $(stat -c%s $dom) == 10000 ] || error "bad size after truncate"
15494 if [ $space_check == 1 ]; then
15495 mdtfree1=$(do_facet $facet \
15496 lctl get_param -n osd*.*$mdtname.kbytesfree)
15497 [ $(($mdtfree1 - $mdtfree2)) -ge 92 ] ||
15498 error "MDT free space is wrong after truncate"
15504 [ $(stat -c%s $dom) == 112400 ] || error "bad size after append"
15505 if [ $space_check == 1 ]; then
15506 mdtfree2=$(do_facet $facet \
15507 lctl get_param -n osd*.*$mdtname.kbytesfree)
15508 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15509 error "MDT free space is wrong after append"
15514 if [ $space_check == 1 ]; then
15515 mdtfree1=$(do_facet $facet \
15516 lctl get_param -n osd*.*$mdtname.kbytesfree)
15517 [ $(($mdtfree1 - $mdtfree2)) -ge 112 ] ||
15518 error "MDT free space is wrong after removal"
15521 # combined striping
15522 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
15523 error "Can't create DoM + OST striping"
15525 dd if=/dev/urandom of=$tmp bs=1024 count=2000
15526 # check also direct IO along write
15527 dd if=$tmp of=$dom bs=102400 count=20 oflag=direct
15529 cmp $tmp $dom || error "file data is different"
15530 [ $(stat -c%s $dom) == 2048000 ] || error "bad size after write"
15536 run_test 270a "DoM: basic functionality tests"
15539 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15540 skip "Need MDS version at least 2.10.55" && return
15542 local dom=$DIR/$tdir/dom_file
15543 local max_size=1048576
15545 mkdir -p $DIR/$tdir
15546 $LFS setstripe -E $max_size -L mdt $dom
15548 # truncate over the limit
15549 $TRUNCATE $dom $(($max_size + 1)) &&
15550 error "successful truncate over the maximum size"
15551 # write over the limit
15552 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
15553 error "successful write over the maximum size"
15554 # append over the limit
15555 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
15556 echo "12345" >> $dom && error "successful append over the maximum size"
15561 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
15564 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15565 skip "Need MDS version at least 2.10.55" && return
15567 mkdir -p $DIR/$tdir
15568 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15570 # check files inherit DoM EA
15571 touch $DIR/$tdir/first
15572 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
15573 error "bad pattern"
15574 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
15575 error "bad stripe count"
15576 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
15577 error "bad stripe size"
15579 # check directory inherits DoM EA and uses it as default
15580 mkdir $DIR/$tdir/subdir
15581 touch $DIR/$tdir/subdir/second
15582 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
15583 error "bad pattern in sub-directory"
15584 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
15585 error "bad stripe count in sub-directory"
15586 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
15587 error "bad stripe size in sub-directory"
15590 run_test 270c "DoM: DoM EA inheritance tests"
15593 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15594 skip "Need MDS version at least 2.10.55" && return
15596 mkdir -p $DIR/$tdir
15597 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15599 # inherit default DoM striping
15600 mkdir $DIR/$tdir/subdir
15601 touch $DIR/$tdir/subdir/f1
15603 # change default directory striping
15604 $LFS setstripe -c 1 $DIR/$tdir/subdir
15605 touch $DIR/$tdir/subdir/f2
15606 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
15607 error "wrong default striping in file 2"
15608 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
15609 error "bad pattern in file 2"
15612 run_test 270d "DoM: change striping from DoM to RAID0"
15615 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15616 skip "Need MDS version at least 2.10.55" && return
15618 mkdir -p $DIR/$tdir/dom
15619 mkdir -p $DIR/$tdir/norm
15622 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
15623 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
15625 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
15626 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
15628 # find DoM files by layout
15629 NUM=$($LFIND -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
15630 [ $NUM -eq $DOMFILES ] ||
15631 error "lfs find -L: found $NUM, expected $DOMFILES"
15632 echo "Test 1: lfs find 20 DOM files by layout: OK"
15634 # there should be 1 dir with default DOM striping
15635 NUM=$($LFIND -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
15637 error "lfs find -L: found $NUM, expected 1 dir"
15638 echo "Test 2: lfs find 1 DOM dir by layout: OK"
15640 # find DoM files by stripe size
15641 NUM=$($LFIND -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
15642 [ $NUM -eq $DOMFILES ] ||
15643 error "lfs find -S: found $NUM, expected $DOMFILES"
15644 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
15646 # find files by stripe offset except DoM files
15647 NUM=$($LFIND -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
15648 [ $NUM -eq $NORMFILES ] ||
15649 error "lfs find -i: found $NUM, expected $NORMFILES"
15650 echo "Test 5: lfs find no DOM files by stripe index: OK"
15653 run_test 270e "DoM: lfs find with DoM files test"
15656 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15657 skip "Need MDS version at least 2.10.55" && return
15659 local mdtname=${FSNAME}-MDT0000-mdtlov
15660 local dom=$DIR/$tdir/dom_file
15661 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
15662 lod.$mdtname.dom_stripesize)
15663 local dom_limit=131072
15665 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
15666 local dom_current=$(do_facet mds1 $LCTL get_param -n \
15667 lod.$mdtname.dom_stripesize)
15668 [ ${dom_limit} -eq ${dom_current} ] ||
15669 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
15671 $LFS mkdir -i 0 -c 1 $DIR/$tdir
15672 $LFS setstripe -d $DIR/$tdir
15673 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
15674 error "Can't set directory default striping"
15676 # exceed maximum stripe size
15677 $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
15678 error "Able to create DoM component size more than LOD limit"
15680 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
15681 dom_current=$(do_facet mds1 $LCTL get_param -n \
15682 lod.$mdtname.dom_stripesize)
15683 [ 0 -eq ${dom_current} ] ||
15684 error "Can't set zero DoM stripe limit"
15686 # too low values to be aligned with smallest stripe size 64K
15687 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
15688 dom_current=$(do_facet mds1 $LCTL get_param -n \
15689 lod.$mdtname.dom_stripesize)
15690 [ 30000 -eq ${dom_current} ] &&
15691 error "Can set too small DoM stripe limit"
15693 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
15694 dom_current=$(do_facet mds1 $LCTL get_param -n \
15695 lod.$mdtname.dom_stripesize)
15697 [ 2147483648 -eq ${dom_current} ] &&
15698 error "Can set too large DoM stripe limit"
15700 do_facet mds1 $LCTL set_param -n \
15701 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
15702 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
15703 error "Can't create DoM component size after limit change"
15704 do_facet mds1 $LCTL set_param -n \
15705 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
15706 $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
15707 error "Can create big DoM component after limit decrease"
15708 touch ${dom}_def ||
15709 error "Can't create file with old default layout"
15711 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
15714 run_test 270f "DoM: maximum DoM stripe size checks"
15717 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15718 skip "Need MDS version at least 2.10.55" && return
15720 local dom=$DIR/$tdir/dom
15722 mkdir -p $DIR/$tdir
15724 $LFS setstripe -E 1024K -L mdt $dom
15726 lctl set_param -n mdc.*.stats=clear
15727 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
15728 cat $dom > /dev/null
15729 local reads=$(lctl get_param -n mdc.*.stats |
15730 awk '/ost_read/ {print $2}')
15731 [ -z $reads ] || error "Unexpected $reads READ RPCs"
15735 run_test 271a "DoM: data is cached for read after write"
15738 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15739 skip "Need MDS version at least 2.10.55" && return
15741 local dom=$DIR/$tdir/dom
15743 mkdir -p $DIR/$tdir
15745 $LFS setstripe -E 1024K -L mdt -E EOF $dom
15747 lctl set_param -n mdc.*.stats=clear
15748 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
15749 cancel_lru_locks mdc
15750 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
15751 # second stat to check size is cached on client
15752 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
15753 local gls=$(lctl get_param -n mdc.*.stats |
15754 awk '/ldlm_glimpse/ {print $2}')
15755 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
15758 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
15761 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15762 skip "Need MDS version at least 2.10.55" && return
15764 local dom=$DIR/$tdir/dom
15766 mkdir -p $DIR/$tdir
15768 $LFS setstripe -E 1024K -L mdt -E EOF $dom
15770 lctl set_param -n mdc.*.stats=clear
15771 lctl set_param -n osc.*.stats=clear
15772 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
15773 cancel_lru_locks mdc
15774 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
15775 # second stat to check size is cached on client
15776 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
15777 local gls=$(lctl get_param -n mdc.*.stats |
15778 awk '/ldlm_glimpse/ {print $2}')
15779 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
15780 local gls=$(lctl get_param -n osc.*.stats |
15781 awk '/ldlm_glimpse/ {print $2}')
15782 [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
15785 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
15788 # test to be enabled with lock_convert
15789 skip "skipped until lock convert will be implemented" && return
15791 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15792 skip "Need MDS version at least 2.10.55" && return
15794 local dom=$DIR/$tdir/dom
15796 mkdir -p $DIR/$tdir
15798 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15800 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15801 local facet=mds$((mdtidx + 1))
15803 cancel_lru_locks mdc
15804 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
15805 createmany -o $dom 1000
15806 lctl set_param -n mdc.*.stats=clear
15807 smalliomany -w $dom 1000 200
15808 lctl get_param -n mdc.*.stats
15809 local enq=$(lctl get_param -n mdc.*.stats |
15810 awk '/ldlm_ibits_enqueue/ {print $2}')
15811 # Each file has 1 open, 1 IO enqueues, total 2000
15812 # but now we have also +1 getxattr for security.capability, total 3000
15813 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
15814 unlinkmany $dom 1000
15816 cancel_lru_locks mdc
15817 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
15818 createmany -o $dom 1000
15819 lctl set_param -n mdc.*.stats=clear
15820 smalliomany -w $dom 1000 200
15821 lctl get_param -n mdc.*.stats
15822 local enq_2=$(lctl get_param -n mdc.*.stats |
15823 awk '/ldlm_ibits_enqueue/ {print $2}')
15824 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
15825 # for OPEN and IO lock.
15826 [ $((enq - enq_2)) -ge 1000 ] ||
15827 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
15828 unlinkmany $dom 1000
15831 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
15833 cleanup_test_300() {
15837 test_striped_dir() {
15842 mkdir -p $DIR/$tdir
15844 SAVE_UMASK=$(umask)
15845 trap cleanup_test_300 RETURN EXIT
15847 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
15848 $DIR/$tdir/striped_dir ||
15849 error "set striped dir error"
15851 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
15852 [ "$mode" = "755" ] || error "expect 755 got $mode"
15854 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
15855 error "getdirstripe failed"
15856 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
15857 if [ "$stripe_count" != "2" ]; then
15858 error "1:stripe_count is $stripe_count, expect 2"
15860 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
15861 if [ "$stripe_count" != "2" ]; then
15862 error "2:stripe_count is $stripe_count, expect 2"
15865 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
15866 if [ "$stripe_index" != "$mdt_index" ]; then
15867 error "stripe_index is $stripe_index, expect $mdt_index"
15870 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15871 error "nlink error after create striped dir"
15873 mkdir $DIR/$tdir/striped_dir/a
15874 mkdir $DIR/$tdir/striped_dir/b
15876 stat $DIR/$tdir/striped_dir/a ||
15877 error "create dir under striped dir failed"
15878 stat $DIR/$tdir/striped_dir/b ||
15879 error "create dir under striped dir failed"
15881 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
15882 error "nlink error after mkdir"
15884 rmdir $DIR/$tdir/striped_dir/a
15885 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
15886 error "nlink error after rmdir"
15888 rmdir $DIR/$tdir/striped_dir/b
15889 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15890 error "nlink error after rmdir"
15892 chattr +i $DIR/$tdir/striped_dir
15893 createmany -o $DIR/$tdir/striped_dir/f 10 &&
15894 error "immutable flags not working under striped dir!"
15895 chattr -i $DIR/$tdir/striped_dir
15897 rmdir $DIR/$tdir/striped_dir ||
15898 error "rmdir striped dir error"
15906 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15907 skip "skipped for lustre < 2.7.0" && return
15908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15909 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15911 test_striped_dir 0 || error "failed on striped dir on MDT0"
15912 test_striped_dir 1 || error "failed on striped dir on MDT0"
15914 run_test 300a "basic striped dir sanity test"
15917 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15918 skip "skipped for lustre < 2.7.0" && return
15919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15920 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15926 test_mkdir $DIR/$tdir
15927 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15928 error "set striped dir error"
15929 for ((i=0; i<10; i++)); do
15930 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
15932 touch $DIR/$tdir/striped_dir/file_$i ||
15933 error "touch error $i"
15934 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
15935 [ $mtime1 -eq $mtime2 ] &&
15936 error "mtime not change after create"
15938 rm -f $DIR/$tdir/striped_dir/file_$i ||
15939 error "unlink error $i"
15940 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
15941 [ $mtime2 -eq $mtime3 ] &&
15942 error "mtime did not change after unlink"
15946 run_test 300b "check ctime/mtime for striped dir"
15949 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15950 skip "skipped for lustre < 2.7.0" && return
15951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15952 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15955 mkdir -p $DIR/$tdir
15956 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
15957 error "set striped dir error"
15959 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
15960 error "chown striped dir failed"
15962 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
15963 error "create 5k files failed"
15965 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
15967 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
15971 run_test 300c "chown && check ls under striped directory"
15974 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15975 skip "skipped for lustre < 2.7.0" && return
15976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15981 mkdir -p $DIR/$tdir
15982 $SETSTRIPE -c 2 $DIR/$tdir
15984 #local striped directory
15985 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15986 error "set striped dir error"
15987 createmany -o $DIR/$tdir/striped_dir/f 10 ||
15988 error "create 10 files failed"
15990 #remote striped directory
15991 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
15992 error "set striped dir error"
15993 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
15994 error "create 10 files failed"
15996 for file in $(find $DIR/$tdir); do
15997 stripe_count=$($GETSTRIPE -c $file)
15998 [ $stripe_count -eq 2 ] ||
15999 error "wrong stripe $stripe_count for $file"
16004 run_test 300d "check default stripe under striped directory"
16007 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16008 skip "Need MDS version at least 2.7.55" && return
16009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16010 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16014 mkdir -p $DIR/$tdir
16016 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16017 error "set striped dir error"
16019 touch $DIR/$tdir/striped_dir/a
16020 touch $DIR/$tdir/striped_dir/b
16021 touch $DIR/$tdir/striped_dir/c
16023 mkdir $DIR/$tdir/striped_dir/dir_a
16024 mkdir $DIR/$tdir/striped_dir/dir_b
16025 mkdir $DIR/$tdir/striped_dir/dir_c
16027 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
16028 error "set striped adir under striped dir error"
16030 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
16031 error "set striped bdir under striped dir error"
16033 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
16034 error "set striped cdir under striped dir error"
16036 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
16037 error "rename dir under striped dir fails"
16039 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
16040 error "rename dir under different stripes fails"
16042 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
16043 error "rename file under striped dir should succeed"
16045 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
16046 error "rename dir under striped dir should succeed"
16050 run_test 300e "check rename under striped directory"
16053 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16054 skip "Need MDS version at least 2.7.55" && return
16055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16056 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16061 mkdir -p $DIR/$tdir
16063 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16064 error "set striped dir error"
16066 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
16067 error "set striped dir error"
16069 touch $DIR/$tdir/striped_dir/a
16070 mkdir $DIR/$tdir/striped_dir/dir_a
16071 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
16072 error "create striped dir under striped dir fails"
16074 touch $DIR/$tdir/striped_dir1/b
16075 mkdir $DIR/$tdir/striped_dir1/dir_b
16076 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
16077 error "create striped dir under striped dir fails"
16079 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
16080 error "rename dir under different striped dir should fail"
16082 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
16083 error "rename striped dir under diff striped dir should fail"
16085 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
16086 error "rename file under diff striped dirs fails"
16090 run_test 300f "check rename cross striped directory"
16092 test_300_check_default_striped_dir()
16095 local default_count=$2
16096 local default_index=$3
16099 local dir_stripe_index
16102 echo "checking $dirname $default_count $default_index"
16103 $LFS setdirstripe -D -c $default_count -i $default_index \
16104 -t all_char $DIR/$tdir/$dirname ||
16105 error "set default stripe on striped dir error"
16106 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
16107 [ $stripe_count -eq $default_count ] ||
16108 error "expect $default_count get $stripe_count for $dirname"
16110 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
16111 [ $stripe_index -eq $default_index ] ||
16112 error "expect $default_index get $stripe_index for $dirname"
16114 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
16115 error "create dirs failed"
16117 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
16118 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
16119 for dir in $(find $DIR/$tdir/$dirname/*); do
16120 stripe_count=$($LFS getdirstripe -c $dir)
16121 [ $stripe_count -eq $default_count ] ||
16122 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
16123 error "stripe count $default_count != $stripe_count for $dir"
16125 stripe_index=$($LFS getdirstripe -i $dir)
16126 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
16127 error "$stripe_index != $default_index for $dir"
16129 #check default stripe
16130 stripe_count=$($LFS getdirstripe -D -c $dir)
16131 [ $stripe_count -eq $default_count ] ||
16132 error "default count $default_count != $stripe_count for $dir"
16134 stripe_index=$($LFS getdirstripe -D -i $dir)
16135 [ $stripe_index -eq $default_index ] ||
16136 error "default index $default_index != $stripe_index for $dir"
16138 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
16142 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16143 skip "Need MDS version at least 2.7.55" && return
16144 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16150 mkdir $DIR/$tdir/normal_dir
16152 #Checking when client cache stripe index
16153 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
16154 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
16155 error "create striped_dir failed"
16157 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
16158 error "create dir0 fails"
16159 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
16160 [ $stripe_index -eq 0 ] ||
16161 error "dir0 expect index 0 got $stripe_index"
16163 mkdir $DIR/$tdir/striped_dir/dir1 ||
16164 error "create dir1 fails"
16165 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
16166 [ $stripe_index -eq 1 ] ||
16167 error "dir1 expect index 1 got $stripe_index"
16169 #check default stripe count/stripe index
16170 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
16171 test_300_check_default_striped_dir normal_dir 1 0
16172 test_300_check_default_striped_dir normal_dir 2 1
16173 test_300_check_default_striped_dir normal_dir 2 -1
16175 #delete default stripe information
16176 echo "delete default stripeEA"
16177 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
16178 error "set default stripe on striped dir error"
16180 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
16181 for dir in $(find $DIR/$tdir/normal_dir/*); do
16182 stripe_count=$($LFS getdirstripe -c $dir)
16183 [ $stripe_count -eq 0 ] ||
16184 error "expect 1 get $stripe_count for $dir"
16185 stripe_index=$($LFS getdirstripe -i $dir)
16186 [ $stripe_index -eq 0 ] ||
16187 error "expect 0 get $stripe_index for $dir"
16190 run_test 300g "check default striped directory for normal directory"
16193 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16194 skip "Need MDS version at least 2.7.55" && return
16195 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16200 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
16201 $DIR/$tdir/striped_dir ||
16202 error "set striped dir error"
16204 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
16205 test_300_check_default_striped_dir striped_dir 1 0
16206 test_300_check_default_striped_dir striped_dir 2 1
16207 test_300_check_default_striped_dir striped_dir 2 -1
16209 #delete default stripe information
16210 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
16211 error "set default stripe on striped dir error"
16213 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
16214 for dir in $(find $DIR/$tdir/striped_dir/*); do
16215 stripe_count=$($LFS getdirstripe -c $dir)
16216 [ $stripe_count -eq 0 ] ||
16217 error "expect 1 get $stripe_count for $dir"
16220 run_test 300h "check default striped directory for striped directory"
16223 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16224 skip "Need MDS version at least 2.7.55" && return
16225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16226 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16232 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
16233 error "set striped dir error"
16235 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16236 error "create files under striped dir failed"
16238 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
16239 error "set striped hashdir error"
16241 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
16242 error "create dir0 under hash dir failed"
16243 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
16244 error "create dir1 under hash dir failed"
16246 # unfortunately, we need to umount to clear dir layout cache for now
16247 # once we fully implement dir layout, we can drop this
16248 umount_client $MOUNT || error "umount failed"
16249 mount_client $MOUNT || error "mount failed"
16251 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
16252 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
16253 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
16255 #set the stripe to be unknown hash type
16256 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
16257 $LCTL set_param fail_loc=0x1901
16258 for ((i = 0; i < 10; i++)); do
16259 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
16260 error "stat f-$i failed"
16261 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
16264 touch $DIR/$tdir/striped_dir/f0 &&
16265 error "create under striped dir with unknown hash should fail"
16267 $LCTL set_param fail_loc=0
16269 umount_client $MOUNT || error "umount failed"
16270 mount_client $MOUNT || error "mount failed"
16274 run_test 300i "client handle unknown hash type striped directory"
16277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16278 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16279 skip "Need MDS version at least 2.7.55" && return
16280 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16286 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
16287 $LCTL set_param fail_loc=0x1702
16288 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
16289 error "set striped dir error"
16291 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16292 error "create files under striped dir failed"
16294 $LCTL set_param fail_loc=0
16296 rm -rf $DIR/$tdir || error "unlink striped dir fails"
16300 run_test 300j "test large update record"
16303 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16304 skip "Need MDS version at least 2.7.55" && return
16305 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16306 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16312 #define OBD_FAIL_LARGE_STRIPE 0x1703
16313 $LCTL set_param fail_loc=0x1703
16314 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
16315 error "set striped dir error"
16316 $LCTL set_param fail_loc=0
16318 $LFS getdirstripe $DIR/$tdir/striped_dir ||
16319 error "getstripeddir fails"
16320 rm -rf $DIR/$tdir/striped_dir ||
16321 error "unlink striped dir fails"
16325 run_test 300k "test large striped directory"
16328 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16329 skip "Need MDS version at least 2.7.55" && return
16330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16331 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16334 test_mkdir -p $DIR/$tdir/striped_dir
16335 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
16336 error "chown $RUNAS_ID failed"
16337 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
16338 error "set default striped dir failed"
16340 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
16341 $LCTL set_param fail_loc=0x80000158
16342 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
16344 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
16345 [ $stripe_index -eq 1 ] ||
16346 error "expect 1 get $stripe_index for $dir"
16348 run_test 300l "non-root user to create dir under striped dir with stale layout"
16351 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16352 skip "Need MDS version at least 2.7.55" && return
16353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16354 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
16356 mkdir -p $DIR/$tdir/striped_dir
16357 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
16358 error "set default stripes dir error"
16360 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
16362 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
16363 [ $stripe_count -eq 0 ] ||
16364 error "expect 0 get $stripe_count for a"
16366 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
16367 error "set default stripes dir error"
16369 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
16371 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
16372 [ $stripe_count -eq 0 ] ||
16373 error "expect 0 get $stripe_count for b"
16375 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
16376 error "set default stripes dir error"
16378 mkdir $DIR/$tdir/striped_dir/c &&
16379 error "default stripe_index is invalid, mkdir c should fails"
16381 rm -rf $DIR/$tdir || error "rmdir fails"
16383 run_test 300m "setstriped directory on single MDT FS"
16386 local list=$(comma_list $(mdts_nodes))
16389 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16393 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16394 skip "Need MDS version at least 2.7.55" && return
16395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16396 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16397 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16400 local list=$(comma_list $(mdts_nodes))
16402 trap cleanup_300n RETURN EXIT
16403 mkdir -p $DIR/$tdir
16404 chmod 777 $DIR/$tdir
16405 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
16406 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16407 error "create striped dir succeeds with gid=0"
16409 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16410 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
16411 error "create striped dir fails with gid=-1"
16413 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16414 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
16415 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16416 error "set default striped dir succeeds with gid=0"
16419 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16420 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
16421 error "set default striped dir fails with gid=-1"
16424 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16425 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
16426 error "create test_dir fails"
16427 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
16428 error "create test_dir1 fails"
16429 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
16430 error "create test_dir2 fails"
16433 run_test 300n "non-root user to create dir under striped dir with default EA"
16436 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16437 skip "Need MDS version at least 2.7.55" && return
16438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16439 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16443 mkdir -p $DIR/$tdir
16445 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
16446 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
16447 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
16448 skip "not enough free inodes $numfree1 $numfree2"
16452 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
16453 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
16454 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
16455 skip "not enough free space $numfree1 $numfree2"
16459 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
16460 error "setdirstripe fails"
16462 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
16463 error "create dirs fails"
16465 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
16466 ls $DIR/$tdir/striped_dir > /dev/null ||
16467 error "ls striped dir fails"
16468 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
16469 error "unlink big striped dir fails"
16471 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
16474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16475 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16476 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16478 mkdir -p $DIR/$tdir
16480 #define OBD_FAIL_OUT_ENOSPC 0x1704
16481 do_facet mds2 lctl set_param fail_loc=0x80001704
16482 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
16483 error "create striped directory should fail"
16485 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
16487 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
16490 run_test 300p "create striped directory without space"
16493 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16494 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16496 local fd=$(free_fd)
16497 local cmd="exec $fd<$tdir"
16499 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
16502 trap "eval $cmd" EXIT
16503 cd $tdir || error "cd $tdir fails"
16504 rmdir ../$tdir || error "rmdir $tdir fails"
16505 mkdir local_dir && error "create dir succeeds"
16506 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
16510 run_test 300q "create remote directory under orphan directory"
16512 prepare_remote_file() {
16513 mkdir $DIR/$tdir/src_dir ||
16514 error "create remote source failed"
16516 cp /etc/hosts $DIR/$tdir/src_dir/a || error
16517 touch $DIR/$tdir/src_dir/a
16519 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
16520 error "create remote target dir failed"
16522 touch $DIR/$tdir/tgt_dir/b
16524 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
16525 error "rename dir cross MDT failed!"
16527 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
16528 error "src_child still exists after rename"
16530 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
16531 error "missing file(a) after rename"
16533 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
16534 error "diff after rename"
16538 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16540 local remote_file=$DIR/$tdir/tgt_dir/b
16542 mkdir -p $DIR/$tdir
16544 prepare_remote_file || error "prepare remote file failed"
16547 $OPENUNLINK $remote_file $remote_file || error
16548 $CHECKSTAT -a $remote_file || error
16550 run_test 310a "open unlink remote file"
16553 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16555 local remote_file=$DIR/$tdir/tgt_dir/b
16557 mkdir -p $DIR/$tdir
16559 prepare_remote_file || error "prepare remote file failed"
16561 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16562 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
16563 $CHECKSTAT -t file $remote_file || error "check file failed"
16565 run_test 310b "unlink remote file with multiple links while open"
16568 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
16569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16570 local remote_file=$DIR/$tdir/tgt_dir/b
16572 mkdir -p $DIR/$tdir
16574 prepare_remote_file || error "prepare remote file failed"
16576 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16577 multiop_bg_pause $remote_file O_uc ||
16578 error "mulitop failed for remote file"
16580 $MULTIOP $DIR/$tfile Ouc
16581 kill -USR1 $MULTIPID
16584 run_test 310c "open-unlink remote file with multiple links"
16588 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
16589 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
16590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16591 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16593 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16595 mkdir -p $DIR/$tdir
16596 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
16597 createmany -o $DIR/$tdir/$tfile. 1000
16599 # statfs data is not real time, let's just calculate it
16600 old_iused=$((old_iused + 1000))
16602 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
16603 osp.*OST0000*MDT0000.create_count")
16604 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
16605 osp.*OST0000*MDT0000.max_create_count")
16606 for idx in $(seq $MDSCOUNT); do
16607 do_facet mds$idx "lctl set_param -n \
16608 osp.*OST0000*MDT000?.max_create_count=0"
16611 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
16612 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
16613 [ $index -ne 0 ] || error "$tfile stripe index is 0"
16615 unlinkmany $DIR/$tdir/$tfile. 1000
16617 for idx in $(seq $MDSCOUNT); do
16618 do_facet mds$idx "lctl set_param -n \
16619 osp.*OST0000*MDT000?.max_create_count=$max_count"
16620 do_facet mds$idx "lctl set_param -n \
16621 osp.*OST0000*MDT000?.create_count=$count"
16625 for i in $(seq 120); do
16626 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16627 # system may be too busy to destroy all objs in time, use
16628 # a somewhat small value to not fail autotest
16629 [ $((old_iused - new_iused)) -gt 400 ] && break
16633 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
16634 [ $((old_iused - new_iused)) -gt 400 ] ||
16635 error "objs not destroyed after unlink"
16637 run_test 311 "disable OSP precreate, and unlink should destroy objs"
16644 local vdevdir=$(dirname $(facet_vdevice $ost))
16645 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
16646 local zfs_zapid=$(do_facet $ost $cmd |
16647 grep -w "/O/0/d$((objid%32))" -C 5 |
16648 awk '/Object/{getline; print $1}')
16649 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
16650 awk "/$objid = /"'{printf $3}')
16655 zfs_object_blksz() {
16659 local vdevdir=$(dirname $(facet_vdevice $ost))
16660 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
16661 local blksz=$(do_facet $ost $cmd $objid |
16662 awk '/dblk/{getline; printf $4}')
16664 case "${blksz: -1}" in
16665 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
16666 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
16673 test_312() { # LU-4856
16674 remote_ost_nodsh && skip "remote OST with nodsh" && return
16676 [ $(facet_fstype ost1) = "zfs" ] ||
16677 { skip "the test only applies to zfs" && return; }
16679 local max_blksz=$(do_facet ost1 \
16680 $ZFS get -p recordsize $(facet_device ost1) |
16681 awk '!/VALUE/{print $3}')
16682 local min_blksz=$(getconf PAGE_SIZE)
16684 # to make life a little bit easier
16685 $LFS mkdir -c 1 -i 0 $DIR/$tdir
16686 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16688 local tf=$DIR/$tdir/$tfile
16690 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16692 # Get ZFS object id
16693 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16695 # block size change by sequential over write
16697 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
16698 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
16700 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16701 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
16705 # block size change by sequential append write
16706 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
16707 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16708 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16710 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
16711 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
16712 oflag=sync conv=notrunc
16714 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16715 [ $blksz -eq $((2 * count * min_blksz)) ] ||
16716 error "blksz error, actual $blksz, " \
16717 "expected: 2 * $count * $min_blksz"
16723 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16724 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16726 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
16727 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16728 [ $blksz -eq $min_blksz ] ||
16729 error "blksz error: $blksz, expected: $min_blksz"
16731 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
16732 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16733 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
16735 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
16736 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16737 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
16739 run_test 312 "make sure ZFS adjusts its block size by write pattern"
16742 remote_ost_nodsh && skip "remote OST with nodsh" && return
16744 local file=$DIR/$tfile
16746 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
16748 # define OBD_FAIL_TGT_RCVD_EIO 0x720
16749 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16750 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
16751 error "write should failed"
16752 do_facet ost1 "$LCTL set_param fail_loc=0"
16755 run_test 313 "io should fail after last_rcvd update fail"
16758 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
16759 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16761 wait_delete_completed
16762 do_facet ost1 "$LCTL set_param fail_loc=0"
16764 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
16766 test_315() { # LU-618
16767 local file=$DIR/$tfile
16770 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
16771 $MULTIOP $file oO_RDONLY:r4096000_c &
16776 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
16779 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
16782 run_test 315 "read should be accounted"
16785 local read_write=$1
16786 if [ "$read_write" = "write" ]; then
16787 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
16788 elif [ "$read_write" = "read" ]; then
16789 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
16791 error "argument error"
16794 # turn off debug for performance testing
16795 local saved_debug=$($LCTL get_param -n debug)
16796 $LCTL set_param debug=0
16798 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
16800 # get ost1 size - lustre-OST0000
16801 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
16802 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
16803 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
16805 if [ "$read_write" = "read" ]; then
16806 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
16809 local start_time=$(date +%s.%N)
16810 $dd_cmd bs=1M count=$blocks oflag=sync ||
16811 error "real dd $read_write error"
16812 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
16814 if [ "$read_write" = "write" ]; then
16818 # define OBD_FAIL_OST_FAKE_RW 0x238
16819 do_facet ost1 $LCTL set_param fail_loc=0x238
16821 local start_time=$(date +%s.%N)
16822 $dd_cmd bs=1M count=$blocks oflag=sync ||
16823 error "fake dd $read_write error"
16824 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
16826 if [ "$read_write" = "write" ]; then
16828 cancel_lru_locks osc
16829 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
16830 error "$tfile size not $blocks MB"
16832 do_facet ost1 $LCTL set_param fail_loc=0
16834 echo "fake $read_write $duration_fake vs. normal $read_write" \
16835 "$duration in seconds"
16836 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
16837 error_not_in_vm "fake write is slower"
16839 $LCTL set_param -n debug="$saved_debug"
16842 test_399a() { # LU-7655 for OST fake write
16843 remote_ost_nodsh && skip "remote OST with nodsh" && return
16847 run_test 399a "fake write should not be slower than normal write"
16849 test_399b() { # LU-8726 for OST fake read
16850 remote_ost_nodsh && skip "remote OST with nodsh" && return
16852 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
16853 skip "ldiskfs only test" && return 0
16857 run_test 399b "fake read should not be slower than normal read"
16859 test_400a() { # LU-1606, was conf-sanity test_74
16860 local extra_flags=''
16861 local out=$TMP/$tfile
16862 local prefix=/usr/include/lustre
16865 if ! which $CC > /dev/null 2>&1; then
16866 skip_env "$CC is not installed"
16870 if ! [[ -d $prefix ]]; then
16871 # Assume we're running in tree and fixup the include path.
16872 extra_flags+=" -I$LUSTRE/include"
16873 extra_flags+=" -L$LUSTRE/utils"
16876 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
16877 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
16878 error "client api broken"
16882 run_test 400a "Lustre client api program can compile and link"
16884 test_400b() { # LU-1606, LU-5011
16886 local out=$TMP/$tfile
16887 local prefix=/usr/include/linux/lustre
16889 # We use a hard coded prefix so that this test will not fail
16890 # when run in tree. There are headers in lustre/include/lustre/
16891 # that are not packaged (like lustre_idl.h) and have more
16892 # complicated include dependencies (like config.h and lnet/types.h).
16893 # Since this test about correct packaging we just skip them when
16894 # they don't exist (see below) rather than try to fixup cppflags.
16896 if ! which $CC > /dev/null 2>&1; then
16897 skip_env "$CC is not installed"
16901 for header in $prefix/*.h; do
16902 if ! [[ -f "$header" ]]; then
16906 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
16907 continue # lustre_ioctl.h is internal header
16910 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
16911 error "cannot compile '$header'"
16915 run_test 400b "packaged headers can be compiled"
16917 test_401a() { #LU-7437
16918 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
16919 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
16921 #count the number of parameters by "list_param -R"
16922 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
16923 #count the number of parameters by listing proc files
16924 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
16925 echo "proc_dirs='$proc_dirs'"
16926 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
16927 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
16930 [ $params -eq $procs ] ||
16931 error "found $params parameters vs. $procs proc files"
16933 # test the list_param -D option only returns directories
16934 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
16935 #count the number of parameters by listing proc directories
16936 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
16939 [ $params -eq $procs ] ||
16940 error "found $params parameters vs. $procs proc files"
16942 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
16945 local save=$($LCTL get_param -n jobid_var)
16948 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
16949 error "no error returned when setting bad parameters"
16951 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
16952 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
16954 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
16955 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
16956 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
16958 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
16961 local jobid_var_old=$($LCTL get_param -n jobid_var)
16962 local jobid_var_new
16964 $LCTL set_param jobid_var= &&
16965 error "no error returned for 'set_param a='"
16967 jobid_var_new=$($LCTL get_param -n jobid_var)
16968 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16969 error "jobid_var was changed by setting without value"
16971 $LCTL set_param jobid_var &&
16972 error "no error returned for 'set_param a'"
16974 jobid_var_new=$($LCTL get_param -n jobid_var)
16975 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16976 error "jobid_var was changed by setting without value"
16978 run_test 401c "Verify 'lctl set_param' without value fails in either format."
16981 local jobid_var_old=$($LCTL get_param -n jobid_var)
16982 local jobid_var_new
16983 local new_value="foo=bar"
16985 $LCTL set_param jobid_var=$new_value ||
16986 error "'set_param a=b' did not accept a value containing '='"
16988 jobid_var_new=$($LCTL get_param -n jobid_var)
16989 [[ "$jobid_var_new" == "$new_value" ]] ||
16990 error "'set_param a=b' failed on a value containing '='"
16992 # Reset the jobid_var to test the other format
16993 $LCTL set_param jobid_var=$jobid_var_old
16994 jobid_var_new=$($LCTL get_param -n jobid_var)
16995 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16996 error "failed to reset jobid_var"
16998 $LCTL set_param jobid_var $new_value ||
16999 error "'set_param a b' did not accept a value containing '='"
17001 jobid_var_new=$($LCTL get_param -n jobid_var)
17002 [[ "$jobid_var_new" == "$new_value" ]] ||
17003 error "'set_param a b' failed on a value containing '='"
17005 $LCTL set_param jobid_var $jobid_var_old
17006 jobid_var_new=$($LCTL get_param -n jobid_var)
17007 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
17008 error "failed to reset jobid_var"
17010 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
17013 local server_version=$(lustre_version_code $SINGLEMDS)
17014 [[ $server_version -ge $(version_code 2.7.66) ]] ||
17015 [[ $server_version -ge $(version_code 2.7.18.4) &&
17016 $server_version -lt $(version_code 2.7.50) ]] ||
17017 [[ $server_version -ge $(version_code 2.7.2) &&
17018 $server_version -lt $(version_code 2.7.11) ]] ||
17019 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
17021 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17022 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
17023 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
17024 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
17025 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
17026 echo "Touch failed - OK"
17028 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
17031 local file1=$DIR/$tfile.1
17032 local file2=$DIR/$tfile.2
17033 local tfile=$TMP/$tfile
17035 rm -f $file1 $file2 $tfile
17040 # 30 sec OBD_TIMEOUT in ll_getattr()
17041 # right before populating st_nlink
17042 $LCTL set_param fail_loc=0x80001409
17043 stat -c %h $file1 > $tfile &
17045 # create an alias, drop all locks and reclaim the dentry
17047 cancel_lru_locks mdc
17048 cancel_lru_locks osc
17049 sysctl -w vm.drop_caches=2
17053 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
17055 rm -f $tfile $file1 $file2
17057 run_test 403 "i_nlink should not drop to zero due to aliasing"
17059 test_404() { # LU-6601
17060 local server_version=$(lustre_version_code $SINGLEMDS)
17061 [[ $server_version -ge $(version_code 2.8.53) ]] ||
17062 { skip "Need server version newer than 2.8.52"; return 0; }
17064 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17065 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
17066 awk '/osp .*-osc-MDT/ { print $4}')
17069 for osp in $mosps; do
17070 echo "Deactivate: " $osp
17071 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
17072 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17073 awk -vp=$osp '$4 == p { print $2 }')
17074 [ $stat = IN ] || {
17075 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17076 error "deactivate error"
17078 echo "Activate: " $osp
17079 do_facet $SINGLEMDS $LCTL --device %$osp activate
17080 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17081 awk -vp=$osp '$4 == p { print $2 }')
17082 [ $stat = UP ] || {
17083 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17084 error "activate error"
17088 run_test 404 "validate manual {de}activated works properly for OSPs"
17091 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
17092 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
17093 skip "Layout swap lock is not supported" && return
17095 check_swap_layouts_support && return 0
17097 test_mkdir $DIR/$tdir
17098 swap_lock_test -d $DIR/$tdir ||
17099 error "One layout swap locked test failed"
17101 run_test 405 "Various layout swap lock tests"
17104 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17105 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
17106 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
17107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17108 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
17109 skip "Need MDS version at least 2.8.50" && return
17111 local def_stripe_count=$($GETSTRIPE -c $MOUNT)
17112 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
17113 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
17114 local def_pool=$($GETSTRIPE -p $MOUNT)
17115 local test_pool=$TESTNAME
17117 if ! combined_mgs_mds ; then
17120 pool_add $test_pool || error "pool_add failed"
17121 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
17122 error "pool_add_targets failed"
17124 # parent set default stripe count only, child will stripe from both
17125 # parent and fs default
17126 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
17127 error "setstripe $MOUNT failed"
17128 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
17129 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
17130 for i in $(seq 10); do
17131 local f=$DIR/$tdir/$tfile.$i
17132 touch $f || error "touch failed"
17133 local count=$($GETSTRIPE -c $f)
17134 [ $count -eq $OSTCOUNT ] ||
17135 error "$f stripe count $count != $OSTCOUNT"
17136 local offset=$($GETSTRIPE -i $f)
17137 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
17138 local size=$($GETSTRIPE -S $f)
17139 [ $size -eq $((def_stripe_size * 2)) ] ||
17140 error "$f stripe size $size != $((def_stripe_size * 2))"
17141 local pool=$($GETSTRIPE -p $f)
17142 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
17145 # change fs default striping, delete parent default striping, now child
17146 # will stripe from new fs default striping only
17147 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
17148 error "change $MOUNT default stripe failed"
17149 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
17150 for i in $(seq 11 20); do
17151 local f=$DIR/$tdir/$tfile.$i
17152 touch $f || error "touch $f failed"
17153 local count=$($GETSTRIPE -c $f)
17154 [ $count -eq 1 ] || error "$f stripe count $count != 1"
17155 local offset=$($GETSTRIPE -i $f)
17156 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
17157 local size=$($GETSTRIPE -S $f)
17158 [ $size -eq $def_stripe_size ] ||
17159 error "$f stripe size $size != $def_stripe_size"
17160 local pool=$($GETSTRIPE -p $f)
17161 [ "#$pool" == "#" ] || error "$f pool $pool is set"
17165 unlinkmany $DIR/$tdir/$tfile. 1 20
17167 # restore FS default striping
17168 if [ -z $def_pool ]; then
17169 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
17170 -i $def_stripe_offset $MOUNT ||
17171 error "restore default striping failed"
17173 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
17174 -i $def_stripe_offset -p $def_pool $MOUNT ||
17175 error "restore default striping with $def_pool failed"
17178 local f=$DIR/$tdir/$tfile
17179 pool_remove_all_targets $test_pool $f
17180 pool_remove $test_pool $f
17182 if ! combined_mgs_mds ; then
17186 run_test 406 "DNE support fs default striping"
17189 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17190 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
17191 skip "Need MDS version at least 2.8.55" && return
17192 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17194 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
17195 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
17196 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
17197 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
17198 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
17200 #define OBD_FAIL_DT_TXN_STOP 0x2019
17201 for idx in $(seq $MDSCOUNT); do
17202 do_facet mds$idx "lctl set_param fail_loc=0x2019"
17204 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
17205 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
17206 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
17209 run_test 407 "transaction fail should cause operation fail"
17212 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
17214 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
17215 lctl set_param fail_loc=0x8000040a
17216 # let ll_prepare_partial_page() fail
17217 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
17221 # create at least 100 unused inodes so that
17222 # shrink_icache_memory(0) should not return 0
17223 touch $DIR/$tfile-{0..100}
17224 rm -f $DIR/$tfile-{0..100}
17227 echo 2 > /proc/sys/vm/drop_caches
17229 run_test 408 "drop_caches should not hang due to page leaks"
17233 [ $MDSCOUNT -lt 2 ] &&
17234 skip "We need at least 2 MDTs for this test" && return
17236 check_mount_and_prep
17238 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
17239 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
17240 touch $DIR/$tdir/guard || error "(2) Fail to create"
17242 local PREFIX=$(str_repeat 'A' 128)
17243 echo "Create 1K hard links start at $(date)"
17244 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17245 error "(3) Fail to hard link"
17247 echo "Links count should be right although linkEA overflow"
17248 stat $DIR/$tdir/guard || error "(4) Fail to stat"
17249 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
17250 [ $linkcount -eq 1001 ] ||
17251 error "(5) Unexpected hard links count: $linkcount"
17253 echo "List all links start at $(date)"
17254 ls -l $DIR/$tdir/foo > /dev/null ||
17255 error "(6) Fail to list $DIR/$tdir/foo"
17257 echo "Unlink hard links start at $(date)"
17258 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17259 error "(7) Fail to unlink"
17261 run_test 409 "Large amount of cross-MDTs hard links on the same file"
17265 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
17266 skip "Need client version at least 2.9.59" && return
17268 # Create a file, and stat it from the kernel
17269 local testfile=$DIR/$tfile
17272 local run_id=$RANDOM
17273 local my_ino=$(stat --format "%i" $testfile)
17275 # Try to insert the module. This will always fail as the
17276 # module is designed to not be inserted.
17277 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
17280 # Anything but success is a test failure
17282 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
17283 error "no inode match"
17285 run_test 410 "Test inode number returned from kernel thread"
17287 cleanup_test411_cgroup() {
17293 local cg_basedir=/sys/fs/cgroup/memory
17295 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
17296 { skip "no setup for cgroup"; return; }
17298 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
17299 error "test file creation failed"
17300 cancel_lru_locks osc
17302 # Create a very small memory cgroup to force a slab allocation error
17303 local cgdir=$cg_basedir/osc_slab_alloc
17304 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
17305 trap "cleanup_test411_cgroup $cgdir" EXIT
17306 echo 2M > $cgdir/memory.kmem.limit_in_bytes
17307 echo 1M > $cgdir/memory.limit_in_bytes
17309 # Should not LBUG, just be killed by oom-killer
17310 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
17311 error "fail to trigger a memory allocation error"
17313 cleanup_test411_cgroup $cgdir
17317 run_test 411 "Slab allocation error with cgroup does not LBUG"
17320 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17321 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17322 skip "Need server version at least 2.9.55" & exit 0
17323 start_full_debug_logging
17327 stop_full_debug_logging
17331 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17332 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17333 awk '/The barrier for/ { print $7 }')
17336 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
17341 barrier_expired() {
17344 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17345 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17346 awk '/will be expired/ { print $7 }')
17348 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
17357 echo "Start barrier_freeze at: $(date)"
17358 #define OBD_FAIL_BARRIER_DELAY 0x2202
17359 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17360 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
17363 local b_status=$(barrier_stat)
17364 echo "Got barrier status at: $(date)"
17365 [ "$b_status" = "'freezing_p1'" ] ||
17366 error "(1) unexpected barrier status $b_status"
17368 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17370 b_status=$(barrier_stat)
17371 [ "$b_status" = "'frozen'" ] ||
17372 error "(2) unexpected barrier status $b_status"
17374 local expired=$(barrier_expired)
17375 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
17376 sleep $((expired + 3))
17378 b_status=$(barrier_stat)
17379 [ "$b_status" = "'expired'" ] ||
17380 error "(3) unexpected barrier status $b_status"
17382 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
17383 error "(4) fail to freeze barrier"
17385 b_status=$(barrier_stat)
17386 [ "$b_status" = "'frozen'" ] ||
17387 error "(5) unexpected barrier status $b_status"
17389 echo "Start barrier_thaw at: $(date)"
17390 #define OBD_FAIL_BARRIER_DELAY 0x2202
17391 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17392 do_facet mgs $LCTL barrier_thaw $FSNAME &
17395 b_status=$(barrier_stat)
17396 echo "Got barrier status at: $(date)"
17397 [ "$b_status" = "'thawing'" ] ||
17398 error "(6) unexpected barrier status $b_status"
17400 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17402 b_status=$(barrier_stat)
17403 [ "$b_status" = "'thawed'" ] ||
17404 error "(7) unexpected barrier status $b_status"
17406 #define OBD_FAIL_BARRIER_FAILURE 0x2203
17407 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
17408 do_facet mgs $LCTL barrier_freeze $FSNAME
17410 b_status=$(barrier_stat)
17411 [ "$b_status" = "'failed'" ] ||
17412 error "(8) unexpected barrier status $b_status"
17414 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17415 do_facet mgs $LCTL barrier_thaw $FSNAME
17419 run_test 801a "write barrier user interfaces and stat machine"
17424 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17425 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
17426 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
17427 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
17428 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
17430 cancel_lru_locks mdc
17432 # 180 seconds should be long enough
17433 do_facet mgs $LCTL barrier_freeze $FSNAME 180
17435 local b_status=$(barrier_stat)
17436 [ "$b_status" = "'frozen'" ] ||
17437 error "(6) unexpected barrier status $b_status"
17439 mkdir $DIR/$tdir/d0/d10 &
17442 touch $DIR/$tdir/d1/f13 &
17445 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
17448 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
17451 rm -f $DIR/$tdir/d4/f12 &
17454 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
17456 # To guarantee taht the 'stat' is not blocked
17457 b_status=$(barrier_stat)
17458 [ "$b_status" = "'frozen'" ] ||
17459 error "(8) unexpected barrier status $b_status"
17461 # let above commands to run at background
17464 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
17465 ps -p $touch_pid || error "(10) touch should be blocked"
17466 ps -p $ln_pid || error "(11) link should be blocked"
17467 ps -p $mv_pid || error "(12) rename should be blocked"
17468 ps -p $rm_pid || error "(13) unlink should be blocked"
17470 b_status=$(barrier_stat)
17471 [ "$b_status" = "'frozen'" ] ||
17472 error "(14) unexpected barrier status $b_status"
17474 do_facet mgs $LCTL barrier_thaw $FSNAME
17475 b_status=$(barrier_stat)
17476 [ "$b_status" = "'thawed'" ] ||
17477 error "(15) unexpected barrier status $b_status"
17479 wait $mkdir_pid || error "(16) mkdir should succeed"
17480 wait $touch_pid || error "(17) touch should succeed"
17481 wait $ln_pid || error "(18) link should succeed"
17482 wait $mv_pid || error "(19) rename should succeed"
17483 wait $rm_pid || error "(20) unlink should succeed"
17487 run_test 801b "modification will be blocked by write barrier"
17490 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17494 stop mds2 || error "(1) Fail to stop mds2"
17496 do_facet mgs $LCTL barrier_freeze $FSNAME 30
17498 local b_status=$(barrier_stat)
17499 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
17500 do_facet mgs $LCTL barrier_thaw $FSNAME
17501 error "(2) unexpected barrier status $b_status"
17504 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17505 error "(3) Fail to rescan barrier bitmap"
17507 do_facet mgs $LCTL barrier_freeze $FSNAME 10
17509 b_status=$(barrier_stat)
17510 [ "$b_status" = "'frozen'" ] ||
17511 error "(4) unexpected barrier status $b_status"
17513 do_facet mgs $LCTL barrier_thaw $FSNAME
17514 b_status=$(barrier_stat)
17515 [ "$b_status" = "'thawed'" ] ||
17516 error "(5) unexpected barrier status $b_status"
17518 local devname=$(mdsdevname 2)
17520 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
17522 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17523 error "(7) Fail to rescan barrier bitmap"
17527 run_test 801c "rescan barrier bitmap"
17529 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
17530 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
17531 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
17537 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
17538 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
17539 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
17545 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17546 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17547 skip "Need server version at least 2.9.55" & exit 0
17549 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17551 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
17552 error "(2) Fail to copy"
17554 trap cleanup_802 EXIT
17556 # sync by force before remount as readonly
17557 sync; sync_all_data; sleep 3; sync_all_data
17561 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
17562 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
17563 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
17565 echo "Mount the server as read only"
17566 setupall server_only || error "(3) Fail to start servers"
17568 echo "Mount client without ro should fail"
17569 mount_client $MOUNT &&
17570 error "(4) Mount client without 'ro' should fail"
17572 echo "Mount client with ro should succeed"
17573 mount_client $MOUNT ro ||
17574 error "(5) Mount client with 'ro' should succeed"
17576 echo "Modify should be refused"
17577 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
17579 echo "Read should be allowed"
17580 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
17581 error "(7) Read should succeed under ro mode"
17585 run_test 802 "simulate readonly device"
17588 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17589 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
17590 skip "MDS needs to be newer than 2.10.54" && return
17592 mkdir -p $DIR/$tdir
17593 # Create some objects on all MDTs to trigger related logs objects
17594 for idx in $(seq $MDSCOUNT); do
17595 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
17596 $DIR/$tdir/dir${idx} ||
17597 error "Fail to create $DIR/$tdir/dir${idx}"
17601 echo "before create:"
17603 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17605 for ((i=0; i<10; i++)); do
17606 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
17607 error "Fail to create $DIR/$tdir/foo$i"
17611 echo "after create:"
17613 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17615 [ $after_used -ge $((before_used + 10)) ] ||
17616 error "before ($before_used) + 10 > after ($after_used)"
17618 for ((i=0; i<10; i++)); do
17619 rm -rf $DIR/$tdir/foo$i ||
17620 error "Fail to remove $DIR/$tdir/foo$i"
17623 wait_delete_completed
17624 echo "after unlink:"
17626 before_used=$after_used
17627 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17629 [ $after_used -le $((before_used - 8)) ] ||
17630 error "before ($before_used) - 8 < after ($after_used)"
17632 run_test 803 "verify agent object for remote object"
17635 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17636 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
17637 skip "MDS needs to be newer than 2.10.54" && return
17639 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
17640 skip "ldiskfs only test" && return 0
17642 mkdir -p $DIR/$tdir
17643 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
17644 error "Fail to create $DIR/$tdir/dir0"
17646 local fid=$($LFS path2fid $DIR/$tdir/dir0)
17647 local dev=$(mdsdevname 2)
17649 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
17650 grep ${fid} || error "NOT found agent entry for dir0"
17652 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
17653 error "Fail to create $DIR/$tdir/dir1"
17655 touch $DIR/$tdir/dir1/foo0 ||
17656 error "Fail to create $DIR/$tdir/dir1/foo0"
17657 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
17660 for idx in $(seq $MDSCOUNT); do
17661 dev=$(mdsdevname $idx)
17662 do_facet mds${idx} \
17663 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
17664 grep ${fid} && rc=$idx
17667 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
17668 error "Fail to rename foo0 to foo1"
17669 if [ $rc -eq 0 ]; then
17670 for idx in $(seq $MDSCOUNT); do
17671 dev=$(mdsdevname $idx)
17672 do_facet mds${idx} \
17673 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
17674 grep ${fid} && rc=$idx
17678 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
17679 error "Fail to rename foo1 to foo2"
17680 if [ $rc -eq 0 ]; then
17681 for idx in $(seq $MDSCOUNT); do
17682 dev=$(mdsdevname $idx)
17683 do_facet mds${idx} \
17684 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
17685 grep ${fid} && rc=$idx
17689 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
17691 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
17692 error "Fail to link to $DIR/$tdir/dir1/foo2"
17693 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
17694 error "Fail to rename foo2 to foo0"
17695 unlink $DIR/$tdir/dir1/foo0 ||
17696 error "Fail to unlink $DIR/$tdir/dir1/foo0"
17697 rm -rf $DIR/$tdir/dir0 ||
17698 error "Fail to rm $DIR/$tdir/dir0"
17700 for idx in $(seq $MDSCOUNT); do
17701 dev=$(mdsdevname $idx)
17705 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
17707 start mds${idx} $dev $MDS_MOUNT_OPTS ||
17708 error "mount mds$idx failed"
17709 df $MOUNT > /dev/null 2>&1
17711 # e2fsck should not return error
17713 error "e2fsck detected error on MDT${idx}: rc=$rc"
17716 run_test 804 "verify agent entry for remote entry"
17719 # tests that do cleanup/setup should be run at the end
17723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17725 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
17726 $LCTL set_param fail_loc=0x903
17728 cancel_lru_locks MGC
17730 FAIL_ON_ERROR=true cleanup
17731 FAIL_ON_ERROR=true setup
17733 run_test 900 "umount should not race with any mgc requeue thread"
17736 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
17737 check_and_cleanup_lustre
17738 if [ "$I_MOUNTED" != "yes" ]; then
17739 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true