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
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054
16 ALWAYS_EXCEPT=" 407 253 312 $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"
21 SRCDIR=$(cd $(dirname $0); echo $PWD)
22 export PATH=$PATH:/sbin
27 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
28 CREATETEST=${CREATETEST:-createtest}
30 LFIND=${LFIND:-"$LFS find"}
31 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
33 OPENFILE=${OPENFILE:-openfile}
34 OPENUNLINK=${OPENUNLINK:-openunlink}
35 export MULTIOP=${MULTIOP:-multiop}
36 READS=${READS:-"reads"}
37 MUNLINK=${MUNLINK:-munlink}
38 SOCKETSERVER=${SOCKETSERVER:-socketserver}
39 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
40 MEMHOG=${MEMHOG:-memhog}
41 DIRECTIO=${DIRECTIO:-directio}
42 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
57 . $LUSTRE/tests/test-framework.sh
59 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
63 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
65 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
66 # bug number for skipped test: LU-4536 LU-1957
67 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180"
69 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
75 if [ -r /etc/SuSE-release ]
77 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
78 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
80 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
87 # Check if we are running on Ubuntu or SLES so we can make decisions on
90 # bug number for skipped test: LU-4341
91 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
92 elif [ -r /etc/os-release ]; then
93 if grep -qi ubuntu /etc/os-release; then
94 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
99 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
100 # bug number for skipped test:
101 # LU-10334 LU-10335 LU-10335 LU-10335
102 ALWAYS_EXCEPT+=" 103a 130a 130b 130c"
103 # LU-10335 LU-10335 LU-10365 LU-10366
104 ALWAYS_EXCEPT+=" 130d 130e 400a 410"
113 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
114 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
123 check_swap_layouts_support()
125 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
126 { skip "Does not support layout lock."; return 0; }
130 check_and_setup_lustre
134 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
135 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
136 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
138 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
139 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
140 rm -rf $DIR/[Rdfs][0-9]*
142 # $RUNAS_ID may get set incorrectly somewhere else
143 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
145 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
149 if [ "${ONLY}" = "MOUNT" ] ; then
150 echo "Lustre is up, please go on"
154 echo "preparing for tests involving mounts"
155 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
157 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
158 echo # add a newline after mke2fs.
162 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
163 lctl set_param debug=-1 2> /dev/null || true
166 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
168 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
170 run_test 0a "touch; rm ====================="
173 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
174 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
176 run_test 0b "chmod 0755 $DIR ============================="
179 $LCTL get_param mdc.*.import | grep "state: FULL" ||
180 error "import not FULL"
181 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
184 run_test 0c "check import proc ============================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
189 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
190 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
193 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
195 run_test 1 "mkdir; remkdir; rmdir =============================="
198 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
199 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
200 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
202 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
204 run_test 2 "mkdir; touch; rmdir; check file ===================="
207 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
208 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
209 touch $DIR/$tdir/$tfile
210 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
212 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
214 run_test 3 "mkdir; touch; rmdir; check dir ====================="
216 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
220 test_mkdir $DIR/$tdir ||
221 error "Create remote directory failed"
223 touch $DIR/$tdir/$tfile ||
224 error "Create file under remote directory failed"
227 error "Expect error removing in-use dir $DIR/$tdir"
229 test -d $DIR/$tdir || error "Remote directory disappeared"
231 rm -rf $DIR/$tdir || error "remove remote dir error"
233 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
236 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
237 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
238 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
239 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
240 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
242 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
245 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
246 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
247 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
248 error "$tfile does not have perm 0666 or UID $UID"
249 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
250 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
251 error "$tfile should be 0666 and owned by UID $UID"
253 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
256 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
258 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
259 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
260 error "$tfile should be owned by UID $RUNAS_ID"
261 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
262 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
263 error "$tfile should be owned by UID $RUNAS_ID"
265 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
268 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
270 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
271 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
272 error "$tfile should be owned by GID $UID"
273 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
274 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
275 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
277 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
280 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
281 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
282 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
283 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
284 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
285 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
286 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
287 error "$tdir/d/subdir should be GID $RUNAS_GID"
288 if [[ $MDSCOUNT -gt 1 ]]; then
289 # check remote dir sgid inherite
290 $LFS mkdir -i 0 $DIR/$tdir.local ||
291 error "mkdir $tdir.local failed"
292 chmod g+s $DIR/$tdir.local ||
293 error "chmod $tdir.local failed"
294 chgrp $RUNAS_GID $DIR/$tdir.local ||
295 error "chgrp $tdir.local failed"
296 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
297 error "mkdir $tdir.remote failed"
298 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
299 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
300 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
301 error "$tdir.remote should be mode 02755"
304 run_test 6g "Is new dir in sgid dir inheriting group?"
306 test_6h() { # bug 7331
307 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
308 touch $DIR/$tfile || error "touch failed"
309 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
310 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
311 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
312 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
313 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
315 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
318 test_mkdir $DIR/$tdir
319 $MCREATE $DIR/$tdir/$tfile
320 chmod 0666 $DIR/$tdir/$tfile
321 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
322 error "$tdir/$tfile should be mode 0666"
324 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
327 if [ ! -d $DIR/$tdir ]; then
328 test_mkdir $DIR/$tdir
330 $MCREATE $DIR/$tdir/$tfile
331 echo -n foo > $DIR/$tdir/$tfile
332 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
333 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
335 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
338 test_mkdir $DIR/$tdir
339 touch $DIR/$tdir/$tfile
340 chmod 0666 $DIR/$tdir/$tfile
341 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
342 error "$tfile mode not 0666"
344 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
347 test_mkdir $DIR/$tdir
348 test_mkdir $DIR/$tdir/d2
349 test_mkdir $DIR/$tdir/d2/d3
350 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
352 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
355 test_mkdir $DIR/$tdir
356 test_mkdir $DIR/$tdir/d2
357 touch $DIR/$tdir/d2/$tfile
358 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
359 error "$tdir/d2/$tfile not a file"
361 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
364 test_mkdir $DIR/$tdir
365 test_mkdir $DIR/$tdir/d2
366 chmod 0666 $DIR/$tdir/d2
367 chmod 0705 $DIR/$tdir/d2
368 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
369 error "$tdir/d2 mode not 0705"
371 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
376 chmod 0666 $DIR/$tdir/$tfile
377 chmod 0654 $DIR/$tdir/$tfile
378 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
379 error "$tdir/d2 mode not 0654"
381 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
384 test_mkdir $DIR/$tdir
385 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
387 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
388 error "$tdir/$tfile size not 0 after truncate"
390 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
393 test_mkdir $DIR/$tdir
394 touch $DIR/$tdir/$tfile
396 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
398 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
401 test_mkdir $DIR/$tdir
402 touch $DIR/$tdir/$tfile
403 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
404 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
405 error "$tdir/${tfile_2} not a file after rename"
406 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
408 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
411 test_mkdir $DIR/$tdir
412 touch $DIR/$tdir/$tfile
413 rm -rf $DIR/$tdir/$tfile
414 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
416 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
419 test_mkdir -p $DIR/$tdir
420 touch $DIR/$tdir/$tfile
421 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
423 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
424 error "$tdir/l-exist not a symlink"
425 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
426 error "$tdir/l-exist not referencing a file"
427 rm -f $DIR/$tdir/l-exist
428 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
430 run_test 17a "symlinks: create, remove (real) =================="
433 test_mkdir -p $DIR/$tdir
434 ln -s no-such-file $DIR/$tdir/l-dangle
436 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
437 error "$tdir/l-dangle not referencing no-such-file"
438 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
439 error "$tdir/l-dangle not referencing non-existent file"
440 rm -f $DIR/$tdir/l-dangle
441 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
443 run_test 17b "symlinks: create, remove (dangling) =============="
445 test_17c() { # bug 3440 - don't save failed open RPC for replay
446 test_mkdir -p $DIR/$tdir
447 ln -s foo $DIR/$tdir/$tfile
448 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
450 run_test 17c "symlinks: open dangling (should return error) ===="
453 test_mkdir -p $DIR/$tdir
454 ln -s foo $DIR/$tdir/$tfile
455 touch $DIR/$tdir/$tfile || error "creating to new symlink"
457 run_test 17d "symlinks: create dangling ========================"
460 test_mkdir -p $DIR/$tdir
461 local foo=$DIR/$tdir/$tfile
462 ln -s $foo $foo || error "create symlink failed"
463 ls -l $foo || error "ls -l failed"
464 ls $foo && error "ls not failed" || true
466 run_test 17e "symlinks: create recursive symlink (should return error) ===="
469 test_mkdir -p $DIR/$tdir
470 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
471 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
472 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
473 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
474 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
475 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
478 run_test 17f "symlinks: long and very long symlink name ========================"
480 # str_repeat(S, N) generate a string that is string S repeated N times
485 while [ $((n -= 1)) -ge 0 ]; do
491 # Long symlinks and LU-2241
493 test_mkdir -p $DIR/$tdir
494 local TESTS="59 60 61 4094 4095"
496 # Fix for inode size boundary in 2.1.4
497 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
500 # Patch not applied to 2.2 or 2.3 branches
501 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
502 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
505 # skip long symlink name for rhel6.5.
506 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
507 grep -q '6.5' /etc/redhat-release &>/dev/null &&
508 TESTS="59 60 61 4062 4063"
511 local SYMNAME=$(str_repeat 'x' $i)
512 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
513 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
516 run_test 17g "symlinks: really long symlink name and inode boundaries"
518 test_17h() { #bug 17378
519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
522 test_mkdir -p $DIR/$tdir
523 if [[ $MDSCOUNT -gt 1 ]]; then
524 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
528 $SETSTRIPE -c -1 $DIR/$tdir
529 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
530 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
531 touch $DIR/$tdir/$tfile || true
533 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
535 test_17i() { #bug 20018
536 remote_mds_nodsh && skip "remote MDS with nodsh" && return
537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
538 test_mkdir -c1 $DIR/$tdir
539 local foo=$DIR/$tdir/$tfile
541 if [[ $MDSCOUNT -gt 1 ]]; then
542 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
546 ln -s $foo $foo || error "create symlink failed"
547 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
548 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
549 ls -l $foo && error "error not detected"
552 run_test 17i "don't panic on short symlink"
554 test_17k() { #bug 22301
555 [[ -z "$(which rsync 2>/dev/null)" ]] &&
556 skip "no rsync command" && return 0
557 rsync --help | grep -q xattr ||
558 skip_env "$(rsync --version | head -n1) does not support xattrs"
559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
560 test_mkdir -p $DIR/$tdir
561 test_mkdir -p $DIR/$tdir.new
562 touch $DIR/$tdir/$tfile
563 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
564 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
565 error "rsync failed with xattrs enabled"
567 run_test 17k "symlinks: rsync with xattrs enabled ========================="
569 test_17l() { # LU-279
570 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
571 skip "no getfattr command" && return 0
572 test_mkdir -p $DIR/$tdir
573 touch $DIR/$tdir/$tfile
574 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
575 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
576 # -h to not follow symlinks. -m '' to list all the xattrs.
577 # grep to remove first line: '# file: $path'.
578 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
580 lgetxattr_size_check $path $xattr ||
581 error "lgetxattr_size_check $path $xattr failed"
585 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
589 local short_sym="0123456789"
590 local WDIR=$DIR/${tdir}m
593 remote_mds_nodsh && skip "remote MDS with nodsh" && return
594 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
595 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
596 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
598 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
599 skip "ldiskfs only test" && return 0
601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
605 # create a long symlink file
606 for ((i = 0; i < 4; ++i)); do
607 long_sym=${long_sym}${long_sym}
610 echo "create 512 short and long symlink files under $WDIR"
611 for ((i = 0; i < 256; ++i)); do
612 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
613 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
619 wait_delete_completed
621 echo "recreate the 512 symlink files with a shorter string"
622 for ((i = 0; i < 512; ++i)); do
623 # rewrite the symlink file with a shorter string
624 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
625 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
628 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
629 local devname=$(mdsdevname $mds_index)
631 echo "stop and checking mds${mds_index}:"
632 # e2fsck should not return error
634 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
637 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
638 df $MOUNT > /dev/null 2>&1
640 error "e2fsck detected error for short/long symlink: rc=$rc"
642 run_test 17m "run e2fsck against MDT which contains short/long symlink"
644 check_fs_consistency_17n() {
648 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
649 # so it only check MDT1/MDT2 instead of all of MDTs.
650 for mdt_index in 1 2; do
651 local devname=$(mdsdevname $mdt_index)
652 # e2fsck should not return error
654 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
657 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
658 error "mount mds$mdt_index failed"
659 df $MOUNT > /dev/null 2>&1
667 remote_mds_nodsh && skip "remote MDS with nodsh" && return
668 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
669 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
670 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
672 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
673 skip "ldiskfs only test" && return 0
675 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
679 test_mkdir $DIR/$tdir
680 for ((i=0; i<10; i++)); do
681 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
682 error "create remote dir error $i"
683 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
684 error "create files under remote dir failed $i"
687 check_fs_consistency_17n ||
688 error "e2fsck report error after create files under remote dir"
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 ||
696 error "e2fsck report error after unlink files under remote dir"
698 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
699 skip "lustre < 2.4.50 does not support migrate mv " && return
701 for ((i = 0; i < 10; i++)); do
702 mkdir -p $DIR/$tdir/remote_dir_${i}
703 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
704 error "create files under remote dir failed $i"
705 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
706 error "migrate remote dir error $i"
708 check_fs_consistency_17n || error "e2fsck report error after migration"
710 for ((i = 0; i < 10; i++)); do
711 rm -rf $DIR/$tdir/remote_dir_${i} ||
712 error "destroy remote dir error $i"
715 check_fs_consistency_17n || error "e2fsck report error after unlink"
717 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
720 remote_mds_nodsh && skip "remote MDS with nodsh" && return
721 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
722 skip "Need MDS version at least 2.3.64" && return
724 local WDIR=$DIR/${tdir}o
730 mdt_index=$($LFS getstripe -M $WDIR/$tfile)
731 mdt_index=$((mdt_index+1))
734 #fail mds will wait the failover finish then set
735 #following fail_loc to avoid interfer the recovery process.
738 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
739 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
740 ls -l $WDIR/$tfile && rc=1
741 do_facet mds${mdt_index} lctl set_param fail_loc=0
742 [[ $rc -ne 0 ]] && error "stat file should fail"
745 run_test 17o "stat file with incompat LMA feature"
748 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
749 ls $DIR || error "Failed to ls $DIR: $?"
751 run_test 18 "touch .../f ; ls ... =============================="
757 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
759 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
762 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
764 run_test 19b "ls -l .../f19 (should return error) =============="
767 [ $RUNAS_ID -eq $UID ] &&
768 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
769 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
771 run_test 19c "$RUNAS touch .../f19 (should return error) =="
774 cat $DIR/f19 && error || true
776 run_test 19d "cat .../f19 (should return error) =============="
785 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
787 run_test 20 "touch .../f ; ls -l ... ==========================="
790 test_mkdir -p $DIR/$tdir
791 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
792 ln -s dangle $DIR/$tdir/link
793 echo foo >> $DIR/$tdir/link
794 cat $DIR/$tdir/dangle
795 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
796 $CHECKSTAT -f -t file $DIR/$tdir/link ||
797 error "$tdir/link not linked to a file"
799 run_test 21 "write to dangling link ============================"
803 test_mkdir -p $DIR/$tdir
804 chown $RUNAS_ID:$RUNAS_GID $WDIR
805 (cd $WDIR || error "cd $WDIR failed";
806 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
808 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
809 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
810 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
812 run_test 22 "unpack tar archive as non-root user ==============="
816 test_mkdir -p $DIR/$tdir
817 local file=$DIR/$tdir/$tfile
819 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
820 openfile -f O_CREAT:O_EXCL $file &&
821 error "$file recreate succeeded" || true
823 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
825 test_23b() { # bug 18988
826 test_mkdir -p $DIR/$tdir
827 local file=$DIR/$tdir/$tfile
830 echo foo > $file || error "write filed"
831 echo bar >> $file || error "append filed"
832 $CHECKSTAT -s 8 $file || error "wrong size"
835 run_test 23b "O_APPEND check =========================="
837 # LU-11069 file offset is correct after appending writes
839 local file=$DIR/$tfile
842 echo CentaurHauls > $file
843 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
844 if ((offset != 26)); then
845 error "wrong offset, expected 26, got '$offset'"
848 run_test 23d "file offset is correct after appending writes"
852 echo '-- same directory rename'
853 test_mkdir $DIR/$tdir
854 touch $DIR/$tdir/$tfile.1
855 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
856 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
858 run_test 24a "rename file to non-existent target"
861 test_mkdir $DIR/$tdir
862 touch $DIR/$tdir/$tfile.{1,2}
863 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
864 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
865 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
867 run_test 24b "rename file to existing target"
870 test_mkdir $DIR/$tdir
871 test_mkdir $DIR/$tdir/d$testnum.1
872 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
873 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
874 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
876 run_test 24c "rename directory to non-existent target"
879 test_mkdir -c1 $DIR/$tdir
880 test_mkdir -c1 $DIR/$tdir/d$testnum.1
881 test_mkdir -c1 $DIR/$tdir/d$testnum.2
882 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
883 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
884 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
886 run_test 24d "rename directory to existing target"
889 echo '-- cross directory renames --'
893 mv $DIR/R5a/f $DIR/R5b/g
894 $CHECKSTAT -a $DIR/R5a/f || error
895 $CHECKSTAT -t file $DIR/R5b/g || error
897 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
902 touch $DIR/R6a/f $DIR/R6b/g
903 mv $DIR/R6a/f $DIR/R6b/g
904 $CHECKSTAT -a $DIR/R6a/f || error
905 $CHECKSTAT -t file $DIR/R6b/g || error
907 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
912 test_mkdir $DIR/R7a/d
913 mv $DIR/R7a/d $DIR/R7b/e
914 $CHECKSTAT -a $DIR/R7a/d || error
915 $CHECKSTAT -t dir $DIR/R7b/e || error
917 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
920 test_mkdir -c1 $DIR/R8a
921 test_mkdir -c1 $DIR/R8b
922 test_mkdir -c1 $DIR/R8a/d
923 test_mkdir -c1 $DIR/R8b/e
924 mrename $DIR/R8a/d $DIR/R8b/e
925 $CHECKSTAT -a $DIR/R8a/d || error
926 $CHECKSTAT -t dir $DIR/R8b/e || error
928 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
931 echo "-- rename error cases"
935 mrename $DIR/R9/f $DIR/R9/a
936 $CHECKSTAT -t file $DIR/R9/f || error
937 $CHECKSTAT -t dir $DIR/R9/a || error
938 $CHECKSTAT -a $DIR/R9/a/f || error
940 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
944 mrename $DIR/R10/f $DIR/R10/g
945 $CHECKSTAT -t dir $DIR/R10 || error
946 $CHECKSTAT -a $DIR/R10/f || error
947 $CHECKSTAT -a $DIR/R10/g || error
949 run_test 24j "source does not exist ============================"
953 test_mkdir $DIR/R11a/d
955 mv $DIR/R11a/f $DIR/R11a/d
956 $CHECKSTAT -a $DIR/R11a/f || error
957 $CHECKSTAT -t file $DIR/R11a/d/f || error
959 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
961 # bug 2429 - rename foo foo foo creates invalid file
964 $MULTIOP $f OcNs || error
966 run_test 24l "Renaming a file to itself ========================"
970 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
971 # on ext3 this does not remove either the source or target files
972 # though the "expected" operation would be to remove the source
973 $CHECKSTAT -t file ${f} || error "${f} missing"
974 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
976 run_test 24m "Renaming a file to a hard link to itself ========="
980 # this stats the old file after it was renamed, so it should fail
984 $CHECKSTAT ${f}.rename
987 run_test 24n "Statting the old file after renaming (Posix rename 2)"
990 test_mkdir -p $DIR/d24o
991 rename_many -s random -v -n 10 $DIR/d24o
993 run_test 24o "rename of files during htree split ==============="
998 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
999 mrename $DIR/R12a $DIR/R12b
1000 $CHECKSTAT -a $DIR/R12a || error
1001 $CHECKSTAT -t dir $DIR/R12b || error
1002 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1003 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1005 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1007 cleanup_multiop_pause() {
1009 kill -USR1 $MULTIPID
1013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1014 test_mkdir $DIR/R13a
1015 test_mkdir $DIR/R13b
1016 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1017 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1020 trap cleanup_multiop_pause EXIT
1021 mrename $DIR/R13a $DIR/R13b
1022 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1023 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1024 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1025 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1026 cleanup_multiop_pause
1027 wait $MULTIPID || error "multiop close failed"
1029 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1031 test_24r() { #bug 3789
1032 test_mkdir $DIR/R14a
1033 test_mkdir $DIR/R14a/b
1034 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1035 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1036 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1038 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1041 test_mkdir $DIR/R15a
1042 test_mkdir $DIR/R15a/b
1043 test_mkdir $DIR/R15a/b/c
1044 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1045 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1046 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1048 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1050 test_mkdir $DIR/R16a
1051 test_mkdir $DIR/R16a/b
1052 test_mkdir $DIR/R16a/b/c
1053 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1054 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1055 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1057 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1059 test_24u() { # bug12192
1060 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1061 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1063 run_test 24u "create stripe file"
1067 size=$(getconf PAGE_SIZE 2>/dev/null)
1068 echo -n ${size:-4096}
1071 simple_cleanup_common() {
1074 [ -z "$DIR" -o -z "$tdir" ] && return 0
1076 local start=$SECONDS
1079 wait_delete_completed
1080 echo "cleanup time $((SECONDS - start))"
1084 max_pages_per_rpc() {
1085 local mdtname="$(printf "MDT%04x" ${1:-0})"
1086 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1091 local nrfiles=${COUNT:-100000}
1092 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1093 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1095 local fname="$DIR/$tdir/$tfile"
1096 test_mkdir "$(dirname $fname)"
1097 # assume MDT0000 has the fewest inodes
1098 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1099 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1100 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1102 trap simple_cleanup_common EXIT
1104 createmany -m "$fname" $nrfiles
1106 cancel_lru_locks mdc
1107 lctl set_param mdc.*.stats clear
1109 # was previously test_24D: LU-6101
1110 # readdir() returns correct number of entries after cursor reload
1111 local num_ls=$(ls $DIR/$tdir | wc -l)
1112 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1113 local num_all=$(ls -a $DIR/$tdir | wc -l)
1114 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1115 $num_all -ne $((nrfiles + 2)) ]; then
1116 error "Expected $nrfiles files, got $num_ls " \
1117 "($num_uniq unique $num_all .&..)"
1119 # LU-5 large readdir
1120 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1121 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1122 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1123 # take into account of overhead in lu_dirpage header and end mark in
1124 # each page, plus one in rpc_num calculation.
1125 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1126 local page_entries=$((($(page_size) - 24) / dirent_size))
1127 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1128 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1129 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1130 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1131 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1132 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1133 error "large readdir doesn't take effect: " \
1134 "$mds_readpage should be about $rpc_max"
1136 simple_cleanup_common
1138 run_test 24v "list large directory (test hash collision, b=17560)"
1140 test_24w() { # bug21506
1142 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1143 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1144 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1145 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1146 [[ "$SZ1" -eq "$SZ2" ]] ||
1147 error "Error reading at the end of the file $tfile"
1149 run_test 24w "Reading a file larger than 4Gb"
1152 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1154 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1155 skip "Need MDS version at least 2.7.56" && return
1157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1159 local remote_dir=$DIR/$tdir/remote_dir
1161 test_mkdir -p $DIR/$tdir
1162 $LFS mkdir -i $MDTIDX $remote_dir ||
1163 error "create remote directory failed"
1165 test_mkdir -p $DIR/$tdir/src_dir
1166 touch $DIR/$tdir/src_file
1167 test_mkdir -p $remote_dir/tgt_dir
1168 touch $remote_dir/tgt_file
1170 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1171 error "rename dir cross MDT failed!"
1173 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1174 error "rename file cross MDT failed!"
1176 touch $DIR/$tdir/ln_file
1177 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1178 error "ln file cross MDT failed"
1180 rm -rf $DIR/$tdir || error "Can not delete directories"
1182 run_test 24x "cross MDT rename/link"
1185 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1188 local remote_dir=$DIR/$tdir/remote_dir
1190 test_mkdir -p $DIR/$tdir
1191 $LFS mkdir -i $MDTIDX $remote_dir ||
1192 error "create remote directory failed"
1194 test_mkdir -p $remote_dir/src_dir
1195 touch $remote_dir/src_file
1196 test_mkdir -p $remote_dir/tgt_dir
1197 touch $remote_dir/tgt_file
1199 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1200 error "rename subdir in the same remote dir failed!"
1202 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1203 error "rename files in the same remote dir failed!"
1205 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1206 error "link files in the same remote dir failed!"
1208 rm -rf $DIR/$tdir || error "Can not delete directories"
1210 run_test 24y "rename/link on the same dir should succeed"
1212 test_24A() { # LU-3182
1216 test_mkdir -p $DIR/$tdir
1217 trap simple_cleanup_common EXIT
1218 createmany -m $DIR/$tdir/$tfile $NFILES
1219 local t=$(ls $DIR/$tdir | wc -l)
1220 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1221 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1222 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1223 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1226 simple_cleanup_common || error "Can not delete directories"
1228 run_test 24A "readdir() returns correct number of entries."
1230 test_24B() { # LU-4805
1231 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1234 test_mkdir $DIR/$tdir
1235 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1236 error "create striped dir failed"
1238 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1239 [ $count -eq 2 ] || error "Expected 2, got $count"
1241 touch $DIR/$tdir/striped_dir/a
1243 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1244 [ $count -eq 3 ] || error "Expected 3, got $count"
1246 touch $DIR/$tdir/striped_dir/.f
1248 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1249 [ $count -eq 4 ] || error "Expected 4, got $count"
1251 rm -rf $DIR/$tdir || error "Can not delete directories"
1253 run_test 24B "readdir for striped dir return correct number of entries"
1256 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1262 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1263 error "create striped dir failed"
1265 cd $DIR/$tdir/d0/striped_dir
1267 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1268 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1269 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1271 [ "$d0_ino" = "$parent_ino" ] ||
1272 error ".. wrong, expect $d0_ino, get $parent_ino"
1274 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1275 error "mv striped dir failed"
1277 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1279 [ "$d1_ino" = "$parent_ino" ] ||
1280 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1282 run_test 24C "check .. in striped dir"
1285 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1289 mkdir $DIR/$tdir/src_dir
1290 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1291 error "create remote source failed"
1293 touch $DIR/$tdir/src_dir/src_child/a
1295 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1296 error "create remote target dir failed"
1298 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1299 error "create remote target child failed"
1301 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1302 error "rename dir cross MDT failed!"
1306 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1307 error "src_child still exists after rename"
1309 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1310 error "missing file(a) after rename"
1312 rm -rf $DIR/$tdir || error "Can not delete directories"
1314 run_test 24E "cross MDT rename/link"
1317 echo '== symlink sanity ============================================='
1321 touch $DIR/s25/foo || error
1323 run_test 25a "create file in symlinked directory ==============="
1326 [ ! -d $DIR/d25 ] && test_25a
1327 $CHECKSTAT -t file $DIR/s25/foo || error
1329 run_test 25b "lookup file in symlinked directory ==============="
1333 test_mkdir $DIR/d26/d26-2
1334 ln -s d26/d26-2 $DIR/s26
1335 touch $DIR/s26/foo || error
1337 run_test 26a "multiple component symlink ======================="
1340 test_mkdir -p $DIR/d26b/d26-2
1341 ln -s d26b/d26-2/foo $DIR/s26-2
1342 touch $DIR/s26-2 || error
1344 run_test 26b "multiple component symlink at end of lookup ======"
1347 test_mkdir $DIR/d26.2
1348 touch $DIR/d26.2/foo
1349 ln -s d26.2 $DIR/s26.2-1
1350 ln -s s26.2-1 $DIR/s26.2-2
1351 ln -s s26.2-2 $DIR/s26.2-3
1352 chmod 0666 $DIR/s26.2-3/foo
1354 run_test 26c "chain of symlinks ================================"
1356 # recursive symlinks (bug 439)
1358 ln -s d26-3/foo $DIR/d26-3
1360 run_test 26d "create multiple component recursive symlink ======"
1363 [ ! -h $DIR/d26-3 ] && test_26d
1366 run_test 26e "unlink multiple component recursive symlink ======"
1368 # recursive symlinks (bug 7022)
1370 test_mkdir -p $DIR/$tdir
1371 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1372 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1373 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1374 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1375 cd $tfile || error "cd $tfile failed"
1376 ln -s .. dotdot || error "ln dotdot failed"
1377 ln -s dotdot/lndir lndir || error "ln lndir failed"
1378 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1379 output=`ls $tfile/$tfile/lndir/bar1`
1380 [ "$output" = bar1 ] && error "unexpected output"
1381 rm -r $tfile || error "rm $tfile failed"
1382 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1384 run_test 26f "rm -r of a directory which has recursive symlink"
1387 test_mkdir -p $DIR/d27 || error "mkdir failed"
1388 $LFS getstripe $DIR/d27
1389 $LFS setstripe -c 1 $DIR/d27/f0 || error "setstripe failed"
1390 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1391 cp /etc/hosts $DIR/d27/f0 || error
1393 run_test 27a "one stripe file"
1396 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1397 test_mkdir -p $DIR/d27
1398 $LFS setstripe -c 2 $DIR/d27/f01 || error "setstripe failed"
1399 $LFS getstripe -c $DIR/d27/f01
1400 [ $($LFS getstripe -c $DIR/d27/f01) -eq 2 ] ||
1401 error "two-stripe file doesn't have two stripes"
1403 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1405 run_test 27b "create and write to two stripe file"
1408 test_mkdir -p $DIR/d27
1409 $LFS setstripe -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1410 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1411 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1413 run_test 27d "create file with default settings"
1416 # LU-5839 adds check for existed layout before setting it
1417 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1418 skip "Need MDS version at least 2.7.56" && return
1419 test_mkdir -p $DIR/d27
1420 $LFS setstripe -c 2 $DIR/d27/f12 || error "setstripe failed"
1421 $LFS setstripe -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1422 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1424 run_test 27e "setstripe existing file (should return error)"
1427 test_mkdir $DIR/$tdir
1428 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1429 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1430 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1431 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1432 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1433 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1435 run_test 27f "setstripe with bad stripe size (should return error)"
1438 test_mkdir -p $DIR/d27
1439 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1440 $LFS getstripe $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1441 error "$DIR/d27/fnone has object"
1443 run_test 27g "$LFS getstripe with no objects"
1446 test_mkdir $DIR/$tdir
1447 touch $DIR/$tdir/$tfile || error "touch failed"
1448 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1449 error "missing objects"
1451 run_test 27i "$LFS getstripe with some objects"
1454 test_mkdir -p $DIR/d27
1455 $LFS setstripe -i $OSTCOUNT $DIR/d27/f27j &&
1456 error "setstripe failed" || true
1458 run_test 27j "setstripe with bad stripe offset (should return error)"
1460 test_27k() { # bug 2844
1461 test_mkdir -p $DIR/d27
1463 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1464 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1465 $LFS setstripe -S 67108864 $FILE || error "setstripe failed"
1466 BLKSIZE=$(stat $FILE | awk '/IO Block:/ { print $7 }')
1467 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1468 dd if=/dev/zero of=$FILE bs=4k count=1
1469 BLKSIZE=$(stat $FILE | awk '/IO Block:/ { print $7 }')
1470 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1472 run_test 27k "limit i_blksize for broken user apps"
1475 test_mkdir -p $DIR/d27
1476 mcreate $DIR/f27l || error "creating file"
1477 $RUNAS $SETSTRIPE -c 1 $DIR/f27l &&
1478 error "setstripe should have failed" || true
1480 run_test 27l "check setstripe permissions (should return error)"
1483 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1485 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1487 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1488 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1491 trap simple_cleanup_common EXIT
1492 test_mkdir -p $DIR/$tdir
1493 $LFS setstripe -i 0 -c 1 $DIR/$tdir/f27m_1
1494 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1495 error "dd should fill OST0"
1497 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1499 [ $i -gt 256 ] && break
1502 touch $DIR/$tdir/f27m_$i
1503 [ $($LFS getstripe $DIR/$tdir/f27m_$i | grep -A 10 obdidx |
1504 awk '{print $1}' | grep -w "0") ] &&
1505 error "OST0 was full but new created file still use it"
1507 touch $DIR/$tdir/f27m_$i
1508 [ $($LFS getstripe $DIR/$tdir/f27m_$i | grep -A 10 obdidx |
1509 awk '{print $1}'| grep -w "0") ] &&
1510 error "OST0 was full but new created file still use it"
1511 simple_cleanup_common
1513 run_test 27m "create file while OST0 was full"
1516 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1517 head -n 1 | awk '{print $1 * 2}')
1521 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1522 # if the OST isn't full anymore.
1524 local OSTIDX=${1:-""}
1526 local list=$(comma_list $(osts_nodes))
1527 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1529 do_nodes $list lctl set_param fail_loc=0
1530 sync # initiate all OST_DESTROYs from MDS to OST
1534 exhaust_precreations() {
1537 local FAILIDX=${3:-$OSTIDX}
1538 local ofacet=ost$((OSTIDX + 1))
1540 test_mkdir -p -c1 $DIR/$tdir
1541 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1542 local mfacet=mds$((mdtidx + 1))
1543 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1545 local OST=$(ostname_from_index $OSTIDX)
1548 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1549 local last_id=$(do_facet $mfacet lctl get_param -n \
1550 osc.$mdtosc_proc1.prealloc_last_id)
1551 local next_id=$(do_facet $mfacet lctl get_param -n \
1552 osc.$mdtosc_proc1.prealloc_next_id)
1554 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1555 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1557 test_mkdir -p $DIR/$tdir/${OST}
1558 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1559 #define OBD_FAIL_OST_ENOSPC 0x215
1560 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1561 echo "Creating to objid $last_id on ost $OST..."
1562 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1563 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1564 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1568 exhaust_all_precreations() {
1570 for (( i=0; i < OSTCOUNT; i++ )) ; do
1571 exhaust_precreations $i $1 -1
1576 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1578 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1579 remote_ost_nodsh && skip "remote OST with nodsh" && return
1582 rm -f $DIR/$tdir/$tfile
1583 exhaust_precreations 0 0x80000215
1584 $LFS setstripe -c -1 $DIR/$tdir
1585 touch $DIR/$tdir/$tfile || error
1586 $LFS getstripe $DIR/$tdir/$tfile
1589 run_test 27n "create file with some full OSTs"
1592 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1594 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1595 remote_ost_nodsh && skip "remote OST with nodsh" && return
1598 rm -f $DIR/$tdir/$tfile
1599 exhaust_all_precreations 0x215
1601 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1606 run_test 27o "create file with all full OSTs (should error)"
1609 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1611 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1612 remote_ost_nodsh && skip "remote OST with nodsh" && return
1615 rm -f $DIR/$tdir/$tfile
1616 test_mkdir -p $DIR/$tdir
1618 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1619 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1620 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1622 exhaust_precreations 0 0x80000215
1623 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1624 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1625 $LFS getstripe $DIR/$tdir/$tfile
1629 run_test 27p "append to a truncated file with some full OSTs"
1632 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1633 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1634 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1635 remote_ost_nodsh && skip "remote OST with nodsh" && return
1638 rm -f $DIR/$tdir/$tfile
1640 test_mkdir -p $DIR/$tdir
1641 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1642 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1643 error "truncate $DIR/$tdir/$tfile failed"
1644 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1646 exhaust_all_precreations 0x215
1648 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1649 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1653 run_test 27q "append to truncated file with all OSTs full (should error)"
1656 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1658 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1659 remote_ost_nodsh && skip "remote OST with nodsh" && return
1662 rm -f $DIR/$tdir/$tfile
1663 exhaust_precreations 0 0x80000215
1665 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error
1669 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1671 test_27s() { # bug 10725
1672 test_mkdir -p $DIR/$tdir
1673 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1674 local stripe_count=0
1675 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1676 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1677 error "stripe width >= 2^32 succeeded" || true
1680 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1682 test_27t() { # bug 10864
1687 $WLFS getstripe $tfile
1690 run_test 27t "check that utils parse path correctly"
1692 test_27u() { # bug 4900
1693 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1694 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1696 local list=$(comma_list $(mdts_nodes))
1698 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1699 do_nodes $list $LCTL set_param fail_loc=0x139
1700 test_mkdir -p $DIR/$tdir
1701 trap simple_cleanup_common EXIT
1702 createmany -o $DIR/$tdir/t- 1000
1703 do_nodes $list $LCTL set_param fail_loc=0
1705 TLOG=$TMP/$tfile.getstripe
1706 $LFS getstripe $DIR/$tdir > $TLOG
1707 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1708 unlinkmany $DIR/$tdir/t- 1000
1710 [[ $OBJS -gt 0 ]] &&
1711 error "$OBJS objects created on OST-0. See $TLOG" || pass
1713 run_test 27u "skip object creation on OSC w/o objects"
1715 test_27v() { # bug 4900
1716 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1718 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1719 remote_ost_nodsh && skip "remote OST with nodsh" && return
1721 exhaust_all_precreations 0x215
1724 test_mkdir $DIR/$tdir
1725 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1727 touch $DIR/$tdir/$tfile
1728 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1730 for (( i=1; i < OSTCOUNT; i++ )); do
1731 do_facet ost$i lctl set_param fail_loc=0x705
1733 local START=`date +%s`
1734 createmany -o $DIR/$tdir/$tfile 32
1736 local FINISH=`date +%s`
1737 local TIMEOUT=`lctl get_param -n timeout`
1738 local PROCESS=$((FINISH - START))
1739 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1740 error "$FINISH - $START >= $TIMEOUT / 2"
1741 sleep $((TIMEOUT / 2 - PROCESS))
1744 run_test 27v "skip object creation on slow OST"
1746 test_27w() { # bug 10997
1747 test_mkdir $DIR/$tdir || error "mkdir failed"
1748 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1749 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1750 error "stripe size $size != 65536" || true
1751 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1752 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1754 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1757 [[ $OSTCOUNT -lt 2 ]] &&
1758 skip_env "skipping multiple stripe count/offset test" && return
1760 test_mkdir $DIR/$tdir || error "mkdir failed"
1761 for i in $(seq 1 $OSTCOUNT); do
1763 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1764 error "setstripe -c $i -i $offset failed"
1765 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1766 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1767 [ $count -ne $i ] && error "stripe count $count != $i" || true
1768 [ $index -ne $offset ] &&
1769 error "stripe offset $index != $offset" || true
1772 run_test 27wa "check $LFS setstripe -c -i options"
1775 remote_ost_nodsh && skip "remote OST with nodsh" && return
1776 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1778 OFFSET=$(($OSTCOUNT - 1))
1780 local OST=$(ostname_from_index $OSTIDX)
1782 test_mkdir -p $DIR/$tdir
1783 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1784 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1786 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1787 for i in $(seq 0 $OFFSET); do
1788 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1789 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1790 error "OST0 was degraded but new created file still use it"
1792 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1794 run_test 27x "create files while OST0 is degraded"
1797 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1798 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1799 remote_ost_nodsh && skip "remote OST with nodsh" && return
1800 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1802 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1803 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1804 osc.$mdtosc.prealloc_last_id)
1805 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1806 osc.$mdtosc.prealloc_next_id)
1807 local fcount=$((last_id - next_id))
1808 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1809 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1811 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1812 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1813 local OST_DEACTIVE_IDX=-1
1818 for OSC in $MDS_OSCS; do
1819 OST=$(osc_to_ost $OSC)
1820 OSTIDX=$(index_from_ostuuid $OST)
1821 if [ $OST_DEACTIVE_IDX == -1 ]; then
1822 OST_DEACTIVE_IDX=$OSTIDX
1824 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1825 echo $OSC "is Deactivated:"
1826 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1830 OSTIDX=$(index_from_ostuuid $OST)
1831 test_mkdir -p $DIR/$tdir
1832 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1834 for OSC in $MDS_OSCS; do
1835 OST=$(osc_to_ost $OSC)
1836 OSTIDX=$(index_from_ostuuid $OST)
1837 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1838 echo $OST "is degraded:"
1839 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1840 obdfilter.$OST.degraded=1
1845 createmany -o $DIR/$tdir/$tfile $fcount
1847 for OSC in $MDS_OSCS; do
1848 OST=$(osc_to_ost $OSC)
1849 OSTIDX=$(index_from_ostuuid $OST)
1850 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1851 echo $OST "is recovered from degraded:"
1852 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1853 obdfilter.$OST.degraded=0
1855 do_facet $SINGLEMDS lctl --device %$OSC activate
1859 # all osp devices get activated, hence -1 stripe count restored
1860 local stripe_count=0
1862 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1863 # devices get activated.
1865 $LFS setstripe -c -1 $DIR/$tfile
1866 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1868 [ $stripe_count -ne $OSTCOUNT ] &&
1869 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1872 run_test 27y "create files while OST0 is degraded and the rest inactive"
1878 lmm_count=$($GETSTRIPE -c $1)
1879 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1880 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1882 local old_ifs="$IFS"
1884 fid=($($LFS path2fid $1))
1887 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1888 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1890 # compare lmm_seq and lu_fid->f_seq
1891 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1892 # compare lmm_object_id and lu_fid->oid
1893 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1895 # check the trusted.fid attribute of the OST objects of the file
1896 local have_obdidx=false
1898 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1899 # skip lines up to and including "obdidx"
1900 [ -z "$obdidx" ] && break
1901 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1902 $have_obdidx || continue
1904 local ost=$((obdidx + 1))
1905 local dev=$(ostdevname $ost)
1908 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1910 seq=$(echo $seq | sed -e "s/^0x//g")
1911 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1912 oid_hex=$(echo $oid)
1914 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1916 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1920 # Don't unmount/remount the OSTs if we don't need to do that.
1921 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1922 # update too, until that use mount/ll_decode_filter_fid/mount.
1923 # Re-enable when debugfs will understand new filter_fid.
1925 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
1926 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1927 $dev 2>/dev/null" | grep "parent=")
1929 if [ -z "$ff" ]; then
1931 mount_fstype ost$ost
1932 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1933 $(facet_mntpt ost$ost)/$obj_file)
1934 unmount_fstype ost$ost
1935 start ost$ost $dev $OST_MOUNT_OPTS
1939 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1941 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1943 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1944 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1946 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
1947 # stripe_size=1048576 component_id=1 component_start=0 \
1948 # component_end=33554432
1949 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
1950 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
1951 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
1953 if grep -q 'stripe=' <<<$ff; then
1954 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
1956 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1957 # into f_ver in this case. See comment on ff_parent.
1958 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
1961 # compare lmm_seq and filter_fid->ff_parent.f_seq
1962 [ $ff_pseq = $lmm_seq ] ||
1963 error "FF parent SEQ $ff_pseq != $lmm_seq"
1964 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1965 [ $ff_poid = $lmm_oid ] ||
1966 error "FF parent OID $ff_poid != $lmm_oid"
1967 (($ff_pstripe == $stripe_nr)) ||
1968 error "FF stripe $ff_pstripe != $stripe_nr"
1970 stripe_nr=$((stripe_nr + 1))
1971 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
1973 if grep -q 'stripe_count=' <<<$ff; then
1974 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
1975 -e 's/ .*//' <<<$ff)
1976 [ $lmm_count = $ff_scnt ] ||
1977 error "FF stripe count $lmm_count != $ff_scnt"
1983 remote_ost_nodsh && skip "remote OST with nodsh" && return
1984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1985 test_mkdir -p $DIR/$tdir
1987 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1988 { error "setstripe -c -1 failed"; return 1; }
1989 # We need to send a write to every object to get parent FID info set.
1990 # This _should_ also work for setattr, but does not currently.
1991 # touch $DIR/$tdir/$tfile-1 ||
1992 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1993 { error "dd $tfile-1 failed"; return 2; }
1994 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1995 { error "setstripe -c -1 failed"; return 3; }
1996 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1997 { error "dd $tfile-2 failed"; return 4; }
1999 # make sure write RPCs have been sent to OSTs
2002 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2003 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2005 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2007 test_27A() { # b=19102
2008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2009 local restore_size=$($GETSTRIPE -S $MOUNT)
2010 local restore_count=$($GETSTRIPE -c $MOUNT)
2011 local restore_offset=$($GETSTRIPE -i $MOUNT)
2012 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
2013 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2014 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2015 local default_size=$($GETSTRIPE -S $MOUNT)
2016 local default_offset=$($GETSTRIPE -i $MOUNT)
2017 local dsize=$((1024 * 1024))
2018 [ $default_size -eq $dsize ] ||
2019 error "stripe size $default_size != $dsize"
2020 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
2021 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
2023 run_test 27A "check filesystem-wide default LOV EA values"
2025 test_27B() { # LU-2523
2026 test_mkdir -p $DIR/$tdir
2027 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2029 # open f1 with O_LOV_DELAY_CREATE
2031 # call setstripe ioctl on open file descriptor for f1
2033 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2037 # open f1 with O_LOV_DELAY_CREATE
2039 # call setstripe ioctl on open file descriptor for f1
2041 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2043 # Allow multiop to fail in imitation of NFS's busted semantics.
2046 run_test 27B "call setstripe on open unlinked file/rename victim"
2048 test_27C() { #LU-2871
2049 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2057 test_mkdir -p $DIR/$tdir
2059 for i in $(seq 0 $((OSTCOUNT - 1))); do
2060 # set stripe across all OSTs starting from OST$i
2061 $SETSTRIPE -i $i -c -1 $tfile$i
2062 # get striping information
2063 ost_idx=($($GETSTRIPE $tfile$i |
2064 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2068 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2069 error "${#ost_idx[@]} != $OSTCOUNT"
2071 for index in $(seq 0 $((OSTCOUNT - 1))); do
2073 for j in $(echo ${ost_idx[@]}); do
2074 if [ $index -eq $j ]; then
2080 error "Can not find $index in ${ost_idx[@]}"
2084 run_test 27C "check full striping across all OSTs"
2087 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2088 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2089 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2090 local POOL=${POOL:-testpool}
2092 local last_ost=$(($OSTCOUNT - 1))
2094 local ost_list=$(seq $first_ost $ost_step $last_ost)
2095 local ost_range="$first_ost $last_ost $ost_step"
2097 if ! combined_mgs_mds ; then
2101 test_mkdir -p $DIR/$tdir
2102 pool_add $POOL || error "pool_add failed"
2103 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2106 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2108 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2109 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2110 skip27D+=" -s 30,31"
2111 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2112 error "llapi_layout_test failed"
2114 destroy_test_pools || error "destroy test pools failed"
2116 if ! combined_mgs_mds ; then
2120 run_test 27D "validate llapi_layout API"
2122 # Verify that default_easize is increased from its initial value after
2123 # accessing a widely striped file.
2125 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2126 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2127 skip "client does not have LU-3338 fix" && return
2129 # 72 bytes is the minimum space required to store striping
2130 # information for a file striped across one OST:
2131 # (sizeof(struct lov_user_md_v3) +
2132 # sizeof(struct lov_user_ost_data_v1))
2134 $LCTL set_param -n llite.*.default_easize $min_easize ||
2135 error "lctl set_param failed"
2136 local easize=$($LCTL get_param -n llite.*.default_easize)
2138 [ $easize -eq $min_easize ] ||
2139 error "failed to set default_easize"
2141 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2142 error "setstripe failed"
2146 easize=$($LCTL get_param -n llite.*.default_easize)
2148 [ $easize -gt $min_easize ] ||
2149 error "default_easize not updated"
2151 run_test 27E "check that default extended attribute size properly increases"
2153 test_27F() { # LU-5346/LU-7975
2154 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2156 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2157 skip "Need MDS version at least 2.8.51" && return
2158 remote_ost_nodsh && skip "remote OST with nodsh" && return
2160 test_mkdir -p $DIR/$tdir
2162 $SETSTRIPE -c 2 $DIR/$tdir
2164 # stop all OSTs to reproduce situation for LU-7975 ticket
2165 for num in $(seq $OSTCOUNT); do
2169 # open/create f0 with O_LOV_DELAY_CREATE
2170 # truncate f0 to a non-0 size
2172 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2174 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2175 # open/write it again to force delayed layout creation
2176 cat /etc/hosts > $DIR/$tdir/f0 &
2180 for num in $(seq $OSTCOUNT); do
2181 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2182 error "ost$num failed to start"
2185 wait $catpid || error "cat failed"
2187 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2188 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2191 run_test 27F "Client resend delayed layout creation with non-zero size"
2193 test_27G() { #LU-10629
2194 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2195 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2196 local POOL=${POOL:-testpool}
2197 local ostrange="0 0 1"
2199 test_mkdir $DIR/$tdir
2200 pool_add $POOL || error "pool_add failed"
2201 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2202 $LFS setstripe -p $POOL $DIR/$tdir
2204 local pool=$($LFS getstripe -p $DIR/$tdir)
2206 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2208 $LFS setstripe -d $DIR/$tdir
2210 pool=$($LFS getstripe -p $DIR/$tdir)
2214 [ -z "$pool" ] || error "'$pool' is not empty"
2216 run_test 27G "Clear OST pool from stripe"
2218 # createtest also checks that device nodes are created and
2219 # then visible correctly (#2091)
2220 test_28() { # bug 2091
2222 $CREATETEST $DIR/d28/ct || error
2224 run_test 28 "create/mknod/mkdir with bad file types ============"
2227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2228 sync; sleep 1; sync # flush out any dirty pages from previous tests
2235 declare -i LOCKCOUNTORIG=0
2236 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2237 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2239 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2241 declare -i LOCKUNUSEDCOUNTORIG=0
2242 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2243 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2250 declare -i LOCKCOUNTCURRENT=0
2251 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2252 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2255 declare -i LOCKUNUSEDCOUNTCURRENT=0
2256 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2257 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2260 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2261 $LCTL set_param -n ldlm.dump_namespaces ""
2262 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2263 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2264 log "dumped log to $TMP/test_29.dk (bug 5793)"
2267 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2268 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2269 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2270 log "dumped log to $TMP/test_29.dk (bug 5793)"
2274 run_test 29 "IT_GETATTR regression ============================"
2276 test_30a() { # was test_30
2277 cp $(which ls) $DIR || cp /bin/ls $DIR
2281 run_test 30a "execute binary from Lustre (execve) =============="
2284 cp `which ls` $DIR || cp /bin/ls $DIR
2286 $RUNAS $DIR/ls / || error
2289 run_test 30b "execute binary from Lustre as non-root ==========="
2291 test_30c() { # b=22376
2292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2293 cp `which ls` $DIR || cp /bin/ls $DIR
2295 cancel_lru_locks mdc
2296 cancel_lru_locks osc
2297 $RUNAS $DIR/ls / || error
2300 run_test 30c "execute binary from Lustre without read perms ===="
2303 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2304 $CHECKSTAT -a $DIR/f31 || error
2306 run_test 31a "open-unlink file =================================="
2309 touch $DIR/f31 || error
2310 ln $DIR/f31 $DIR/f31b || error
2311 $MULTIOP $DIR/f31b Ouc || error
2312 $CHECKSTAT -t file $DIR/f31 || error
2314 run_test 31b "unlink file with multiple links while open ======="
2317 touch $DIR/f31 || error
2318 ln $DIR/f31 $DIR/f31c || error
2319 multiop_bg_pause $DIR/f31 O_uc || return 1
2321 $MULTIOP $DIR/f31c Ouc
2322 kill -USR1 $MULTIPID
2325 run_test 31c "open-unlink file with multiple links ============="
2328 opendirunlink $DIR/d31d $DIR/d31d || error
2329 $CHECKSTAT -a $DIR/d31d || error
2331 run_test 31d "remove of open directory ========================="
2333 test_31e() { # bug 2904
2334 openfilleddirunlink $DIR/d31e || error
2336 run_test 31e "remove of open non-empty directory ==============="
2338 test_31f() { # bug 4554
2339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2341 test_mkdir $DIR/d31f
2342 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2343 cp /etc/hosts $DIR/d31f
2345 $GETSTRIPE $DIR/d31f/hosts
2346 multiop_bg_pause $DIR/d31f D_c || return 1
2349 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2350 test_mkdir $DIR/d31f
2351 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2352 cp /etc/hosts $DIR/d31f
2354 $GETSTRIPE $DIR/d31f/hosts
2355 multiop_bg_pause $DIR/d31f D_c || return 1
2358 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2359 wait $MULTIPID || error "first opendir $MULTIPID failed"
2363 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2364 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2367 run_test 31f "remove of open directory with open-unlink file ==="
2370 echo "-- cross directory link --"
2371 test_mkdir -c1 $DIR/${tdir}ga
2372 test_mkdir -c1 $DIR/${tdir}gb
2373 touch $DIR/${tdir}ga/f
2374 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2375 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2376 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2377 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2378 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2380 run_test 31g "cross directory link==============="
2383 echo "-- cross directory link --"
2384 test_mkdir -c1 $DIR/${tdir}
2385 test_mkdir -c1 $DIR/${tdir}/dir
2386 touch $DIR/${tdir}/f
2387 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2388 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2389 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2390 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2391 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2393 run_test 31h "cross directory link under child==============="
2396 echo "-- cross directory link --"
2397 test_mkdir -c1 $DIR/$tdir
2398 test_mkdir -c1 $DIR/$tdir/dir
2399 touch $DIR/$tdir/dir/f
2400 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2401 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2402 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2403 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2404 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2406 run_test 31i "cross directory link under parent==============="
2409 test_mkdir -c1 -p $DIR/$tdir
2410 test_mkdir -c1 -p $DIR/$tdir/dir1
2411 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2412 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2413 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2414 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2417 run_test 31j "link for directory==============="
2420 test_mkdir -c1 -p $DIR/$tdir
2422 touch $DIR/$tdir/exist
2423 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2424 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2425 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2426 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2427 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2428 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2429 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2432 run_test 31k "link to file: the same, non-existing, dir==============="
2438 touch $DIR/d31m2/exist
2439 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2440 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2441 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2442 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2443 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2444 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2447 run_test 31m "link to file: the same, non-existing, dir==============="
2450 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2451 nlink=$(stat --format=%h $DIR/$tfile)
2452 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2454 local cmd="exec $fd<$DIR/$tfile"
2457 trap "eval $cmd" EXIT
2458 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2459 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2460 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2461 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2462 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2465 run_test 31n "check link count of unlinked file"
2468 local TEMPNAME=$(mktemp $1_XXXXXX)
2469 mlink $TEMPNAME $1 2> /dev/null &&
2470 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2474 test_31o() { # LU-2901
2475 test_mkdir -p $DIR/$tdir
2476 for LOOP in $(seq 100); do
2477 rm -f $DIR/$tdir/$tfile*
2478 for THREAD in $(seq 8); do
2479 link_one $DIR/$tdir/$tfile.$LOOP &
2482 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2483 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2484 error "$LINKS duplicate links to $tfile.$LOOP" &&
2488 run_test 31o "duplicate hard links with same filename"
2491 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2493 test_mkdir $DIR/$tdir
2494 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2495 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2497 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2498 error "open unlink test1 failed"
2499 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2500 error "open unlink test2 failed"
2502 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2503 error "test1 still exists"
2504 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2505 error "test2 still exists"
2507 run_test 31p "remove of open striped directory"
2509 cleanup_test32_mount() {
2512 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2513 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2514 losetup -d $loopdev || true
2520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2521 echo "== more mountpoints and symlinks ================="
2522 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2523 trap cleanup_test32_mount EXIT
2524 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2525 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2526 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2527 cleanup_test32_mount
2529 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2533 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2534 trap cleanup_test32_mount EXIT
2535 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2536 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2537 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2538 cleanup_test32_mount
2540 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2544 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2545 trap cleanup_test32_mount EXIT
2546 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2547 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2548 test_mkdir -p $DIR/$tdir/d2/test_dir
2549 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2550 cleanup_test32_mount
2552 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2556 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2557 trap cleanup_test32_mount EXIT
2558 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2559 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2560 test_mkdir -p $DIR/$tdir/d2/test_dir
2561 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2562 cleanup_test32_mount
2564 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2567 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2568 test_mkdir -p $DIR/d32e/tmp
2569 TMP_DIR=$DIR/d32e/tmp
2570 ln -s $DIR/d32e $TMP_DIR/symlink11
2571 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2572 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2573 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2575 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2578 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2579 test_mkdir -p $DIR/d32f/tmp
2580 TMP_DIR=$DIR/d32f/tmp
2581 ln -s $DIR/d32f $TMP_DIR/symlink11
2582 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2583 ls $DIR/d32f/tmp/symlink11 || error
2584 ls $DIR/d32f/symlink01 || error
2586 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2589 TMP_DIR=$DIR/$tdir/tmp
2590 test_mkdir -p $DIR/$tdir/tmp
2591 test_mkdir $DIR/${tdir}2
2592 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2593 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2594 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2595 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2596 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2597 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2599 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2602 rm -fr $DIR/$tdir $DIR/${tdir}2
2603 TMP_DIR=$DIR/$tdir/tmp
2604 test_mkdir -p $DIR/$tdir/tmp
2605 test_mkdir $DIR/${tdir}2
2606 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2607 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2608 ls $TMP_DIR/symlink12 || error
2609 ls $DIR/$tdir/symlink02 || error
2611 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2615 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2616 trap cleanup_test32_mount EXIT
2617 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2618 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2619 touch $DIR/$tdir/test_file
2620 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2621 cleanup_test32_mount
2623 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2627 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2628 trap cleanup_test32_mount EXIT
2629 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2630 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2631 touch $DIR/$tdir/test_file
2632 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2633 cleanup_test32_mount
2635 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2640 trap cleanup_test32_mount EXIT
2641 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2642 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2643 test_mkdir -p $DIR/$tdir/d2
2644 touch $DIR/$tdir/d2/test_file || error
2645 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2646 cleanup_test32_mount
2648 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2653 trap cleanup_test32_mount EXIT
2654 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2655 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2656 test_mkdir -p $DIR/$tdir/d2
2657 touch $DIR/$tdir/d2/test_file
2658 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2659 cleanup_test32_mount
2661 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2665 test_mkdir -p $DIR/d32m/tmp
2666 TMP_DIR=$DIR/d32m/tmp
2667 ln -s $DIR $TMP_DIR/symlink11
2668 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2669 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2670 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2672 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2676 test_mkdir -p $DIR/d32n/tmp
2677 TMP_DIR=$DIR/d32n/tmp
2678 ln -s $DIR $TMP_DIR/symlink11
2679 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2680 ls -l $DIR/d32n/tmp/symlink11 || error
2681 ls -l $DIR/d32n/symlink01 || error
2683 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2687 test_mkdir -p $DIR/d32o/tmp
2688 TMP_DIR=$DIR/d32o/tmp
2689 ln -s $DIR/$tfile $TMP_DIR/symlink12
2690 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2691 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2692 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2693 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2694 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2696 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2706 test_mkdir -p $DIR/d32p/tmp
2708 TMP_DIR=$DIR/d32p/tmp
2710 ln -s $DIR/$tfile $TMP_DIR/symlink12
2712 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2714 cat $DIR/d32p/tmp/symlink12 || error
2716 cat $DIR/d32p/symlink02 || error
2719 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2723 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2724 trap cleanup_test32_mount EXIT
2725 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2726 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2727 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2728 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2729 cleanup_test32_mount
2731 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2734 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2735 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2736 trap cleanup_test32_mount EXIT
2737 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2738 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2739 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2740 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2741 cleanup_test32_mount
2743 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2748 chmod 444 $DIR/$tfile
2749 chown $RUNAS_ID $DIR/$tfile
2751 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2754 run_test 33aa "write file with mode 444 (should return error) ===="
2758 test_mkdir -p $DIR/d33
2759 chown $RUNAS_ID $DIR/d33
2760 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2761 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2762 error "open RDWR" || true
2764 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2768 test_mkdir -p $DIR/d33
2769 chown $RUNAS_ID $DIR/d33
2770 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2772 run_test 33b "test open file with malformed flags (No panic)"
2775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2781 remote_ost_nodsh && skip "remote OST with nodsh" && return
2784 test_mkdir -p $DIR/d33
2785 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2788 for ostnum in $(seq $OSTCOUNT); do
2789 # test-framework's OST numbering is one-based, while Lustre's
2791 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2792 # Parsing llobdstat's output sucks; we could grep the /proc
2793 # path, but that's likely to not be as portable as using the
2794 # llobdstat utility. So we parse lctl output instead.
2795 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2796 obdfilter/$ostname/stats |
2797 awk '/^write_bytes/ {print $7}' )
2798 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2799 if (( ${write_bytes:-0} > 0 ))
2806 $all_zeros || return 0
2809 echo foo > $DIR/d33/bar
2813 # Total up write_bytes after writing. We'd better find non-zeros.
2814 for ostnum in $(seq $OSTCOUNT); do
2815 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2816 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2817 obdfilter/$ostname/stats |
2818 awk '/^write_bytes/ {print $7}' )
2819 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2820 if (( ${write_bytes:-0} > 0 ))
2829 for ostnum in $(seq $OSTCOUNT); do
2830 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2831 echo "Check that write_bytes is present in obdfilter/*/stats:"
2832 do_facet ost$ostnum lctl get_param -n \
2833 obdfilter/$ostname/stats
2835 error "OST not keeping write_bytes stats (b22312)"
2838 run_test 33c "test llobdstat and write_bytes"
2841 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2844 local remote_dir=$DIR/$tdir/remote_dir
2846 test_mkdir -p $DIR/$tdir
2847 $LFS mkdir -i $MDTIDX $remote_dir ||
2848 error "create remote directory failed"
2850 touch $remote_dir/$tfile
2851 chmod 444 $remote_dir/$tfile
2852 chown $RUNAS_ID $remote_dir/$tfile
2854 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2856 chown $RUNAS_ID $remote_dir
2857 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2858 error "create" || true
2859 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2860 error "open RDWR" || true
2861 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2863 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2866 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2870 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2871 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2872 mkdir $DIR/$tdir/local_dir
2874 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2875 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2876 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2878 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2879 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2881 rmdir $DIR/$tdir/* || error "rmdir failed"
2884 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2885 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2886 mkdir $DIR/$tdir/local_dir
2888 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2889 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2890 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2892 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2893 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2895 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2898 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2899 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2900 mkdir $DIR/$tdir/local_dir
2902 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2903 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2904 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2906 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2907 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2909 run_test 33e "mkdir and striped directory should have same mode"
2913 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2918 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2921 chmod go+rwx $DIR/$tdir
2922 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2923 trap cleanup_33f EXIT
2925 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2926 error "cannot create striped directory"
2928 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2929 error "cannot create files in striped directory"
2931 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2932 error "cannot remove files in striped directory"
2934 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2935 error "cannot remove striped directory"
2939 run_test 33f "nonroot user can create, access, and remove a striped directory"
2942 mkdir -p $DIR/$tdir/dir2
2944 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2946 [[ $err =~ "exists" ]] || error "Not exists error"
2948 run_test 33g "nonroot user create already existing root created file"
2950 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2953 $MCREATE $DIR/f34 || error
2954 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2955 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2956 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2957 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2959 run_test 34a "truncate file that has not been opened ==========="
2962 [ ! -f $DIR/f34 ] && test_34a
2963 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2964 $OPENFILE -f O_RDONLY $DIR/f34
2965 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2966 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2968 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2971 [ ! -f $DIR/f34 ] && test_34a
2972 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2973 $OPENFILE -f O_RDWR $DIR/f34
2974 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2975 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2977 run_test 34c "O_RDWR opening file-with-size works =============="
2980 [ ! -f $DIR/f34 ] && test_34a
2981 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2982 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2985 run_test 34d "write to sparse file ============================="
2989 $MCREATE $DIR/f34e || error
2990 $TRUNCATE $DIR/f34e 1000 || error
2991 $CHECKSTAT -s 1000 $DIR/f34e || error
2992 $OPENFILE -f O_RDWR $DIR/f34e
2993 $CHECKSTAT -s 1000 $DIR/f34e || error
2995 run_test 34e "create objects, some with size and some without =="
2997 test_34f() { # bug 6242, 6243
2998 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3001 $MCREATE $DIR/f34f || error
3002 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3003 dd if=$DIR/f34f of=$TMP/f34f
3004 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3005 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3006 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3007 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3008 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3010 run_test 34f "read from a file with no objects until EOF ======="
3013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3014 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
3015 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
3016 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
3017 cancel_lru_locks osc
3018 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
3019 error "wrong size after lock cancel"
3021 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
3022 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
3023 error "expanding truncate failed"
3024 cancel_lru_locks osc
3025 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
3026 error "wrong expanded size after lock cancel"
3028 run_test 34g "truncate long file ==============================="
3031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3035 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
3036 sync # Flush the cache so that multiop below does not block on cache
3037 # flush when getting the group lock
3038 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3041 # Since just timed wait is not good enough, let's do a sync write
3042 # that way we are sure enough time for a roundtrip + processing
3043 # passed + 2 seconds of extra margin.
3044 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
3048 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3049 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3053 local nsz=`stat -c %s $DIR/$tfile`
3054 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3056 run_test 34h "ftruncate file under grouplock should not block"
3059 cp /bin/sh $DIR/f35a
3061 chown $RUNAS_ID $DIR/f35a
3062 $RUNAS $DIR/f35a && error || true
3065 run_test 35a "exec file with mode 444 (should return and not leak) ====="
3069 utime $DIR/f36 || error
3071 run_test 36a "MDS utime check (mknod, utime) ==================="
3075 utime $DIR/f36 || error
3077 run_test 36b "OST utime check (open, utime) ===================="
3082 chown $RUNAS_ID $DIR/d36
3083 $RUNAS utime $DIR/d36/f36 || error
3085 run_test 36c "non-root MDS utime check (mknod, utime) =========="
3088 [ ! -d $DIR/d36 ] && test_36c
3089 echo "" > $DIR/d36/f36
3090 $RUNAS utime $DIR/d36/f36 || error
3092 run_test 36d "non-root OST utime check (open, utime) ==========="
3095 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3096 test_mkdir -p $DIR/$tdir
3097 touch $DIR/$tdir/$tfile
3098 $RUNAS utime $DIR/$tdir/$tfile && \
3099 error "utime worked, expected failure" || true
3101 run_test 36e "utime on non-owned file (should return error) ===="
3105 local LANG_SAVE=$LANG
3106 local LC_LANG_SAVE=$LC_LANG
3107 export LANG=C LC_LANG=C # for date language
3109 DATESTR="Dec 20 2000"
3110 test_mkdir -p $DIR/$tdir
3111 lctl set_param fail_loc=$fl
3113 cp /etc/hosts $DIR/$tdir/$tfile
3114 sync & # write RPC generated with "current" inode timestamp, but delayed
3116 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3117 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3118 cancel_lru_locks osc
3119 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3121 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3122 echo "BEFORE: $LS_BEFORE" && \
3123 echo "AFTER : $LS_AFTER" && \
3124 echo "WANT : $DATESTR" && \
3125 error "$DIR/$tdir/$tfile timestamps changed" || true
3127 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3132 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3133 subr_36fh "0x80000214"
3135 run_test 36f "utime on file racing with OST BRW write =========="
3138 remote_ost_nodsh && skip "remote OST with nodsh" && return
3139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3144 test_mkdir -p $DIR/$tdir
3145 fmd_max_age=$(do_facet ost1 \
3146 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3149 fmd_before=$(do_facet ost1 \
3150 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3151 touch $DIR/$tdir/$tfile
3152 sleep $((fmd_max_age + 12))
3153 fmd_after=$(do_facet ost1 \
3154 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3156 echo "fmd_before: $fmd_before"
3157 echo "fmd_after: $fmd_after"
3158 [[ $fmd_after -gt $fmd_before ]] &&
3159 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3160 error "fmd didn't expire after ping" || true
3162 run_test 36g "filter mod data cache expiry ====================="
3165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3166 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3167 subr_36fh "0x80000227"
3169 run_test 36h "utime on file racing with OST BRW write =========="
3172 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3174 test_mkdir $DIR/$tdir
3175 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3177 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3178 local new_mtime=$((mtime + 200))
3180 #change Modify time of striped dir
3181 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3182 error "change mtime failed"
3184 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3186 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3188 run_test 36i "change mtime on striped directory"
3190 # test_37 - duplicate with tests 32q 32r
3193 local file=$DIR/$tfile
3195 openfile -f O_DIRECTORY $file
3198 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3199 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3201 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3203 test_39a() { # was test_39
3205 touch $DIR/${tfile}2
3206 # ls -l $DIR/$tfile $DIR/${tfile}2
3207 # ls -lu $DIR/$tfile $DIR/${tfile}2
3208 # ls -lc $DIR/$tfile $DIR/${tfile}2
3210 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3211 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3213 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3215 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3217 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3218 error "O_TRUNC didn't change timestamps"
3221 run_test 39a "mtime changed on create ==========================="
3224 test_mkdir -p -c1 $DIR/$tdir
3225 cp -p /etc/passwd $DIR/$tdir/fopen
3226 cp -p /etc/passwd $DIR/$tdir/flink
3227 cp -p /etc/passwd $DIR/$tdir/funlink
3228 cp -p /etc/passwd $DIR/$tdir/frename
3229 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3232 echo "aaaaaa" >> $DIR/$tdir/fopen
3233 echo "aaaaaa" >> $DIR/$tdir/flink
3234 echo "aaaaaa" >> $DIR/$tdir/funlink
3235 echo "aaaaaa" >> $DIR/$tdir/frename
3237 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3238 local link_new=`stat -c %Y $DIR/$tdir/flink`
3239 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3240 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3242 cat $DIR/$tdir/fopen > /dev/null
3243 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3244 rm -f $DIR/$tdir/funlink2
3245 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3247 for (( i=0; i < 2; i++ )) ; do
3248 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3249 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3250 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3251 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3253 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3254 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3255 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3256 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3258 cancel_lru_locks osc
3259 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3262 run_test 39b "mtime change on open, link, unlink, rename ======"
3264 # this should be set to past
3265 TEST_39_MTIME=`date -d "1 year ago" +%s`
3271 local mtime0=`stat -c %Y $DIR1/$tfile`
3273 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3274 local mtime1=`stat -c %Y $DIR1/$tfile`
3275 [ "$mtime1" = $TEST_39_MTIME ] || \
3276 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3279 echo hello >> $DIR1/$tfile
3281 local mtime2=`stat -c %Y $DIR1/$tfile`
3282 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3283 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3285 mv $DIR1/$tfile $DIR1/$tfile-1
3287 for (( i=0; i < 2; i++ )) ; do
3288 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3289 [ "$mtime2" = "$mtime3" ] || \
3290 error "mtime ($mtime2) changed (to $mtime3) on rename"
3292 cancel_lru_locks osc
3293 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3296 run_test 39c "mtime change on rename ==========================="
3300 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3303 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3305 for (( i=0; i < 2; i++ )) ; do
3306 local mtime=`stat -c %Y $DIR1/$tfile`
3307 [ $mtime = $TEST_39_MTIME ] || \
3308 error "mtime($mtime) is not set to $TEST_39_MTIME"
3310 cancel_lru_locks osc
3311 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3314 run_test 39d "create, utime, stat =============================="
3318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3320 local mtime1=`stat -c %Y $DIR1/$tfile`
3322 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3324 for (( i=0; i < 2; i++ )) ; do
3325 local mtime2=`stat -c %Y $DIR1/$tfile`
3326 [ $mtime2 = $TEST_39_MTIME ] || \
3327 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3329 cancel_lru_locks osc
3330 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3333 run_test 39e "create, stat, utime, stat ========================"
3337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3339 mtime1=`stat -c %Y $DIR1/$tfile`
3342 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3344 for (( i=0; i < 2; i++ )) ; do
3345 local mtime2=`stat -c %Y $DIR1/$tfile`
3346 [ $mtime2 = $TEST_39_MTIME ] || \
3347 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3349 cancel_lru_locks osc
3350 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3353 run_test 39f "create, stat, sleep, utime, stat ================="
3357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3358 echo hello >> $DIR1/$tfile
3359 local mtime1=`stat -c %Y $DIR1/$tfile`
3362 chmod o+r $DIR1/$tfile
3364 for (( i=0; i < 2; i++ )) ; do
3365 local mtime2=`stat -c %Y $DIR1/$tfile`
3366 [ "$mtime1" = "$mtime2" ] || \
3367 error "lost mtime: $mtime2, should be $mtime1"
3369 cancel_lru_locks osc
3370 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3373 run_test 39g "write, chmod, stat ==============================="
3377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3382 echo hello >> $DIR1/$tfile
3383 local mtime1=`stat -c %Y $DIR1/$tfile`
3385 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3387 if [ "$d1" != "$d2" ]; then
3388 echo "write and touch not within one second"
3390 for (( i=0; i < 2; i++ )) ; do
3391 local mtime2=`stat -c %Y $DIR1/$tfile`
3392 [ "$mtime2" = $TEST_39_MTIME ] || \
3393 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3395 cancel_lru_locks osc
3396 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3400 run_test 39h "write, utime within one second, stat ============="
3403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3407 echo hello >> $DIR1/$tfile
3408 local mtime1=`stat -c %Y $DIR1/$tfile`
3410 mv $DIR1/$tfile $DIR1/$tfile-1
3412 for (( i=0; i < 2; i++ )) ; do
3413 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3415 [ "$mtime1" = "$mtime2" ] || \
3416 error "lost mtime: $mtime2, should be $mtime1"
3418 cancel_lru_locks osc
3419 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3422 run_test 39i "write, rename, stat =============================="
3425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3426 start_full_debug_logging
3430 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3431 lctl set_param fail_loc=0x80000412
3432 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3433 error "multiop failed"
3435 local mtime1=`stat -c %Y $DIR1/$tfile`
3437 mv $DIR1/$tfile $DIR1/$tfile-1
3439 kill -USR1 $multipid
3440 wait $multipid || error "multiop close failed"
3442 for (( i=0; i < 2; i++ )) ; do
3443 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3444 [ "$mtime1" = "$mtime2" ] ||
3445 error "mtime is lost on close: $mtime2, " \
3448 cancel_lru_locks osc
3449 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3451 lctl set_param fail_loc=0
3452 stop_full_debug_logging
3454 run_test 39j "write, rename, close, stat ======================="
3457 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3461 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3463 local mtime1=`stat -c %Y $DIR1/$tfile`
3465 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3467 kill -USR1 $multipid
3468 wait $multipid || error "multiop close failed"
3470 for (( i=0; i < 2; i++ )) ; do
3471 local mtime2=`stat -c %Y $DIR1/$tfile`
3473 [ "$mtime2" = $TEST_39_MTIME ] || \
3474 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3476 cancel_lru_locks osc
3477 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3480 run_test 39k "write, utime, close, stat ========================"
3482 # this should be set to future
3483 TEST_39_ATIME=`date -d "1 year" +%s`
3486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3488 local atime_diff=$(do_facet $SINGLEMDS \
3489 lctl get_param -n mdd.*MDT0000*.atime_diff)
3493 # test setting directory atime to future
3494 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3495 local atime=$(stat -c %X $DIR/$tdir)
3496 [ "$atime" = $TEST_39_ATIME ] ||
3497 error "atime is not set to future: $atime, $TEST_39_ATIME"
3499 # test setting directory atime from future to now
3500 local now=$(date +%s)
3501 touch -a -d @$now $DIR/$tdir
3503 atime=$(stat -c %X $DIR/$tdir)
3504 [ "$atime" -eq "$now" ] ||
3505 error "atime is not updated from future: $atime, $now"
3507 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3510 # test setting directory atime when now > dir atime + atime_diff
3511 local d1=$(date +%s)
3513 local d2=$(date +%s)
3514 cancel_lru_locks mdc
3515 atime=$(stat -c %X $DIR/$tdir)
3516 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3517 error "atime is not updated : $atime, should be $d2"
3519 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3522 # test not setting directory atime when now < dir atime + atime_diff
3524 cancel_lru_locks mdc
3525 atime=$(stat -c %X $DIR/$tdir)
3526 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3527 error "atime is updated to $atime, should remain $d1<atime<$d2"
3529 do_facet $SINGLEMDS \
3530 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3532 run_test 39l "directory atime update ==========================="
3535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3538 local far_past_mtime=$(date -d "May 29 1953" +%s)
3539 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3541 touch -m -d @$far_past_mtime $DIR1/$tfile
3542 touch -a -d @$far_past_atime $DIR1/$tfile
3544 for (( i=0; i < 2; i++ )) ; do
3545 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3546 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3547 error "atime or mtime set incorrectly"
3549 cancel_lru_locks osc
3550 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3553 run_test 39m "test atime and mtime before 1970"
3555 test_39n() { # LU-3832
3556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3557 local atime_diff=$(do_facet $SINGLEMDS \
3558 lctl get_param -n mdd.*MDT0000*.atime_diff)
3563 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3566 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3567 atime0=$(stat -c %X $DIR/$tfile)
3570 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3571 atime1=$(stat -c %X $DIR/$tfile)
3574 cancel_lru_locks mdc
3575 cancel_lru_locks osc
3576 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3577 atime2=$(stat -c %X $DIR/$tfile)
3579 do_facet $SINGLEMDS \
3580 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3582 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3583 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3585 run_test 39n "check that O_NOATIME is honored"
3588 TESTDIR=$DIR/$tdir/$tfile
3589 [ -e $TESTDIR ] && rm -rf $TESTDIR
3596 links2=$(stat -c %h .)
3597 [ $(($links1 + 2)) != $links2 ] &&
3598 error "wrong links count $(($links1 + 2)) != $links2"
3600 links3=$(stat -c %h .)
3601 [ $(($links1 + 1)) != $links3 ] &&
3602 error "wrong links count $links1 != $links3"
3605 run_test 39o "directory cached attributes updated after create ========"
3608 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3610 TESTDIR=$DIR/$tdir/$tfile
3611 [ -e $TESTDIR ] && rm -rf $TESTDIR
3612 test_mkdir -p $TESTDIR
3616 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3617 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3619 links2=$(stat -c %h .)
3620 [ $(($links1 + 2)) != $links2 ] &&
3621 error "wrong links count $(($links1 + 2)) != $links2"
3623 links3=$(stat -c %h .)
3624 [ $(($links1 + 1)) != $links3 ] &&
3625 error "wrong links count $links1 != $links3"
3628 run_test 39p "remote directory cached attributes updated after create ========"
3631 test_39q() { # LU-8041
3632 local testdir=$DIR/$tdir
3634 multiop_bg_pause $testdir D_c || error "multiop failed"
3636 cancel_lru_locks mdc
3637 kill -USR1 $multipid
3638 local atime=$(stat -c %X $testdir)
3639 [ "$atime" -ne 0 ] || error "atime is zero"
3641 run_test 39q "close won't zero out atime"
3644 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3645 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3646 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3647 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3648 error "$tfile is not 4096 bytes in size"
3650 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3654 small_write $DIR/f41 18
3656 run_test 41 "test small file write + fstat ====================="
3658 count_ost_writes() {
3659 lctl get_param -n osc.*.stats |
3660 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3661 END { printf("%0.0f", writes) }'
3668 BG_DIRTY_RATIO_SAVE=10
3669 MAX_BG_DIRTY_RATIO=25
3673 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3674 # dirty_ratio, dirty_background_ratio
3675 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3676 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3677 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3678 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3680 # if file not here, we are a 2.4 kernel
3681 kill -CONT `pidof kupdated`
3686 # setup the trap first, so someone cannot exit the test at the
3687 # exact wrong time and mess up a machine
3688 trap start_writeback EXIT
3689 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3690 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3691 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3692 sysctl -w vm.dirty_writeback_centisecs=0
3693 sysctl -w vm.dirty_writeback_centisecs=0
3694 # save and increase /proc/sys/vm/dirty_ratio
3695 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3696 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3697 # save and increase /proc/sys/vm/dirty_background_ratio
3698 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3699 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3701 # if file not here, we are a 2.4 kernel
3702 kill -STOP `pidof kupdated`
3706 # ensure that all stripes have some grant before we test client-side cache
3708 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3709 dd if=/dev/zero of=$i bs=4k count=1
3714 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3715 # file truncation, and file removal.
3717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3719 cancel_lru_locks osc
3721 sync; sleep 1; sync # just to be safe
3722 BEFOREWRITES=`count_ost_writes`
3723 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3724 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3725 AFTERWRITES=`count_ost_writes`
3726 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3727 error "$BEFOREWRITES < $AFTERWRITES"
3730 run_test 42a "ensure that we don't flush on close"
3733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3735 cancel_lru_locks osc
3738 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3739 BEFOREWRITES=$(count_ost_writes)
3740 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3741 AFTERWRITES=$(count_ost_writes)
3742 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3743 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3745 BEFOREWRITES=$(count_ost_writes)
3746 sync || error "sync: $?"
3747 AFTERWRITES=$(count_ost_writes)
3748 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3749 error "$BEFOREWRITES < $AFTERWRITES on sync"
3751 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3755 run_test 42b "test destroy of file with cached dirty data ======"
3757 # if these tests just want to test the effect of truncation,
3758 # they have to be very careful. consider:
3759 # - the first open gets a {0,EOF}PR lock
3760 # - the first write conflicts and gets a {0, count-1}PW
3761 # - the rest of the writes are under {count,EOF}PW
3762 # - the open for truncate tries to match a {0,EOF}PR
3763 # for the filesize and cancels the PWs.
3764 # any number of fixes (don't get {0,EOF} on open, match
3765 # composite locks, do smarter file size management) fix
3766 # this, but for now we want these tests to verify that
3767 # the cancellation with truncate intent works, so we
3768 # start the file with a full-file pw lock to match against
3769 # until the truncate.
3774 cancel_lru_locks osc
3776 # prime the file with 0,EOF PW to match
3780 # now the real test..
3781 dd if=/dev/zero of=$file bs=1024 count=100
3782 BEFOREWRITES=`count_ost_writes`
3783 $TRUNCATE $file $offset
3784 cancel_lru_locks osc
3785 AFTERWRITES=`count_ost_writes`
3790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3792 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3793 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3796 run_test 42c "test partial truncate of file with cached dirty data"
3799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3801 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3802 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3805 run_test 42d "test complete truncate of file with cached dirty data"
3807 test_42e() { # bug22074
3808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3809 local TDIR=$DIR/${tdir}e
3810 local pagesz=$(page_size)
3811 local pages=16 # hardcoded 16 pages, don't change it.
3812 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3813 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3817 test_mkdir -p $DIR/${tdir}e
3818 $SETSTRIPE -c 1 $TDIR
3819 createmany -o $TDIR/f $files
3821 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3823 # we assume that with $OSTCOUNT files, at least one of them will
3824 # be allocated on OST0.
3825 warmup_files=$((OSTCOUNT * max_dirty_mb))
3826 createmany -o $TDIR/w $warmup_files
3828 # write a large amount of data into one file and sync, to get good
3829 # avail_grant number from OST.
3830 for ((i=0; i<$warmup_files; i++)); do
3831 idx=$($GETSTRIPE -i $TDIR/w$i)
3832 [ $idx -ne 0 ] && continue
3833 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3836 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3838 $LCTL get_param $proc_osc0/cur_dirty_bytes
3839 $LCTL get_param $proc_osc0/cur_grant_bytes
3841 # create as much dirty pages as we can while not to trigger the actual
3842 # RPCs directly. but depends on the env, VFS may trigger flush during this
3843 # period, hopefully we are good.
3844 for ((i=0; i<$warmup_files; i++)); do
3845 idx=$($GETSTRIPE -i $TDIR/w$i)
3846 [ $idx -ne 0 ] && continue
3847 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3849 $LCTL get_param $proc_osc0/cur_dirty_bytes
3850 $LCTL get_param $proc_osc0/cur_grant_bytes
3852 # perform the real test
3853 $LCTL set_param $proc_osc0/rpc_stats 0
3854 for ((;i<$files; i++)); do
3855 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3856 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3859 $LCTL get_param $proc_osc0/rpc_stats
3862 local have_ppr=false
3863 $LCTL get_param $proc_osc0/rpc_stats |
3864 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3865 # skip lines until we are at the RPC histogram data
3866 [ "$PPR" == "pages" ] && have_ppr=true && continue
3867 $have_ppr || continue
3869 # we only want the percent stat for < 16 pages
3870 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3872 percent=$((percent + WPCT))
3873 if [[ $percent -gt 15 ]]; then
3874 error "less than 16-pages write RPCs" \
3881 run_test 42e "verify sub-RPC writes are not done synchronously"
3883 test_43A() { # was test_43
3884 test_mkdir -p $DIR/$tdir
3885 cp -p /bin/ls $DIR/$tdir/$tfile
3886 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3888 # give multiop a chance to open
3891 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3894 run_test 43A "execution of file opened for write should return -ETXTBSY"
3897 test_mkdir $DIR/$tdir
3898 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3899 cp -p multiop $DIR/$tdir/multiop
3900 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3901 error "multiop open $TMP/$tfile.junk failed"
3903 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3904 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3905 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3907 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3911 test_mkdir $DIR/$tdir
3912 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3913 cp -p multiop $DIR/$tdir/multiop
3914 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3915 error "multiop open $TMP/$tfile.junk failed"
3917 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3918 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3919 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3921 run_test 43b "truncate of file being executed should return -ETXTBSY"
3924 local testdir="$DIR/$tdir"
3927 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3928 ( cd $testdir && md5sum -c )
3930 run_test 43c "md5sum of copy into lustre"
3932 test_44A() { # was test_44
3933 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3934 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3935 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3937 run_test 44A "zero length read from a sparse stripe"
3940 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3942 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3943 [[ $nstripe -gt $OSTCOUNT ]] &&
3944 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3946 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3948 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3949 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3953 OFFSETS="0 $((stride/2)) $((stride-1))"
3954 for offset in $OFFSETS; do
3955 for i in $(seq 0 $((nstripe-1))); do
3956 local GLOBALOFFSETS=""
3958 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3959 local myfn=$DIR/d44a-$size
3960 echo "--------writing $myfn at $size"
3961 ll_sparseness_write $myfn $size ||
3962 error "ll_sparseness_write"
3963 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3964 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3965 error "ll_sparseness_verify $GLOBALOFFSETS"
3967 for j in $(seq 0 $((nstripe-1))); do
3969 size=$((((j + $nstripe )*$stride + $offset)))
3970 ll_sparseness_write $myfn $size ||
3971 error "ll_sparseness_write"
3972 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3974 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3975 error "ll_sparseness_verify $GLOBALOFFSETS"
3980 run_test 44a "test sparse pwrite ==============================="
3984 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3990 before=`dirty_osc_total`
3991 echo executing "\"$*\""
3993 after=`dirty_osc_total`
3994 echo before $before, after $after
3997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3999 # Obtain grants from OST if it supports it
4000 echo blah > ${f}_grant
4003 do_dirty_record "echo blah > $f"
4004 [[ $before -eq $after ]] && error "write wasn't cached"
4005 do_dirty_record "> $f"
4006 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4007 do_dirty_record "echo blah > $f"
4008 [[ $before -eq $after ]] && error "write wasn't cached"
4009 do_dirty_record "sync"
4010 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4011 do_dirty_record "echo blah > $f"
4012 [[ $before -eq $after ]] && error "write wasn't cached"
4013 do_dirty_record "cancel_lru_locks osc"
4014 [[ $before -gt $after ]] ||
4015 error "lock cancellation didn't lower dirty count"
4018 run_test 45 "osc io page accounting ============================"
4020 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4021 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4022 # objects offset and an assert hit when an rpc was built with 1023's mapped
4023 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4025 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4029 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4031 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
4032 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4036 run_test 46 "dirtying a previously written page ================"
4038 # test_47 is removed "Device nodes check" is moved to test_28
4040 test_48a() { # bug 2399
4041 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
4042 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
4043 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
4045 test_mkdir $DIR/$tdir
4047 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4048 test_mkdir $DIR/$tdir || error "recreate directory failed"
4049 touch foo || error "'touch foo' failed after recreating cwd"
4050 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
4051 touch .foo || error "'touch .foo' failed after recreating cwd"
4052 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
4053 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4054 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4055 cd . || error "'cd .' failed after recreating cwd"
4056 test_mkdir . && error "'mkdir .' worked after recreating cwd"
4057 rmdir . && error "'rmdir .' worked after recreating cwd"
4058 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4059 cd .. || error "'cd ..' failed after recreating cwd"
4061 run_test 48a "Access renamed working dir (should return errors)="
4063 test_48b() { # bug 2399
4065 test_mkdir $DIR/$tdir
4067 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4068 touch foo && error "'touch foo' worked after removing cwd"
4069 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4070 touch .foo && error "'touch .foo' worked after removing cwd"
4071 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4072 ls . > /dev/null && error "'ls .' worked after removing cwd"
4073 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4074 test_mkdir . && error "'mkdir .' worked after removing cwd"
4075 rmdir . && error "'rmdir .' worked after removing cwd"
4076 ln -s . foo && error "'ln -s .' worked after removing cwd"
4077 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4079 run_test 48b "Access removed working dir (should return errors)="
4081 test_48c() { # bug 2350
4082 #lctl set_param debug=-1
4085 test_mkdir -p $DIR/$tdir/dir
4087 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4088 $TRACE touch foo && error "touch foo worked after removing cwd"
4089 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4090 touch .foo && error "touch .foo worked after removing cwd"
4091 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
4092 $TRACE ls . && error "'ls .' worked after removing cwd"
4093 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4094 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
4095 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4096 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4097 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4099 run_test 48c "Access removed working subdir (should return errors)"
4101 test_48d() { # bug 2350
4102 #lctl set_param debug=-1
4105 test_mkdir -p $DIR/$tdir/dir
4107 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4108 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4109 $TRACE touch foo && error "'touch foo' worked after removing parent"
4110 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
4111 touch .foo && error "'touch .foo' worked after removing parent"
4112 test_mkdir .foo && error "mkdir .foo worked after removing parent"
4113 $TRACE ls . && error "'ls .' worked after removing parent"
4114 $TRACE ls .. && error "'ls ..' worked after removing parent"
4115 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
4116 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4117 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4120 run_test 48d "Access removed parent subdir (should return errors)"
4122 test_48e() { # bug 4134
4123 #lctl set_param debug=-1
4126 test_mkdir -p $DIR/$tdir/dir
4128 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4129 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4130 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4131 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4132 # On a buggy kernel addition of "touch foo" after cd .. will
4133 # produce kernel oops in lookup_hash_it
4134 touch ../foo && error "'cd ..' worked after recreate parent"
4136 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4138 run_test 48e "Access to recreated parent subdir (should return errors)"
4140 test_49() { # LU-1030
4141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4142 remote_ost_nodsh && skip "remote OST with nodsh" && return
4143 # get ost1 size - lustre-OST0000
4144 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4146 # write 800M at maximum
4147 [[ $ost1_size -lt 2 ]] && ost1_size=2
4148 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4150 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4151 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4154 # change max_pages_per_rpc while writing the file
4155 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4156 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4157 # loop until dd process exits
4158 while ps ax -opid | grep -wq $dd_pid; do
4159 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4160 sleep $((RANDOM % 5 + 1))
4162 # restore original max_pages_per_rpc
4163 $LCTL set_param $osc1_mppc=$orig_mppc
4164 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4166 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4170 test_mkdir $DIR/$tdir
4172 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4174 run_test 50 "special situations: /proc symlinks ==============="
4176 test_51a() { # was test_51
4177 # bug 1516 - create an empty entry right after ".." then split dir
4178 test_mkdir -c1 $DIR/$tdir
4179 touch $DIR/$tdir/foo
4180 $MCREATE $DIR/$tdir/bar
4182 createmany -m $DIR/$tdir/longfile 201
4184 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4185 $MCREATE $DIR/$tdir/longfile$FNUM
4190 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4192 run_test 51a "special situations: split htree with empty entry =="
4194 cleanup_print_lfs_df () {
4201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4202 local dir=$DIR/$tdir
4204 local nrdirs=$((65536 + 100))
4206 # cleanup the directory
4209 test_mkdir -p -c1 $dir
4213 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4214 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4215 [[ $numfree -lt $nrdirs ]] &&
4216 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4219 # need to check free space for the directories as well
4220 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4221 numfree=$(( blkfree / $(fs_inode_ksize) ))
4222 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4225 trap cleanup_print_lfs_df EXIT
4228 createmany -d $dir/d $nrdirs || {
4229 unlinkmany $dir/d $nrdirs
4230 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4234 nrdirs=$(ls -U $dir | wc -l)
4236 # unlink all but 100 subdirectories, then check it still works
4238 local delete=$((nrdirs - left))
4243 # for ldiskfs the nlink count should be 1, but this is OSD specific
4244 # and so this is listed for informational purposes only
4245 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4246 unlinkmany -d $dir/d $delete ||
4247 error "unlink of first $delete subdirs failed"
4249 echo "nlink between: $(stat -c %h $dir)"
4250 local found=$(ls -U $dir | wc -l)
4251 [ $found -ne $left ] &&
4252 error "can't find subdirs: found only $found, expected $left"
4254 unlinkmany -d $dir/d $delete $left ||
4255 error "unlink of second $left subdirs failed"
4256 # regardless of whether the backing filesystem tracks nlink accurately
4257 # or not, the nlink count shouldn't be more than "." and ".." here
4258 local after=$(stat -c %h $dir)
4259 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4260 echo "nlink after: $after"
4262 cleanup_print_lfs_df
4264 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4268 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4269 test_mkdir -p $DIR/$tdir
4270 createmany -o $DIR/$tdir/t- 1000
4271 $GETSTRIPE $DIR/$tdir > $TMP/$tfile
4272 for N in $(seq 0 $((OSTCOUNT - 1))); do
4273 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4274 END { printf("%0.0f", objs) }' $TMP/$tfile)
4275 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4276 '($1 == '$N') { objs += 1 } \
4277 END { printf("%0.0f", objs) }')
4278 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4280 unlinkmany $DIR/$tdir/t- 1000
4283 for N in $(seq 1 $((OSTCOUNT - 1))); do
4284 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4285 error "OST $N has less objects vs OST $NLAST" \
4286 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4287 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4288 error "OST $N has less objects vs OST $NLAST" \
4289 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4291 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4292 error "OST $N has less #0 objects vs OST $NLAST" \
4293 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4294 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4295 error "OST $N has less #0 objects vs OST $NLAST" \
4296 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4301 run_test 51d "check object distribution"
4304 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4305 skip "ldiskfs only test"
4309 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4310 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4312 touch $DIR/$tdir/d0/foo
4313 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4314 error "file exceed 65000 nlink limit!"
4315 unlinkmany $DIR/$tdir/d0/f- 65001
4318 run_test 51e "check file nlink limit"
4321 test_mkdir $DIR/$tdir
4324 local ulimit_old=$(ulimit -n)
4325 local spare=20 # number of spare fd's for scripts/libraries, etc.
4326 local mdt=$(lfs getstripe -M $DIR/$tdir)
4327 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4329 echo "MDT$mdt numfree=$numfree, max=$max"
4330 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4331 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4332 while ! ulimit -n $((numfree + spare)); do
4333 numfree=$((numfree * 3 / 4))
4335 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4337 echo "left ulimit at $ulimit_old"
4340 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4341 unlinkmany $DIR/$tdir/f $numfree
4342 error "create+open $numfree files in $DIR/$tdir failed"
4344 ulimit -n $ulimit_old
4346 # if createmany exits at 120s there will be fewer than $numfree files
4347 unlinkmany $DIR/$tdir/f $numfree || true
4349 run_test 51f "check many open files limit"
4352 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4353 test_mkdir -p $DIR/$tdir
4354 touch $DIR/$tdir/foo
4355 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4356 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4357 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4358 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4359 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4361 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4362 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4363 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4365 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4366 cp -r $DIR/$tdir $TMP/
4367 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4369 run_test 52a "append-only flag test (should return errors)"
4372 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4373 test_mkdir -p $DIR/$tdir
4374 touch $DIR/$tdir/foo
4375 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4376 cat test > $DIR/$tdir/foo && error "cat test worked"
4377 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4378 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4379 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4381 echo foo >> $DIR/$tdir/foo && error "echo worked"
4382 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4383 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4384 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4385 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4387 chattr -i $DIR/$tdir/foo || error "chattr failed"
4389 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4391 run_test 52b "immutable flag test (should return errors) ======="
4394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4395 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4396 remote_ost_nodsh && skip "remote OST with nodsh" && return
4409 local support_last_seq=true
4411 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4412 support_last_seq=false
4415 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4417 for value in $(do_facet $SINGLEMDS \
4418 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4419 param=$(echo ${value[0]} | cut -d "=" -f1)
4420 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4422 if $support_last_seq; then
4423 param_seq=$(echo $param |
4424 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4425 mds_last_seq=$(do_facet $SINGLEMDS \
4426 $LCTL get_param -n $param_seq)
4428 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4430 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4431 node=$(facet_active_host ost$((ostnum+1)))
4432 param="obdfilter.$ostname.last_id"
4433 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4434 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4435 ost_last_id=$ost_last
4437 if $support_last_seq; then
4438 ost_last_id=$(echo $ost_last |
4439 awk -F':' '{print $2}' |
4441 ost_last_seq=$(echo $ost_last |
4442 awk -F':' '{print $1}')
4443 [[ $ost_last_seq = $mds_last_seq ]] || continue
4446 if [[ $ost_last_id != $mds_last ]]; then
4447 error "$ost_last_id != $mds_last"
4454 $found || error "can not match last_seq/last_id for $mdtosc"
4457 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4460 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4462 $SOCKETSERVER $DIR/socket ||
4463 error "$SOCKETSERVER $DIR/socket failed: $?"
4464 $SOCKETCLIENT $DIR/socket ||
4465 error "$SOCKETCLIENT $DIR/socket failed: $?"
4466 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4468 run_test 54a "unix domain socket test =========================="
4474 dd if=/dev/zero of=$f bs=$(page_size) count=1
4476 run_test 54b "char device works in lustre ======================"
4479 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4480 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4481 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4483 for i in $(seq 3 7); do
4484 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4493 loopdev="$DIR/loop54c"
4496 $UMOUNT $DIR/$tdir || rc=$?
4497 losetup -d $loopdev || true
4498 losetup -d $LOOPDEV || true
4499 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4505 loopdev="$DIR/loop54c"
4508 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4509 trap cleanup_54c EXIT
4510 mknod $loopdev b 7 $LOOPNUM
4511 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4512 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4513 losetup $loopdev $DIR/$tfile ||
4514 error "can't set up $loopdev for $DIR/$tfile"
4515 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4516 test_mkdir -p $DIR/$tdir
4517 mount -t ext2 $loopdev $DIR/$tdir ||
4518 error "error mounting $loopdev on $DIR/$tdir"
4519 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4522 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4526 run_test 54c "block device works in lustre ====================="
4532 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4534 run_test 54d "fifo device works in lustre ======================"
4539 cp -aL /dev/console $f
4540 echo $string > $f || error "echo $string to $f failed"
4542 run_test 54e "console/tty device works in lustre ======================"
4544 #The test_55 used to be iopen test and it was removed by bz#24037.
4545 #run_test 55 "check iopen_connect_dentry() ======================"
4547 test_56a() { # was test_56
4550 test_mkdir -p $DIR/$tdir/dir
4552 NUMFILESx2=$(($NUMFILES * 2))
4553 for i in $(seq 1 $NUMFILES); do
4554 touch $DIR/$tdir/file$i
4555 touch $DIR/$tdir/dir/file$i
4558 # test lfs getstripe with --recursive
4559 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4560 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4561 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4562 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4563 [[ $FILENUM -eq $NUMFILES ]] ||
4564 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4565 echo "$GETSTRIPE --recursive passed."
4567 # test lfs getstripe with file instead of dir
4568 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4569 [[ $FILENUM -eq 1 ]] ||
4570 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4571 echo "$GETSTRIPE file1 passed."
4573 #test lfs getstripe with --verbose
4574 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4575 grep -c lmm_magic) -eq $NUMFILES ]] ||
4576 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4577 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4578 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4580 #test lfs getstripe with -v prints lmm_fid
4581 [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
4582 error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
4583 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
4584 error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
4585 echo "$GETSTRIPE --verbose passed."
4587 #check for FID information
4588 local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
4589 local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
4590 awk '/lmm_fid: / { print $2 }')
4591 local fid3=$($LFS path2fid $DIR/$tdir/file1)
4592 [ "$fid1" != "$fid2" ] &&
4593 error "getstripe --fid $fid1 != getstripe --verbose $fid2"
4594 [ "$fid1" != "$fid3" ] &&
4595 error "getstripe --fid $fid1 != lfs path2fid $fid3"
4596 echo "$GETSTRIPE --fid passed."
4598 #test lfs getstripe with --obd
4599 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4600 grep -q "unknown obduuid" ||
4601 error "$GETSTRIPE --obd wrong_uuid should return error message"
4603 [[ $OSTCOUNT -lt 2 ]] &&
4604 skip_env "skipping other $GETSTRIPE --obd test" && return
4607 OBDUUID=$(ostuuid_from_index $OSTIDX)
4608 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4609 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4610 [[ $FOUND -eq $FILENUM ]] ||
4611 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4612 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4613 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4614 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4615 error "$GETSTRIPE --obd: should not show file on other obd"
4616 echo "$GETSTRIPE --obd passed"
4618 run_test 56a "check $GETSTRIPE"
4621 test_mkdir $DIR/$tdir
4623 for i in $(seq 1 $NUMDIRS); do
4624 test_mkdir $DIR/$tdir/dir$i
4627 # test lfs getdirstripe default mode is non-recursion, which is
4628 # different from lfs getstripe
4629 dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
4630 [[ $dircnt -eq 1 ]] ||
4631 error "$LFS getdirstripe: found $dircnt, not 1"
4632 dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
4633 grep -c lmv_stripe_count)
4634 [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
4635 error "$LFS getdirstripe --recursive: found $dircnt, \
4636 not $((NUMDIRS + 1))"
4638 run_test 56b "check $LFS getdirstripe"
4642 local ost_name=$(ostname_from_index $ost_idx)
4644 local old_status=$(ost_dev_status $ost_idx)
4645 [[ -z "$old_status" ]] ||
4646 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4648 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4651 local new_status=$(ost_dev_status $ost_idx)
4652 [[ "$new_status" = "D" ]] ||
4653 error "OST $ost_name is in status of '$new_status', not 'D'"
4655 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4658 new_status=$(ost_dev_status $ost_idx)
4659 [[ -z "$new_status" ]] ||
4660 error "OST $ost_name is in status of '$new_status', not ''"
4662 run_test 56c "check 'lfs df' showing device status"
4667 local LOCAL_NUMFILES="$1"
4668 local LOCAL_NUMDIRS="$2"
4669 local MKDIR_PARAMS="$3"
4670 local DIR_STRIPE_PARAMS="$4"
4672 if [ ! -d "$TDIR" ] ; then
4673 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4674 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4675 for i in `seq 1 $LOCAL_NUMFILES` ; do
4678 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4679 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4680 for j in `seq 1 $LOCAL_NUMFILES` ; do
4681 touch $TDIR/dir$i/file$j
4687 setup_56_special() {
4691 if [ ! -e "$TDIR/loop1b" ] ; then
4692 for i in `seq 1 $LOCAL_NUMFILES` ; do
4693 mknod $TDIR/loop${i}b b 7 $i
4694 mknod $TDIR/null${i}c c 1 3
4695 ln -s $TDIR/file1 $TDIR/link${i}l
4697 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4698 mknod $TDIR/dir$i/loop${i}b b 7 $i
4699 mknod $TDIR/dir$i/null${i}c c 1 3
4700 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4709 setup_56 $NUMFILES $NUMDIRS
4711 EXPECTED=$(($NUMDIRS + 2))
4712 # test lfs find with -name
4713 for i in $(seq 1 $NUMFILES) ; do
4714 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4715 [ $NUMS -eq $EXPECTED ] ||
4716 error "lfs find -name \"*$i\" $TDIR wrong: "\
4717 "found $NUMS, expected $EXPECTED"
4720 run_test 56g "check lfs find -name ============================="
4726 setup_56 $NUMFILES $NUMDIRS
4728 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4729 # test lfs find with ! -name
4730 for i in $(seq 1 $NUMFILES) ; do
4731 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4732 [ $NUMS -eq $EXPECTED ] ||
4733 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4734 "found $NUMS, expected $EXPECTED"
4737 run_test 56h "check lfs find ! -name ============================="
4741 test_mkdir -p $DIR/$tdir
4742 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4743 CMD="$LFIND -ost $UUID $DIR/$tdir"
4745 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4747 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4751 setup_56_special $NUMFILES $NUMDIRS
4753 EXPECTED=$((NUMDIRS + 1))
4754 CMD="$LFIND -type d $TDIR"
4755 NUMS=$($CMD | wc -l)
4756 [ $NUMS -eq $EXPECTED ] ||
4757 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4759 run_test 56j "check lfs find -type d ============================="
4763 setup_56_special $NUMFILES $NUMDIRS
4765 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4766 CMD="$LFIND -type f $TDIR"
4767 NUMS=$($CMD | wc -l)
4768 [ $NUMS -eq $EXPECTED ] ||
4769 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4771 run_test 56k "check lfs find -type f ============================="
4775 setup_56_special $NUMFILES $NUMDIRS
4777 EXPECTED=$((NUMDIRS + NUMFILES))
4778 CMD="$LFIND -type b $TDIR"
4779 NUMS=$($CMD | wc -l)
4780 [ $NUMS -eq $EXPECTED ] ||
4781 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4783 run_test 56l "check lfs find -type b ============================="
4787 setup_56_special $NUMFILES $NUMDIRS
4789 EXPECTED=$((NUMDIRS + NUMFILES))
4790 CMD="$LFIND -type c $TDIR"
4791 NUMS=$($CMD | wc -l)
4792 [ $NUMS -eq $EXPECTED ] ||
4793 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4795 run_test 56m "check lfs find -type c ============================="
4799 setup_56_special $NUMFILES $NUMDIRS
4801 EXPECTED=$((NUMDIRS + NUMFILES))
4802 CMD="$LFIND -type l $TDIR"
4803 NUMS=$($CMD | wc -l)
4804 [ $NUMS -eq $EXPECTED ] ||
4805 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4807 run_test 56n "check lfs find -type l ============================="
4811 setup_56 $NUMFILES $NUMDIRS
4812 utime $TDIR/file1 > /dev/null || error "utime (1)"
4813 utime $TDIR/file2 > /dev/null || error "utime (2)"
4814 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4815 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4816 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4817 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4820 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4821 [ $NUMS -eq $EXPECTED ] || \
4822 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4825 CMD="$LFIND -mtime 0 $TDIR"
4826 NUMS=$($CMD | wc -l)
4827 [ $NUMS -eq $EXPECTED ] ||
4828 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4830 run_test 56o "check lfs find -mtime for old files =========================="
4833 [ $RUNAS_ID -eq $UID ] &&
4834 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4837 setup_56 $NUMFILES $NUMDIRS
4839 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4841 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4842 NUMS=$($CMD | wc -l)
4843 [ $NUMS -eq $EXPECTED ] || \
4844 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4846 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4847 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4848 NUMS=$($CMD | wc -l)
4849 [ $NUMS -eq $EXPECTED ] || \
4850 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4852 run_test 56p "check lfs find -uid and ! -uid ==============================="
4855 [ $RUNAS_ID -eq $UID ] &&
4856 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4859 setup_56 $NUMFILES $NUMDIRS
4861 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4864 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4865 NUMS=$($CMD | wc -l)
4866 [ $NUMS -eq $EXPECTED ] ||
4867 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4869 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4870 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4871 NUMS=$($CMD | wc -l)
4872 [ $NUMS -eq $EXPECTED ] ||
4873 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4875 run_test 56q "check lfs find -gid and ! -gid ==============================="
4879 setup_56 $NUMFILES $NUMDIRS
4882 CMD="$LFIND -size 0 -type f $TDIR"
4883 NUMS=$($CMD | wc -l)
4884 [ $NUMS -eq $EXPECTED ] ||
4885 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4887 CMD="$LFIND ! -size 0 -type f $TDIR"
4888 NUMS=$($CMD | wc -l)
4889 [ $NUMS -eq $EXPECTED ] ||
4890 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4891 echo "test" > $TDIR/$tfile
4892 echo "test2" > $TDIR/$tfile.2 && sync
4894 CMD="$LFIND -size 5 -type f $TDIR"
4895 NUMS=$($CMD | wc -l)
4896 [ $NUMS -eq $EXPECTED ] ||
4897 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4899 CMD="$LFIND -size +5 -type f $TDIR"
4900 NUMS=$($CMD | wc -l)
4901 [ $NUMS -eq $EXPECTED ] ||
4902 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4904 CMD="$LFIND -size +0 -type f $TDIR"
4905 NUMS=$($CMD | wc -l)
4906 [ $NUMS -eq $EXPECTED ] ||
4907 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4909 CMD="$LFIND ! -size -5 -type f $TDIR"
4910 NUMS=$($CMD | wc -l)
4911 [ $NUMS -eq $EXPECTED ] ||
4912 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4914 CMD="$LFIND -size -5 -type f $TDIR"
4915 NUMS=$($CMD | wc -l)
4916 [ $NUMS -eq $EXPECTED ] ||
4917 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4919 run_test 56r "check lfs find -size works =========================="
4921 test_56s() { # LU-611
4926 for i in $(seq 1 $NUMDIRS); do
4927 $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile
4930 CMD="$LFIND -c $OSTCOUNT $TDIR"
4931 NUMS=$($CMD | wc -l)
4932 [ $NUMS -eq $EXPECTED ] || {
4934 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4938 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4939 if [[ $OSTCOUNT -gt 1 ]]; then
4940 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4944 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4948 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4949 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4950 NUMS=$($CMD | wc -l)
4951 [ $NUMS -eq $EXPECTED ] || {
4953 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4956 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4957 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4958 NUMS=$($CMD | wc -l)
4959 [ $NUMS -eq $EXPECTED ] || {
4961 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4965 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4966 NUMS=$($CMD | wc -l)
4967 [ $NUMS -eq $EXPECTED ] || {
4969 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4972 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4973 NUMS=$($CMD | wc -l)
4974 [ $NUMS -eq $EXPECTED ] || {
4976 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4980 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4981 NUMS=$($CMD | wc -l)
4982 [ $NUMS -eq $EXPECTED ] || {
4984 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4987 run_test 56s "check lfs find -stripe-count works"
4989 test_56t() { # LU-611
4994 for i in $(seq 1 $NUMDIRS); do
4995 $SETSTRIPE -S 4M $TDIR/dir$i/$tfile
4998 CMD="$LFIND -S 4M $TDIR"
4999 NUMS=$($CMD | wc -l)
5000 [ $NUMS -eq $EXPECTED ] || {
5002 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5006 setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
5008 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
5010 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
5011 CMD="$LFIND -stripe-size 512k -type f $TDIR"
5012 NUMS=$($CMD | wc -l)
5013 [ $NUMS -eq $EXPECTED ] ||
5014 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5016 CMD="$LFIND -stripe-size +320k -type f $TDIR"
5017 NUMS=$($CMD | wc -l)
5018 [ $NUMS -eq $EXPECTED ] ||
5019 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5021 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
5022 CMD="$LFIND -stripe-size +200k -type f $TDIR"
5023 NUMS=$($CMD | wc -l)
5024 [ $NUMS -eq $EXPECTED ] ||
5025 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5027 CMD="$LFIND -stripe-size -640k -type f $TDIR"
5028 NUMS=$($CMD | wc -l)
5029 [ $NUMS -eq $EXPECTED ] ||
5030 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5033 CMD="$LFIND -stripe-size 256k -type f $TDIR"
5034 NUMS=$($CMD | wc -l)
5035 [ $NUMS -eq $EXPECTED ] ||
5036 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5038 CMD="$LFIND -stripe-size -320k -type f $TDIR"
5039 NUMS=$($CMD | wc -l)
5040 [ $NUMS -eq $EXPECTED ] ||
5041 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5044 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
5045 NUMS=$($CMD | wc -l)
5046 [ $NUMS -eq $EXPECTED ] ||
5047 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5049 run_test 56t "check lfs find -stripe-size works"
5051 test_56u() { # LU-611
5053 setup_56 $NUMFILES $NUMDIRS "-i 0"
5055 if [[ $OSTCOUNT -gt 1 ]]; then
5056 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
5062 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
5063 CMD="$LFIND -stripe-index 0 -type f $TDIR"
5064 NUMS=$($CMD | wc -l)
5065 [ $NUMS -eq $EXPECTED ] ||
5066 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5069 CMD="$LFIND -stripe-index 1 -type f $TDIR"
5070 NUMS=$($CMD | wc -l)
5071 [ $NUMS -eq $EXPECTED ] ||
5072 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5074 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
5075 NUMS=$($CMD | wc -l)
5076 [ $NUMS -eq $EXPECTED ] ||
5077 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5080 # This should produce an error and not return any files
5081 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
5082 NUMS=$($CMD 2>/dev/null | wc -l)
5083 [ $NUMS -eq $EXPECTED ] ||
5084 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5086 if [[ $OSTCOUNT -gt 1 ]]; then
5087 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
5088 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
5089 NUMS=$($CMD | wc -l)
5090 [ $NUMS -eq $EXPECTED ] ||
5091 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5094 run_test 56u "check lfs find -stripe-index works"
5101 setup_56 $NUMFILES $NUMDIRS
5103 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
5104 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
5106 for file in $($LFIND -mdt $UUID $TDIR); do
5107 file_mdt_idx=$($GETSTRIPE -M $file)
5108 [ $file_mdt_idx -eq $MDT_IDX ] ||
5109 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
5112 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5115 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5119 rm -rf $TDIR || error "remove $TDIR failed"
5120 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5123 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
5124 error "$GETSTRIPE -S -d $TDIR failed"
5125 stripe_size=${stripe_size%% *}
5127 local file_size=$((stripe_size * OSTCOUNT))
5128 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5129 local required_space=$((file_num * file_size))
5131 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5133 [[ $free_space -le $((required_space / 1024)) ]] &&
5134 skip_env "need $required_space bytes, have $free_space KB" &&
5138 local dd_count=$((file_size / dd_bs))
5140 # write data into the files
5144 for i in $(seq 1 $NUMFILES); do
5146 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5147 error "write data into $file failed"
5149 for i in $(seq 1 $NUMDIRS); do
5150 for j in $(seq 1 $NUMFILES); do
5151 file=$TDIR/dir$i/file$j
5152 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5153 error "write data into $file failed"
5157 # $LFS_MIGRATE will fail if hard link migration is unsupported
5158 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5159 createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 ||
5160 error "creating links to $TDIR/dir1/file1 failed"
5164 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5167 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
5169 eval $cmd || error "$cmd failed"
5171 check_stripe_count $TDIR/file1 $expected
5173 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5175 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5176 # OST 1 if it is on OST 0. This file is small enough to
5177 # be on only one stripe.
5178 file=$TDIR/migr_1_ost
5179 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5180 error "write data into $file failed"
5181 local obdidx=$($LFS getstripe -i $file)
5182 local oldmd5=$(md5sum $file)
5184 [[ $obdidx -eq 0 ]] && newobdidx=1
5185 cmd="$LFS migrate -i $newobdidx $file"
5187 eval $cmd || error "$cmd failed"
5188 local realobdix=$($LFS getstripe -i $file)
5189 local newmd5=$(md5sum $file)
5190 [[ $newobdidx -ne $realobdix ]] &&
5191 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
5192 [[ "$oldmd5" != "$newmd5" ]] &&
5193 error "md5sum differ: $oldmd5, $newmd5"
5197 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
5199 eval $cmd || error "$cmd failed"
5201 for j in $(seq 1 $NUMFILES); do
5202 check_stripe_count $TDIR/dir1/file$j $expected
5205 # lfs_migrate works with lfs find
5206 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
5207 $LFS_MIGRATE -y -c $expected"
5209 eval $cmd || error "$cmd failed"
5211 for i in $(seq 2 $NUMFILES); do
5212 check_stripe_count $TDIR/file$i $expected
5214 for i in $(seq 2 $NUMDIRS); do
5215 for j in $(seq 1 $NUMFILES); do
5216 check_stripe_count $TDIR/dir$i/file$j $expected
5220 run_test 56w "check lfs_migrate -c stripe_count works"
5223 check_swap_layouts_support && return 0
5224 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5226 local dir0=$DIR/$tdir
5227 local ref1=/etc/passwd
5228 local file1=$dir0/file1
5230 test_mkdir $dir0 || error "creating dir $dir0"
5231 $LFS setstripe -c 2 $file1
5233 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5234 stripe=$($LFS getstripe -c $file1)
5235 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5236 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5241 run_test 56x "lfs migration support"
5244 check_swap_layouts_support && return 0
5245 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5247 local dir0=$DIR/$tdir/$testnum
5248 test_mkdir -p $dir0 || error "creating dir $dir0"
5250 local ref1=/etc/passwd
5251 local file1=$dir0/file1
5253 $LFS setstripe -c 2 $file1
5255 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5256 local stripe=$($LFS getstripe -c $file1)
5257 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5258 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5263 run_test 56xa "lfs migration --block support"
5265 check_migrate_links() {
5267 local file1="$dir/file1"
5270 local total_count=$(($begin + $count - 1))
5271 local symlink_count=10
5274 if [ ! -f "$file1" ]; then
5275 echo -n "creating initial file..."
5276 $LFS setstripe -c 1 -S "512k" "$file1" ||
5277 error "cannot setstripe initial file"
5280 echo -n "creating symlinks..."
5281 for s in $(seq 1 $symlink_count); do
5282 ln -s "$file1" "$dir/slink$s" ||
5283 error "cannot create symlinks"
5287 echo -n "creating nonlinked files..."
5288 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5289 error "cannot create nonlinked files"
5294 if [ ! -f "$dir/file$total_count" ]; then
5295 echo -n "creating hard links $begin:$total_count..."
5296 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5297 /dev/null || error "cannot create hard links"
5301 echo -n "checking number of hard links listed in xattrs..."
5302 local fid=$($LFS getstripe -F "$file1")
5303 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5306 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5307 echo "hard link list has unexpected size, skipping test"
5310 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5311 error "link names should exceed xattrs size"
5314 echo -n "migrating files..."
5315 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5317 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5320 # make sure all links have been properly migrated
5321 echo -n "verifying files..."
5322 fid=$($LFS getstripe -F "$file1") ||
5323 error "cannot get fid for file $file1"
5324 for i in $(seq 2 $total_count); do
5325 local fid2=$($LFS getstripe -F $dir/file$i)
5326 [ "$fid2" == "$fid" ] ||
5327 error "migrated hard link has mismatched FID"
5330 # make sure hard links were properly detected, and migration was
5331 # performed only once for the entire link set; nonlinked files should
5333 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5334 local expected=$(($uniq_count + 1))
5335 [ "$actual" -eq "$expected" ] ||
5336 error "hard links individually migrated ($actual != $expected)"
5338 # make sure the correct number of hard links are present
5339 local hardlinks=$(stat -c '%h' "$file1")
5340 [ $hardlinks -eq $total_count ] ||
5341 error "num hard links $hardlinks != $total_count"
5348 local dir0="$DIR/$tdir"
5350 test_mkdir "$dir0" || error "cannot create dir $dir0"
5352 echo "testing lfs migrate mode when all links fit within xattrs"
5353 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 2 99
5355 echo "testing rsync mode when all links fit within xattrs"
5356 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 2 99
5358 echo "testing lfs migrate mode when all links do not fit within xattrs"
5359 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 101 100
5361 echo "testing rsync mode when all links do not fit within xattrs"
5362 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 101 100
5367 run_test 56xb "lfs migration hard link support"
5370 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5371 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5375 local dir0=$DIR/$tdir/$testnum
5376 test_mkdir -p $dir0 || error "creating dir $dir0"
5377 local f1=$dir0/file1
5378 local f2=$dir0/file2
5380 touch $f1 || error "creating std file $f1"
5381 $MULTIOP $f2 H2c || error "creating released file $f2"
5383 # a directory can be raid0, so ask only for files
5384 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5385 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5387 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5388 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5390 # only files can be released, so no need to force file search
5391 res=$($LFIND $dir0 -L released)
5392 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5394 res=$($LFIND $dir0 \! -L released)
5395 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5398 run_test 56y "lfs find -L raid0|released"
5400 test_56z() { # LU-4824
5401 # This checks to make sure 'lfs find' continues after errors
5402 # There are two classes of errors that should be caught:
5403 # - If multiple paths are provided, all should be searched even if one
5405 # - If errors are encountered during the search, it should not terminate
5408 test_mkdir $DIR/$tdir
5409 for i in d{0..9}; do
5410 test_mkdir $DIR/$tdir/$i
5412 touch $DIR/$tdir/d{0..9}/$tfile
5413 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5414 error "$LFS find did not return an error"
5415 # Make a directory unsearchable. This should NOT be the last entry in
5416 # directory order. Arbitrarily pick the 6th entry
5417 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5418 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5419 # The user should be able to see 10 directories and 9 files
5420 [ $count == 19 ] || error "$LFS find did not continue after error"
5422 run_test 56z "lfs find should continue after an error"
5424 test_56aa() { # LU-5937
5425 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5428 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5430 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5431 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5433 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5435 run_test 56aa "lfs find --size under striped dir"
5438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5439 # note test will not do anything if MDS is not local
5440 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5441 skip "ldiskfs only test"
5445 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5446 local MNTDEV="osd*.*MDT*.mntdev"
5447 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5448 [ -z "$DEV" ] && error "can't access $MNTDEV"
5449 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5450 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5451 error "can't access $DEV"
5452 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5453 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5457 run_test 57a "verify MDS filesystem created with large inodes =="
5460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5461 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5462 skip "ldiskfs only test"
5466 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5467 local dir=$DIR/$tdir
5471 local FILEN=$dir/f$FILECOUNT
5473 rm -rf $dir || error "removing $dir"
5474 test_mkdir -p -c1 $dir || error "creating $dir"
5475 local mdtidx=$($LFS getstripe -M $dir)
5476 local mdtname=MDT$(printf %04x $mdtidx)
5477 local facet=mds$((mdtidx + 1))
5479 echo "mcreating $FILECOUNT files"
5480 createmany -m $dir/f 1 $FILECOUNT || \
5481 error "creating files in $dir"
5483 # verify that files do not have EAs yet
5484 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5485 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5489 df $dir #make sure we get new statfs data
5490 local MDSFREE=$(do_facet $facet \
5491 lctl get_param -n osd*.*$mdtname.kbytesfree)
5492 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5493 echo "opening files to create objects/EAs"
5495 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5496 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5499 # verify that files have EAs now
5500 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5501 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5503 sleep 1 #make sure we get new statfs data
5505 local MDSFREE2=$(do_facet $facet \
5506 lctl get_param -n osd*.*$mdtname.kbytesfree)
5507 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5508 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5509 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5510 error "MDC before $MDCFREE != after $MDCFREE2"
5512 echo "MDC before $MDCFREE != after $MDCFREE2"
5513 echo "unable to confirm if MDS has large inodes"
5518 run_test 57b "default LOV EAs are stored inside large inodes ==="
5521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5522 [ -z "$(which wiretest 2>/dev/null)" ] &&
5523 skip_env "could not find wiretest" && return
5526 run_test 58 "verify cross-platform wire constants =============="
5529 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5530 echo "touch 130 files"
5531 createmany -o $DIR/f59- 130
5533 unlinkmany $DIR/f59- 130
5535 # wait for commitment of removal
5536 wait_delete_completed
5538 run_test 59 "verify cancellation of llog records async ========="
5540 TEST60_HEAD="test_60 run $RANDOM"
5542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5543 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5544 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5545 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5546 skip_env "missing subtest run-llog.sh" && return
5548 log "$TEST60_HEAD - from kernel mode"
5549 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5550 do_facet mgs sh run-llog.sh
5551 do_facet mgs $LCTL dk > $TMP/$tfile
5553 # LU-6388: test llog_reader
5554 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5555 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5556 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5557 skip_env "missing llog_reader" && return
5558 local fstype=$(facet_fstype mgs)
5559 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5560 skip_env "Only for ldiskfs or zfs type mgs" && return
5562 local mntpt=$(facet_mntpt mgs)
5563 local mgsdev=$(mgsdevname 1)
5575 #get fid and record list
5576 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5578 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5580 #remount mgs as ldiskfs or zfs type
5581 stop mgs || error "stop mgs failed"
5582 mount_fstype mgs || error "remount mgs failed"
5583 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5586 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5587 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5592 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5594 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5596 echo "obj_file is $obj_file"
5597 do_facet mgs $llog_reader $obj_file
5599 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5600 awk '{ print $3 }' | sed -e "s/^type=//g")
5601 if [ $rec_type != $rec ]; then
5602 echo "FAILED test_60a wrong record type $rec_type," \
5608 #check obj path if record type is LLOG_LOGID_MAGIC
5609 if [ "$rec" == "1064553b" ]; then
5610 path=$(do_facet mgs $llog_reader $obj_file |
5611 grep "path=" | awk '{ print $NF }' |
5612 sed -e "s/^path=//g")
5613 if [ $obj_file != $mntpt/$path ]; then
5614 echo "FAILED test_60a wrong obj path" \
5615 "$montpt/$path, should be $obj_file"
5622 #restart mgs before "error", otherwise it will block the next test
5623 stop mgs || error "stop mgs failed"
5624 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5625 $pass || error "test failed, see FAILED test_60a messages for specifics"
5627 run_test 60a "llog_test run from kernel module and test llog_reader"
5630 # test old logid format
5631 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5632 do_facet mgs $LCTL dl | grep MGS
5633 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5634 error "old llog_print failed"
5637 # test new logid format
5638 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5639 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5640 error "new llog_print failed"
5643 run_test 60aa "llog_print works with FIDs and simple names"
5645 test_60b() { # bug 6411
5646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5648 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5660 [[ $LLOG_COUNT -gt 100 ]] &&
5661 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5663 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5667 echo "create 5000 files"
5668 createmany -o $DIR/f60c- 5000
5669 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5670 lctl set_param fail_loc=0x80000137
5671 unlinkmany $DIR/f60c- 5000
5672 lctl set_param fail_loc=0
5674 run_test 60c "unlink file when mds full"
5677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5678 SAVEPRINTK=$(lctl get_param -n printk)
5680 # verify "lctl mark" is even working"
5681 MESSAGE="test message ID $RANDOM $$"
5682 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5683 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5685 lctl set_param printk=0 || error "set lnet.printk failed"
5686 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5687 MESSAGE="new test message ID $RANDOM $$"
5688 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5689 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5690 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5692 lctl set_param -n printk="$SAVEPRINTK"
5694 run_test 60d "test printk console message masking"
5697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5698 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5700 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5701 do_facet mds1 lctl set_param fail_loc=0x15b
5704 run_test 60e "no space while new llog is being created"
5707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5709 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5710 cancel_lru_locks osc
5711 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5714 run_test 61 "mmap() writes don't make sync hang ================"
5716 # bug 2330 - insufficient obd_match error checking causes LBUG
5718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5721 cancel_lru_locks osc
5722 lctl set_param fail_loc=0x405
5723 cat $f && error "cat succeeded, expect -EIO"
5724 lctl set_param fail_loc=0
5726 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5727 # match every page all of the time.
5728 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5730 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5731 # Though this test is irrelevant anymore, it helped to reveal some
5732 # other grant bugs (LU-4482), let's keep it.
5733 test_63a() { # was test_63
5734 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5735 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5736 for i in `seq 10` ; do
5737 dd if=/dev/zero of=$DIR/f63 bs=8k &
5743 rm -f $DIR/f63 || true
5745 run_test 63a "Verify oig_wait interruption does not crash ======="
5747 # bug 2248 - async write errors didn't return to application on sync
5748 # bug 3677 - async write errors left page locked
5750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5752 lctl set_param debug=-1
5754 # ensure we have a grant to do async writes
5755 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5758 sync # sync lest earlier test intercept the fail_loc
5760 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5761 lctl set_param fail_loc=0x80000406
5762 $MULTIOP $DIR/$tfile Owy && \
5763 error "sync didn't return ENOMEM"
5764 sync; sleep 2; sync # do a real sync this time to flush page
5765 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5766 error "locked page left in cache after async error" || true
5769 run_test 63b "async write errors should be returned to fsync ==="
5772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5774 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5776 run_test 64a "verify filter grant calculations (in kernel) ====="
5779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5780 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5782 run_test 64b "check out-of-space detection on client ==========="
5785 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5787 run_test 64c "verify grant shrink ========================------"
5789 # this does exactly what osc_request.c:osc_announce_cached() does in
5790 # order to calculate max amount of grants to ask from server
5794 local page_size=$(get_page_size client)
5796 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
5797 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
5799 ((rpc_in_flight ++));
5800 nrpages=$((nrpages * rpc_in_flight))
5802 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
5804 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size))
5806 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
5807 local undirty=$((nrpages * page_size))
5809 local max_extent_pages
5810 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
5811 grep grant_max_extent_size | awk '{print $2}')
5812 max_extent_pages=$((max_extent_pages / page_size))
5813 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
5814 local grant_extent_tax
5815 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
5816 grep grant_extent_tax | awk '{print $2}')
5818 undirty=$((undirty + nrextents * grant_extent_tax))
5823 # this is size of unit for grant allocation. It should be equal to
5824 # what tgt_grant.c:tgt_grant_chunk() calculates
5828 local grant_extent_tax
5830 max_brw_size=$($LCTL get_param osc.${tgt}.import |
5831 grep max_brw_size | awk '{print $2}')
5833 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
5834 grep grant_extent_tax | awk '{print $2}')
5836 echo $(((max_brw_size + grant_extent_tax) * 2))
5840 [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
5841 skip "OST < 2.10.55 doesn't limit grants enough" && return 0
5843 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
5845 [[ $($LCTL get_param osc.${tgt}.import |
5846 grep "connect_flags:.*grant_param") ]] || \
5847 { skip "no grant_param connect flag"; return; }
5849 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
5851 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
5853 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
5855 $SETSTRIPE $DIR/$tfile -i 0 -c 1
5856 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
5861 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
5862 if [[ $cur_grant -gt $max_cur_granted ]]
5865 error "cur_grant $cur_grant > $max_cur_granted"
5868 [[ $? -ne 0 ]] && break;
5871 $LCTL set_param debug="$olddebug" 2> /dev/null || true
5873 run_test 64d "check grant limit exceed"
5875 # bug 1414 - set/get directories' stripe info
5877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5878 test_mkdir -p $DIR/$tdir
5880 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5882 run_test 65a "directory with no stripe info ===================="
5885 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5886 test_mkdir -p $DIR/$tdir
5887 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5889 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5892 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5894 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5898 if [[ $OSTCOUNT -gt 1 ]]; then
5899 test_mkdir -p $DIR/$tdir
5900 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5902 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5903 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5905 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5908 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5912 test_mkdir -p $DIR/$tdir
5913 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5914 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5916 if [[ $STRIPECOUNT -le 0 ]]; then
5918 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5919 #LOV_MAX_STRIPE_COUNT is 2000
5920 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5922 sc=$(($STRIPECOUNT - 1))
5924 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5925 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5926 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5927 error "lverify failed"
5929 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5933 test_mkdir -p $DIR/$tdir
5935 $SETSTRIPE $DIR/$tdir || error "setstripe"
5936 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5937 error "no stripe info failed"
5939 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5941 run_test 65e "directory setstripe defaults ======================="
5944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5945 test_mkdir -p $DIR/${tdir}f
5946 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5948 run_test 65f "dir setstripe permission (should return error) ==="
5951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5952 test_mkdir -p $DIR/$tdir
5953 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5955 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5957 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5958 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5959 error "delete default stripe failed"
5961 run_test 65g "directory setstripe -d ==========================="
5964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5965 test_mkdir -p $DIR/$tdir
5966 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5968 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5970 test_mkdir -p $DIR/$tdir/dd1
5971 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5972 error "stripe info inherit failed"
5974 run_test 65h "directory stripe info inherit ===================="
5976 test_65i() { # bug6367
5977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5978 $SETSTRIPE -S 65536 -c -1 $MOUNT
5980 run_test 65i "set non-default striping on root directory (bug 6367)="
5982 test_65ia() { # bug12836
5983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5984 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5986 run_test 65ia "getstripe on -1 default directory striping"
5988 test_65ib() { # bug12836
5989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5990 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5992 run_test 65ib "getstripe -v on -1 default directory striping"
5994 test_65ic() { # bug12836
5995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5996 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5998 run_test 65ic "new find on -1 default directory striping"
6000 test_65j() { # bug6367
6001 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6003 # if we aren't already remounting for each test, do so for this test
6004 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
6005 cleanup || error "failed to unmount"
6008 $SETSTRIPE -d $MOUNT || error "setstripe failed"
6010 run_test 65j "set default striping on root directory (bug 6367)="
6012 test_65k() { # bug11679
6013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6014 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6015 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6017 local disable_precreate=true
6018 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
6019 disable_precreate=false
6021 echo "Check OST status: "
6022 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
6023 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
6025 for OSC in $MDS_OSCS; do
6026 echo $OSC "is active"
6027 do_facet $SINGLEMDS lctl --device %$OSC activate
6030 for INACTIVE_OSC in $MDS_OSCS; do
6031 local ost=$(osc_to_ost $INACTIVE_OSC)
6032 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
6033 lov.*md*.target_obd |
6034 awk -F: /$ost/'{ print $1 }' | head -n 1)
6037 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
6038 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
6040 echo "Deactivate: " $INACTIVE_OSC
6041 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
6043 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
6044 osp.$ost*MDT0000.create_count")
6045 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
6046 osp.$ost*MDT0000.max_create_count")
6047 $disable_precreate &&
6048 do_facet $SINGLEMDS "lctl set_param -n \
6049 osp.$ost*MDT0000.max_create_count=0"
6051 for idx in $(seq 0 $((OSTCOUNT - 1))); do
6052 [ -f $DIR/$tdir/$idx ] && continue
6053 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
6054 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
6055 error "setstripe $idx should succeed"
6056 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
6058 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
6061 do_facet $SINGLEMDS "lctl set_param -n \
6062 osp.$ost*MDT0000.max_create_count=$max_count"
6063 do_facet $SINGLEMDS "lctl set_param -n \
6064 osp.$ost*MDT0000.create_count=$count"
6065 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6066 echo $INACTIVE_OSC "is Activate"
6068 wait_osc_import_state mds ost$ostnum FULL
6071 run_test 65k "validate manual striping works properly with deactivated OSCs"
6073 test_65l() { # bug 12836
6074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6075 test_mkdir -p $DIR/$tdir/test_dir
6076 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
6077 $LFS find -mtime -1 $DIR/$tdir >/dev/null
6079 run_test 65l "lfs find on -1 stripe dir ========================"
6082 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
6085 run_test 65m "normal user can't set filesystem default stripe"
6087 # bug 2543 - update blocks count on client
6089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6091 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6092 sync; sync_all_data; sync; sync_all_data
6093 cancel_lru_locks osc
6094 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6095 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6097 run_test 66 "update inode blocks count on client ==============="
6100 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6104 swapon -s | awk '($1 == "'$1'") { print $4 }'
6107 # bug5265, obdfilter oa2dentry return -ENOENT
6108 # #define OBD_FAIL_SRV_ENOENT 0x217
6110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6111 remote_ost_nodsh && skip "remote OST with nodsh" && return
6114 $SETSTRIPE -c 1 -i 0 $f
6116 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6118 do_facet ost1 lctl set_param fail_loc=0x217
6119 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6120 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6122 do_facet ost1 lctl set_param fail_loc=0
6123 $DIRECTIO write $f 0 2 || error "write error"
6125 cancel_lru_locks osc
6126 $DIRECTIO read $f 0 1 || error "read error"
6128 do_facet ost1 lctl set_param fail_loc=0x217
6129 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6131 do_facet ost1 lctl set_param fail_loc=0
6134 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6137 test_mkdir -p $DIR/$tdir
6138 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6139 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6141 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6143 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6145 [ "$RUNAS_ID" = "$UID" ] &&
6146 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6148 # Check that testing environment is properly set up. Skip if not
6149 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
6150 skip_env "User $RUNAS_ID does not exist - skipping"
6154 chmod 777 $DIR/$tfile
6155 chmod ug+s $DIR/$tfile
6156 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6157 error "$RUNAS dd $DIR/$tfile failed"
6158 # See if we are still setuid/sgid
6159 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6160 error "S/gid is not dropped on write"
6161 # Now test that MDS is updated too
6162 cancel_lru_locks mdc
6163 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6164 error "S/gid is not dropped on MDS"
6167 run_test 72a "Test that remove suid works properly (bug5695) ===="
6169 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6172 [ "$RUNAS_ID" = "$UID" ] && \
6173 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6174 [ "$RUNAS_ID" -eq 0 ] && \
6175 skip_env "RUNAS_ID = 0 -- skipping" && return
6177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6178 # Check that testing environment is properly set up. Skip if not
6179 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
6180 skip_env "User $RUNAS_ID does not exist - skipping"
6183 touch $DIR/${tfile}-f{g,u}
6184 test_mkdir $DIR/${tfile}-dg
6185 test_mkdir $DIR/${tfile}-du
6186 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6187 chmod g+s $DIR/${tfile}-{f,d}g
6188 chmod u+s $DIR/${tfile}-{f,d}u
6189 for perm in 777 2777 4777; do
6190 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6191 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6192 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6193 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6197 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6199 # bug 3462 - multiple simultaneous MDC requests
6201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6202 test_mkdir $DIR/d73-1
6203 test_mkdir $DIR/d73-2
6204 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6207 lctl set_param fail_loc=0x80000129
6208 $MULTIOP $DIR/d73-1/f73-2 Oc &
6210 lctl set_param fail_loc=0
6212 $MULTIOP $DIR/d73-2/f73-3 Oc &
6216 wait $pid1 || return 1
6220 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6221 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6222 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6226 run_test 73 "multiple MDC requests (should not deadlock)"
6228 test_74a() { # bug 6149, 6184
6229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6230 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6232 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6233 # will spin in a tight reconnection loop
6235 $LCTL set_param fail_loc=0x8000030e
6236 # get any lock that won't be difficult - lookup works.
6238 $LCTL set_param fail_loc=0
6242 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6244 test_74b() { # bug 13310
6245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6246 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6248 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6249 # will spin in a tight reconnection loop
6250 $LCTL set_param fail_loc=0x8000030e
6251 # get a "difficult" lock
6253 $LCTL set_param fail_loc=0
6257 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6261 #define OBD_FAIL_LDLM_NEW_LOCK
6262 $LCTL set_param fail_loc=0x319
6263 touch $DIR/$tfile && error "touch successful"
6264 $LCTL set_param fail_loc=0
6267 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6270 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6273 test_76() { # Now for bug 20433, added originally in bug 1443
6274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6275 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6276 cancel_lru_locks osc
6277 BEFORE_INODES=$(num_inodes)
6278 echo "before inodes: $BEFORE_INODES"
6280 [ "$SLOW" = "no" ] && COUNT=100
6281 for i in $(seq $COUNT); do
6285 cancel_lru_locks osc
6286 AFTER_INODES=$(num_inodes)
6287 echo "after inodes: $AFTER_INODES"
6289 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6291 AFTER_INODES=$(num_inodes)
6293 echo "wait $wait seconds inodes: $AFTER_INODES"
6294 if [ $wait -gt 30 ]; then
6295 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6299 run_test 76 "confirm clients recycle inodes properly ===="
6305 # Note: in sptlrpc modes which enable its own bulk checksum, the
6306 # original crc32_le bulk checksum will be automatically disabled,
6307 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6308 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6309 # In this case set_checksums() will not be no-op, because sptlrpc
6310 # bulk checksum will be enabled all through the test.
6312 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6313 lctl set_param -n osc.*.checksums $1
6317 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6318 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6319 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6320 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6323 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6324 log "set checksum type to $1"
6327 F77_TMP=$TMP/f77-temp
6330 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6331 error "error writing to $F77_TMP"
6334 test_77a() { # bug 10889
6335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6336 $GSS && skip "could not run with gss" && return
6337 [ ! -f $F77_TMP ] && setup_f77
6339 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6343 run_test 77a "normal checksum read/write operation"
6345 test_77b() { # bug 10889
6346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6347 $GSS && skip "could not run with gss" && return
6348 [ ! -f $F77_TMP ] && setup_f77
6349 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6350 $LCTL set_param fail_loc=0x80000409
6353 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6354 error "dd error: $?"
6355 $LCTL set_param fail_loc=0
6357 for algo in $CKSUM_TYPES; do
6358 cancel_lru_locks osc
6359 set_checksum_type $algo
6360 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6361 $LCTL set_param fail_loc=0x80000408
6362 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6363 $LCTL set_param fail_loc=0
6366 set_checksum_type $ORIG_CSUM_TYPE
6369 run_test 77b "checksum error on client write, read"
6374 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6376 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6377 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6378 $check_ost && [ -n $ost_file_prefix ] &&
6379 do_facet ost1 rm -f ${ost_file_prefix}\*
6383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6384 $GSS && skip "could not run with gss" && return
6387 local osc_file_prefix
6389 local check_ost=false
6390 local ost_file_prefix
6396 # ensure corruption will occur on first OSS/OST
6397 $LFS setstripe -i 0 $DIR/$tfile
6399 [ ! -f $F77_TMP ] && setup_f77
6400 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6401 error "dd write error: $?"
6402 fid=$($LFS path2fid $DIR/$tfile)
6404 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6407 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6408 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6410 echo "OSS do not support bulk pages dump upon error"
6413 osc_file_prefix=$($LCTL get_param -n debug_path)
6414 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6416 trap cleanup_77c EXIT
6419 # enable bulk pages dump upon error on Client
6420 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6421 # enable bulk pages dump upon error on OSS
6423 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6425 # flush Client cache to allow next read to reach OSS
6426 cancel_lru_locks osc
6428 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6429 $LCTL set_param fail_loc=0x80000408
6430 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6431 $LCTL set_param fail_loc=0
6435 # check cksum dump on Client
6436 osc_file=$(ls ${osc_file_prefix}*)
6437 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6438 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6439 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6440 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6441 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6443 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6444 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6445 error "dump content does not match on Client"
6447 $check_ost || { skip "No need to check cksum dump on OSS"; return 0; }
6449 # check cksum dump on OSS
6450 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6451 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6452 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6453 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6454 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6455 error "dump content does not match on OSS"
6459 run_test 77c "checksum error on client read with debug"
6461 test_77d() { # bug 10889
6462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6463 $GSS && skip "could not run with gss" && return
6464 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6465 $LCTL set_param fail_loc=0x80000409
6467 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6468 error "direct write: rc=$?"
6469 $LCTL set_param fail_loc=0
6472 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6473 $LCTL set_param fail_loc=0x80000408
6475 cancel_lru_locks osc
6476 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6477 error "direct read: rc=$?"
6478 $LCTL set_param fail_loc=0
6481 run_test 77d "checksum error on OST direct write, read"
6483 test_77f() { # bug 10889
6484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6485 $GSS && skip "could not run with gss" && return
6487 for algo in $CKSUM_TYPES; do
6488 cancel_lru_locks osc
6489 set_checksum_type $algo
6490 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6491 $LCTL set_param fail_loc=0x409
6492 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6493 error "direct write succeeded"
6494 $LCTL set_param fail_loc=0
6496 set_checksum_type $ORIG_CSUM_TYPE
6499 run_test 77f "repeat checksum error on write (expect error)"
6501 test_77g() { # bug 10889
6502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6503 $GSS && skip "could not run with gss" && return
6504 remote_ost_nodsh && skip "remote OST with nodsh" && return
6506 [ ! -f $F77_TMP ] && setup_f77
6508 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6509 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6510 do_facet ost1 lctl set_param fail_loc=0x8000021a
6512 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6513 error "write error: rc=$?"
6514 do_facet ost1 lctl set_param fail_loc=0
6517 cancel_lru_locks osc
6518 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6519 do_facet ost1 lctl set_param fail_loc=0x8000021b
6521 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6522 do_facet ost1 lctl set_param fail_loc=0
6525 run_test 77g "checksum error on OST write, read"
6527 test_77j() { # bug 13805
6528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6529 $GSS && skip "could not run with gss" && return
6530 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6531 lctl set_param fail_loc=0x40c
6532 remount_client $MOUNT
6533 lctl set_param fail_loc=0
6534 # wait async osc connect to finish and reflect updated state value
6536 for (( i=0; i < OSTCOUNT; i++ )) ; do
6537 wait_osc_import_state client ost$((i+1)) FULL
6540 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6541 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6542 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6543 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6545 remount_client $MOUNT
6547 run_test 77j "client only supporting ADLER32"
6549 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6558 test_78() { # bug 10901
6559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6560 remote_ost || { skip_env "local OST" && return; }
6563 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6564 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6565 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6566 echo "MemTotal: $MEMTOTAL"
6568 # reserve 256MB of memory for the kernel and other running processes,
6569 # and then take 1/2 of the remaining memory for the read/write buffers.
6570 if [ $MEMTOTAL -gt 512 ] ;then
6571 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6573 # for those poor memory-starved high-end clusters...
6574 MEMTOTAL=$((MEMTOTAL / 2))
6576 echo "Mem to use for directio: $MEMTOTAL"
6578 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6579 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6580 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6581 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6583 echo "Smallest OST: $SMALLESTOST"
6584 [[ $SMALLESTOST -lt 10240 ]] &&
6585 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6587 trap cleanup_test_78 EXIT
6589 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6590 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6592 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6593 echo "File size: $F78SIZE"
6594 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6595 for i in $(seq 1 $NSEQ); do
6596 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6597 echo directIO rdwr round $i of $NSEQ
6598 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6603 run_test 78 "handle large O_DIRECT writes correctly ============"
6605 test_79() { # bug 12743
6606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6607 wait_delete_completed
6609 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6610 BKFREE=$(calc_osc_kbytes kbytesfree)
6611 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6613 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6614 DFTOTAL=`echo $STRING | cut -d, -f1`
6615 DFUSED=`echo $STRING | cut -d, -f2`
6616 DFAVAIL=`echo $STRING | cut -d, -f3`
6617 DFFREE=$(($DFTOTAL - $DFUSED))
6619 ALLOWANCE=$((64 * $OSTCOUNT))
6621 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6622 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6623 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6625 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6626 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6627 error "df free($DFFREE) mismatch OST free($BKFREE)"
6629 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6630 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6631 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6634 run_test 79 "df report consistency check ======================="
6636 test_80() { # bug 10718
6637 remote_ost_nodsh && skip "remote OST with nodsh" && return
6638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6639 # relax strong synchronous semantics for slow backends like ZFS
6640 local soc="obdfilter.*.sync_on_lock_cancel"
6641 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6643 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6644 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6645 facet_active_host $host; done | sort -u)
6646 do_nodes $hosts lctl set_param $soc=never
6649 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6651 local BEFORE=`date +%s`
6652 cancel_lru_locks osc
6653 local AFTER=`date +%s`
6654 local DIFF=$((AFTER-BEFORE))
6655 if [ $DIFF -gt 1 ] ; then
6656 error "elapsed for 1M@1T = $DIFF"
6659 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6663 run_test 80 "Page eviction is equally fast at high offsets too ===="
6665 test_81a() { # LU-456
6666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6667 remote_ost_nodsh && skip "remote OST with nodsh" && return
6668 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6669 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6670 do_facet ost1 lctl set_param fail_loc=0x80000228
6672 # write should trigger a retry and success
6673 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6674 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6676 if [ $RC -ne 0 ] ; then
6677 error "write should success, but failed for $RC"
6680 run_test 81a "OST should retry write when get -ENOSPC ==============="
6682 test_81b() { # LU-456
6683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6684 remote_ost_nodsh && skip "remote OST with nodsh" && return
6685 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6686 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6687 do_facet ost1 lctl set_param fail_loc=0x228
6689 # write should retry several times and return -ENOSPC finally
6690 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6691 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6694 if [ $RC -ne $ENOSPC ] ; then
6695 error "dd should fail for -ENOSPC, but succeed."
6698 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6700 test_82() { # LU-1031
6701 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6705 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6707 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6709 kill -USR1 $MULTIPID2
6711 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6712 error "First grouplock does not block second one"
6714 echo "Second grouplock blocks first one"
6716 kill -USR1 $MULTIPID1
6720 run_test 82 "Basic grouplock test ==============================="
6723 local sfile="/boot/System.map-$(uname -r)"
6724 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6725 $LCTL set_param fail_loc=0x140d
6726 cp $sfile $DIR/$tfile || error "write failed"
6727 diff -c $sfile $DIR/$tfile || error "files are different"
6728 $LCTL set_param fail_loc=0
6731 run_test 83 "Short write in ptask ==============================="
6734 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6736 test_mkdir -p $DIR/d99cvsroot
6737 chown $RUNAS_ID $DIR/d99cvsroot
6738 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6741 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6744 run_test 99a "cvs init ========================================="
6747 [ -z "$(which cvs 2>/dev/null)" ] &&
6748 skip_env "could not find cvs" && return
6749 [ ! -d $DIR/d99cvsroot ] && test_99a
6751 # some versions of cvs import exit(1) when asked to import links or
6752 # files they can't read. ignore those files.
6753 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6754 ! -perm /4 -printf '-I %f\n')
6755 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6756 d99reposname vtag rtag
6758 run_test 99b "cvs import ======================================="
6761 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6762 [ ! -d $DIR/d99cvsroot ] && test_99b
6764 test_mkdir -p $DIR/d99reposname
6765 chown $RUNAS_ID $DIR/d99reposname
6766 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6768 run_test 99c "cvs checkout ====================================="
6771 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6772 [ ! -d $DIR/d99cvsroot ] && test_99c
6773 cd $DIR/d99reposname
6775 $RUNAS cvs add -m 'addmsg' foo99
6777 run_test 99d "cvs add =========================================="
6780 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6781 [ ! -d $DIR/d99cvsroot ] && test_99c
6782 cd $DIR/d99reposname
6785 run_test 99e "cvs update ======================================="
6788 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6789 [ ! -d $DIR/d99cvsroot ] && test_99d
6790 cd $DIR/d99reposname
6791 $RUNAS cvs commit -m 'nomsg' foo99
6792 rm -fr $DIR/d99cvsroot
6794 run_test 99f "cvs commit ======================================="
6797 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6798 [[ "$NETTYPE" =~ tcp ]] ||
6799 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
6802 remote_ost_nodsh && skip "remote OST with nodsh" && return
6803 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6805 { skip "useless for local single node setup" && return; }
6807 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6808 [ "$PROT" != "tcp" ] && continue
6809 RPORT=$(echo $REMOTE | cut -d: -f2)
6810 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6813 LPORT=`echo $LOCAL | cut -d: -f2`
6814 if [ $LPORT -ge 1024 ]; then
6815 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6817 error_exit "local: $LPORT > 1024, remote: $RPORT"
6820 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6822 run_test 100 "check local port using privileged port ==========="
6824 function get_named_value()
6833 echo $line | sed "s/^$tag[ ]*//"
6840 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6841 awk '/^max_cached_mb/ { print $2 }')
6844 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6850 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
6854 local cache_limit=32
6856 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6857 trap cleanup_101a EXIT
6858 $LCTL set_param -n llite.*.read_ahead_stats 0
6859 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6862 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6864 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6865 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6868 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6869 get_named_value 'read but discarded' | cut -d" " -f1); do
6870 discard=$(($discard + $s))
6874 if [[ $(($discard * 10)) -gt $nreads ]]; then
6875 $LCTL get_param osc.*-osc*.rpc_stats
6876 $LCTL get_param llite.*.read_ahead_stats
6877 error "too many ($discard) discarded pages"
6879 rm -f $DIR/$tfile || true
6881 run_test 101a "check read-ahead for random reads ================"
6884 test_mkdir -p $DIR/$tdir
6885 local STRIPE_SIZE=$1
6886 local FILE_LENGTH=$2
6889 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6891 local list=$(comma_list $(osts_nodes))
6892 set_osd_param $list '' read_cache_enable 0
6893 set_osd_param $list '' writethrough_cache_enable 0
6895 trap cleanup_test101bc EXIT
6896 # prepare the read-ahead file
6897 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6899 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6900 count=$FILE_SIZE_MB 2> /dev/null
6904 cleanup_test101bc() {
6909 local list=$(comma_list $(osts_nodes))
6910 set_osd_param $list '' read_cache_enable 1
6911 set_osd_param $list '' writethrough_cache_enable 1
6915 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6920 local STRIPE_SIZE=$2
6921 local FILE_LENGTH=$3
6922 local RA_INC=1048576
6923 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6924 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6925 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6926 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6927 get_named_value 'read but discarded' |
6928 cut -d" " -f1 | calc_total)
6929 if [[ $DISCARD -gt $discard_limit ]]; then
6930 $LCTL get_param llite.*.read_ahead_stats
6931 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6933 echo "Read-ahead success for size ${READ_SIZE}"
6938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6939 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6940 local STRIPE_SIZE=1048576
6941 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6942 if [ $SLOW == "yes" ]; then
6943 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6945 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6948 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6950 # prepare the read-ahead file
6951 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6952 cancel_lru_locks osc
6953 for BIDX in 2 4 8 16 32 64 128 256
6955 local BSIZE=$((BIDX*4096))
6956 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6957 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6958 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6959 $LCTL set_param -n llite.*.read_ahead_stats 0
6960 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6961 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6962 cancel_lru_locks osc
6963 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6968 run_test 101b "check stride-io mode read-ahead ================="
6971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6972 local STRIPE_SIZE=1048576
6973 local FILE_LENGTH=$((STRIPE_SIZE*100))
6977 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6979 cancel_lru_locks osc
6980 $LCTL set_param osc.*.rpc_stats 0
6981 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6982 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6983 local stats=$($LCTL get_param -n $osc_rpc_stats)
6984 local lines=$(echo "$stats" | awk 'END {print NR;}')
6987 if [ $lines -le 20 ]; then
6990 for size in 1 2 4 8; do
6991 local rpc=$(echo "$stats" |
6992 awk '($1 == "'$size':") {print $2; exit; }')
6994 error "Small $((size*4))k read IO $rpc !"
6996 echo "$osc_rpc_stats check passed!"
7001 run_test 101c "check stripe_size aligned read-ahead ================="
7004 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
7005 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
7009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7010 local file=$DIR/$tfile
7011 local sz_MB=${FILESIZE_101d:-500}
7012 local ra_MB=${READAHEAD_MB:-40}
7014 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
7015 [ $free_MB -lt $sz_MB ] &&
7016 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
7018 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
7019 $SETSTRIPE -c -1 $file || error "setstripe failed"
7021 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
7022 echo Cancel LRU locks on lustre client to flush the client cache
7023 cancel_lru_locks osc
7025 echo Disable read-ahead
7026 local old_READAHEAD=$(set_read_ahead 0)
7028 echo Reading the test file $file with read-ahead disabled
7029 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7031 echo Cancel LRU locks on lustre client to flush the client cache
7032 cancel_lru_locks osc
7033 echo Enable read-ahead with ${ra_MB}MB
7034 set_read_ahead $ra_MB
7036 echo Reading the test file $file with read-ahead enabled
7037 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7039 echo "read-ahead disabled time read $raOFF"
7040 echo "read-ahead enabled time read $raON"
7042 set_read_ahead $old_READAHEAD
7044 wait_delete_completed
7046 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
7047 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
7049 run_test 101d "file read with and without read-ahead enabled"
7052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7053 local file=$DIR/$tfile
7054 local size_KB=500 #KB
7058 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
7059 local need_KB=$((count * size_KB))
7060 [[ $free_KB -le $need_KB ]] &&
7061 skip_env "Need free space $need_KB, have $free_KB" && return
7063 echo "Creating $count ${size_KB}K test files"
7064 for ((i = 0; i < $count; i++)); do
7065 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
7068 echo "Cancel LRU locks on lustre client to flush the client cache"
7069 cancel_lru_locks osc
7071 echo "Reset readahead stats"
7072 $LCTL set_param -n llite.*.read_ahead_stats 0
7074 for ((i = 0; i < $count; i++)); do
7075 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
7078 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7079 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7081 for ((i = 0; i < $count; i++)); do
7082 rm -rf $file.$i 2>/dev/null
7085 #10000 means 20% reads are missing in readahead
7086 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7088 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7091 which iozone || { skip "no iozone installed" && return; }
7093 local old_debug=$($LCTL get_param debug)
7094 old_debug=${old_debug#*=}
7095 $LCTL set_param debug="reada mmap"
7097 # create a test file
7098 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7100 echo Cancel LRU locks on lustre client to flush the client cache
7101 cancel_lru_locks osc
7103 echo Reset readahead stats
7104 $LCTL set_param -n llite.*.read_ahead_stats 0
7106 echo mmap read the file with small block size
7107 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7110 echo checking missing pages
7111 $LCTL get_param llite.*.read_ahead_stats
7112 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7113 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7115 $LCTL set_param debug="$old_debug"
7116 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7119 run_test 101f "check mmap read performance"
7121 test_101g_brw_size_test() {
7123 local pages=$((mb * 1048576 / $(page_size)))
7125 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7126 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7127 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7128 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7132 $LCTL set_param -n osc.*.rpc_stats=0
7134 # 10 RPCs should be enough for the test
7136 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
7137 { error "dd write ${mb} MB blocks failed"; return 3; }
7138 cancel_lru_locks osc
7139 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
7140 { error "dd write ${mb} MB blocks failed"; return 4; }
7142 # calculate number of full-sized read and write RPCs
7143 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7144 sed -n '/pages per rpc/,/^$/p' |
7145 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7146 END { print reads,writes }'))
7147 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7149 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7157 local osts=$(get_facets OST)
7158 local list=$(comma_list $(osts_nodes))
7159 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7160 local brw_size="obdfilter.*.brw_size"
7161 local ostver=$(lustre_version_code ost1)
7163 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7165 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7166 if [ $ostver -ge $(version_code 2.8.52) ] ||
7167 [ $ostver -ge $(version_code 2.7.17) -a \
7168 $ostver -lt $(version_code 2.7.50) ]; then
7169 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7170 if [[ $orig_mb -lt 16 ]]; then
7171 save_lustre_params $osts "$brw_size" > $p
7172 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7173 error "set 16MB RPC size failed"
7175 echo "remount client to enable new RPC size"
7176 remount_client $MOUNT || error "remount_client failed"
7179 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7180 # should be able to set brw_size=12, but no rpc_stats for that
7181 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7184 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7186 if [[ $orig_mb -lt 16 ]]; then
7187 restore_lustre_params < $p
7188 remount_client $MOUNT || error "remount_client restore failed"
7191 rm -f $p $DIR/$tfile
7193 run_test 101g "Big bulk(4/16 MiB) readahead"
7196 test_mkdir $DIR/$tdir
7197 chown $RUNAS_ID $DIR/$tdir
7200 STRIPE_COUNT=$OSTCOUNT
7201 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7203 trap cleanup_test102 EXIT
7205 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7207 for num in 1 2 3 4; do
7208 for count in $(seq 1 $STRIPE_COUNT); do
7209 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7210 local size=`expr $STRIPE_SIZE \* $num`
7211 local file=file"$num-$idx-$count"
7212 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7218 $1 tar cf $TMP/f102.tar $tdir --xattrs
7224 rm -rf $DIR/d0.sanity/d102
7228 local testfile=$DIR/$tfile
7232 [ "$UID" != 0 ] && skip_env "must run as root" && return
7233 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7234 skip_env "must have user_xattr" && return
7236 [ -z "$(which setfattr 2>/dev/null)" ] &&
7237 skip_env "could not find setfattr" && return
7239 echo "set/get xattr..."
7240 setfattr -n trusted.name1 -v value1 $testfile ||
7241 error "setfattr -n trusted.name1=value1 $testfile failed"
7242 getfattr -n trusted.name1 $testfile 2> /dev/null |
7243 grep "trusted.name1=.value1" ||
7244 error "$testfile missing trusted.name1=value1"
7246 setfattr -n user.author1 -v author1 $testfile ||
7247 error "setfattr -n user.author1=author1 $testfile failed"
7248 getfattr -n user.author1 $testfile 2> /dev/null |
7249 grep "user.author1=.author1" ||
7250 error "$testfile missing trusted.author1=author1"
7253 setfattr -n trusted.name2 -v value2 $testfile ||
7254 error "$testfile unable to set trusted.name2"
7255 setfattr -n trusted.name3 -v value3 $testfile ||
7256 error "$testfile unable to set trusted.name3"
7257 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7258 grep "trusted.name" | wc -l) -eq 3 ] ||
7259 error "$testfile missing 3 trusted.name xattrs"
7261 setfattr -n user.author2 -v author2 $testfile ||
7262 error "$testfile unable to set user.author2"
7263 setfattr -n user.author3 -v author3 $testfile ||
7264 error "$testfile unable to set user.author3"
7265 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7266 grep "user.author" | wc -l) -eq 3 ] ||
7267 error "$testfile missing 3 user.author xattrs"
7269 echo "remove xattr..."
7270 setfattr -x trusted.name1 $testfile ||
7271 error "$testfile error deleting trusted.name1"
7272 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7273 error "$testfile did not delete trusted.name1 xattr"
7275 setfattr -x user.author1 $testfile ||
7276 error "$testfile error deleting user.author1"
7277 echo "set lustre special xattr ..."
7278 $LFS setstripe -c1 $testfile
7279 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7280 awk -F "=" '/trusted.lov/ { print $2 }' )
7281 setfattr -n "trusted.lov" -v $lovea $testfile ||
7282 error "$testfile doesn't ignore setting trusted.lov again"
7283 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7284 error "$testfile allow setting invalid trusted.lov"
7287 run_test 102a "user xattr test =================================="
7290 [ -z "$(which setfattr 2>/dev/null)" ] &&
7291 skip_env "could not find setfattr" && return
7293 # b10930: get/set/list trusted.lov xattr
7294 echo "get/set/list trusted.lov xattr ..."
7295 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7296 local testfile=$DIR/$tfile
7297 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7298 error "setstripe failed"
7299 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7300 error "getstripe failed"
7301 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7302 error "can't get trusted.lov from $testfile"
7304 local testfile2=${testfile}2
7305 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7306 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7309 setfattr -n trusted.lov -v $value $testfile2
7310 local stripe_size=$($GETSTRIPE -S $testfile2)
7311 local stripe_count=$($GETSTRIPE -c $testfile2)
7312 [[ $stripe_size -eq 65536 ]] ||
7313 error "stripe size $stripe_size != 65536"
7314 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7315 error "stripe count $stripe_count != $STRIPECOUNT"
7318 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7321 [ -z "$(which setfattr 2>/dev/null)" ] &&
7322 skip_env "could not find setfattr" && return
7324 # b10930: get/set/list lustre.lov xattr
7325 echo "get/set/list lustre.lov xattr ..."
7326 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7327 test_mkdir $DIR/$tdir
7328 chown $RUNAS_ID $DIR/$tdir
7329 local testfile=$DIR/$tdir/$tfile
7330 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7331 error "setstripe failed"
7332 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7333 error "getstripe failed"
7334 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7335 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7337 local testfile2=${testfile}2
7338 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7339 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7341 $RUNAS $MCREATE $testfile2
7342 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7343 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7344 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7345 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7346 [ $stripe_count -eq $STRIPECOUNT ] ||
7347 error "stripe count $stripe_count != $STRIPECOUNT"
7349 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7351 compare_stripe_info1() {
7352 local stripe_index_all_zero=true
7354 for num in 1 2 3 4; do
7355 for count in $(seq 1 $STRIPE_COUNT); do
7356 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7357 local size=$((STRIPE_SIZE * num))
7358 local file=file"$num-$offset-$count"
7359 stripe_size=$($LFS getstripe -S $PWD/$file)
7360 [[ $stripe_size -ne $size ]] &&
7361 error "$file: size $stripe_size != $size"
7362 stripe_count=$($LFS getstripe -c $PWD/$file)
7363 # allow fewer stripes to be created, ORI-601
7364 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7365 error "$file: count $stripe_count != $count"
7366 stripe_index=$($LFS getstripe -i $PWD/$file)
7367 [[ $stripe_index -ne 0 ]] &&
7368 stripe_index_all_zero=false
7372 $stripe_index_all_zero &&
7373 error "all files are being extracted starting from OST index 0"
7377 have_xattrs_include() {
7378 tar --help | grep -q xattrs-include &&
7379 echo --xattrs-include="lustre.*"
7383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7384 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7385 local xinc=$(have_xattrs_include)
7387 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7389 compare_stripe_info1
7391 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
7394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7395 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7396 local xinc=$(have_xattrs_include)
7398 test_mkdir $DIR/$tdir.restore
7400 tar cf - --xattrs $tdir | tar xf - \
7401 -C $DIR/$tdir.restore --xattrs $xinc
7402 cd $DIR/$tdir.restore/$tdir
7403 compare_stripe_info1
7405 run_test 102f "tar copy files, not keep osts ==========="
7408 local xsize=${1:-1024} # in bytes
7409 local file=$DIR/$tfile
7411 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7412 skip "must have user_xattr" && return 0
7413 [ -z "$(which setfattr 2>/dev/null)" ] &&
7414 skip_env "could not find setfattr" && return 0
7415 [ -z "$(which getfattr 2>/dev/null)" ] &&
7416 skip_env "could not find getfattr" && return 0
7420 local value="$(generate_string $xsize)"
7422 local xbig=trusted.big
7423 log "save $xbig on $file"
7424 setfattr -n $xbig -v $value $file ||
7425 error "saving $xbig on $file failed"
7427 local orig=$(get_xattr_value $xbig $file)
7428 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7430 local xsml=trusted.sml
7431 log "save $xsml on $file"
7432 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7434 local new=$(get_xattr_value $xbig $file)
7435 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7437 log "grow $xsml on $file"
7438 setfattr -n $xsml -v "$value" $file ||
7439 error "growing $xsml on $file failed"
7441 new=$(get_xattr_value $xbig $file)
7442 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7443 log "$xbig still valid after growing $xsml"
7448 test_102h() { # bug 15777
7451 run_test 102h "grow xattr from inside inode to external block"
7454 large_xattr_enabled || { skip "ea_inode feature disabled" && return; }
7455 grow_xattr $(max_xattr_size)
7457 run_test 102ha "grow xattr from inside inode to external inode"
7459 test_102i() { # bug 17038
7460 [ -z "$(which getfattr 2>/dev/null)" ] &&
7461 skip "could not find getfattr" && return
7463 ln -s $DIR/$tfile $DIR/${tfile}link
7464 getfattr -n trusted.lov $DIR/$tfile ||
7465 error "lgetxattr on $DIR/$tfile failed"
7466 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7467 grep -i "no such attr" ||
7468 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7469 rm -f $DIR/$tfile $DIR/${tfile}link
7471 run_test 102i "lgetxattr test on symbolic link ============"
7474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7475 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7476 local xinc=$(have_xattrs_include)
7477 setup_test102 "$RUNAS"
7478 chown $RUNAS_ID $DIR/$tdir
7479 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7481 compare_stripe_info1 "$RUNAS"
7483 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7486 [ -z "$(which setfattr 2>/dev/null)" ] &&
7487 skip "could not find setfattr" && return
7489 # b22187 just check that does not crash for regular file.
7490 setfattr -n trusted.lov $DIR/$tfile
7491 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
7492 local test_kdir=$DIR/$tdir
7493 test_mkdir $test_kdir
7494 local default_size=`$GETSTRIPE -S $test_kdir`
7495 local default_count=`$GETSTRIPE -c $test_kdir`
7496 local default_offset=`$GETSTRIPE -i $test_kdir`
7497 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7498 error 'dir setstripe failed'
7499 setfattr -n trusted.lov $test_kdir
7500 local stripe_size=`$GETSTRIPE -S $test_kdir`
7501 local stripe_count=`$GETSTRIPE -c $test_kdir`
7502 local stripe_offset=`$GETSTRIPE -i $test_kdir`
7503 [ $stripe_size -eq $default_size ] ||
7504 error "stripe size $stripe_size != $default_size"
7505 [ $stripe_count -eq $default_count ] ||
7506 error "stripe count $stripe_count != $default_count"
7507 [ $stripe_offset -eq $default_offset ] ||
7508 error "stripe offset $stripe_offset != $default_offset"
7509 rm -rf $DIR/$tfile $test_kdir
7511 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7514 [ -z "$(which getfattr 2>/dev/null)" ] &&
7515 skip "could not find getfattr" && return
7517 # LU-532 trusted. xattr is invisible to non-root
7518 local testfile=$DIR/$tfile
7522 echo "listxattr as user..."
7523 chown $RUNAS_ID $testfile
7524 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7525 grep -q "trusted" &&
7526 error "$testfile trusted xattrs are user visible"
7530 run_test 102l "listxattr size test =================================="
7532 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7533 local path=$DIR/$tfile
7536 listxattr_size_check $path || error "listattr_size_check $path failed"
7538 run_test 102m "Ensure listxattr fails on small bufffer ========"
7542 getxattr() { # getxattr path name
7543 # Return the base64 encoding of the value of xattr name on path.
7547 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7549 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7551 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7553 getfattr --absolute-names --encoding=base64 --name=$name $path |
7554 awk -F= -v name=$name '$1 == name {
7555 print substr($0, index($0, "=") + 1);
7559 test_102n() { # LU-4101 mdt: protect internal xattrs
7560 [ -z "$(which setfattr 2>/dev/null)" ] &&
7561 skip "could not find setfattr" && return
7562 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7564 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7568 local file0=$DIR/$tfile.0
7569 local file1=$DIR/$tfile.1
7570 local xattr0=$TMP/$tfile.0
7571 local xattr1=$TMP/$tfile.1
7572 local namelist="lov lma lmv link fid version som hsm"
7576 rm -rf $file0 $file1 $xattr0 $xattr1
7579 # Get 'before' xattrs of $file1.
7580 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7582 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7583 namelist+=" lfsck_namespace"
7584 for name in $namelist; do
7585 # Try to copy xattr from $file0 to $file1.
7586 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7588 setfattr --name=trusted.$name --value="$value" $file1 ||
7589 error "setxattr 'trusted.$name' failed"
7591 # Try to set a garbage xattr.
7592 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7594 if [[ x$name == "xlov" ]]; then
7595 setfattr --name=trusted.lov --value="$value" $file1 &&
7596 error "setxattr invalid 'trusted.lov' success"
7598 setfattr --name=trusted.$name --value="$value" $file1 ||
7599 error "setxattr invalid 'trusted.$name' failed"
7602 # Try to remove the xattr from $file1. We don't care if this
7603 # appears to succeed or fail, we just don't want there to be
7604 # any changes or crashes.
7605 setfattr --remove=$trusted.$name $file1 2> /dev/null
7608 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7611 # Try to copy xattr from $file0 to $file1.
7612 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7614 setfattr --name=trusted.$name --value="$value" $file1 ||
7615 error "setxattr 'trusted.$name' failed"
7617 # Try to set a garbage xattr.
7618 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7620 setfattr --name=trusted.$name --value="$value" $file1 ||
7621 error "setxattr 'trusted.$name' failed"
7623 # Try to remove the xattr from $file1. We don't care if this
7624 # appears to succeed or fail, we just don't want there to be
7625 # any changes or crashes.
7626 setfattr --remove=$trusted.$name $file1 2> /dev/null
7629 # Get 'after' xattrs of file1.
7630 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7632 if ! diff $xattr0 $xattr1; then
7633 error "before and after xattrs of '$file1' differ"
7636 rm -rf $file0 $file1 $xattr0 $xattr1
7640 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7642 test_102p() { # LU-4703 setxattr did not check ownership
7643 local testfile=$DIR/$tfile
7645 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7646 skip "MDS needs to be at least 2.5.56" && return
7650 echo "setfacl as user..."
7651 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7652 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7654 echo "setfattr as user..."
7655 setfacl -m "u:$RUNAS_ID:---" $testfile
7656 $RUNAS setfattr -x system.posix_acl_access $testfile
7657 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7659 run_test 102p "check setxattr(2) correctly fails without permission"
7662 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7663 skip "MDS needs to be at least 2.6.92" && return
7664 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7666 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7669 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7670 skip "MDS needs to be at least 2.6.93" && return
7671 touch $DIR/$tfile || error "touch"
7672 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7673 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7674 rm $DIR/$tfile || error "rm"
7677 mkdir -p $DIR/$tdir || error "mkdir"
7678 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7679 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7680 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7681 error "$testfile error deleting user.author1"
7682 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7683 grep "user.$(basename $tdir)" &&
7684 error "$tdir did not delete user.$(basename $tdir)"
7685 rmdir $DIR/$tdir || error "rmdir"
7688 test_mkdir $DIR/$tdir || error "make striped dir"
7689 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7690 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7691 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7692 error "$testfile error deleting user.author1"
7693 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7694 grep "user.$(basename $tdir)" &&
7695 error "$tdir did not delete user.$(basename $tdir)"
7696 rmdir $DIR/$tdir || error "rm striped dir"
7698 run_test 102r "set EAs with empty values"
7701 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
7702 skip "MDS needs to be at least 2.11.52"
7704 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
7706 save_lustre_params client "llite.*.xattr_cache" > $save
7708 for cache in 0 1; do
7709 lctl set_param llite.*.xattr_cache=$cache
7712 touch $DIR/$tfile || error "touch"
7713 for prefix in lustre security system trusted user; do
7714 # Note getxattr() may fail with 'Operation not
7715 # supported' or 'No such attribute' depending
7716 # on prefix and cache.
7717 getfattr -n $prefix.n102s $DIR/$tfile &&
7718 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
7722 restore_lustre_params < $save
7724 run_test 102s "getting nonexistent xattrs should fail"
7728 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7733 [ "$UID" != 0 ] && skip_env "must run as root" && return
7734 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7735 skip "must have acl enabled" && return
7736 [ -z "$(which setfacl 2>/dev/null)" ] &&
7737 skip_env "could not find setfacl" && return
7738 $GSS && skip "could not run under gss" && return
7739 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7741 gpasswd -a daemon bin # LU-5641
7742 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7744 declare -a identity_old
7746 for num in $(seq $MDSCOUNT); do
7747 switch_identity $num true || identity_old[$num]=$?
7755 echo "performing cp ..."
7756 run_acl_subtest cp || error "run_acl_subtest cp failed"
7757 echo "performing getfacl-noacl..."
7758 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7759 echo "performing misc..."
7760 run_acl_subtest misc || error "misc test failed"
7761 echo "performing permissions..."
7762 run_acl_subtest permissions || error "permissions failed"
7763 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7764 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7765 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7766 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7768 echo "performing permissions xattr..."
7769 run_acl_subtest permissions_xattr ||
7770 error "permissions_xattr failed"
7772 echo "performing setfacl..."
7773 run_acl_subtest setfacl || error "setfacl test failed"
7775 # inheritance test got from HP
7776 echo "performing inheritance..."
7777 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7778 chmod +x make-tree || error "chmod +x failed"
7779 run_acl_subtest inheritance || error "inheritance test failed"
7782 echo "LU-974 ignore umask when acl is enabled..."
7783 run_acl_subtest 974 || error "LU-974 umask test failed"
7784 if [ $MDSCOUNT -ge 2 ]; then
7785 run_acl_subtest 974_remote ||
7786 error "LU-974 umask test failed under remote dir"
7789 echo "LU-2561 newly created file is same size as directory..."
7790 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7791 run_acl_subtest 2561 || error "LU-2561 test failed"
7793 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7796 run_acl_subtest 4924 || error "LU-4924 test failed"
7801 for num in $(seq $MDSCOUNT); do
7802 if [ "${identity_old[$num]}" = 1 ]; then
7803 switch_identity $num false || identity_old[$num]=$?
7807 run_test 103a "acl test ========================================="
7810 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7812 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7813 local mountopts=$MDS_MOUNT_OPTS
7815 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7819 stop $SINGLEMDS || error "failed to stop MDT."
7821 if [ -z "$MDS_MOUNT_OPTS" ]; then
7822 MDS_MOUNT_OPTS="-o noacl"
7824 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7826 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7827 error "failed to start MDT."
7828 MDS_MOUNT_OPTS=$mountopts
7832 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7836 stop $SINGLEMDS || error "failed to stop MDT."
7838 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7839 error "failed to start MDT."
7844 run_test 103b "MDS mount option 'noacl'"
7848 cp -rp $DIR/$tdir $DIR/$tdir.bak
7850 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7851 error "$DIR/$tdir shouldn't contain default ACL"
7852 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7853 error "$DIR/$tdir.bak shouldn't contain default ACL"
7856 run_test 103c "'cp -rp' won't set empty acl"
7859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7861 lfs df || error "lfs df failed"
7862 lfs df -ih || error "lfs df -ih failed"
7863 lfs df -h $DIR || error "lfs df -h $DIR failed"
7864 lfs df -i $DIR || error "lfs df -i $DIR failed"
7865 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7866 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7868 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7869 lctl --device %$OSC deactivate
7870 lfs df || error "lfs df with deactivated OSC failed"
7871 lctl --device %$OSC activate
7872 # wait the osc back to normal
7873 wait_osc_import_state client ost FULL
7875 lfs df || error "lfs df with reactivated OSC failed"
7878 run_test 104a "lfs df [-ih] [path] test ========================="
7881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7882 [ $RUNAS_ID -eq $UID ] &&
7883 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7885 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7886 grep "Permission denied" | wc -l)))
7887 if [ $denied_cnt -ne 0 ]; then
7888 error "lfs check servers test failed"
7891 run_test 104b "$RUNAS lfs check servers test ===================="
7894 # doesn't work on 2.4 kernels
7896 if $(flock_is_enabled); then
7897 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7899 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7903 run_test 105a "flock when mounted without -o flock test ========"
7907 if $(flock_is_enabled); then
7908 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7910 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7914 run_test 105b "fcntl when mounted without -o flock test ========"
7918 if $(flock_is_enabled); then
7919 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7921 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7925 run_test 105c "lockf when mounted without -o flock test ========"
7927 test_105d() { # bug 15924
7928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7929 test_mkdir -p $DIR/$tdir
7930 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7931 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7932 $LCTL set_param fail_loc=0x80000315
7933 flocks_test 2 $DIR/$tdir
7935 run_test 105d "flock race (should not freeze) ========"
7937 test_105e() { # bug 22660 && 22040
7938 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7940 flocks_test 3 $DIR/$tfile
7942 run_test 105e "Two conflicting flocks from same process ======="
7944 test_106() { #bug 10921
7945 test_mkdir -p $DIR/$tdir
7946 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7947 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7949 run_test 106 "attempt exec of dir followed by chown of that dir"
7952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7959 local save_pattern=$(sysctl -n kernel.core_pattern)
7960 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7961 sysctl -w kernel.core_pattern=$file
7962 sysctl -w kernel.core_uses_pid=0
7970 kill -s 11 $SLEEPPID
7972 if [ -e $file ]; then
7973 size=`stat -c%s $file`
7974 [ $size -eq 0 ] && error "Fail to create core file $file"
7976 error "Fail to create core file $file"
7979 sysctl -w kernel.core_pattern=$save_pattern
7980 sysctl -w kernel.core_uses_pid=$save_uses_pid
7983 run_test 107 "Coredump on SIG"
7986 test_mkdir -p $DIR/$tdir
7987 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7988 error "mkdir with 255 char failed"
7989 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7990 error "mkdir with 256 char should fail, but did not"
7991 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7992 error "create with 255 char failed"
7993 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7994 error "create with 256 char should fail, but did not"
7999 run_test 110 "filename length checking"
8002 # Purpose: To verify dynamic thread (OSS) creation.
8005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8006 remote_ost_nodsh && skip "remote OST with nodsh" && return
8008 # Lustre does not stop service threads once they are started.
8009 # Reset number of running threads to default.
8014 local save_params="$TMP/sanity-$TESTNAME.parameters"
8016 # Get ll_ost_io count before I/O
8017 OSTIO_pre=$(do_facet ost1 \
8018 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
8019 # Exit if lustre is not running (ll_ost_io not running).
8020 [ -z "$OSTIO_pre" ] && error "no OSS threads"
8022 echo "Starting with $OSTIO_pre threads"
8023 local thread_max=$((OSTIO_pre * 2))
8024 local rpc_in_flight=$((thread_max * 2))
8025 # Number of I/O Process proposed to be started.
8027 local facets=$(get_facets OST)
8029 save_lustre_params client \
8030 "osc.*OST*.max_rpcs_in_flight" > $save_params
8031 save_lustre_params $facets \
8032 "ost.OSS.ost_io.threads_max" >> $save_params
8034 # Set in_flight to $rpc_in_flight
8035 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
8036 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
8037 nfiles=${rpc_in_flight}
8038 # Set ost thread_max to $thread_max
8040 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
8042 # 5 Minutes should be sufficient for max number of OSS
8043 # threads(thread_max) to be created.
8047 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
8049 for i in $(seq $nfiles); do
8050 local file=$DIR/$tdir/${tfile}-$i
8051 $LFS setstripe -c -1 -i 0 $file
8052 ($WTL $file $timeout)&
8055 # I/O Started - Wait for thread_started to reach thread_max or report
8056 # error if thread_started is more than thread_max.
8057 echo "Waiting for thread_started to reach thread_max"
8058 local thread_started=0
8059 local end_time=$((SECONDS + timeout))
8061 while [ $SECONDS -le $end_time ] ; do
8063 # Get ost i/o thread_started count.
8064 thread_started=$(do_facet ost1 \
8066 ost.OSS.ost_io.threads_started | cut -d= -f2")
8067 # Break out if thread_started is equal/greater than thread_max
8068 if [[ $thread_started -ge $thread_max ]]; then
8069 echo ll_ost_io thread_started $thread_started, \
8070 equal/greater than thread_max $thread_max
8076 # Cleanup - We have the numbers, Kill i/o jobs if running.
8077 jobcount=($(jobs -p))
8078 for i in $(seq 0 $((${#jobcount[@]}-1)))
8080 kill -9 ${jobcount[$i]}
8081 if [ $? -ne 0 ] ; then
8083 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8087 # Cleanup files left by WTL binary.
8088 for i in $(seq $nfiles); do
8089 local file=$DIR/$tdir/${tfile}-$i
8091 if [ $? -ne 0 ] ; then
8092 echo "Warning: Failed to delete file $file"
8096 restore_lustre_params <$save_params
8097 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8099 # Error out if no new thread has started or Thread started is greater
8101 if [[ $thread_started -le $OSTIO_pre ||
8102 $thread_started -gt $thread_max ]]; then
8103 error "ll_ost_io: thread_started $thread_started" \
8104 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
8105 "No new thread started or thread started greater " \
8109 run_test 115 "verify dynamic thread creation===================="
8112 wait_delete_completed
8113 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8114 echo "OST kbytes available: ${AVAIL[@]}"
8119 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8120 #echo OST $i: ${AVAIL[i]}kb
8121 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8125 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8130 echo "Min free space: OST $MINI: $MINV"
8131 echo "Max free space: OST $MAXI: $MAXV"
8134 test_116a() { # was previously test_116()
8135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8136 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8138 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8140 echo -n "Free space priority "
8141 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
8146 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
8147 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
8149 trap simple_cleanup_common EXIT
8152 # Check if we need to generate uneven OSTs
8153 test_mkdir -p $DIR/$tdir/OST${MINI}
8154 local FILL=$((MINV / 4))
8155 local DIFF=$((MAXV - MINV))
8156 local DIFF2=$((DIFF * 100 / MINV))
8158 local threshold=$(do_facet $SINGLEMDS \
8159 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
8160 threshold=${threshold%%%}
8161 echo -n "Check for uneven OSTs: "
8162 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
8164 if [[ $DIFF2 -gt $threshold ]]; then
8166 echo "Don't need to fill OST$MINI"
8168 # generate uneven OSTs. Write 2% over the QOS threshold value
8170 DIFF=$((threshold - DIFF2 + 2))
8171 DIFF2=$((MINV * DIFF / 100))
8172 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
8173 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
8174 error "setstripe failed"
8175 DIFF=$((DIFF2 / 2048))
8177 while [ $i -lt $DIFF ]; do
8179 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8180 bs=2M count=1 2>/dev/null
8189 DIFF=$((MAXV - MINV))
8190 DIFF2=$((DIFF * 100 / MINV))
8191 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8192 if [ $DIFF2 -gt $threshold ]; then
8195 echo "failed - QOS mode won't be used"
8196 skip "QOS imbalance criteria not met"
8197 simple_cleanup_common
8206 # now fill using QOS
8207 $SETSTRIPE -c 1 $DIR/$tdir
8208 FILL=$((FILL / 200))
8209 if [ $FILL -gt 600 ]; then
8212 echo "writing $FILL files to QOS-assigned OSTs"
8214 while [ $i -lt $FILL ]; do
8216 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8220 echo "wrote $i 200k files"
8224 echo "Note: free space may not be updated, so measurements might be off"
8226 DIFF2=$((MAXV - MINV))
8227 echo "free space delta: orig $DIFF final $DIFF2"
8228 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8229 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8230 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8231 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8232 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8233 if [[ $DIFF -gt 0 ]]; then
8234 FILL=$((DIFF2 * 100 / DIFF - 100))
8235 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8238 # Figure out which files were written where
8239 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8240 awk '/'$MINI1': / {print $2; exit}')
8242 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8243 echo "$MINC files created on smaller OST $MINI1"
8244 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8245 awk '/'$MAXI1': / {print $2; exit}')
8247 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8248 echo "$MAXC files created on larger OST $MAXI1"
8249 if [[ $MINC -gt 0 ]]; then
8250 FILL=$((MAXC * 100 / MINC - 100))
8251 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8253 [[ $MAXC -gt $MINC ]] ||
8254 error_ignore LU-9 "stripe QOS didn't balance free space"
8255 simple_cleanup_common
8257 run_test 116a "stripe QOS: free space balance ==================="
8259 test_116b() { # LU-2093
8260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8261 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8263 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8264 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8265 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8266 [ -z "$old_rr" ] && skip "no QOS" && return 0
8267 do_facet $SINGLEMDS lctl set_param \
8268 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8270 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8271 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8272 do_facet $SINGLEMDS lctl set_param fail_loc=0
8274 do_facet $SINGLEMDS lctl set_param \
8275 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8277 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8279 test_117() # bug 10891
8281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8282 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8283 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8284 lctl set_param fail_loc=0x21e
8285 > $DIR/$tfile || error "truncate failed"
8286 lctl set_param fail_loc=0
8287 echo "Truncate succeeded."
8290 run_test 117 "verify osd extend =========="
8292 NO_SLOW_RESENDCOUNT=4
8293 export OLD_RESENDCOUNT=""
8294 set_resend_count () {
8295 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8296 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8297 lctl set_param -n $PROC_RESENDCOUNT $1
8298 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8301 # for reduce test_118* time (b=14842)
8302 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8304 # Reset async IO behavior after error case
8306 FILE=$DIR/reset_async
8308 # Ensure all OSCs are cleared
8309 $SETSTRIPE -c -1 $FILE
8310 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8315 test_118a() #bug 11710
8317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8320 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8321 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8322 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8324 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8325 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8330 run_test 118a "verify O_SYNC works =========="
8334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8335 remote_ost_nodsh && skip "remote OST with nodsh" && return
8339 #define OBD_FAIL_SRV_ENOENT 0x217
8340 set_nodes_failloc "$(osts_nodes)" 0x217
8341 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8343 set_nodes_failloc "$(osts_nodes)" 0
8344 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8345 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8348 if [[ $RC -eq 0 ]]; then
8349 error "Must return error due to dropped pages, rc=$RC"
8353 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8354 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8358 echo "Dirty pages not leaked on ENOENT"
8360 # Due to the above error the OSC will issue all RPCs syncronously
8361 # until a subsequent RPC completes successfully without error.
8362 $MULTIOP $DIR/$tfile Ow4096yc
8367 run_test 118b "Reclaim dirty pages on fatal error =========="
8371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8373 # for 118c, restore the original resend count, LU-1940
8374 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8375 set_resend_count $OLD_RESENDCOUNT
8376 remote_ost_nodsh && skip "remote OST with nodsh" && return
8380 #define OBD_FAIL_OST_EROFS 0x216
8381 set_nodes_failloc "$(osts_nodes)" 0x216
8383 # multiop should block due to fsync until pages are written
8384 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8388 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8389 error "Multiop failed to block on fsync, pid=$MULTIPID"
8392 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8394 if [[ $WRITEBACK -eq 0 ]]; then
8395 error "No page in writeback, writeback=$WRITEBACK"
8398 set_nodes_failloc "$(osts_nodes)" 0
8401 if [[ $RC -ne 0 ]]; then
8402 error "Multiop fsync failed, rc=$RC"
8405 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8406 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8408 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8409 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8413 echo "Dirty pages flushed via fsync on EROFS"
8416 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8418 # continue to use small resend count to reduce test_118* time (b=14842)
8419 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8424 remote_ost_nodsh && skip "remote OST with nodsh" && return
8428 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8429 set_nodes_failloc "$(osts_nodes)" 0x214
8430 # multiop should block due to fsync until pages are written
8431 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8435 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8436 error "Multiop failed to block on fsync, pid=$MULTIPID"
8439 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8441 if [[ $WRITEBACK -eq 0 ]]; then
8442 error "No page in writeback, writeback=$WRITEBACK"
8445 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8446 set_nodes_failloc "$(osts_nodes)" 0
8448 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8449 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8451 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8452 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8456 echo "Dirty pages gaurenteed flushed via fsync"
8459 run_test 118d "Fsync validation inject a delay of the bulk =========="
8462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8465 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8466 lctl set_param fail_loc=0x8000040a
8468 # Should simulate EINVAL error which is fatal
8469 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8471 if [[ $RC -eq 0 ]]; then
8472 error "Must return error due to dropped pages, rc=$RC"
8475 lctl set_param fail_loc=0x0
8477 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8478 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8479 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8481 if [[ $LOCKED -ne 0 ]]; then
8482 error "Locked pages remain in cache, locked=$LOCKED"
8485 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8486 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8490 echo "No pages locked after fsync"
8495 run_test 118f "Simulate unrecoverable OSC side error =========="
8498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8501 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8502 lctl set_param fail_loc=0x406
8504 # simulate local -ENOMEM
8505 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8508 lctl set_param fail_loc=0
8509 if [[ $RC -eq 0 ]]; then
8510 error "Must return error due to dropped pages, rc=$RC"
8513 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8514 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8515 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8517 if [[ $LOCKED -ne 0 ]]; then
8518 error "Locked pages remain in cache, locked=$LOCKED"
8521 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8522 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8526 echo "No pages locked after fsync"
8531 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8535 remote_ost_nodsh && skip "remote OST with nodsh" && return
8539 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8540 set_nodes_failloc "$(osts_nodes)" 0x20e
8541 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8542 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8545 set_nodes_failloc "$(osts_nodes)" 0
8546 if [[ $RC -eq 0 ]]; then
8547 error "Must return error due to dropped pages, rc=$RC"
8550 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8551 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8552 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8554 if [[ $LOCKED -ne 0 ]]; then
8555 error "Locked pages remain in cache, locked=$LOCKED"
8558 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8559 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8563 echo "No pages locked after fsync"
8567 run_test 118h "Verify timeout in handling recoverables errors =========="
8569 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8573 remote_ost_nodsh && skip "remote OST with nodsh" && return
8577 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8578 set_nodes_failloc "$(osts_nodes)" 0x20e
8580 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8581 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8584 set_nodes_failloc "$(osts_nodes)" 0
8588 if [[ $RC -ne 0 ]]; then
8589 error "got error, but should be not, rc=$RC"
8592 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8593 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8594 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8595 if [[ $LOCKED -ne 0 ]]; then
8596 error "Locked pages remain in cache, locked=$LOCKED"
8599 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8600 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8604 echo "No pages locked after fsync"
8608 run_test 118i "Fix error before timeout in recoverable error =========="
8610 [ "$SLOW" = "no" ] && set_resend_count 4
8613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8614 remote_ost_nodsh && skip "remote OST with nodsh" && return
8618 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8619 set_nodes_failloc "$(osts_nodes)" 0x220
8621 # return -EIO from OST
8622 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8624 set_nodes_failloc "$(osts_nodes)" 0x0
8625 if [[ $RC -eq 0 ]]; then
8626 error "Must return error due to dropped pages, rc=$RC"
8629 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8630 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8631 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8632 if [[ $LOCKED -ne 0 ]]; then
8633 error "Locked pages remain in cache, locked=$LOCKED"
8636 # in recoverable error on OST we want resend and stay until it finished
8637 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8638 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8642 echo "No pages locked after fsync"
8646 run_test 118j "Simulate unrecoverable OST side error =========="
8650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8651 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8653 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8654 set_nodes_failloc "$(osts_nodes)" 0x20e
8655 test_mkdir -p $DIR/$tdir
8657 for ((i=0;i<10;i++)); do
8658 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8659 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8666 set_nodes_failloc "$(osts_nodes)" 0
8669 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8675 test_mkdir -p $DIR/$tdir
8676 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8679 run_test 118l "fsync dir ========="
8681 test_118m() # LU-3066
8683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8684 test_mkdir -p $DIR/$tdir
8685 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8688 run_test 118m "fdatasync dir ========="
8690 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8692 test_119a() # bug 11737
8694 BSIZE=$((512 * 1024))
8695 directio write $DIR/$tfile 0 1 $BSIZE
8696 # We ask to read two blocks, which is more than a file size.
8697 # directio will indicate an error when requested and actual
8698 # sizes aren't equeal (a normal situation in this case) and
8699 # print actual read amount.
8700 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8701 if [ "$NOB" != "$BSIZE" ]; then
8702 error "read $NOB bytes instead of $BSIZE"
8706 run_test 119a "Short directIO read must return actual read amount"
8708 test_119b() # bug 11737
8710 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8712 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8713 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8715 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8716 error "direct read failed"
8719 run_test 119b "Sparse directIO read must return actual read amount"
8721 test_119c() # bug 13099
8724 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8725 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8728 run_test 119c "Testing for direct read hitting hole"
8730 test_119d() # bug 15950
8732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8733 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8734 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8736 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8737 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8738 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8739 lctl set_param fail_loc=0x40d
8740 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8743 cat $DIR/$tfile > /dev/null &
8744 lctl set_param fail_loc=0
8747 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8749 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8750 error "the read rpcs have not completed in 2s"
8752 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8754 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8757 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8758 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8759 test_mkdir -p $DIR/$tdir
8760 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8761 skip "no early lock cancel on server" && return 0
8763 lru_resize_disable mdc
8764 lru_resize_disable osc
8765 cancel_lru_locks mdc
8766 # asynchronous object destroy at MDT could cause bl ast to client
8767 cancel_lru_locks osc
8769 stat $DIR/$tdir > /dev/null
8770 can1=$(do_facet $SINGLEMDS \
8771 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8772 awk '/ldlm_cancel/ {print $2}')
8773 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8774 awk '/ldlm_bl_callback/ {print $2}')
8775 test_mkdir -c1 $DIR/$tdir/d1
8776 can2=$(do_facet $SINGLEMDS \
8777 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8778 awk '/ldlm_cancel/ {print $2}')
8779 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8780 awk '/ldlm_bl_callback/ {print $2}')
8781 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8782 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8783 lru_resize_enable mdc
8784 lru_resize_enable osc
8786 run_test 120a "Early Lock Cancel: mkdir test"
8789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8790 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8791 test_mkdir $DIR/$tdir
8792 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8793 skip "no early lock cancel on server" && return 0
8794 lru_resize_disable mdc
8795 lru_resize_disable osc
8796 cancel_lru_locks mdc
8797 stat $DIR/$tdir > /dev/null
8798 can1=$(do_facet $SINGLEMDS \
8799 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8800 awk '/ldlm_cancel/ {print $2}')
8801 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8802 awk '/ldlm_bl_callback/ {print $2}')
8804 can2=$(do_facet $SINGLEMDS \
8805 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8806 awk '/ldlm_cancel/ {print $2}')
8807 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8808 awk '/ldlm_bl_callback/ {print $2}')
8809 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8810 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8811 lru_resize_enable mdc
8812 lru_resize_enable osc
8814 run_test 120b "Early Lock Cancel: create test"
8817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8818 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8819 test_mkdir -c1 $DIR/$tdir
8820 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8821 skip "no early lock cancel on server" && return 0
8822 lru_resize_disable mdc
8823 lru_resize_disable osc
8824 test_mkdir -p -c1 $DIR/$tdir/d1
8825 test_mkdir -p -c1 $DIR/$tdir/d2
8826 touch $DIR/$tdir/d1/f1
8827 cancel_lru_locks mdc
8828 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8829 can1=$(do_facet $SINGLEMDS \
8830 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8831 awk '/ldlm_cancel/ {print $2}')
8832 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8833 awk '/ldlm_bl_callback/ {print $2}')
8834 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8835 can2=$(do_facet $SINGLEMDS \
8836 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8837 awk '/ldlm_cancel/ {print $2}')
8838 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8839 awk '/ldlm_bl_callback/ {print $2}')
8840 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8841 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8842 lru_resize_enable mdc
8843 lru_resize_enable osc
8845 run_test 120c "Early Lock Cancel: link test"
8848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8849 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8850 test_mkdir -p -c1 $DIR/$tdir
8851 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8852 skip "no early lock cancel on server" && return 0
8853 lru_resize_disable mdc
8854 lru_resize_disable osc
8856 cancel_lru_locks mdc
8857 stat $DIR/$tdir > /dev/null
8858 can1=$(do_facet $SINGLEMDS \
8859 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8860 awk '/ldlm_cancel/ {print $2}')
8861 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8862 awk '/ldlm_bl_callback/ {print $2}')
8863 chmod a+x $DIR/$tdir
8864 can2=$(do_facet $SINGLEMDS \
8865 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8866 awk '/ldlm_cancel/ {print $2}')
8867 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8868 awk '/ldlm_bl_callback/ {print $2}')
8869 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8870 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8871 lru_resize_enable mdc
8872 lru_resize_enable osc
8874 run_test 120d "Early Lock Cancel: setattr test"
8877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8878 ! $($LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_can) &&
8879 skip "no early lock cancel on server" && return 0
8880 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8881 local dlmtrace_set=false
8883 test_mkdir -p -c1 $DIR/$tdir
8884 lru_resize_disable mdc
8885 lru_resize_disable osc
8886 ! $LCTL get_param debug | grep -q dlmtrace &&
8887 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8888 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8889 cancel_lru_locks mdc
8890 cancel_lru_locks osc
8891 dd if=$DIR/$tdir/f1 of=/dev/null
8892 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8893 # XXX client can not do early lock cancel of OST lock
8894 # during unlink (LU-4206), so cancel osc lock now.
8896 cancel_lru_locks osc
8897 can1=$(do_facet $SINGLEMDS \
8898 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8899 awk '/ldlm_cancel/ {print $2}')
8900 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8901 awk '/ldlm_bl_callback/ {print $2}')
8902 unlink $DIR/$tdir/f1
8904 can2=$(do_facet $SINGLEMDS \
8905 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8906 awk '/ldlm_cancel/ {print $2}')
8907 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8908 awk '/ldlm_bl_callback/ {print $2}')
8909 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8910 $LCTL dk $TMP/cancel.debug.txt
8911 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8912 $LCTL dk $TMP/blocking.debug.txt
8913 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8914 lru_resize_enable mdc
8915 lru_resize_enable osc
8917 run_test 120e "Early Lock Cancel: unlink test"
8920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8921 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8922 skip "no early lock cancel on server" && return 0
8923 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8924 test_mkdir -p -c1 $DIR/$tdir
8925 lru_resize_disable mdc
8926 lru_resize_disable osc
8927 test_mkdir -p -c1 $DIR/$tdir/d1
8928 test_mkdir -p -c1 $DIR/$tdir/d2
8929 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8930 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8931 cancel_lru_locks mdc
8932 cancel_lru_locks osc
8933 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8934 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8935 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8936 # XXX client can not do early lock cancel of OST lock
8937 # during rename (LU-4206), so cancel osc lock now.
8939 cancel_lru_locks osc
8940 can1=$(do_facet $SINGLEMDS \
8941 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8942 awk '/ldlm_cancel/ {print $2}')
8943 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8944 awk '/ldlm_bl_callback/ {print $2}')
8945 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8947 can2=$(do_facet $SINGLEMDS \
8948 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8949 awk '/ldlm_cancel/ {print $2}')
8950 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8951 awk '/ldlm_bl_callback/ {print $2}')
8952 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8953 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8954 lru_resize_enable mdc
8955 lru_resize_enable osc
8957 run_test 120f "Early Lock Cancel: rename test"
8960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8961 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8962 skip "no early lock cancel on server" && return 0
8963 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8964 lru_resize_disable mdc
8965 lru_resize_disable osc
8967 echo create $count files
8968 test_mkdir -p $DIR/$tdir
8969 cancel_lru_locks mdc
8970 cancel_lru_locks osc
8973 can0=$(do_facet $SINGLEMDS \
8974 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8975 awk '/ldlm_cancel/ {print $2}')
8976 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8977 awk '/ldlm_bl_callback/ {print $2}')
8978 createmany -o $DIR/$tdir/f $count
8980 can1=$(do_facet $SINGLEMDS \
8981 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8982 awk '/ldlm_cancel/ {print $2}')
8983 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8984 awk '/ldlm_bl_callback/ {print $2}')
8986 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8987 echo rm $count files
8990 can2=$(do_facet $SINGLEMDS \
8991 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8992 awk '/ldlm_cancel/ {print $2}')
8993 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8994 awk '/ldlm_bl_callback/ {print $2}')
8996 echo total: $count removes in $((t2-t1))
8997 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8999 # wait for commitment of removal
9000 lru_resize_enable mdc
9001 lru_resize_enable osc
9003 run_test 120g "Early Lock Cancel: performance test"
9005 test_121() { #bug #10589
9006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9008 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
9009 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
9010 lctl set_param fail_loc=0x310
9011 cancel_lru_locks osc > /dev/null
9012 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
9013 lctl set_param fail_loc=0
9014 [[ $reads -eq $writes ]] ||
9015 error "read $reads blocks, must be $writes blocks"
9017 run_test 121 "read cancel race ========="
9019 test_123a() { # was test 123, statahead(bug 11401)
9020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9022 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
9023 log "testing on UP system. Performance may be not as good as expected."
9028 test_mkdir -p $DIR/$tdir
9029 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
9030 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
9032 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
9033 createmany -o $DIR/$tdir/$tfile $j $((i - j))
9035 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9036 lctl set_param -n llite.*.statahead_max 0
9037 lctl get_param llite.*.statahead_max
9038 cancel_lru_locks mdc
9039 cancel_lru_locks osc
9041 time ls -l $DIR/$tdir | wc -l
9043 delta=$((etime - stime))
9044 log "ls $i files without statahead: $delta sec"
9045 lctl set_param llite.*.statahead_max=$max
9047 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9048 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
9049 cancel_lru_locks mdc
9050 cancel_lru_locks osc
9052 time ls -l $DIR/$tdir | wc -l
9054 delta_sa=$((etime - stime))
9055 log "ls $i files with statahead: $delta_sa sec"
9056 lctl get_param -n llite.*.statahead_stats
9057 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9059 [[ $swrong -lt $ewrong ]] &&
9060 log "statahead was stopped, maybe too many locks held!"
9061 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
9063 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9064 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9065 lctl set_param -n llite.*.statahead_max 0
9066 lctl get_param llite.*.statahead_max
9067 cancel_lru_locks mdc
9068 cancel_lru_locks osc
9070 time ls -l $DIR/$tdir | wc -l
9072 delta=$((etime - stime))
9073 log "ls $i files again without statahead: $delta sec"
9074 lctl set_param llite.*.statahead_max=$max
9075 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9076 if [ $SLOWOK -eq 0 ]; then
9077 error "ls $i files is slower with statahead!"
9079 log "ls $i files is slower with statahead!"
9085 [ $delta -gt 20 ] && break
9086 [ $delta -gt 8 ] && MULT=$((50 / delta))
9087 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
9095 delta=$((etime - stime))
9096 log "rm -r $DIR/$tdir/: $delta seconds"
9098 lctl get_param -n llite.*.statahead_stats
9100 run_test 123a "verify statahead work"
9102 test_123b () { # statahead(bug 15027)
9103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9104 test_mkdir -p $DIR/$tdir
9105 createmany -o $DIR/$tdir/$tfile-%d 1000
9107 cancel_lru_locks mdc
9108 cancel_lru_locks osc
9110 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
9111 lctl set_param fail_loc=0x80000803
9112 ls -lR $DIR/$tdir > /dev/null
9114 lctl set_param fail_loc=0x0
9115 lctl get_param -n llite.*.statahead_stats
9120 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
9123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9124 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9125 skip "no lru resize on server" && return 0
9127 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9129 log "create $NR files at $DIR/$tdir"
9130 createmany -o $DIR/$tdir/f $NR ||
9131 error "failed to create $NR files in $DIR/$tdir"
9133 cancel_lru_locks mdc
9134 ls -l $DIR/$tdir > /dev/null
9138 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
9139 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
9140 LRU_SIZE=$($LCTL get_param -n $PARAM)
9141 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
9142 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
9144 log "NS=$(basename $NSDIR)"
9149 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9150 skip "Not enough cached locks created!"
9157 # We know that lru resize allows one client to hold $LIMIT locks
9158 # for 10h. After that locks begin to be killed by client.
9160 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9162 if [ $LIMIT -lt $LRU_SIZE ]; then
9163 skip "Limit is too small $LIMIT"
9167 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9168 # killing locks. Some time was spent for creating locks. This means
9169 # that up to the moment of sleep finish we must have killed some of
9170 # them (10-100 locks). This depends on how fast ther were created.
9171 # Many of them were touched in almost the same moment and thus will
9172 # be killed in groups.
9173 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9175 # Use $LRU_SIZE_B here to take into account real number of locks
9176 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9177 local LRU_SIZE_B=$LRU_SIZE
9179 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9180 log "OLD_LVF=$OLD_LVF"
9181 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9183 # Let's make sure that we really have some margin. Client checks
9184 # cached locks every 10 sec.
9186 log "Sleep ${SLEEP} sec"
9188 while ((SEC<$SLEEP)); do
9192 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9196 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9197 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9199 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9200 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9201 unlinkmany $DIR/$tdir/f $NR
9205 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9206 log "unlink $NR files at $DIR/$tdir"
9207 unlinkmany $DIR/$tdir/f $NR
9209 run_test 124a "lru resize ======================================="
9211 get_max_pool_limit()
9213 local limit=$($LCTL get_param \
9214 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9217 if [[ $l -gt $max ]]; then
9225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9226 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9227 skip "no lru resize on server" && return 0
9229 LIMIT=$(get_max_pool_limit)
9231 NR=$(($(default_lru_size)*20))
9232 if [[ $NR -gt $LIMIT ]]; then
9233 log "Limit lock number by $LIMIT locks"
9237 IFree=$(mdsrate_inodes_available)
9238 if [ $IFree -lt $NR ]; then
9239 log "Limit lock number by $IFree inodes"
9243 lru_resize_disable mdc
9244 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
9245 error "failed to create $DIR/$tdir/disable_lru_resize"
9247 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9248 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9249 cancel_lru_locks mdc
9252 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9255 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9258 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9262 nolruresize_delta=$((etime-stime))
9263 log "ls -la time: $nolruresize_delta seconds"
9264 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9265 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9267 lru_resize_enable mdc
9268 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
9269 error "failed to create $DIR/$tdir/enable_lru_resize"
9271 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9272 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9273 cancel_lru_locks mdc
9276 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9279 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9282 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9286 lruresize_delta=$((etime-stime))
9287 log "ls -la time: $lruresize_delta seconds"
9288 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9290 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9291 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9292 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9293 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9295 log "lru resize performs the same with no lru resize"
9297 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9299 run_test 124b "lru resize (performance test) ======================="
9302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9303 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9304 skip "no lru resize on server" && return 0
9306 # cache ununsed locks on client
9308 cancel_lru_locks mdc
9309 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9310 createmany -o $DIR/$tdir/f $nr ||
9311 error "failed to create $nr files in $DIR/$tdir"
9312 ls -l $DIR/$tdir > /dev/null
9314 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9315 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9316 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9317 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9318 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9320 # set lru_max_age to 1 sec
9321 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9322 echo "sleep $((recalc_p * 2)) seconds..."
9323 sleep $((recalc_p * 2))
9325 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9326 # restore lru_max_age
9327 $LCTL set_param -n $nsdir.lru_max_age $max_age
9328 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9329 unlinkmany $DIR/$tdir/f $nr
9331 run_test 124c "LRUR cancel very aged locks"
9333 test_125() { # 13358
9334 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9335 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
9336 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9337 test_mkdir -p $DIR/d125 || error "mkdir failed"
9338 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
9339 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
9340 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
9342 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9344 test_126() { # bug 12829/13455
9345 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9346 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
9347 $GSS && skip "must run as gss disabled" && return
9349 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9350 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9352 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9354 run_test 126 "check that the fsgid provided by the client is taken into account"
9356 test_127a() { # bug 15521
9357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9358 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9359 $LCTL set_param osc.*.stats=0
9360 FSIZE=$((2048 * 1024))
9361 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9362 cancel_lru_locks osc
9363 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9365 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9366 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9367 echo "got $COUNT $NAME"
9368 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9369 eval $NAME=$COUNT || error "Wrong proc format"
9372 read_bytes|write_bytes)
9373 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9374 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9375 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9376 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9377 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9378 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9379 error "sumsquare is too small: $SUMSQ"
9380 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9381 error "sumsquare is too big: $SUMSQ"
9385 done < $DIR/${tfile}.tmp
9387 #check that we actually got some stats
9388 [ "$read_bytes" ] || error "Missing read_bytes stats"
9389 [ "$write_bytes" ] || error "Missing write_bytes stats"
9390 [ "$read_bytes" != 0 ] || error "no read done"
9391 [ "$write_bytes" != 0 ] || error "no write done"
9393 run_test 127a "verify the client stats are sane"
9395 test_127b() { # bug LU-333
9396 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9397 $LCTL set_param llite.*.stats=0
9398 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9399 # perform 2 reads and writes so MAX is different from SUM.
9400 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9401 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9402 cancel_lru_locks osc
9403 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9404 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9406 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9407 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9408 echo "got $COUNT $NAME"
9409 eval $NAME=$COUNT || error "Wrong proc format"
9413 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9414 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9415 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9416 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9419 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9420 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9421 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9422 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9426 done < $TMP/${tfile}.tmp
9428 #check that we actually got some stats
9429 [ "$read_bytes" ] || error "Missing read_bytes stats"
9430 [ "$write_bytes" ] || error "Missing write_bytes stats"
9431 [ "$read_bytes" != 0 ] || error "no read done"
9432 [ "$write_bytes" != 0 ] || error "no write done"
9434 rm -f $TMP/${tfile}.tmp
9436 run_test 127b "verify the llite client stats are sane"
9438 test_128() { # bug 15212
9440 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9445 result=$(grep error $TMP/$tfile.log)
9446 rm -f $DIR/$tfile $TMP/$tfile.log
9448 error "consecutive find's under interactive lfs failed"
9450 run_test 128 "interactive lfs for 2 consecutive find's"
9457 local ldproc=/proc/fs/ldiskfs
9458 local facets=$(get_facets MDS)
9460 for facet in ${facets//,/ }; do
9461 canondev=$(ldiskfs_canon \
9462 *.$(convert_facet2label $facet).mntdev $facet)
9463 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9464 ldproc=/sys/fs/ldiskfs
9465 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9466 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9471 local facets=$(get_facets MDS)
9472 for facet in ${facets//,/ }; do
9473 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9479 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9480 { skip "Need MDS version with at least 2.5.56"; return 0; }
9482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9483 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9484 skip "ldiskfs only test"
9487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9490 local has_warning=false
9495 # block size of mds1
9496 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9497 set_dir_limits $maxsize $maxsize
9498 local dirsize=$(stat -c%s "$DIR/$tdir")
9500 while [[ $dirsize -le $maxsize ]]; do
9501 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9503 if ! $has_warning; then
9504 check_mds_dmesg '"is approaching"' && has_warning=true
9507 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9508 # EFBIG for previous versions included in ldiskfs series
9509 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9511 echo "return code $rc received as expected"
9513 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9514 error_exit "create failed w/o dir size limit"
9516 check_mds_dmesg '"has reached"' ||
9517 error_exit "reached message should be output"
9519 [ $has_warning = "false" ] &&
9520 error_exit "warning message should be output"
9522 dirsize=$(stat -c%s "$DIR/$tdir")
9524 [[ $dirsize -ge $maxsize ]] && return 0
9525 error_exit "current dir size $dirsize, " \
9526 "previous limit $maxsize"
9527 elif [ $rc -ne 0 ]; then
9529 error_exit "return $rc received instead of expected " \
9530 "$EFBIG or $ENOSPC, files in dir $dirsize"
9532 nfiles=$((nfiles + 1))
9533 dirsize=$(stat -c%s "$DIR/$tdir")
9537 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9539 run_test 129 "test directory size limit ========================"
9548 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9549 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9552 trap cleanup_130 EXIT RETURN
9554 local fm_file=$DIR/$tfile
9555 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9556 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9557 error "dd failed for $fm_file"
9559 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9560 filefrag -ves $fm_file
9562 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9563 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9564 [ $RC != 0 ] && error "filefrag $fm_file failed"
9566 filefrag_op=$(filefrag -ve $fm_file |
9567 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9568 lun=$($GETSTRIPE -i $fm_file)
9570 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9573 for line in $filefrag_op
9575 frag_lun=`echo $line | cut -d: -f5`
9576 ext_len=`echo $line | cut -d: -f4`
9577 if (( $frag_lun != $lun )); then
9579 error "FIEMAP on 1-stripe file($fm_file) failed"
9582 (( tot_len += ext_len ))
9585 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9587 error "FIEMAP on 1-stripe file($fm_file) failed;"
9593 echo "FIEMAP on single striped file succeeded"
9595 run_test 130a "FIEMAP (1-stripe file)"
9598 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9600 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9601 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9604 trap cleanup_130 EXIT RETURN
9606 local fm_file=$DIR/$tfile
9607 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9608 error "setstripe on $fm_file"
9609 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9610 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9612 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9613 error "dd failed on $fm_file"
9615 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9616 filefrag_op=$(filefrag -ve $fm_file |
9617 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9619 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9620 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9625 for line in $filefrag_op
9627 frag_lun=$(echo $line | cut -d: -f5 |
9628 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9629 ext_len=$(echo $line | cut -d: -f4)
9630 if (( $frag_lun != $last_lun )); then
9631 if (( tot_len != 1024 )); then
9633 error "FIEMAP on $fm_file failed; returned " \
9634 "len $tot_len for OST $last_lun instead of 1024"
9641 (( tot_len += ext_len ))
9644 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9646 error "FIEMAP on $fm_file failed; returned wrong number of " \
9647 "luns or wrong len for OST $last_lun"
9653 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9655 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9658 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9660 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9661 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9664 trap cleanup_130 EXIT RETURN
9666 local fm_file=$DIR/$tfile
9667 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9668 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9669 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9671 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9672 error "dd failed on $fm_file"
9674 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9675 filefrag_op=$(filefrag -ve $fm_file |
9676 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9678 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9679 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9684 for line in $filefrag_op
9686 frag_lun=$(echo $line | cut -d: -f5 |
9687 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9688 ext_len=$(echo $line | cut -d: -f4)
9689 if (( $frag_lun != $last_lun )); then
9690 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9691 if (( logical != 512 )); then
9693 error "FIEMAP on $fm_file failed; returned " \
9694 "logical start for lun $logical instead of 512"
9697 if (( tot_len != 512 )); then
9699 error "FIEMAP on $fm_file failed; returned " \
9700 "len $tot_len for OST $last_lun instead of 1024"
9707 (( tot_len += ext_len ))
9710 if (( num_luns != 2 || tot_len != 512 )); then
9712 error "FIEMAP on $fm_file failed; returned wrong number of " \
9713 "luns or wrong len for OST $last_lun"
9719 echo "FIEMAP on 2-stripe file with hole succeeded"
9721 run_test 130c "FIEMAP (2-stripe file with hole)"
9724 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9726 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9727 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9730 trap cleanup_130 EXIT RETURN
9732 local fm_file=$DIR/$tfile
9733 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9734 error "setstripe on $fm_file"
9735 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9736 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9738 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
9739 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
9740 error "dd failed on $fm_file"
9742 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9743 filefrag_op=$(filefrag -ve $fm_file |
9744 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9746 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9747 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9752 for line in $filefrag_op
9754 frag_lun=$(echo $line | cut -d: -f5 |
9755 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9756 ext_len=$(echo $line | cut -d: -f4)
9757 if (( $frag_lun != $last_lun )); then
9758 if (( tot_len != 1024 )); then
9760 error "FIEMAP on $fm_file failed; returned " \
9761 "len $tot_len for OST $last_lun instead of 1024"
9768 (( tot_len += ext_len ))
9771 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
9773 error "FIEMAP on $fm_file failed; returned wrong number of " \
9774 "luns or wrong len for OST $last_lun"
9780 echo "FIEMAP on N-stripe file succeeded"
9782 run_test 130d "FIEMAP (N-stripe file)"
9785 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9787 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9788 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9790 trap cleanup_130 EXIT RETURN
9792 local fm_file=$DIR/$tfile
9793 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9794 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9795 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9798 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9799 for ((i = 0; i < $NUM_BLKS; i++))
9801 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9804 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9805 filefrag_op=$(filefrag -ve $fm_file |
9806 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9808 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9809 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9814 for line in $filefrag_op
9816 frag_lun=$(echo $line | cut -d: -f5 |
9817 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9818 ext_len=$(echo $line | cut -d: -f4)
9819 if (( $frag_lun != $last_lun )); then
9820 if (( tot_len != $EXPECTED_LEN )); then
9822 error "FIEMAP on $fm_file failed; returned " \
9823 "len $tot_len for OST $last_lun instead " \
9831 (( tot_len += ext_len ))
9834 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9836 error "FIEMAP on $fm_file failed; returned wrong number " \
9837 "of luns or wrong len for OST $last_lun"
9843 echo "FIEMAP with continuation calls succeeded"
9845 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9847 # Test for writev/readv
9849 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
9850 error "writev test failed"
9851 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
9852 error "readv failed"
9855 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9858 local fsize=$((524288 + 1048576 + 1572864))
9859 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
9860 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9861 error "append writev test failed"
9863 ((fsize += 1572864 + 1048576))
9864 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
9865 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9866 error "append writev test failed"
9869 run_test 131b "test append writev"
9872 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9875 run_test 131c "test read/write on file w/o objects"
9878 rwv -f $DIR/$tfile -w -n 1 1572864
9879 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9880 if [ "$NOB" != 1572864 ]; then
9881 error "Short read filed: read $NOB bytes instead of 1572864"
9885 run_test 131d "test short read"
9888 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9889 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9890 error "read hitting hole failed"
9893 run_test 131e "test read hitting hole"
9902 mds*) res=$(do_facet $facet \
9903 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9905 ost*) res=$(do_facet $facet \
9906 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9908 *) error "Wrong facet '$facet'" ;;
9911 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9912 # if the argument $3 is zero, it means any stat increment is ok.
9913 if [[ $want -gt 0 ]]; then
9914 local count=$(echo $res | awk '{ print $2 }')
9915 [[ $count -ne $want ]] &&
9916 error "The $op counter on $facet is $count, not $want"
9921 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9922 remote_ost_nodsh && skip "remote OST with nodsh" && return
9923 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9925 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9926 { skip "MDS doesn't support rename stats"; return; }
9927 local testdir=$DIR/${tdir}/stats_testdir
9928 mkdir -p $DIR/${tdir}
9931 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9932 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9934 # verify mdt stats first.
9935 mkdir ${testdir} || error "mkdir failed"
9936 check_stats $SINGLEMDS "mkdir" 1
9937 touch ${testdir}/${tfile} || error "touch failed"
9938 check_stats $SINGLEMDS "open" 1
9939 check_stats $SINGLEMDS "close" 1
9940 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
9941 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
9942 check_stats $SINGLEMDS "mknod" 2
9944 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
9945 check_stats $SINGLEMDS "unlink" 1
9946 rm -f ${testdir}/${tfile} || error "file remove failed"
9947 check_stats $SINGLEMDS "unlink" 2
9949 # remove working dir and check mdt stats again.
9950 rmdir ${testdir} || error "rmdir failed"
9951 check_stats $SINGLEMDS "rmdir" 1
9953 local testdir1=$DIR/${tdir}/stats_testdir1
9955 mkdir -p ${testdir1}
9956 touch ${testdir1}/test1
9957 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9958 check_stats $SINGLEMDS "crossdir_rename" 1
9960 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9961 check_stats $SINGLEMDS "samedir_rename" 1
9965 run_test 133a "Verifying MDT stats ========================================"
9968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9969 remote_ost_nodsh && skip "remote OST with nodsh" && return
9970 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9971 local testdir=$DIR/${tdir}/stats_testdir
9972 mkdir -p ${testdir} || error "mkdir failed"
9973 touch ${testdir}/${tfile} || error "touch failed"
9974 cancel_lru_locks mdc
9977 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9978 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9980 # extra mdt stats verification.
9981 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9982 check_stats $SINGLEMDS "setattr" 1
9983 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9984 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9986 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9987 check_stats $SINGLEMDS "getattr" 1
9989 $LFS df || error "lfs failed"
9990 check_stats $SINGLEMDS "statfs" 1
9994 run_test 133b "Verifying extra MDT stats =================================="
9997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9998 remote_ost_nodsh && skip "remote OST with nodsh" && return
9999 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10000 local testdir=$DIR/${tdir}/stats_testdir
10001 test_mkdir -p ${testdir} || error "mkdir failed"
10003 # verify obdfilter stats.
10004 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10006 cancel_lru_locks osc
10007 wait_delete_completed
10010 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10011 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10013 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
10015 cancel_lru_locks osc
10016 check_stats ost1 "write" 1
10018 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
10019 check_stats ost1 "read" 1
10021 > ${testdir}/${tfile} || error "truncate failed"
10022 check_stats ost1 "punch" 1
10024 rm -f ${testdir}/${tfile} || error "file remove failed"
10025 wait_delete_completed
10026 check_stats ost1 "destroy" 1
10028 rm -rf $DIR/${tdir}
10030 run_test 133c "Verifying OST stats ========================================"
10037 while [ $value -ge 2 ]; do
10042 if [ $orig -gt $order ]; then
10050 local size=('K' 'M' 'G' 'T');
10052 local size_string=$value
10054 while [ $value -ge 1024 ]; do
10055 if [ $i -gt 3 ]; then
10056 #T is the biggest unit we get here, if that is bigger,
10058 size_string=${value}T
10061 value=$((value >> 10))
10062 if [ $value -lt 1024 ]; then
10063 size_string=${value}${size[$i]}
10072 get_rename_size() {
10074 local context=${2:-.}
10075 local sample=$(do_facet $SINGLEMDS $LCTL \
10076 get_param mdt.$FSNAME-MDT0000.rename_stats |
10077 grep -A1 $context |
10078 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
10083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10084 remote_ost_nodsh && skip "remote OST with nodsh" && return
10085 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10086 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10087 { skip "MDS doesn't support rename stats"; return; }
10089 local testdir1=$DIR/${tdir}/stats_testdir1
10090 local testdir2=$DIR/${tdir}/stats_testdir2
10091 mkdir -p $DIR/${tdir}
10093 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10095 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
10096 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
10098 createmany -o $testdir1/test 512 || error "createmany failed"
10100 # check samedir rename size
10101 mv ${testdir1}/test0 ${testdir1}/test_0
10103 local testdir1_size=$(ls -l $DIR/${tdir} |
10104 awk '/stats_testdir1/ {print $5}')
10105 local testdir2_size=$(ls -l $DIR/${tdir} |
10106 awk '/stats_testdir2/ {print $5}')
10108 testdir1_size=$(order_2 $testdir1_size)
10109 testdir2_size=$(order_2 $testdir2_size)
10111 testdir1_size=$(size_in_KMGT $testdir1_size)
10112 testdir2_size=$(size_in_KMGT $testdir2_size)
10114 echo "source rename dir size: ${testdir1_size}"
10115 echo "target rename dir size: ${testdir2_size}"
10117 local cmd="do_facet $SINGLEMDS $LCTL "
10118 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
10120 eval $cmd || error "$cmd failed"
10121 local samedir=$($cmd | grep 'same_dir')
10122 local same_sample=$(get_rename_size $testdir1_size)
10123 [ -z "$samedir" ] && error "samedir_rename_size count error"
10124 [[ $same_sample -eq 1 ]] ||
10125 error "samedir_rename_size error $same_sample"
10126 echo "Check same dir rename stats success"
10128 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10130 # check crossdir rename size
10131 mv ${testdir1}/test_0 ${testdir2}/test_0
10133 testdir1_size=$(ls -l $DIR/${tdir} |
10134 awk '/stats_testdir1/ {print $5}')
10135 testdir2_size=$(ls -l $DIR/${tdir} |
10136 awk '/stats_testdir2/ {print $5}')
10138 testdir1_size=$(order_2 $testdir1_size)
10139 testdir2_size=$(order_2 $testdir2_size)
10141 testdir1_size=$(size_in_KMGT $testdir1_size)
10142 testdir2_size=$(size_in_KMGT $testdir2_size)
10144 echo "source rename dir size: ${testdir1_size}"
10145 echo "target rename dir size: ${testdir2_size}"
10147 eval $cmd || error "$cmd failed"
10148 local crossdir=$($cmd | grep 'crossdir')
10149 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10150 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10151 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10152 [[ $src_sample -eq 1 ]] ||
10153 error "crossdir_rename_size error $src_sample"
10154 [[ $tgt_sample -eq 1 ]] ||
10155 error "crossdir_rename_size error $tgt_sample"
10156 echo "Check cross dir rename stats success"
10157 rm -rf $DIR/${tdir}
10159 run_test 133d "Verifying rename_stats ========================================"
10162 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10163 remote_ost_nodsh && skip "remote OST with nodsh" && return
10164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10165 local testdir=$DIR/${tdir}/stats_testdir
10166 local ctr f0 f1 bs=32768 count=42 sum
10168 mkdir -p ${testdir} || error "mkdir failed"
10170 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10172 for ctr in {write,read}_bytes; do
10174 cancel_lru_locks osc
10176 do_facet ost1 $LCTL set_param -n \
10177 "obdfilter.*.exports.clear=clear"
10179 if [ $ctr = write_bytes ]; then
10181 f1=${testdir}/${tfile}
10183 f0=${testdir}/${tfile}
10187 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10190 cancel_lru_locks osc
10192 sum=$(do_facet ost1 $LCTL get_param \
10193 "obdfilter.*.exports.*.stats" |
10194 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10195 $1 == ctr { sum += $7 }
10196 END { printf("%0.0f", sum) }')
10198 if ((sum != bs * count)); then
10199 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10203 rm -rf $DIR/${tdir}
10205 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10207 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10210 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10211 remote_ost_nodsh && skip "remote OST with nodsh" && return
10212 # First without trusting modes.
10213 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10214 echo "proc_dirs='$proc_dirs'"
10215 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10216 find $proc_dirs -exec cat '{}' \; &> /dev/null
10218 # Second verifying readability.
10219 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10221 # eventually, this can also be replaced with "lctl get_param -R",
10222 # but not until that option is always available on the server
10224 for facet in mds1 ost1; do
10225 local facet_proc_dirs=$(do_facet $facet \
10226 \\\ls -d $proc_regexp 2>/dev/null)
10227 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10228 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10229 do_facet $facet find $facet_proc_dirs \
10230 ! -name req_history \
10231 -exec cat '{}' \\\; &> /dev/null
10233 do_facet $facet find $facet_proc_dirs \
10234 ! -name req_history \
10236 -exec cat '{}' \\\; &> /dev/null ||
10237 error "proc file read failed"
10240 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
10243 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10244 remote_ost_nodsh && skip "remote OST with nodsh" && return
10245 # Second verifying writability.
10246 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10247 echo "proc_dirs='$proc_dirs'"
10248 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10251 -not -name force_lbug \
10252 -not -name changelog_mask \
10253 -exec badarea_io '{}' \; &> /dev/null ||
10254 error "find $proc_dirs failed"
10257 for facet in mds1 ost1; do
10258 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10259 skip "Too old lustre on $facet" && continue
10260 local facet_proc_dirs=$(do_facet $facet \
10261 \\\ls -d $proc_regexp 2> /dev/null)
10262 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10263 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10264 do_facet $facet find $facet_proc_dirs \
10266 -not -name force_lbug \
10267 -not -name changelog_mask \
10268 -exec badarea_io '{}' \\\; &> /dev/null ||
10269 error "$facet find $facet_proc_dirs failed"
10272 # remount the FS in case writes/reads /proc break the FS
10273 cleanup || error "failed to unmount"
10274 setup || error "failed to setup"
10277 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
10280 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10281 remote_ost_nodsh && skip "remote OST with nodsh" && return
10282 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10283 skip "Need MDS version at least 2.9.54" && return
10286 for facet in client mds1 ost1; do
10287 local facet_proc_dirs=$(do_facet $facet \
10288 \\\ls -d $proc_regexp 2> /dev/null)
10289 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10290 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10291 # Get the list of files that are missing the terminating newline
10292 local missing=($(do_facet $facet \
10293 find ${facet_proc_dirs} -type f \| \
10294 while read F\; do \
10295 awk -v FS='\v' -v RS='\v\v' \
10296 "'END { if(NR>0 && \
10297 \\\$NF !~ /.*\\\n\$/) \
10298 print FILENAME}'" \
10301 [ ${#missing[*]} -eq 0 ] ||
10302 error "files do not end with newline: ${missing[*]}"
10305 run_test 133h "Proc files should end with newlines"
10308 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10309 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10310 skip "Need MDS version at least 2.7.54" && return
10312 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10313 cancel_lru_locks mdc
10315 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10316 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10317 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10320 createmany -o $DIR/$tdir/f $nr ||
10321 error "failed to create $nr files in $DIR/$tdir"
10322 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10324 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10325 do_facet mds1 $LCTL set_param fail_loc=0x327
10326 do_facet mds1 $LCTL set_param fail_val=500
10329 echo "sleep 10 seconds ..."
10331 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10333 do_facet mds1 $LCTL set_param fail_loc=0
10334 do_facet mds1 $LCTL set_param fail_val=0
10335 [ $lck_cnt -lt $unused ] ||
10336 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10339 unlinkmany $DIR/$tdir/f $nr
10341 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10344 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10345 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10346 skip "Need MDS version at least 2.7.54" && return
10348 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10349 cancel_lru_locks mdc
10351 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10352 ldlm.lock_reclaim_threshold_mb)
10353 # disable reclaim temporarily
10354 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10356 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10357 do_facet mds1 $LCTL set_param fail_loc=0x328
10358 do_facet mds1 $LCTL set_param fail_val=500
10360 $LCTL set_param debug=+trace
10363 createmany -o $DIR/$tdir/f $nr &
10364 local create_pid=$!
10366 echo "Sleep $TIMEOUT seconds ..."
10368 if ! ps -p $create_pid > /dev/null 2>&1; then
10369 do_facet mds1 $LCTL set_param fail_loc=0
10370 do_facet mds1 $LCTL set_param fail_val=0
10371 do_facet mds1 $LCTL set_param \
10372 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10373 error "createmany finished incorrectly!"
10375 do_facet mds1 $LCTL set_param fail_loc=0
10376 do_facet mds1 $LCTL set_param fail_val=0
10377 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10378 wait $create_pid || return 1
10380 unlinkmany $DIR/$tdir/f $nr
10382 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10384 test_140() { #bug-17379
10385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10386 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
10387 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10388 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10390 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10391 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10393 while i=`expr $i + 1`; do
10394 test_mkdir -p $i || error "Creating dir $i"
10395 cd $i || error "Changing to $i"
10396 ln -s ../stat stat || error "Creating stat symlink"
10397 # Read the symlink until ELOOP present,
10398 # not LBUGing the system is considered success,
10399 # we didn't overrun the stack.
10400 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10401 [ $ret -ne 0 ] && {
10402 if [ $ret -eq 40 ]; then
10405 error "Open stat symlink"
10411 echo "The symlink depth = $i"
10412 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10413 error "Invalid symlink depth"
10415 # Test recursive symlink
10416 ln -s symlink_self symlink_self
10417 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10418 echo "open symlink_self returns $ret"
10419 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10421 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10425 local TF="$TMP/$tfile"
10427 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10429 cancel_lru_locks osc
10430 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10431 remount_client $MOUNT
10433 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10436 $TRUNCATE $DIR/$tfile 6000
10437 cancel_lru_locks osc
10438 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10441 echo "12345" >>$DIR/$tfile
10442 cancel_lru_locks osc
10443 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10446 echo "12345" >>$DIR/$tfile
10447 cancel_lru_locks osc
10448 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10453 run_test 150 "truncate/append tests"
10455 #LU-2902 roc_hit was not able to read all values from lproc
10456 function roc_hit_init() {
10457 local list=$(comma_list $(osts_nodes))
10458 local dir=$DIR/$tdir-check
10459 local file=$dir/file
10465 #use setstripe to do a write to every ost
10466 for i in $(seq 0 $((OSTCOUNT-1))); do
10467 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10468 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10469 idx=$(printf %04x $i)
10470 BEFORE=$(get_osd_param $list *OST*$idx stats |
10471 awk '$1 == "cache_access" {sum += $7}
10472 END { printf("%0.0f", sum) }')
10474 cancel_lru_locks osc
10475 cat $file >/dev/null
10477 AFTER=$(get_osd_param $list *OST*$idx stats |
10478 awk '$1 == "cache_access" {sum += $7}
10479 END { printf("%0.0f", sum) }')
10481 echo BEFORE:$BEFORE AFTER:$AFTER
10482 if ! let "AFTER - BEFORE == 4"; then
10484 error "roc_hit is not safe to use"
10492 function roc_hit() {
10493 local list=$(comma_list $(osts_nodes))
10494 echo $(get_osd_param $list '' stats |
10495 awk '$1 == "cache_hit" {sum += $7}
10496 END { printf("%0.0f", sum) }')
10499 function set_cache() {
10502 if [ "$2" == "off" ]; then
10505 local list=$(comma_list $(osts_nodes))
10506 set_osd_param $list '' $1_cache_enable $on
10508 cancel_lru_locks osc
10512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10513 remote_ost_nodsh && skip "remote OST with nodsh" && return
10516 local list=$(comma_list $(osts_nodes))
10518 # check whether obdfilter is cache capable at all
10519 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10520 echo "not cache-capable obdfilter"
10524 # check cache is enabled on all obdfilters
10525 if get_osd_param $list '' read_cache_enable | grep 0; then
10526 echo "oss cache is disabled"
10530 set_osd_param $list '' writethrough_cache_enable 1
10532 # check write cache is enabled on all obdfilters
10533 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10534 echo "oss write cache is NOT enabled"
10540 #define OBD_FAIL_OBD_NO_LRU 0x609
10541 do_nodes $list $LCTL set_param fail_loc=0x609
10543 # pages should be in the case right after write
10544 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10547 local BEFORE=$(roc_hit)
10548 cancel_lru_locks osc
10549 cat $DIR/$tfile >/dev/null
10550 local AFTER=$(roc_hit)
10552 do_nodes $list $LCTL set_param fail_loc=0
10554 if ! let "AFTER - BEFORE == CPAGES"; then
10555 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10558 # the following read invalidates the cache
10559 cancel_lru_locks osc
10560 set_osd_param $list '' read_cache_enable 0
10561 cat $DIR/$tfile >/dev/null
10563 # now data shouldn't be found in the cache
10565 cancel_lru_locks osc
10566 cat $DIR/$tfile >/dev/null
10568 if let "AFTER - BEFORE != 0"; then
10569 error "IN CACHE: before: $BEFORE, after: $AFTER"
10572 set_osd_param $list '' read_cache_enable 1
10575 run_test 151 "test cache on oss and controls ==============================="
10578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10579 local TF="$TMP/$tfile"
10581 # simulate ENOMEM during write
10582 #define OBD_FAIL_OST_NOMEM 0x226
10583 lctl set_param fail_loc=0x80000226
10584 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10586 sync || error "sync failed"
10587 lctl set_param fail_loc=0
10589 # discard client's cache
10590 cancel_lru_locks osc
10592 # simulate ENOMEM during read
10593 lctl set_param fail_loc=0x80000226
10594 cmp $TF $DIR/$tfile || error "cmp failed"
10595 lctl set_param fail_loc=0
10599 run_test 152 "test read/write with enomem ============================"
10602 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10604 run_test 153 "test if fdatasync does not crash ======================="
10606 dot_lustre_fid_permission_check() {
10608 local ffid=$MOUNT/.lustre/fid/$fid
10611 echo "stat fid $fid"
10612 stat $ffid > /dev/null || error "stat $ffid failed."
10613 echo "touch fid $fid"
10614 touch $ffid || error "touch $ffid failed."
10615 echo "write to fid $fid"
10616 cat /etc/hosts > $ffid || error "write $ffid failed."
10617 echo "read fid $fid"
10618 diff /etc/hosts $ffid || error "read $ffid failed."
10619 echo "append write to fid $fid"
10620 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10621 echo "rename fid $fid"
10622 mv $ffid $test_dir/$tfile.1 &&
10623 error "rename $ffid to $tfile.1 should fail."
10624 touch $test_dir/$tfile.1
10625 mv $test_dir/$tfile.1 $ffid &&
10626 error "rename $tfile.1 to $ffid should fail."
10627 rm -f $test_dir/$tfile.1
10628 echo "truncate fid $fid"
10629 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10630 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10631 echo "link fid $fid"
10632 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10634 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10635 echo "setfacl fid $fid"
10636 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10637 echo "getfacl fid $fid"
10638 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10640 echo "unlink fid $fid"
10641 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10642 echo "mknod fid $fid"
10643 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10645 fid=[0xf00000400:0x1:0x0]
10646 ffid=$MOUNT/.lustre/fid/$fid
10648 echo "stat non-exist fid $fid"
10649 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10650 echo "write to non-exist fid $fid"
10651 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10652 echo "link new fid $fid"
10653 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10655 mkdir -p $test_dir/$tdir
10656 touch $test_dir/$tdir/$tfile
10657 fid=$($LFS path2fid $test_dir/$tdir)
10660 error "error: could not get fid for $test_dir/$dir/$tfile."
10662 ffid=$MOUNT/.lustre/fid/$fid
10665 ls $ffid > /dev/null || error "ls $ffid failed."
10666 echo "touch $fid/$tfile.1"
10667 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10669 echo "touch $MOUNT/.lustre/fid/$tfile"
10670 touch $MOUNT/.lustre/fid/$tfile && \
10671 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10673 echo "setxattr to $MOUNT/.lustre/fid"
10674 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10676 echo "listxattr for $MOUNT/.lustre/fid"
10677 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10679 echo "delxattr from $MOUNT/.lustre/fid"
10680 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10682 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10683 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10684 error "touch invalid fid should fail."
10686 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10687 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10688 error "touch non-normal fid should fail."
10690 echo "rename $tdir to $MOUNT/.lustre/fid"
10691 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10692 error "rename to $MOUNT/.lustre/fid should fail."
10694 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10696 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10697 local new_obf_mode=777
10699 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10700 chmod $new_obf_mode $DIR/.lustre/fid ||
10701 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10703 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10704 [ $obf_mode -eq $new_obf_mode ] ||
10705 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10707 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10708 chmod $old_obf_mode $DIR/.lustre/fid ||
10709 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10712 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10713 fid=$($LFS path2fid $test_dir/$tfile-2)
10715 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10717 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10718 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10719 error "create lov data thru .lustre failed"
10721 echo "cp /etc/passwd $test_dir/$tfile-2"
10722 cp /etc/passwd $test_dir/$tfile-2 ||
10723 error "copy to $test_dir/$tfile-2 failed."
10724 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10725 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10726 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10728 rm -rf $test_dir/tfile.lnk
10729 rm -rf $test_dir/$tfile-2
10733 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10734 skip "Need MDS version at least 2.4.1" && return
10736 local tf=$DIR/$tfile
10739 local fid=$($LFS path2fid $tf)
10740 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10742 # check that we get the same pathname back
10743 local found=$($LFS fid2path $MOUNT "$fid")
10744 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10745 [ "$found" == "$tf" ] ||
10746 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10748 run_test 154A "lfs path2fid and fid2path basic checks"
10751 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10752 skip "Need MDS version at least 2.4.1" && return
10754 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10755 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10756 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10757 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10759 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10760 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10762 # check that we get the same pathname
10763 echo "PFID: $PFID, name: $name"
10764 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10765 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10766 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10767 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10769 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10771 run_test 154B "verify the ll_decode_linkea tool"
10774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10775 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10776 { skip "Need MDS version at least 2.2.51"; return 0; }
10777 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10778 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10780 cp /etc/hosts $DIR/$tfile
10782 fid=$($LFS path2fid $DIR/$tfile)
10784 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10786 dot_lustre_fid_permission_check "$fid" $DIR ||
10787 error "dot lustre permission check $fid failed"
10789 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10791 touch $MOUNT/.lustre/file &&
10792 error "creation is not allowed under .lustre"
10794 mkdir $MOUNT/.lustre/dir &&
10795 error "mkdir is not allowed under .lustre"
10799 run_test 154a "Open-by-FID"
10802 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10803 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10804 { skip "Need MDS version at least 2.2.51"; return 0; }
10805 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10807 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10809 local remote_dir=$DIR/$tdir/remote_dir
10813 mkdir -p $DIR/$tdir
10814 $LFS mkdir -i $MDTIDX $remote_dir ||
10815 error "create remote directory failed"
10817 cp /etc/hosts $remote_dir/$tfile
10819 fid=$($LFS path2fid $remote_dir/$tfile)
10821 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10823 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10824 error "dot lustre permission check $fid failed"
10827 run_test 154b "Open-by-FID for remote directory"
10830 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10831 skip "Need MDS version at least 2.4.1" && return
10833 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10834 local FID1=$($LFS path2fid $DIR/$tfile.1)
10835 local FID2=$($LFS path2fid $DIR/$tfile.2)
10836 local FID3=$($LFS path2fid $DIR/$tfile.3)
10839 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10840 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10841 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10843 [ "$FID" = "${!want}" ] ||
10844 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10848 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10850 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10851 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10855 run_test 154c "lfs path2fid and fid2path multiple arguments"
10858 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10859 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10860 skip "Need MDS version at least 2.5.53" && return
10862 if remote_mds; then
10863 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10867 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10874 local fid=$($LFS path2fid $DIR/$tfile)
10877 cmd="exec $fd<$DIR/$tfile"
10879 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10880 echo "$fid_list" | grep "$fid"
10883 cmd="exec $fd>/dev/null"
10885 if [ $rc -ne 0 ]; then
10886 error "FID $fid not found in open files list $fid_list"
10889 run_test 154d "Verify open file fid"
10893 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10894 skip "Need MDS version at least 2.6.50" && return
10896 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10897 error ".lustre returned by readdir"
10900 run_test 154e ".lustre is not returned by readdir"
10903 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10904 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10905 test_mkdir -p -c1 $DIR/$tdir/d
10906 # test dirs inherit from its stripe
10907 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10908 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10909 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10910 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10913 # get fid of parents
10914 local FID0=$($LFS path2fid $DIR/$tdir/d)
10915 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10916 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10917 local FID3=$($LFS path2fid $DIR)
10919 # check that path2fid --parents returns expected <parent_fid>/name
10920 # 1) test for a directory (single parent)
10921 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10922 [ "$parent" == "$FID0/foo1" ] ||
10923 error "expected parent: $FID0/foo1, got: $parent"
10925 # 2) test for a file with nlink > 1 (multiple parents)
10926 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10927 echo "$parent" | grep -F "$FID1/$tfile" ||
10928 error "$FID1/$tfile not returned in parent list"
10929 echo "$parent" | grep -F "$FID2/link" ||
10930 error "$FID2/link not returned in parent list"
10932 # 3) get parent by fid
10933 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10934 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10935 echo "$parent" | grep -F "$FID1/$tfile" ||
10936 error "$FID1/$tfile not returned in parent list (by fid)"
10937 echo "$parent" | grep -F "$FID2/link" ||
10938 error "$FID2/link not returned in parent list (by fid)"
10940 # 4) test for entry in root directory
10941 parent=$($LFS path2fid --parents $DIR/f)
10942 echo "$parent" | grep -F "$FID3/f" ||
10943 error "$FID3/f not returned in parent list"
10945 # 5) test it on root directory
10946 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10947 error "$MOUNT should not have parents"
10949 # enable xattr caching and check that linkea is correctly updated
10950 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10951 save_lustre_params client "llite.*.xattr_cache" > $save
10952 lctl set_param llite.*.xattr_cache 1
10954 # 6.1) linkea update on rename
10955 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10957 # get parents by fid
10958 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10959 # foo1 should no longer be returned in parent list
10960 echo "$parent" | grep -F "$FID1" &&
10961 error "$FID1 should no longer be in parent list"
10962 # the new path should appear
10963 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10964 error "$FID2/$tfile.moved is not in parent list"
10966 # 6.2) linkea update on unlink
10967 rm -f $DIR/$tdir/d/foo2/link
10968 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10969 # foo2/link should no longer be returned in parent list
10970 echo "$parent" | grep -F "$FID2/link" &&
10971 error "$FID2/link should no longer be in parent list"
10975 restore_lustre_params < $save
10978 run_test 154f "get parent fids by reading link ea"
10982 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
10983 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
10984 { skip "Need MDS version at least 2.6.92"; return 0; }
10985 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10987 mkdir -p $DIR/$tdir
10988 llapi_fid_test -d $DIR/$tdir
10990 run_test 154g "various llapi FID tests"
10992 test_155_small_load() {
10993 local temp=$TMP/$tfile
10994 local file=$DIR/$tfile
10996 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10997 error "dd of=$temp bs=6096 count=1 failed"
10999 cancel_lru_locks osc
11000 cmp $temp $file || error "$temp $file differ"
11002 $TRUNCATE $temp 6000
11003 $TRUNCATE $file 6000
11004 cmp $temp $file || error "$temp $file differ (truncate1)"
11006 echo "12345" >>$temp
11007 echo "12345" >>$file
11008 cmp $temp $file || error "$temp $file differ (append1)"
11010 echo "12345" >>$temp
11011 echo "12345" >>$file
11012 cmp $temp $file || error "$temp $file differ (append2)"
11018 test_155_big_load() {
11019 remote_ost_nodsh && skip "remote OST with nodsh" && return
11020 local temp=$TMP/$tfile
11021 local file=$DIR/$tfile
11024 local cache_size=$(do_facet ost$((MAXI+1)) \
11025 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
11026 local large_file_size=$((cache_size * 2))
11028 echo "OSS cache size: $cache_size KB"
11029 echo "Large file size: $large_file_size KB"
11031 [ $MAXV -le $large_file_size ] && \
11032 skip_env "max available OST size needs > $large_file_size KB" && \
11035 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
11037 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
11038 error "dd of=$temp bs=$large_file_size count=1k failed"
11041 cancel_lru_locks osc
11042 cmp $temp $file || error "$temp $file differ"
11048 save_writethrough() {
11049 local facets=$(get_facets OST)
11051 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
11052 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
11056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11057 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11058 save_writethrough $p
11061 set_cache writethrough on
11062 test_155_small_load
11063 restore_lustre_params < $p
11066 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
11069 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11070 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11071 save_writethrough $p
11074 set_cache writethrough off
11075 test_155_small_load
11076 restore_lustre_params < $p
11079 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
11082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11083 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11084 save_writethrough $p
11087 set_cache writethrough on
11088 test_155_small_load
11089 restore_lustre_params < $p
11092 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
11095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11096 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11097 save_writethrough $p
11100 set_cache writethrough off
11101 test_155_small_load
11102 restore_lustre_params < $p
11105 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
11108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11109 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11110 save_writethrough $p
11113 set_cache writethrough on
11115 restore_lustre_params < $p
11118 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11122 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11123 save_writethrough $p
11126 set_cache writethrough off
11128 restore_lustre_params < $p
11131 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11135 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11136 save_writethrough $p
11139 set_cache writethrough on
11141 restore_lustre_params < $p
11144 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11148 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11149 save_writethrough $p
11152 set_cache writethrough off
11154 restore_lustre_params < $p
11157 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11160 remote_ost_nodsh && skip "remote OST with nodsh" && return
11161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11165 local file="$DIR/$tfile"
11166 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11168 [ "$(facet_fstype ost1)" = "zfs" -a \
11169 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11170 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
11173 save_writethrough $p
11176 log "Turn on read and write cache"
11178 set_cache writethrough on
11180 log "Write data and read it back."
11181 log "Read should be satisfied from the cache."
11182 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11184 cancel_lru_locks osc
11185 cat $file >/dev/null
11187 if ! let "AFTER - BEFORE == CPAGES"; then
11188 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11190 log "cache hits:: before: $BEFORE, after: $AFTER"
11193 log "Read again; it should be satisfied from the cache."
11195 cancel_lru_locks osc
11196 cat $file >/dev/null
11198 if ! let "AFTER - BEFORE == CPAGES"; then
11199 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11201 log "cache hits:: before: $BEFORE, after: $AFTER"
11204 log "Turn off the read cache and turn on the write cache"
11206 set_cache writethrough on
11208 log "Read again; it should be satisfied from the cache."
11210 cancel_lru_locks osc
11211 cat $file >/dev/null
11213 if ! let "AFTER - BEFORE == CPAGES"; then
11214 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11216 log "cache hits:: before: $BEFORE, after: $AFTER"
11219 log "Read again; it should not be satisfied from the cache."
11221 cancel_lru_locks osc
11222 cat $file >/dev/null
11224 if ! let "AFTER - BEFORE == 0"; then
11225 error "IN CACHE: before: $BEFORE, after: $AFTER"
11227 log "cache hits:: before: $BEFORE, after: $AFTER"
11230 log "Write data and read it back."
11231 log "Read should be satisfied from the cache."
11232 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11234 cancel_lru_locks osc
11235 cat $file >/dev/null
11237 if ! let "AFTER - BEFORE == CPAGES"; then
11238 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11240 log "cache hits:: before: $BEFORE, after: $AFTER"
11243 log "Read again; it should not be satisfied from the cache."
11245 cancel_lru_locks osc
11246 cat $file >/dev/null
11248 if ! let "AFTER - BEFORE == 0"; then
11249 error "IN CACHE: before: $BEFORE, after: $AFTER"
11251 log "cache hits:: before: $BEFORE, after: $AFTER"
11254 log "Turn off read and write cache"
11256 set_cache writethrough off
11258 log "Write data and read it back"
11259 log "It should not be satisfied from the cache."
11261 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11262 cancel_lru_locks osc
11264 cat $file >/dev/null
11266 if ! let "AFTER - BEFORE == 0"; then
11267 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11269 log "cache hits:: before: $BEFORE, after: $AFTER"
11272 log "Turn on the read cache and turn off the write cache"
11274 set_cache writethrough off
11276 log "Write data and read it back"
11277 log "It should not be satisfied from the cache."
11279 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11281 cancel_lru_locks osc
11282 cat $file >/dev/null
11284 if ! let "AFTER - BEFORE == 0"; then
11285 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11287 log "cache hits:: before: $BEFORE, after: $AFTER"
11290 log "Read again; it should be satisfied from the cache."
11292 cancel_lru_locks osc
11293 cat $file >/dev/null
11295 if ! let "AFTER - BEFORE == CPAGES"; then
11296 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11298 log "cache hits:: before: $BEFORE, after: $AFTER"
11302 restore_lustre_params < $p
11305 run_test 156 "Verification of tunables"
11308 cleanup_changelog () {
11310 echo "Deregistering changelog client $CL_USER"
11311 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11315 if [[ $MDSCOUNT -gt 1 ]]; then
11316 error_ignore bz17935 $*
11324 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11326 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11328 if [ $MASK -eq 1 ]; then
11329 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11331 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11335 changelog_extract_field() {
11339 local identifier=$4
11341 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11342 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11348 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11349 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11350 { skip "Need MDS version at least 2.2.0"; return; }
11352 local CL_USERS="mdd.$MDT0.changelog_users"
11353 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11354 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11355 changelog_register -n)
11356 echo "Registered as changelog user $CL_USER"
11357 trap cleanup_changelog EXIT
11358 $GET_CL_USERS | grep -q $CL_USER ||
11359 error "User $CL_USER not found in changelog_users"
11362 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11363 touch $DIR/$tdir/pics/2008/zachy/timestamp
11364 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11365 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11366 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11367 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11368 rm $DIR/$tdir/pics/desktop.jpg
11370 $LFS changelog $MDT0 | tail -5
11372 echo "verifying changelog mask"
11373 changelog_chmask "MKDIR"
11374 changelog_chmask "CLOSE"
11376 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11377 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11379 changelog_chmask "MKDIR"
11380 changelog_chmask "CLOSE"
11382 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11383 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11385 $LFS changelog $MDT0
11386 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11387 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11388 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11389 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11392 echo "verifying target fid"
11393 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11394 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11395 [ "$fidc" == "$fidf" ] ||
11396 err17935 "fid in changelog $fidc != file fid $fidf"
11397 echo "verifying parent fid"
11398 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11399 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11400 [ "$fidc" == "$fidf" ] ||
11401 err17935 "pfid in changelog $fidc != dir fid $fidf"
11403 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11404 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11405 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11406 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11407 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11408 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11410 MIN_REC=$($GET_CL_USERS |
11411 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11412 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11413 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11414 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11415 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11417 # LU-3446 changelog index reset on MDT restart
11418 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11419 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11420 $LFS changelog_clear $MDT0 $CL_USER 0
11421 stop $SINGLEMDS || error "Fail to stop MDT."
11422 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11423 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11424 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11425 [ $CUR_REC1 == $CUR_REC2 ] ||
11426 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11428 echo "verifying user deregister"
11430 $GET_CL_USERS | grep -q $CL_USER &&
11431 error "User $CL_USER still in changelog_users"
11433 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11434 if [ $CL_USER -eq 0 ]; then
11435 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11436 touch $DIR/$tdir/chloe
11437 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11438 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11439 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11441 echo "$CL_USER other changelog users; can't verify off"
11444 run_test 160a "changelog sanity"
11446 test_160b() { # LU-3587
11447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11448 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11449 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11450 { skip "Need MDS version at least 2.2.0"; return; }
11452 local CL_USERS="mdd.$MDT0.changelog_users"
11453 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11454 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11455 changelog_register -n)
11456 echo "Registered as changelog user $CL_USER"
11457 trap cleanup_changelog EXIT
11458 $GET_CL_USERS | grep -q $CL_USER ||
11459 error "User $CL_USER not found in changelog_users"
11461 local LONGNAME1=$(str_repeat a 255)
11462 local LONGNAME2=$(str_repeat b 255)
11465 echo "creating very long named file"
11466 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11467 echo "moving very long named file"
11468 mv $LONGNAME1 $LONGNAME2
11470 $LFS changelog $MDT0 | grep RENME
11474 run_test 160b "Verify that very long rename doesn't crash in changelog"
11477 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11480 local server_version=$(lustre_version_code $SINGLEMDS)
11482 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11483 [[ $server_version -gt $(version_code 2.5.1) &&
11484 $server_version -lt $(version_code 2.5.50) ]] ||
11485 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11488 # Registration step
11489 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11490 changelog_register -n)
11491 trap cleanup_changelog EXIT
11494 mkdir -p $DIR/$tdir
11495 $MCREATE $DIR/$tdir/foo_160c
11496 changelog_chmask "TRUNC"
11497 $TRUNCATE $DIR/$tdir/foo_160c 200
11498 changelog_chmask "TRUNC"
11499 $TRUNCATE $DIR/$tdir/foo_160c 199
11500 $LFS changelog $MDT0
11501 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11502 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11503 $LFS changelog_clear $MDT0 $CL_USER 0
11505 # Deregistration step
11508 run_test 160c "verify that changelog log catch the truncate event"
11511 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11512 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11514 local server_version=$(lustre_version_code mds1)
11515 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11517 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11518 { skip "Need MDS version at least 2.7.60+"; return; }
11519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11521 # Registration step
11522 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11523 changelog_register -n)
11525 trap cleanup_changelog EXIT
11526 mkdir -p $DIR/$tdir/migrate_dir
11527 $LFS changelog_clear $MDT0 $CL_USER 0
11529 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11530 $LFS changelog $MDT0
11531 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11532 $LFS changelog_clear $MDT0 $CL_USER 0
11533 [ $MIGRATES -eq 1 ] ||
11534 error "MIGRATE changelog mask count $MIGRATES != 1"
11536 # Deregistration step
11539 run_test 160d "verify that changelog log catch the migrate event"
11542 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11545 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11546 changelog_register -n)
11547 echo "Registered as changelog user $CL_USER"
11548 trap cleanup_changelog EXIT
11550 # Delete a future user (expect fail)
11551 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11554 if [ $rc -eq 0 ]; then
11555 error "Deleted non-existant user cl77"
11556 elif [ $rc -ne 2 ]; then
11557 error "changelog_deregister failed with $rc, " \
11558 "expected 2 (ENOENT)"
11561 # Clear to a bad index (1 billion should be safe)
11562 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11565 if [ $rc -eq 0 ]; then
11566 error "Successfully cleared to invalid CL index"
11567 elif [ $rc -ne 22 ]; then
11568 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11571 run_test 160e "changelog negative testing"
11574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11575 test_mkdir -p -c1 $DIR/$tdir
11576 cp /etc/hosts $DIR/$tdir/$tfile
11577 test_mkdir -c1 $DIR/$tdir/foo1
11578 test_mkdir -c1 $DIR/$tdir/foo2
11579 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11580 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11581 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11582 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11583 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11584 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11585 $LFS fid2path $DIR $FID
11586 err17935 "bad link ea"
11589 rm $DIR/$tdir/foo2/zachary
11591 rm $DIR/$tdir/foo2/thor
11593 rm $DIR/$tdir/$tfile
11595 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11596 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11598 $LFS fid2path $DIR $FID
11599 err17935 "bad link rename"
11601 rm $DIR/$tdir/foo2/maggie
11604 local longname=filename_avg_len_is_thirty_two_
11605 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11606 error "failed to hardlink many files"
11607 links=$($LFS fid2path $DIR $FID | wc -l)
11608 echo -n "${links}/1000 links in link EA"
11609 [[ $links -gt 60 ]] ||
11610 err17935 "expected at least 60 links in link EA"
11611 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11612 error "failed to unlink many hardlinks"
11614 run_test 161a "link ea sanity"
11617 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11618 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11620 local remote_dir=$DIR/$tdir/remote_dir
11622 mkdir -p $DIR/$tdir
11623 $LFS mkdir -i $MDTIDX $remote_dir ||
11624 error "create remote directory failed"
11626 cp /etc/hosts $remote_dir/$tfile
11627 mkdir -p $remote_dir/foo1
11628 mkdir -p $remote_dir/foo2
11629 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11630 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11631 ln $remote_dir/$tfile $remote_dir/foo1/luna
11632 ln $remote_dir/$tfile $remote_dir/foo2/thor
11634 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11636 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11637 $LFS fid2path $DIR $FID
11638 err17935 "bad link ea"
11641 rm $remote_dir/foo2/zachary
11643 rm $remote_dir/foo2/thor
11645 rm $remote_dir/$tfile
11647 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11648 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11649 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11650 $LFS fid2path $DIR $FID
11651 err17935 "bad link rename"
11653 rm $remote_dir/foo2/maggie
11656 local longname=filename_avg_len_is_thirty_two_
11657 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11658 error "failed to hardlink many files"
11659 links=$($LFS fid2path $DIR $FID | wc -l)
11660 echo -n "${links}/1000 links in link EA"
11661 [[ ${links} -gt 60 ]] ||
11662 err17935 "expected at least 60 links in link EA"
11663 unlinkmany $remote_dir/foo2/$longname 1000 ||
11664 error "failed to unlink many hardlinks"
11666 run_test 161b "link ea sanity under remote directory"
11669 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11671 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11672 skip "Need MDS version at least 2.1.5" && return
11674 # define CLF_RENAME_LAST 0x0001
11675 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11676 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11677 changelog_register -n)
11679 trap cleanup_changelog EXIT
11681 mkdir -p $DIR/$tdir
11682 touch $DIR/$tdir/foo_161c
11683 touch $DIR/$tdir/bar_161c
11684 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11685 $LFS changelog $MDT0 | grep RENME
11686 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11688 $LFS changelog_clear $MDT0 $CL_USER 0
11689 if [ x$flags != "x0x1" ]; then
11690 error "flag $flags is not 0x1"
11692 echo "rename overwrite a target having nlink = 1," \
11693 "changelog record has flags of $flags"
11695 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11696 touch $DIR/$tdir/foo_161c
11697 touch $DIR/$tdir/bar_161c
11698 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11699 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11700 $LFS changelog $MDT0 | grep RENME
11701 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11702 $LFS changelog_clear $MDT0 $CL_USER 0
11703 if [ x$flags != "x0x0" ]; then
11704 error "flag $flags is not 0x0"
11706 echo "rename overwrite a target having nlink > 1," \
11707 "changelog record has flags of $flags"
11709 # rename doesn't overwrite a target (changelog flag 0x0)
11710 touch $DIR/$tdir/foo_161c
11711 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11712 $LFS changelog $MDT0 | grep RENME
11713 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11714 $LFS changelog_clear $MDT0 $CL_USER 0
11715 if [ x$flags != "x0x0" ]; then
11716 error "flag $flags is not 0x0"
11718 echo "rename doesn't overwrite a target," \
11719 "changelog record has flags of $flags"
11721 # define CLF_UNLINK_LAST 0x0001
11722 # unlink a file having nlink = 1 (changelog flag 0x1)
11723 rm -f $DIR/$tdir/foo2_161c
11724 $LFS changelog $MDT0 | grep UNLNK
11725 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11726 $LFS changelog_clear $MDT0 $CL_USER 0
11727 if [ x$flags != "x0x1" ]; then
11728 error "flag $flags is not 0x1"
11730 echo "unlink a file having nlink = 1," \
11731 "changelog record has flags of $flags"
11733 # unlink a file having nlink > 1 (changelog flag 0x0)
11734 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11735 rm -f $DIR/$tdir/foobar_161c
11736 $LFS changelog $MDT0 | grep UNLNK
11737 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11738 $LFS changelog_clear $MDT0 $CL_USER 0
11739 if [ x$flags != "x0x0" ]; then
11740 error "flag $flags is not 0x0"
11742 echo "unlink a file having nlink > 1," \
11743 "changelog record has flags of $flags"
11746 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11753 # cleanup previous run
11754 rm -rf $DIR/$tdir/$tfile
11756 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11757 changelog_register -n)
11758 [[ $? -eq 0 ]] || error "changelog_register failed"
11760 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11761 # interfer with $MOUNT/.lustre/fid/ access
11763 [[ $? -eq 0 ]] || error "mkdir failed"
11765 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11766 $LCTL set_param fail_loc=0x8000140c
11768 $LCTL set_param fail_val=5
11771 echo foofoo > $DIR/$tdir/$tfile &
11774 # wait for create to be delayed
11778 [[ $? -eq 0 ]] || error "create should be blocked"
11780 local tempfile=$(mktemp)
11781 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11782 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11783 # some delay may occur during ChangeLog publishing and file read just
11784 # above, that could allow file write to happen finally
11785 [[ -s $tempfile ]] && echo "file should be empty"
11787 $LCTL set_param fail_loc=0
11790 [[ $? -eq 0 ]] || error "create failed"
11792 $LFS changelog_clear $MDT0 $user 0
11793 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11795 run_test 161d "create with concurrent .lustre/fid access"
11802 local path=$(${LFS} fid2path $*)
11803 # Remove the '//' indicating a remote directory
11804 path=$(echo $path | sed 's#//#/#g')
11807 if [ $RC -ne 0 ]; then
11808 err17935 "path looked up of $expected failed. Error $RC"
11810 elif [ "${path}" != "${expected}" ]; then
11811 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11814 echo "fid $fid resolves to path $path (expected $expected)"
11817 test_162a() { # was test_162
11818 # Make changes to filesystem
11819 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11820 test_mkdir -p -c1 $DIR/$tdir/d2
11821 touch $DIR/$tdir/d2/$tfile
11822 touch $DIR/$tdir/d2/x1
11823 touch $DIR/$tdir/d2/x2
11824 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11825 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11827 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11828 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11829 error "check path $tdir/d2/$tfile failed"
11832 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11833 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11834 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11835 error "check path $tdir/d2/p/q/r/slink failed"
11837 # softlink to wrong file
11838 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11839 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11840 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11841 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11844 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11845 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11846 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11847 # fid2path dir/fsname should both work
11848 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11849 error "check path $tdir/d2/a/b/c/new_file failed"
11850 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11851 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11853 # hardlink count: check that there are 2 links
11854 # Doesnt work with CMD yet: 17935
11855 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11856 err17935 "expected 2 links"
11858 # hardlink indexing: remove the first link
11859 rm $DIR/$tdir/d2/p/q/r/hlink
11860 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11861 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11865 run_test 162a "path lookup sanity"
11868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11869 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11872 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11873 error "create striped dir failed"
11875 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11876 tail -n 1 | awk '{print $2}')
11877 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11879 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11880 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11883 for ((i=0;i<5;i++)); do
11884 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11885 error "get fid for f$i failed"
11886 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11887 error "check path $tdir/striped_dir/f$i failed"
11889 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11890 error "get fid for d$i failed"
11891 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11892 error "check path $tdir/striped_dir/d$i failed"
11897 run_test 162b "striped directory path lookup sanity"
11899 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11901 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11902 skip "Need MDS version at least 2.7.51" && return
11903 test_mkdir $DIR/$tdir.local
11904 test_mkdir $DIR/$tdir.remote
11905 local lpath=$tdir.local
11906 local rpath=$tdir.remote
11908 for ((i = 0; i <= 101; i++)); do
11911 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11912 error "get fid for local directory $DIR/$lpath failed"
11913 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11914 error "check path for local directory $DIR/$lpath failed"
11917 test_mkdir $DIR/$rpath
11918 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11919 error "get fid for remote directory $DIR/$rpath failed"
11920 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11921 error "check path for remote directory $DIR/$rpath failed"
11926 run_test 162c "fid2path works with paths 100 or more directories deep"
11929 # do directio so as not to populate the page cache
11930 log "creating a 10 Mb file"
11931 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11932 log "starting reads"
11933 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11934 log "truncating the file"
11935 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11937 kill %+ || true # reads might have finished
11938 echo "wait until dd is finished"
11940 log "removing the temporary file"
11941 rm -rf $DIR/$tfile || error "tmp file removal failed"
11943 run_test 169 "parallel read and truncate should not deadlock"
11946 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11947 $LCTL clear # bug 18514
11948 $LCTL debug_daemon start $TMP/${tfile}_log_good
11950 $LCTL debug_daemon stop
11951 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11952 error "sed failed to read log_good"
11954 $LCTL debug_daemon start $TMP/${tfile}_log_good
11956 $LCTL debug_daemon stop
11958 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11959 error "lctl df log_bad failed"
11961 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11962 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11964 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11965 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11967 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11968 error "bad_line good_line1 good_line2 are empty"
11970 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11971 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11972 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11974 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11975 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11976 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11978 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11979 error "bad_line_new good_line_new are empty"
11981 local expected_good=$((good_line1 + good_line2*2))
11983 rm -f $TMP/${tfile}*
11984 # LU-231, short malformed line may not be counted into bad lines
11985 if [ $bad_line -ne $bad_line_new ] &&
11986 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11987 error "expected $bad_line bad lines, but got $bad_line_new"
11991 if [ $expected_good -ne $good_line_new ]; then
11992 error "expected $expected_good good lines, but got $good_line_new"
11997 run_test 170 "test lctl df to handle corrupted log ====================="
11999 test_171() { # bug20592
12000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12001 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
12002 $LCTL set_param fail_loc=0x50e
12003 $LCTL set_param fail_val=3000
12004 multiop_bg_pause $DIR/$tfile O_s || true
12006 kill -USR1 $MULTIPID
12010 if dmesg | grep "recursive fault"; then
12011 error "caught a recursive fault"
12013 $LCTL set_param fail_loc=0
12016 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
12018 # it would be good to share it with obdfilter-survey/iokit-libecho code
12019 setup_obdecho_osc () {
12022 local obdfilter_name=$2
12023 echo "Creating new osc for $obdfilter_name on $ost_nid"
12024 # make sure we can find loopback nid
12025 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
12027 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
12028 ${obdfilter_name}_osc_UUID || rc=2; }
12029 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
12030 ${obdfilter_name}_UUID $ost_nid || rc=3; }
12034 cleanup_obdecho_osc () {
12035 local obdfilter_name=$1
12036 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
12037 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
12044 local pages=${3:-64}
12049 local obd_size=$(get_obd_size $node $OBD)
12050 local page_size=$(get_page_size $node)
12051 if [[ -n "$obd_size" ]]; then
12052 local new_count=$((obd_size / (pages * page_size / 1024)))
12053 [[ $new_count -ge $count ]] || count=$new_count
12056 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
12057 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
12059 if [ $rc -eq 0 ]; then
12060 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
12061 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
12063 echo "New object id is $id"
12064 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
12066 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
12067 "test_brw $count w v $pages $id" || rc=4; }
12068 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
12070 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
12071 "cleanup" || rc=5; }
12072 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
12073 "detach" || rc=6; }
12074 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
12079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12080 remote_ost_nodsh && skip "remote OST with nodsh" && return
12082 local rmmod_local=0
12084 if ! module_loaded obdecho; then
12085 load_module obdecho/obdecho
12089 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
12090 local host=$(lctl get_param -n osc.$osc.import |
12091 awk '/current_connection:/ {print $2}' )
12092 local target=$(lctl get_param -n osc.$osc.import |
12093 awk '/target:/ {print $2}' )
12094 target=${target%_UUID}
12096 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
12097 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
12098 [[ -n $target ]] && cleanup_obdecho_osc $target
12099 [ $rmmod_local -eq 1 ] && rmmod obdecho
12102 run_test 180a "test obdecho on osc"
12105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12106 remote_ost_nodsh && skip "remote OST with nodsh" && return
12108 local rmmod_remote=0
12110 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12111 rmmod_remote=true || error "failed to load module obdecho"
12112 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
12113 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12114 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12117 run_test 180b "test obdecho directly on obdfilter"
12119 test_180c() { # LU-2598
12120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12121 remote_ost_nodsh && skip "remote OST with nodsh" && return
12122 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12123 skip "Need MDS version at least 2.4.0" && return
12126 local rmmod_remote=false
12127 local pages=16384 # 64MB bulk I/O RPC size
12130 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12131 rmmod_remote=true || error "failed to load module obdecho"
12133 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
12135 if [ -n "$target" ]; then
12136 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12138 echo "there is no obdfilter target on ost1"
12141 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12144 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12146 test_181() { # bug 22177
12147 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12148 # create enough files to index the directory
12149 createmany -o $DIR/$tdir/foobar 4000
12150 # print attributes for debug purpose
12153 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12155 # remove the files & current working dir
12156 unlinkmany $DIR/$tdir/foobar 4000
12158 kill -USR1 $MULTIPID
12160 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12163 run_test 181 "Test open-unlinked dir ========================"
12169 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12171 $LCTL set_param mdc.*.rpc_stats=clear
12173 for (( i = 0; i < $tcount; i++ )) ; do
12174 mkdir $DIR/$tdir/$i
12177 for (( i = 0; i < $tcount; i++ )) ; do
12178 createmany -o $DIR/$tdir/$i/f- $fcount &
12182 for (( i = 0; i < $tcount; i++ )) ; do
12183 unlinkmany $DIR/$tdir/$i/f- $fcount &
12187 $LCTL get_param mdc.*.rpc_stats
12191 run_test 182 "Test parallel modify metadata operations ================"
12193 test_183() { # LU-2275
12194 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12195 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12196 skip "Need MDS version at least 2.3.56" && return
12198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12199 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12200 echo aaa > $DIR/$tdir/$tfile
12202 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12203 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12205 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12206 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12208 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12210 # Flush negative dentry cache
12211 touch $DIR/$tdir/$tfile
12213 # We are not checking for any leaked references here, they'll
12214 # become evident next time we do cleanup with module unload.
12217 run_test 183 "No crash or request leak in case of strange dispositions ========"
12219 # test suite 184 is for LU-2016, LU-2017
12221 check_swap_layouts_support && return 0
12223 dir0=$DIR/$tdir/$testnum
12224 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
12229 $SETSTRIPE -c1 $file1
12231 $SETSTRIPE -c2 $file2
12233 gen1=$($GETSTRIPE -g $file1)
12234 gen2=$($GETSTRIPE -g $file2)
12236 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12237 gen=$($GETSTRIPE -g $file1)
12238 [[ $gen1 != $gen ]] ||
12239 "Layout generation on $file1 does not change"
12240 gen=$($GETSTRIPE -g $file2)
12241 [[ $gen2 != $gen ]] ||
12242 "Layout generation on $file2 does not change"
12244 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12245 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12247 run_test 184a "Basic layout swap"
12250 check_swap_layouts_support && return 0
12252 dir0=$DIR/$tdir/$testnum
12253 mkdir -p $dir0 || error "creating dir $dir0"
12260 $SETSTRIPE -c1 $file1
12261 $SETSTRIPE -c2 $file2
12262 $SETSTRIPE -c1 $file3
12263 chown $RUNAS_ID $file3
12264 gen1=$($GETSTRIPE -g $file1)
12265 gen2=$($GETSTRIPE -g $file2)
12267 $LFS swap_layouts $dir1 $dir2 &&
12268 error "swap of directories layouts should fail"
12269 $LFS swap_layouts $dir1 $file1 &&
12270 error "swap of directory and file layouts should fail"
12271 $RUNAS $LFS swap_layouts $file1 $file2 &&
12272 error "swap of file we cannot write should fail"
12273 $LFS swap_layouts $file1 $file3 &&
12274 error "swap of file with different owner should fail"
12275 /bin/true # to clear error code
12277 run_test 184b "Forbidden layout swap (will generate errors)"
12280 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12281 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12282 check_swap_layouts_support && return 0
12284 local dir0=$DIR/$tdir/$testnum
12285 mkdir -p $dir0 || error "creating dir $dir0"
12287 local ref1=$dir0/ref1
12288 local ref2=$dir0/ref2
12289 local file1=$dir0/file1
12290 local file2=$dir0/file2
12291 # create a file large enough for the concurrent test
12292 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12293 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12294 echo "ref file size: ref1($(stat -c %s $ref1))," \
12295 "ref2($(stat -c %s $ref2))"
12298 dd if=$ref1 of=$file1 bs=16k &
12301 # Make sure dd starts to copy file
12302 while [ ! -f $file1 ]; do sleep 0.1; done
12304 $LFS swap_layouts $file1 $file2
12307 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12308 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12310 # how many bytes copied before swapping layout
12311 local copied=$(stat -c %s $file2)
12312 local remaining=$(stat -c %s $ref1)
12313 remaining=$((remaining - copied))
12314 echo "Copied $copied bytes before swapping layout..."
12316 cmp -n $copied $file1 $ref2 | grep differ &&
12317 error "Content mismatch [0, $copied) of ref2 and file1"
12318 cmp -n $copied $file2 $ref1 ||
12319 error "Content mismatch [0, $copied) of ref1 and file2"
12320 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12321 error "Content mismatch [$copied, EOF) of ref1 and file1"
12324 rm -f $ref1 $ref2 $file1 $file2
12326 run_test 184c "Concurrent write and layout swap"
12329 check_swap_layouts_support && return 0
12330 [ -z "$(which getfattr 2>/dev/null)" ] &&
12331 skip "no getfattr command" && return 0
12333 local file1=$DIR/$tdir/$tfile-1
12334 local file2=$DIR/$tdir/$tfile-2
12335 local file3=$DIR/$tdir/$tfile-3
12339 mkdir -p $DIR/$tdir
12340 touch $file1 || error "create $file1 failed"
12341 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12342 error "create $file2 failed"
12343 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12344 error "create $file3 failed"
12345 lovea1=$(get_layout_param $file1)
12347 $LFS swap_layouts $file2 $file3 ||
12348 error "swap $file2 $file3 layouts failed"
12349 $LFS swap_layouts $file1 $file2 ||
12350 error "swap $file1 $file2 layouts failed"
12352 lovea2=$(get_layout_param $file2)
12355 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12357 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12358 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12360 run_test 184d "allow stripeless layouts swap"
12363 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12364 { skip "Need MDS version at least 2.6.94"; return 0; }
12365 check_swap_layouts_support && return 0
12366 [ -z "$(which getfattr 2>/dev/null)" ] &&
12367 skip "no getfattr command" && return 0
12369 local file1=$DIR/$tdir/$tfile-1
12370 local file2=$DIR/$tdir/$tfile-2
12371 local file3=$DIR/$tdir/$tfile-3
12374 mkdir -p $DIR/$tdir
12375 touch $file1 || error "create $file1 failed"
12376 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12377 error "create $file2 failed"
12378 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12379 error "create $file3 failed"
12381 $LFS swap_layouts $file1 $file2 ||
12382 error "swap $file1 $file2 layouts failed"
12384 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12385 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12387 echo 123 > $file1 || error "Should be able to write into $file1"
12389 $LFS swap_layouts $file1 $file3 ||
12390 error "swap $file1 $file3 layouts failed"
12392 echo 123 > $file1 || error "Should be able to write into $file1"
12394 rm -rf $file1 $file2 $file3
12396 run_test 184e "Recreate layout after stripeless layout swaps"
12398 test_185() { # LU-2441
12399 # LU-3553 - no volatile file support in old servers
12400 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12401 { skip "Need MDS version at least 2.3.60"; return 0; }
12403 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12404 touch $DIR/$tdir/spoo
12405 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12406 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12407 error "cannot create/write a volatile file"
12408 [ "$FILESET" == "" ] &&
12409 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12410 error "FID is still valid after close"
12412 multiop_bg_pause $DIR/$tdir vVw4096_c
12419 # assume that the next FID for this client is sequential, since stdout
12420 # is unfortunately eaten by multiop_bg_pause
12421 local n=$((${fidv[1]} + 1))
12422 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12423 if [ "$FILESET" == "" ]; then
12424 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12425 error "FID is missing before close"
12427 kill -USR1 $multi_pid
12428 # 1 second delay, so if mtime change we will see it
12430 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12431 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12433 run_test 185 "Volatile file support"
12436 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12437 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12438 skip "Need MDS version at least 2.3.0" && return
12440 local dir0=$DIR/$tdir/$testnum
12441 mkdir -p $dir0 || error "creating dir $dir0"
12443 local file=$dir0/file1
12444 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12445 local dv1=$($LFS data_version $file)
12446 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12447 local dv2=$($LFS data_version $file)
12448 [[ $dv1 != $dv2 ]] ||
12449 error "data version did not change on write $dv1 == $dv2"
12454 run_test 187a "Test data version change"
12457 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12458 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12459 skip "Need MDS version at least 2.3.0" && return
12461 local dir0=$DIR/$tdir/$testnum
12462 mkdir -p $dir0 || error "creating dir $dir0"
12464 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12465 [[ ${DV[0]} != ${DV[1]} ]] ||
12466 error "data version did not change on write"\
12467 " ${DV[0]} == ${DV[1]}"
12472 run_test 187b "Test data version change on volatile file"
12475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12476 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12477 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12479 local POOL=${POOL:-cea1}
12480 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12481 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12484 local last_ost=$(($OSTCOUNT - 1))
12486 local ost_list=$(seq $first_ost $ost_step $last_ost)
12487 local ost_range="$first_ost $last_ost $ost_step"
12488 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12489 local file_dir=$POOL_ROOT/file_tst
12490 local subdir=$test_path/subdir
12493 if ! combined_mgs_mds ; then
12498 # former test_200a test_200b
12499 pool_add $POOL || { rc=$? ; break; }
12500 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12501 # former test_200c test_200d
12502 mkdir -p $test_path
12503 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12504 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12506 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12507 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12508 || { rc=$? ; break; }
12509 # former test_200e test_200f
12510 local files=$((OSTCOUNT*3))
12511 pool_alloc_files $POOL $test_path $files "$ost_list" \
12512 || { rc=$? ; break; }
12513 pool_create_files $POOL $file_dir $files "$ost_list" \
12514 || { rc=$? ; break; }
12515 # former test_200g test_200h
12516 pool_lfs_df $POOL || { rc=$? ; break; }
12517 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12519 # former test_201a test_201b test_201c
12520 pool_remove_first_target $POOL || { rc=$? ; break; }
12522 local f=$test_path/$tfile
12523 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12524 pool_remove $POOL $f || { rc=$? ; break; }
12530 if ! combined_mgs_mds ; then
12535 run_test 200 "OST pools"
12537 # usage: default_attr <count | size | offset>
12539 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12542 # usage: check_default_stripe_attr
12543 check_default_stripe_attr() {
12544 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12547 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12549 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12553 error "unknown getstripe attr '$1'"
12556 [ $ACTUAL != $EXPECTED ] &&
12557 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12561 test_mkdir -p $DIR/$tdir
12562 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12564 check_default_stripe_attr --stripe-count
12565 check_default_stripe_attr --stripe-size
12566 check_default_stripe_attr --stripe-index
12570 run_test 204a "Print default stripe attributes ================="
12573 test_mkdir -p $DIR/$tdir
12574 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12576 check_default_stripe_attr --stripe-size
12577 check_default_stripe_attr --stripe-index
12581 run_test 204b "Print default stripe size and offset ==========="
12584 test_mkdir -p $DIR/$tdir
12585 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12587 check_default_stripe_attr --stripe-count
12588 check_default_stripe_attr --stripe-index
12592 run_test 204c "Print default stripe count and offset ==========="
12595 test_mkdir -p $DIR/$tdir
12596 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12598 check_default_stripe_attr --stripe-count
12599 check_default_stripe_attr --stripe-size
12603 run_test 204d "Print default stripe count and size ============="
12606 test_mkdir -p $DIR/$tdir
12607 $SETSTRIPE -d $DIR/$tdir
12609 check_default_stripe_attr --stripe-count --raw
12610 check_default_stripe_attr --stripe-size --raw
12611 check_default_stripe_attr --stripe-index --raw
12615 run_test 204e "Print raw stripe attributes ================="
12618 test_mkdir -p $DIR/$tdir
12619 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12621 check_default_stripe_attr --stripe-size --raw
12622 check_default_stripe_attr --stripe-index --raw
12626 run_test 204f "Print raw stripe size and offset ==========="
12629 test_mkdir -p $DIR/$tdir
12630 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12632 check_default_stripe_attr --stripe-count --raw
12633 check_default_stripe_attr --stripe-index --raw
12637 run_test 204g "Print raw stripe count and offset ==========="
12640 test_mkdir -p $DIR/$tdir
12641 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12643 check_default_stripe_attr --stripe-count --raw
12644 check_default_stripe_attr --stripe-size --raw
12648 run_test 204h "Print raw stripe count and size ============="
12650 # Figure out which job scheduler is being used, if any,
12651 # or use a fake one
12652 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12653 JOBENV=SLURM_JOB_ID
12654 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12656 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12658 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12659 JOBENV=LOADL_STEP_ID
12660 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12663 $LCTL list_param jobid_name > /dev/null 2>&1
12664 if [ $? -eq 0 ]; then
12671 verify_jobstats() {
12676 # we don't really need to clear the stats for this test to work, since each
12677 # command has a unique jobid, but it makes debugging easier if needed.
12678 # for facet in $facets; do
12679 # local dev=$(convert_facet2label $facet)
12680 # # clear old jobstats
12681 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12684 # use a new JobID for each test, or we might see an old one
12685 [ "$JOBENV" = "FAKE_JOBID" ] &&
12686 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12690 [ "$JOBENV" = "nodelocal" ] && {
12691 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12692 $LCTL set_param jobid_name=$FAKE_JOBID
12696 log "Test: ${cmd[*]}"
12697 log "Using JobID environment variable $JOBENV=$JOBVAL"
12699 if [ $JOBENV = "FAKE_JOBID" ]; then
12700 FAKE_JOBID=$JOBVAL ${cmd[*]}
12705 # all files are created on OST0000
12706 for facet in $facets; do
12707 local stats="*.$(convert_facet2label $facet).job_stats"
12708 if [ $(do_facet $facet lctl get_param $stats |
12709 grep -c $JOBVAL) -ne 1 ]; then
12710 do_facet $facet lctl get_param $stats
12711 error "No jobstats for $JOBVAL found on $facet::$stats"
12718 NEW_JOBENV=${1:-$OLD_JOBENV}
12719 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12720 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12725 do_facet $SINGLEMDS \
12726 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12727 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12731 test_205() { # Job stats
12732 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12733 { skip "Need MDS version with at least 2.7.1"; return 0; }
12735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12736 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12737 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12738 remote_ost_nodsh && skip "remote OST with nodsh" && return
12740 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12741 skip "Server doesn't support jobstats" && return 0
12742 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12744 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12745 if [ $OLD_JOBENV != $JOBENV ]; then
12746 jobstats_set $JOBENV
12747 trap cleanup_205 EXIT
12750 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12751 echo "Registered as changelog user $CL_USER"
12753 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12754 lctl get_param -n mdt.*.job_cleanup_interval)
12755 local interval_new=5
12756 do_facet $SINGLEMDS \
12757 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12758 local start=$SECONDS
12762 cmd="mkdir $DIR/$tdir"
12763 verify_jobstats "$cmd" "$SINGLEMDS"
12765 cmd="rmdir $DIR/$tdir"
12766 verify_jobstats "$cmd" "$SINGLEMDS"
12767 # mkdir on secondary MDT
12768 if [ $MDSCOUNT -gt 1 ]; then
12769 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12770 verify_jobstats "$cmd" "mds2"
12773 cmd="mknod $DIR/$tfile c 1 3"
12774 verify_jobstats "$cmd" "$SINGLEMDS"
12776 cmd="rm -f $DIR/$tfile"
12777 verify_jobstats "$cmd" "$SINGLEMDS"
12778 # create all files on OST0000 so verify_jobstats can find OST stats
12780 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12781 verify_jobstats "$cmd" "$SINGLEMDS"
12783 cmd="touch $DIR/$tfile"
12784 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12786 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12787 verify_jobstats "$cmd" "ost1"
12789 cancel_lru_locks osc
12790 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12791 verify_jobstats "$cmd" "ost1"
12793 cmd="$TRUNCATE $DIR/$tfile 0"
12794 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12796 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12797 verify_jobstats "$cmd" "$SINGLEMDS"
12798 # jobstats expiry - sleep until old stats should be expired
12799 local left=$((interval_new + 5 - (SECONDS - start)))
12800 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12801 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12803 cmd="mkdir $DIR/$tdir.expire"
12804 verify_jobstats "$cmd" "$SINGLEMDS"
12805 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12806 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12808 # Ensure that jobid are present in changelog (if supported by MDS)
12809 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12811 $LFS changelog $MDT0 | tail -9
12812 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12813 [ $jobids -eq 9 ] ||
12814 error "Wrong changelog jobid count $jobids != 9"
12818 jobstats_set $JOBENV
12820 $LFS changelog $MDT0 | tail -1
12821 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12822 [ $jobids -eq 0 ] ||
12823 error "Unexpected jobids when jobid_var=$JOBENV"
12828 run_test 205 "Verify job stats"
12830 # LU-1480, LU-1773 and LU-1657
12832 mkdir -p $DIR/$tdir
12833 $SETSTRIPE -c -1 $DIR/$tdir
12834 #define OBD_FAIL_LOV_INIT 0x1403
12835 $LCTL set_param fail_loc=0xa0001403
12836 $LCTL set_param fail_val=1
12837 touch $DIR/$tdir/$tfile || true
12839 run_test 206 "fail lov_init_raid0() doesn't lbug"
12842 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12843 local fsz=`stat -c %s $DIR/$tfile`
12844 cancel_lru_locks mdc
12846 # do not return layout in getattr intent
12847 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12848 $LCTL set_param fail_loc=0x170
12849 local sz=`stat -c %s $DIR/$tfile`
12851 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12855 run_test 207a "can refresh layout at glimpse"
12858 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12859 local cksum=`md5sum $DIR/$tfile`
12860 local fsz=`stat -c %s $DIR/$tfile`
12861 cancel_lru_locks mdc
12862 cancel_lru_locks osc
12864 # do not return layout in getattr intent
12865 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12866 $LCTL set_param fail_loc=0x171
12868 # it will refresh layout after the file is opened but before read issues
12869 echo checksum is "$cksum"
12870 echo "$cksum" |md5sum -c --quiet || error "file differs"
12874 run_test 207b "can refresh layout at open"
12877 # FIXME: in this test suite, only RD lease is used. This is okay
12878 # for now as only exclusive open is supported. After generic lease
12879 # is done, this test suite should be revised. - Jinshan
12881 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12882 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12883 { skip "Need MDS version at least 2.4.52"; return 0; }
12885 echo "==== test 1: verify get lease work"
12886 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12888 echo "==== test 2: verify lease can be broken by upcoming open"
12889 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12893 $MULTIOP $DIR/$tfile oO_RDONLY:c
12894 kill -USR1 $PID && wait $PID || error "break lease error"
12896 echo "==== test 3: verify lease can't be granted if an open already exists"
12897 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12901 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12902 kill -USR1 $PID && wait $PID || error "open file error"
12904 echo "==== test 4: lease can sustain over recovery"
12905 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12911 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12913 echo "==== test 5: lease broken can't be regained by replay"
12914 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12918 # open file to break lease and then recovery
12919 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12922 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12926 run_test 208 "Exclusive open"
12929 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12930 skip_env "must have disp_stripe" && return
12933 sync; sleep 5; sync;
12935 echo 3 > /proc/sys/vm/drop_caches
12936 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12938 # open/close 500 times
12939 for i in $(seq 500); do
12943 echo 3 > /proc/sys/vm/drop_caches
12944 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12946 echo "before: $req_before, after: $req_after"
12947 [ $((req_after - req_before)) -ge 300 ] &&
12948 error "open/close requests are not freed"
12951 run_test 209 "read-only open/close requests should be freed promptly"
12955 size=$((size % 8192 + 1))
12956 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12957 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12958 rm -f $DIR/f212 $DIR/f212.xyz
12960 run_test 212 "Sendfile test ============================================"
12963 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12964 cancel_lru_locks osc
12965 lctl set_param fail_loc=0x8000040f
12966 # generate a read lock
12967 cat $DIR/$tfile > /dev/null
12968 # write to the file, it will try to cancel the above read lock.
12969 cat /etc/hosts >> $DIR/$tfile
12971 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12973 test_214() { # for bug 20133
12974 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12975 for (( i=0; i < 340; i++ )) ; do
12976 touch $DIR/$tdir/d214c/a$i
12979 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12980 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12981 ls $DIR/d214c || error "ls $DIR/d214c failed"
12982 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12983 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12985 run_test 214 "hash-indexed directory test - bug 20133"
12987 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12988 create_lnet_proc_files() {
12989 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
12990 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
12992 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12993 rm -f "$TMP/lnet_$1.sys_tmp"
12996 # counterpart of create_lnet_proc_files
12997 remove_lnet_proc_files() {
12998 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
13001 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13002 # 3rd arg as regexp for body
13003 check_lnet_proc_stats() {
13004 local l=$(cat "$TMP/lnet_$1" |wc -l)
13005 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
13007 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
13010 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13011 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
13012 # optional and can be regexp for 2nd line (lnet.routes case)
13013 check_lnet_proc_entry() {
13014 local blp=2 # blp stands for 'position of 1st line of body'
13015 [ -z "$5" ] || blp=3 # lnet.routes case
13017 local l=$(cat "$TMP/lnet_$1" |wc -l)
13018 # subtracting one from $blp because the body can be empty
13019 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
13021 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
13022 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
13024 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
13025 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
13027 # bail out if any unexpected line happened
13028 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
13029 [ "$?" != 0 ] || error "$2 misformatted"
13032 test_215() { # for bugs 18102, 21079, 21517
13033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13034 local N='(0|[1-9][0-9]*)' # non-negative numeric
13035 local P='[1-9][0-9]*' # positive numeric
13036 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
13037 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
13038 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
13039 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
13041 local L1 # regexp for 1st line
13042 local L2 # regexp for 2nd line (optional)
13043 local BR # regexp for the rest (body)
13045 # lnet.stats should look as 11 space-separated non-negative numerics
13046 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
13047 create_lnet_proc_files "stats"
13048 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
13049 remove_lnet_proc_files "stats"
13051 # lnet.routes should look like this:
13052 # Routing disabled/enabled
13053 # net hops priority state router
13054 # where net is a string like tcp0, hops > 0, priority >= 0,
13055 # state is up/down,
13056 # router is a string like 192.168.1.1@tcp2
13057 L1="^Routing (disabled|enabled)$"
13058 L2="^net +hops +priority +state +router$"
13059 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
13060 create_lnet_proc_files "routes"
13061 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
13062 remove_lnet_proc_files "routes"
13064 # lnet.routers should look like this:
13065 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
13066 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
13067 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
13068 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
13069 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
13070 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
13071 create_lnet_proc_files "routers"
13072 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
13073 remove_lnet_proc_files "routers"
13075 # lnet.peers should look like this:
13076 # nid refs state last max rtr min tx min queue
13077 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
13078 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
13079 # numeric (0 or >0 or <0), queue >= 0.
13080 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
13081 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
13082 create_lnet_proc_files "peers"
13083 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
13084 remove_lnet_proc_files "peers"
13086 # lnet.buffers should look like this:
13087 # pages count credits min
13088 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
13089 L1="^pages +count +credits +min$"
13090 BR="^ +$N +$N +$I +$I$"
13091 create_lnet_proc_files "buffers"
13092 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
13093 remove_lnet_proc_files "buffers"
13095 # lnet.nis should look like this:
13096 # nid status alive refs peer rtr max tx min
13097 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
13098 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
13099 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
13100 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
13101 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
13102 create_lnet_proc_files "nis"
13103 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
13104 remove_lnet_proc_files "nis"
13106 # can we successfully write to lnet.stats?
13107 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
13108 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
13110 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
13112 test_216() { # bug 20317
13113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13114 remote_ost_nodsh && skip "remote OST with nodsh" && return
13117 local facets=$(get_facets OST)
13118 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13120 save_lustre_params client "osc.*.contention_seconds" > $p
13121 save_lustre_params $facets \
13122 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13123 save_lustre_params $facets \
13124 "ldlm.namespaces.filter-*.contended_locks" >> $p
13125 save_lustre_params $facets \
13126 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13127 clear_stats osc.*.osc_stats
13129 # agressive lockless i/o settings
13130 do_nodes $(comma_list $(osts_nodes)) \
13131 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13132 ldlm.namespaces.filter-*.contended_locks=0 \
13133 ldlm.namespaces.filter-*.contention_seconds=60"
13134 lctl set_param -n osc.*.contention_seconds=60
13136 $DIRECTIO write $DIR/$tfile 0 10 4096
13137 $CHECKSTAT -s 40960 $DIR/$tfile
13139 # disable lockless i/o
13140 do_nodes $(comma_list $(osts_nodes)) \
13141 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13142 ldlm.namespaces.filter-*.contended_locks=32 \
13143 ldlm.namespaces.filter-*.contention_seconds=0"
13144 lctl set_param -n osc.*.contention_seconds=0
13145 clear_stats osc.*.osc_stats
13147 dd if=/dev/zero of=$DIR/$tfile count=0
13148 $CHECKSTAT -s 0 $DIR/$tfile
13150 restore_lustre_params <$p
13154 run_test 216 "check lockless direct write updates file size and kms correctly"
13156 test_217() { # bug 22430
13157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13161 for node in $(nodes_list); do
13162 nid=$(host_nids_address $node $NETTYPE)
13163 if [[ $nid = *-* ]] ; then
13164 echo "lctl ping $(h2nettype $nid)"
13165 lctl ping $(h2nettype $nid)
13167 echo "skipping $node (no hyphen detected)"
13171 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13174 # do directio so as not to populate the page cache
13175 log "creating a 10 Mb file"
13176 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13177 log "starting reads"
13178 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13179 log "truncating the file"
13180 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13182 kill %+ || true # reads might have finished
13183 echo "wait until dd is finished"
13185 log "removing the temporary file"
13186 rm -rf $DIR/$tfile || error "tmp file removal failed"
13188 run_test 218 "parallel read and truncate should not deadlock ======================="
13191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13192 # write one partial page
13193 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13194 # set no grant so vvp_io_commit_write will do sync write
13195 $LCTL set_param fail_loc=0x411
13196 # write a full page at the end of file
13197 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13199 $LCTL set_param fail_loc=0
13200 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13201 $LCTL set_param fail_loc=0x411
13202 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13205 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13206 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13208 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13210 test_220() { #LU-325
13211 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13212 remote_ost_nodsh && skip "remote OST with nodsh" && return
13213 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13214 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13217 # create on MDT0000 so the last_id and next_id are correct
13219 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13223 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13224 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13225 osc.$mdtosc_proc1.prealloc_last_id)
13226 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13227 osc.$mdtosc_proc1.prealloc_next_id)
13231 if ! combined_mgs_mds ; then
13235 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13236 #define OBD_FAIL_OST_ENOINO 0x229
13237 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13238 create_pool $FSNAME.$TESTNAME || return 1
13239 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13241 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13243 MDSOBJS=$((last_id - next_id))
13244 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13246 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13247 echo "OST still has $count kbytes free"
13249 echo "create $MDSOBJS files @next_id..."
13250 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13252 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13253 osc.$mdtosc_proc1.prealloc_last_id)
13254 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13255 osc.$mdtosc_proc1.prealloc_next_id)
13257 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13262 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13263 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13265 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
13266 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
13267 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
13268 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
13269 echo "unlink $MDSOBJS files @$next_id..."
13270 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
13272 if ! combined_mgs_mds ; then
13276 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13280 dd if=`which date` of=$MOUNT/date oflag=sync
13281 chmod +x $MOUNT/date
13283 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13284 $LCTL set_param fail_loc=0x80001401
13286 $MOUNT/date > /dev/null
13289 run_test 221 "make sure fault and truncate race to not cause OOM"
13292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13294 test_mkdir -p $DIR/$tdir
13295 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13296 createmany -o $DIR/$tdir/$tfile 10
13297 cancel_lru_locks mdc
13298 cancel_lru_locks osc
13299 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13300 $LCTL set_param fail_loc=0x31a
13301 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13302 $LCTL set_param fail_loc=0
13305 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
13308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13310 test_mkdir -p $DIR/$tdir
13311 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13312 createmany -o $DIR/$tdir/$tfile 10
13313 cancel_lru_locks mdc
13314 cancel_lru_locks osc
13315 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13316 $LCTL set_param fail_loc=0x31a
13317 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13318 $LCTL set_param fail_loc=0
13320 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
13323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13325 test_mkdir -p $DIR/$tdir
13326 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13327 createmany -o $DIR/$tdir/$tfile 10
13328 cancel_lru_locks mdc
13329 cancel_lru_locks osc
13330 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13331 $LCTL set_param fail_loc=0x31b
13332 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13333 $LCTL set_param fail_loc=0
13336 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13338 test_224a() { # LU-1039, MRP-303
13339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13340 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13341 $LCTL set_param fail_loc=0x508
13342 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13343 $LCTL set_param fail_loc=0
13346 run_test 224a "Don't panic on bulk IO failure"
13348 test_224b() { # LU-1039, MRP-303
13349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13350 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13351 cancel_lru_locks osc
13352 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13353 $LCTL set_param fail_loc=0x515
13354 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13355 $LCTL set_param fail_loc=0
13358 run_test 224b "Don't panic on bulk IO failure"
13360 test_224c() { # LU-6441
13361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13362 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13364 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13365 save_writethrough $p
13366 set_cache writethrough on
13368 local pages_per_rpc=$($LCTL get_param \
13369 osc.*.max_pages_per_rpc)
13370 local at_max=$($LCTL get_param -n at_max)
13371 local timeout=$($LCTL get_param -n timeout)
13372 local test_at="$LCTL get_param -n at_max"
13373 local param_at="$FSNAME.sys.at_max"
13374 local test_timeout="$LCTL get_param -n timeout"
13375 local param_timeout="$FSNAME.sys.timeout"
13377 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13379 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13380 error "conf_param at_max=0 failed"
13381 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13382 error "conf_param timeout=5 failed"
13384 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13385 do_facet ost1 $LCTL set_param fail_loc=0x520
13386 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13387 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13389 do_facet ost1 $LCTL set_param fail_loc=0
13391 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13392 error "conf_param at_max=$at_max failed"
13393 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13394 $timeout || error "conf_param timeout=$timeout failed"
13396 $LCTL set_param -n $pages_per_rpc
13397 restore_lustre_params < $p
13400 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13402 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13404 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13405 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13406 if [ -z ${MDSSURVEY} ]; then
13407 skip_env "mds-survey not found" && return
13410 [ $MDSCOUNT -ge 2 ] &&
13411 skip "skipping now for more than one MDT" && return
13413 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13414 { skip "Need MDS version at least 2.2.51"; return; }
13416 local mds=$(facet_host $SINGLEMDS)
13417 local target=$(do_nodes $mds 'lctl dl' | \
13418 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13420 local cmd1="file_count=1000 thrhi=4"
13421 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13422 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13423 local cmd="$cmd1 $cmd2 $cmd3"
13425 rm -f ${TMP}/mds_survey*
13427 eval $cmd || error "mds-survey with zero-stripe failed"
13428 cat ${TMP}/mds_survey*
13429 rm -f ${TMP}/mds_survey*
13431 run_test 225a "Metadata survey sanity with zero-stripe"
13434 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13435 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13436 if [ -z ${MDSSURVEY} ]; then
13437 skip_env "mds-survey not found" && return
13439 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13440 { skip "Need MDS version at least 2.2.51"; return; }
13442 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13443 skip_env "Need to mount OST to test" && return
13446 local mds=$(facet_host $SINGLEMDS)
13447 local target=$(do_nodes $mds 'lctl dl' | \
13448 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13450 local cmd1="file_count=1000 thrhi=4"
13451 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13452 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13453 local cmd="$cmd1 $cmd2 $cmd3"
13455 rm -f ${TMP}/mds_survey*
13457 eval $cmd || error "mds-survey with stripe_count failed"
13458 cat ${TMP}/mds_survey*
13459 rm -f ${TMP}/mds_survey*
13461 run_test 225b "Metadata survey sanity with stripe_count = 1"
13463 mcreate_path2fid () {
13469 local path=$DIR/$tdir/$name
13474 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13475 error "cannot create $desc"
13477 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13479 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13481 fid_path=$($LFS fid2path $MOUNT $fid)
13483 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13485 [ "$path" == "$fid_path" ] ||
13486 error "fid2path returned $fid_path, expected $path"
13488 echo "pass with $path and $fid"
13493 mkdir -p $DIR/$tdir
13495 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13496 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13497 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13498 mcreate_path2fid 0040666 0 0 dir "directory"
13499 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13500 mcreate_path2fid 0100666 0 0 file "regular file"
13501 mcreate_path2fid 0120666 0 0 link "symbolic link"
13502 mcreate_path2fid 0140666 0 0 sock "socket"
13504 run_test 226a "call path2fid and fid2path on files of all type"
13507 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13511 mkdir -p $DIR/$tdir
13512 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13513 error "create remote directory failed"
13514 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13515 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13516 "character special file (null)"
13517 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13518 "character special file (no device)"
13519 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13520 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13521 "block special file (loop)"
13522 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13523 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13524 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13526 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13528 # LU-1299 Executing or running ldd on a truncated executable does not
13529 # cause an out-of-memory condition.
13531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13532 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13533 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13534 chmod +x $MOUNT/date
13536 $MOUNT/date > /dev/null
13537 ldd $MOUNT/date > /dev/null
13540 run_test 227 "running truncated executable does not cause OOM"
13542 # LU-1512 try to reuse idle OI blocks
13544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13545 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13546 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13547 skip "ldiskfs only test" && return
13549 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13550 local myDIR=$DIR/$tdir
13553 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13554 $LCTL set_param fail_loc=0x80001002
13555 createmany -o $myDIR/t- 10000
13556 $LCTL set_param fail_loc=0
13557 # The guard is current the largest FID holder
13559 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13561 local IDX=$(($SEQ % 64))
13563 do_facet $SINGLEMDS sync
13564 # Make sure journal flushed.
13566 local blk1=$(do_facet $SINGLEMDS \
13567 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13568 grep Blockcount | awk '{print $4}')
13570 # Remove old files, some OI blocks will become idle.
13571 unlinkmany $myDIR/t- 10000
13572 # Create new files, idle OI blocks should be reused.
13573 createmany -o $myDIR/t- 2000
13574 do_facet $SINGLEMDS sync
13575 # Make sure journal flushed.
13577 local blk2=$(do_facet $SINGLEMDS \
13578 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13579 grep Blockcount | awk '{print $4}')
13581 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13583 run_test 228a "try to reuse idle OI blocks"
13586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13587 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13588 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13589 skip "ldiskfs only test" && return
13591 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13592 local myDIR=$DIR/$tdir
13595 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13596 $LCTL set_param fail_loc=0x80001002
13597 createmany -o $myDIR/t- 10000
13598 $LCTL set_param fail_loc=0
13599 # The guard is current the largest FID holder
13601 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13603 local IDX=$(($SEQ % 64))
13605 do_facet $SINGLEMDS sync
13606 # Make sure journal flushed.
13608 local blk1=$(do_facet $SINGLEMDS \
13609 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13610 grep Blockcount | awk '{print $4}')
13612 # Remove old files, some OI blocks will become idle.
13613 unlinkmany $myDIR/t- 10000
13616 stop $SINGLEMDS || error "Fail to stop MDT."
13618 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13620 df $MOUNT || error "Fail to df."
13621 # Create new files, idle OI blocks should be reused.
13622 createmany -o $myDIR/t- 2000
13623 do_facet $SINGLEMDS sync
13624 # Make sure journal flushed.
13626 local blk2=$(do_facet $SINGLEMDS \
13627 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13628 grep Blockcount | awk '{print $4}')
13630 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13632 run_test 228b "idle OI blocks can be reused after MDT restart"
13636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13637 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13638 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13639 skip "ldiskfs only test" && return
13641 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13642 local myDIR=$DIR/$tdir
13645 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13646 $LCTL set_param fail_loc=0x80001002
13647 # 20000 files can guarantee there are index nodes in the OI file
13648 createmany -o $myDIR/t- 20000
13649 $LCTL set_param fail_loc=0
13650 # The guard is current the largest FID holder
13652 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13654 local IDX=$(($SEQ % 64))
13656 do_facet $SINGLEMDS sync
13657 # Make sure journal flushed.
13659 local blk1=$(do_facet $SINGLEMDS \
13660 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13661 grep Blockcount | awk '{print $4}')
13663 # Remove old files, some OI blocks will become idle.
13664 unlinkmany $myDIR/t- 20000
13666 # The OI file should become empty now
13668 # Create new files, idle OI blocks should be reused.
13669 createmany -o $myDIR/t- 2000
13670 do_facet $SINGLEMDS sync
13671 # Make sure journal flushed.
13673 local blk2=$(do_facet $SINGLEMDS \
13674 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13675 grep Blockcount | awk '{print $4}')
13677 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13679 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13681 test_229() { # LU-2482, LU-3448
13682 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13683 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13685 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13686 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13690 # Create a file with a released layout and stripe count 2.
13691 $MULTIOP $DIR/$tfile H2c ||
13692 error "failed to create file with released layout"
13694 $GETSTRIPE -v $DIR/$tfile
13696 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13697 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
13699 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13700 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13701 stat $DIR/$tfile || error "failed to stat released file"
13703 chown $RUNAS_ID $DIR/$tfile ||
13704 error "chown $RUNAS_ID $DIR/$tfile failed"
13706 chgrp $RUNAS_ID $DIR/$tfile ||
13707 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13709 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13710 rm $DIR/$tfile || error "failed to remove released file"
13712 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13716 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13719 test_mkdir $DIR/$tdir
13720 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13721 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13722 [ $mdt_idx -ne 0 ] &&
13723 error "create local directory on wrong MDT $mdt_idx"
13725 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13726 error "create remote directory failed"
13727 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13728 [ $mdt_idx -ne $MDTIDX ] &&
13729 error "create remote directory on wrong MDT $mdt_idx"
13731 createmany -o $DIR/$tdir/test_230/t- 10 ||
13732 error "create files on remote directory failed"
13733 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13734 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13735 rm -r $DIR/$tdir || error "unlink remote directory failed"
13737 run_test 230a "Create remote directory and files under the remote directory"
13740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13741 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13748 local migrate_dir=$DIR/$tdir/migrate_dir
13749 local other_dir=$DIR/$tdir/other_dir
13751 test_mkdir $DIR/$tdir
13752 test_mkdir -i0 -c1 $migrate_dir
13753 test_mkdir -i0 -c1 $other_dir
13754 for ((i=0; i<10; i++)); do
13755 mkdir -p $migrate_dir/dir_${i}
13756 createmany -o $migrate_dir/dir_${i}/f 10 ||
13757 error "create files under remote dir failed $i"
13760 cp /etc/passwd $migrate_dir/$tfile
13761 cp /etc/passwd $other_dir/$tfile
13762 chattr +SAD $migrate_dir
13763 chattr +SAD $migrate_dir/$tfile
13765 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13766 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13767 local old_dir_mode=$(stat -c%f $migrate_dir)
13768 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13770 mkdir -p $migrate_dir/dir_default_stripe2
13771 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13772 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13774 mkdir -p $other_dir
13775 ln $migrate_dir/$tfile $other_dir/luna
13776 ln $migrate_dir/$tfile $migrate_dir/sofia
13777 ln $other_dir/$tfile $migrate_dir/david
13778 ln -s $migrate_dir/$tfile $other_dir/zachary
13779 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13780 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13782 $LFS migrate -m $MDTIDX $migrate_dir ||
13783 error "fails on migrating remote dir to MDT1"
13785 echo "migratate to MDT1, then checking.."
13786 for ((i = 0; i < 10; i++)); do
13787 for file in $(find $migrate_dir/dir_${i}); do
13788 mdt_index=$($LFS getstripe -M $file)
13789 [ $mdt_index == $MDTIDX ] ||
13790 error "$file is not on MDT${MDTIDX}"
13794 # the multiple link file should still in MDT0
13795 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13796 [ $mdt_index == 0 ] ||
13797 error "$file is not on MDT${MDTIDX}"
13799 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13800 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13801 error " expect $old_dir_flag get $new_dir_flag"
13803 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13804 [ "$old_file_flag" = "$new_file_flag" ] ||
13805 error " expect $old_file_flag get $new_file_flag"
13807 local new_dir_mode=$(stat -c%f $migrate_dir)
13808 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13809 error "expect mode $old_dir_mode get $new_dir_mode"
13811 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13812 [ "$old_file_mode" = "$new_file_mode" ] ||
13813 error "expect mode $old_file_mode get $new_file_mode"
13815 diff /etc/passwd $migrate_dir/$tfile ||
13816 error "$tfile different after migration"
13818 diff /etc/passwd $other_dir/luna ||
13819 error "luna different after migration"
13821 diff /etc/passwd $migrate_dir/sofia ||
13822 error "sofia different after migration"
13824 diff /etc/passwd $migrate_dir/david ||
13825 error "david different after migration"
13827 diff /etc/passwd $other_dir/zachary ||
13828 error "zachary different after migration"
13830 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13831 error "${tfile}_ln different after migration"
13833 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13834 error "${tfile}_ln_other different after migration"
13836 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13837 [ $stripe_count = 2 ] ||
13838 error "dir strpe_count $d != 2 after migration."
13840 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13841 [ $stripe_count = 2 ] ||
13842 error "file strpe_count $d != 2 after migration."
13844 #migrate back to MDT0
13847 $LFS migrate -m $MDTIDX $migrate_dir ||
13848 error "fails on migrating remote dir to MDT0"
13850 echo "migrate back to MDT0, checking.."
13851 for file in $(find $migrate_dir); do
13852 mdt_index=$($LFS getstripe -M $file)
13853 [ $mdt_index == $MDTIDX ] ||
13854 error "$file is not on MDT${MDTIDX}"
13857 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13858 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13859 error " expect $old_dir_flag get $new_dir_flag"
13861 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13862 [ "$old_file_flag" = "$new_file_flag" ] ||
13863 error " expect $old_file_flag get $new_file_flag"
13865 local new_dir_mode=$(stat -c%f $migrate_dir)
13866 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13867 error "expect mode $old_dir_mode get $new_dir_mode"
13869 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13870 [ "$old_file_mode" = "$new_file_mode" ] ||
13871 error "expect mode $old_file_mode get $new_file_mode"
13873 diff /etc/passwd ${migrate_dir}/$tfile ||
13874 error "$tfile different after migration"
13876 diff /etc/passwd ${other_dir}/luna ||
13877 error "luna different after migration"
13879 diff /etc/passwd ${migrate_dir}/sofia ||
13880 error "sofia different after migration"
13882 diff /etc/passwd ${other_dir}/zachary ||
13883 error "zachary different after migration"
13885 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13886 error "${tfile}_ln different after migration"
13888 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13889 error "${tfile}_ln_other different after migration"
13891 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13892 [ $stripe_count = 2 ] ||
13893 error "dir strpe_count $d != 2 after migration."
13895 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13896 [ $stripe_count = 2 ] ||
13897 error "file strpe_count $d != 2 after migration."
13899 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13901 run_test 230b "migrate directory"
13904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13905 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13906 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13910 local migrate_dir=$DIR/$tdir/migrate_dir
13912 #If migrating directory fails in the middle, all entries of
13913 #the directory is still accessiable.
13914 test_mkdir $DIR/$tdir
13915 test_mkdir -i0 -c1 $migrate_dir
13917 createmany -o $migrate_dir/f 10 ||
13918 error "create files under ${migrate_dir} failed"
13920 #failed after migrating 5 entries
13921 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13922 do_facet mds1 lctl set_param fail_loc=0x20001801
13923 do_facet mds1 lctl set_param fail_val=5
13924 local t=$(ls $migrate_dir | wc -l)
13925 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13926 error "migrate should fail after 5 entries"
13928 mkdir $migrate_dir/dir &&
13929 error "mkdir succeeds under migrating directory"
13930 touch $migrate_dir/file &&
13931 error "touch file succeeds under migrating directory"
13933 local u=$(ls $migrate_dir | wc -l)
13934 [ "$u" == "$t" ] || error "$u != $t during migration"
13936 for file in $(find $migrate_dir); do
13937 stat $file || error "stat $file failed"
13940 do_facet mds1 lctl set_param fail_loc=0
13941 do_facet mds1 lctl set_param fail_val=0
13943 $LFS migrate -m $MDTIDX $migrate_dir ||
13944 error "migrate open files should failed with open files"
13946 echo "Finish migration, then checking.."
13947 for file in $(find $migrate_dir); do
13948 mdt_index=$($LFS getstripe -M $file)
13949 [ $mdt_index == $MDTIDX ] ||
13950 error "$file is not on MDT${MDTIDX}"
13953 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13955 run_test 230c "check directory accessiblity if migration is failed"
13958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13959 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13962 local migrate_dir=$DIR/$tdir/migrate_dir
13966 test_mkdir $DIR/$tdir
13967 test_mkdir -i0 -c1 $migrate_dir
13969 for ((i=0; i<100; i++)); do
13970 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13971 createmany -o $migrate_dir/dir_${i}/f 100 ||
13972 error "create files under remote dir failed $i"
13975 $LFS migrate -m $MDTIDX $migrate_dir ||
13976 error "migrate remote dir error"
13978 echo "Finish migration, then checking.."
13979 for file in $(find $migrate_dir); do
13980 mdt_index=$($LFS getstripe -M $file)
13981 [ $mdt_index == $MDTIDX ] ||
13982 error "$file is not on MDT${MDTIDX}"
13985 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13987 run_test 230d "check migrate big directory"
13990 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13991 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13997 mkdir -p $DIR/$tdir
13998 mkdir $DIR/$tdir/migrate_dir
13999 mkdir $DIR/$tdir/other_dir
14000 touch $DIR/$tdir/migrate_dir/a
14001 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
14002 ls $DIR/$tdir/other_dir
14004 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14005 error "migrate dir fails"
14007 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14008 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14010 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14011 [ $mdt_index == 0 ] || error "a is not on MDT0"
14013 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
14014 error "migrate dir fails"
14016 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
14017 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
14019 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14020 [ $mdt_index == 1 ] || error "a is not on MDT1"
14022 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
14023 [ $mdt_index == 1 ] || error "b is not on MDT1"
14025 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14026 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
14028 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
14030 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14032 run_test 230e "migrate mulitple local link files"
14035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14036 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14040 mkdir -p $DIR/$tdir
14041 mkdir $DIR/$tdir/migrate_dir
14042 $LFS mkdir -i1 $DIR/$tdir/other_dir
14043 touch $DIR/$tdir/migrate_dir/a
14044 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
14045 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
14046 ls $DIR/$tdir/other_dir
14048 # a should be migrated to MDT1, since no other links on MDT0
14049 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14050 error "#1 migrate dir fails"
14051 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14052 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14053 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14054 [ $mdt_index == 1 ] || error "a is not on MDT1"
14056 # a should stay on MDT1, because it is a mulitple link file
14057 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14058 error "#2 migrate dir fails"
14059 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14060 [ $mdt_index == 1 ] || error "a is not on MDT1"
14062 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14063 error "#3 migrate dir fails"
14065 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14066 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
14067 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
14069 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
14070 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
14072 # a should be migrated to MDT0, since no other links on MDT1
14073 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14074 error "#4 migrate dir fails"
14075 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14076 [ $mdt_index == 0 ] || error "a is not on MDT0"
14078 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14080 run_test 230f "migrate mulitple remote link files"
14083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14086 mkdir -p $DIR/$tdir/migrate_dir
14088 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
14089 error "migrating dir to non-exist MDT succeeds"
14092 run_test 230g "migrate dir to non-exist MDT"
14095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14096 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14097 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
14098 skip "Need MDS version at least 2.7.64" && return
14101 mkdir -p $DIR/$tdir/migrate_dir
14103 $LFS migrate -m1 $DIR &&
14104 error "migrating mountpoint1 should fail"
14106 $LFS migrate -m1 $DIR/$tdir/.. &&
14107 error "migrating mountpoint2 should fail"
14109 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
14110 error "migrating $tdir fail"
14112 mdt_index=$($LFS getstripe -M $DIR/$tdir)
14113 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14115 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14116 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14119 run_test 230h "migrate .. and root"
14122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14123 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14125 mkdir -p $DIR/$tdir/migrate_dir
14127 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
14128 error "migration fails with a tailing slash"
14130 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14131 error "migration fails with two tailing slashes"
14133 run_test 230i "lfs migrate -m tolerates trailing slashes"
14137 # For simplicity this test assumes that max_pages_per_rpc
14138 # is the same across all OSCs
14139 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14140 local bulk_size=$((max_pages * 4096))
14141 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14144 mkdir -p $DIR/$tdir
14145 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14146 error "failed to set stripe with -S ${brw_size}M option"
14148 # clear the OSC stats
14149 $LCTL set_param osc.*.stats=0 &>/dev/null
14152 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14153 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14154 oflag=direct &>/dev/null || error "dd failed"
14156 sync; sleep 1; sync # just to be safe
14157 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14158 if [ x$nrpcs != "x1" ]; then
14159 $LCTL get_param osc.*.stats
14160 error "found $nrpcs ost_write RPCs, not 1 as expected"
14164 # Drop the OSC cache, otherwise we will read from it
14165 cancel_lru_locks osc
14167 # clear the OSC stats
14168 $LCTL set_param osc.*.stats=0 &>/dev/null
14170 # Client reads $bulk_size.
14171 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14172 iflag=direct &>/dev/null || error "dd failed"
14174 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14175 if [ x$nrpcs != "x1" ]; then
14176 $LCTL get_param osc.*.stats
14177 error "found $nrpcs ost_read RPCs, not 1 as expected"
14180 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14183 mkdir -p $DIR/$tdir
14185 for i in {0..1023}; do
14186 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14187 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14188 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14192 run_test 231b "must not assert on fully utilized OST request buffer"
14195 mkdir -p $DIR/$tdir
14196 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14197 $LCTL set_param fail_loc=0x31c
14199 # ignore dd failure
14200 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
14202 $LCTL set_param fail_loc=0
14203 umount_client $MOUNT || error "umount failed"
14204 mount_client $MOUNT || error "mount failed"
14206 run_test 232 "failed lock should not block umount"
14209 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14210 { skip "Need MDS version at least 2.3.64"; return; }
14211 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14213 local fid=$($LFS path2fid $MOUNT)
14214 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14215 error "cannot access $MOUNT using its FID '$fid'"
14217 run_test 233a "checking that OBF of the FS root succeeds"
14220 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14221 { skip "Need MDS version at least 2.5.90"; return; }
14222 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14224 local fid=$($LFS path2fid $MOUNT/.lustre)
14225 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14226 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14228 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14229 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14230 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14232 run_test 233b "checking that OBF of the FS .lustre succeeds"
14235 local p="$TMP/sanityN-$TESTNAME.parameters"
14236 save_lustre_params client "llite.*.xattr_cache" > $p
14237 lctl set_param llite.*.xattr_cache 1 ||
14238 { skip "xattr cache is not supported"; return 0; }
14240 mkdir -p $DIR/$tdir || error "mkdir failed"
14241 touch $DIR/$tdir/$tfile || error "touch failed"
14242 # OBD_FAIL_LLITE_XATTR_ENOMEM
14243 $LCTL set_param fail_loc=0x1405
14244 # output of the form: attr 2 4 44 3 fc13 x86_64
14245 V=($(IFS=".-" rpm -q attr))
14246 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
14247 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
14248 # attr pre-2.4.44-7 had a bug with rc
14249 # LU-3703 - SLES 11 and FC13 clients have older attr
14250 getfattr -n user.attr $DIR/$tdir/$tfile &&
14251 error "getfattr should have failed with ENOMEM"
14253 skip "LU-3703: attr version $(getfattr --version) too old"
14255 $LCTL set_param fail_loc=0x0
14258 restore_lustre_params < $p
14261 run_test 234 "xattr cache should not crash on ENOMEM"
14264 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14265 skip "Need MDS version at least 2.4.52" && return
14266 flock_deadlock $DIR/$tfile
14271 124) error "process hangs on a deadlock"
14273 *) error "error executing flock_deadlock $DIR/$tfile"
14277 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14281 check_swap_layouts_support && return 0
14282 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
14284 local ref1=/etc/passwd
14285 local ref2=/etc/group
14286 local file1=$DIR/$tdir/f1
14287 local file2=$DIR/$tdir/f2
14289 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14290 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14291 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14292 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14293 local fd=$(free_fd)
14294 local cmd="exec $fd<>$file2"
14297 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14298 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14301 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14306 run_test 236 "Layout swap on open unlinked file"
14308 # test to verify file handle related system calls
14309 # (name_to_handle_at/open_by_handle_at)
14310 # The new system calls are supported in glibc >= 2.14.
14313 echo "Test file_handle syscalls" > $DIR/$tfile ||
14314 error "write failed"
14315 check_fhandle_syscalls $DIR/$tfile ||
14316 error "check_fhandle_syscalls failed"
14318 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14320 # LU-4659 linkea consistency
14322 local server_version=$(lustre_version_code $SINGLEMDS)
14324 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14325 [[ $server_version -gt $(version_code 2.5.1) &&
14326 $server_version -lt $(version_code 2.5.50) ]] ||
14327 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14330 ln $DIR/$tfile $DIR/$tfile.lnk
14331 touch $DIR/$tfile.new
14332 mv $DIR/$tfile.new $DIR/$tfile
14333 local fid1=$($LFS path2fid $DIR/$tfile)
14334 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14335 local path1=$($LFS fid2path $FSNAME "$fid1")
14336 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14337 local path2=$($LFS fid2path $FSNAME "$fid2")
14338 [ $tfile.lnk == $path2 ] ||
14339 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14342 run_test 238 "Verify linkea consistency"
14345 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14346 skip "Need MDS version at least 2.5.60" && return
14347 local list=$(comma_list $(mdts_nodes))
14349 mkdir -p $DIR/$tdir
14350 createmany -o $DIR/$tdir/f- 5000
14351 unlinkmany $DIR/$tdir/f- 5000
14352 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.1) ] &&
14353 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14354 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14355 osp.*MDT*.sync_in_flight" | calc_sum)
14356 [ "$changes" -eq 0 ] || error "$changes not synced"
14358 run_test 239 "osp_sync test"
14360 test_239a() { #LU-5297
14361 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14363 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14364 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14365 chgrp $RUNAS_GID $DIR/$tfile
14366 wait_delete_completed
14368 run_test 239a "process invalid osp sync record correctly"
14370 test_239b() { #LU-5297
14371 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14373 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14374 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14375 chgrp $RUNAS_GID $DIR/$tfile1
14376 wait_delete_completed
14377 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14379 chgrp $RUNAS_GID $DIR/$tfile2
14380 wait_delete_completed
14382 run_test 239b "process osp sync record with ENOMEM error correctly"
14385 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14386 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14388 mkdir -p $DIR/$tdir
14390 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14391 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14392 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14393 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14395 umount_client $MOUNT || error "umount failed"
14396 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14397 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14398 mount_client $MOUNT || error "failed to mount client"
14400 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14401 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14403 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14406 for LOOP in $(seq $1); do
14407 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14408 cancel_lru_locks osc || true
14413 for LOOP in $(seq $1); do
14414 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14415 iflag=direct 2>/dev/null
14419 test_241a() { # was test_241
14420 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14422 cancel_lru_locks osc
14423 test_241_bio 1000 &
14428 run_test 241a "bio vs dio"
14431 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14433 test_241_dio 1000 &
14438 run_test 241b "dio vs dio"
14441 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14442 mkdir -p $DIR/$tdir
14443 touch $DIR/$tdir/$tfile
14445 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14446 do_facet mds1 lctl set_param fail_loc=0x105
14447 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14449 do_facet mds1 lctl set_param fail_loc=0
14450 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14452 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14456 test_mkdir -p $DIR/$tdir
14457 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14459 run_test 243 "various group lock tests"
14463 test_mkdir -p $DIR/$tdir
14464 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14465 sendfile_grouplock $DIR/$tdir/$tfile || \
14466 error "sendfile+grouplock failed"
14469 run_test 244 "sendfile with group lock tests"
14472 local flagname="multi_mod_rpcs"
14473 local connect_data_name="max_mod_rpcs"
14476 # check if multiple modify RPCs flag is set
14477 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14478 grep "connect_flags:")
14481 echo "$out" | grep -qw $flagname
14482 if [ $? -ne 0 ]; then
14483 echo "connect flag $flagname is not set"
14487 # check if multiple modify RPCs data is set
14488 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14491 echo "$out" | grep -qw $connect_data_name ||
14492 error "import should have connect data $connect_data_name"
14494 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14496 test_246() { # LU-7371
14497 remote_ost_nodsh && skip "remote OST with nodsh" && return
14498 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14499 skip "Need OST version >= 2.7.62" && return 0
14500 do_facet ost1 $LCTL set_param fail_val=4095
14501 #define OBD_FAIL_OST_READ_SIZE 0x234
14502 do_facet ost1 $LCTL set_param fail_loc=0x234
14503 $LFS setstripe $DIR/$tfile -i 0 -c 1
14504 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14505 cancel_lru_locks $FSNAME-OST0000
14506 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14508 run_test 246 "Read file of size 4095 should return right length"
14511 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14513 { skip "Fileset feature is not supported"; return; }
14515 local submount=${MOUNT}_$tdir
14518 mkdir -p $submount || error "mkdir $submount failed"
14519 FILESET="$FILESET/$tdir" mount_client $submount ||
14520 error "mount $submount failed"
14521 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14522 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14523 error "read $MOUNT/$tdir/$tfile failed"
14524 umount_client $submount || error "umount $submount failed"
14527 run_test 247a "mount subdir as fileset"
14530 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14531 { skip "Fileset feature is not supported"; return; }
14533 local submount=${MOUNT}_$tdir
14535 rm -rf $MOUNT/$tdir
14536 mkdir -p $submount || error "mkdir $submount failed"
14538 FILESET="$FILESET/$tdir" mount_client $submount &&
14539 error "mount $submount should fail"
14542 run_test 247b "mount subdir that dose not exist"
14545 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14546 { skip "Fileset feature is not supported"; return; }
14548 local submount=${MOUNT}_$tdir
14550 mkdir -p $MOUNT/$tdir/dir1
14551 mkdir -p $submount || error "mkdir $submount failed"
14552 FILESET="$FILESET/$tdir" mount_client $submount ||
14553 error "mount $submount failed"
14554 local fid=$($LFS path2fid $MOUNT/)
14555 $LFS fid2path $submount $fid && error "fid2path should fail"
14556 umount_client $submount || error "umount $submount failed"
14559 run_test 247c "running fid2path outside root"
14562 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14563 { skip "Fileset feature is not supported"; return; }
14565 local submount=${MOUNT}_$tdir
14567 mkdir -p $MOUNT/$tdir/dir1
14568 mkdir -p $submount || error "mkdir $submount failed"
14569 FILESET="$FILESET/$tdir" mount_client $submount ||
14570 error "mount $submount failed"
14571 local fid=$($LFS path2fid $submount/dir1)
14572 $LFS fid2path $submount $fid || error "fid2path should succeed"
14573 umount_client $submount || error "umount $submount failed"
14576 run_test 247d "running fid2path inside root"
14580 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14582 { skip "Fileset feature is not supported"; return; }
14584 local submount=${MOUNT}_$tdir
14587 mkdir -p $submount || error "mkdir $submount failed"
14588 FILESET="$FILESET/.." mount_client $submount &&
14589 error "mount $submount should fail"
14592 run_test 247e "mount .. as fileset"
14595 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14596 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14598 # create a large file for fast read verification
14599 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14601 # make sure the file is created correctly
14602 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14603 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14605 echo "Test 1: verify that fast read is 4 times faster on cache read"
14607 # small read with fast read enabled
14608 $LCTL set_param -n llite.*.fast_read=1
14609 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14610 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14611 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14612 # small read with fast read disabled
14613 $LCTL set_param -n llite.*.fast_read=0
14614 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14615 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14616 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14618 # verify that fast read is 4 times faster for cache read
14619 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14620 error_not_in_vm "fast read was not 4 times faster: " \
14621 "$t_fast vs $t_slow"
14623 echo "Test 2: verify the performance between big and small read"
14624 $LCTL set_param -n llite.*.fast_read=1
14626 # 1k non-cache read
14627 cancel_lru_locks osc
14628 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14629 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14630 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14632 # 1M non-cache read
14633 cancel_lru_locks osc
14634 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14635 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14636 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14638 # verify that big IO is not 4 times faster than small IO
14639 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14640 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14642 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14645 run_test 248 "fast read verification"
14647 test_249() { # LU-7890
14649 $SETSTRIPE -c 1 $DIR/$tfile
14651 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14652 skip "Need at least version 2.8.54"
14654 # Offset 2T == 4k * 512M
14655 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14656 error "dd to 2T offset failed"
14658 run_test 249 "Write above 2T file size"
14661 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14662 && skip "no 16TB file size limit on ZFS" && return
14664 $SETSTRIPE -c 1 $DIR/$tfile
14665 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14666 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14667 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14668 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14669 conv=notrunc,fsync && error "append succeeded"
14672 run_test 250 "Write above 16T limit"
14675 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14677 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14678 #Skip once - writing the first stripe will succeed
14679 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14680 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14681 error "short write happened"
14683 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14684 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14685 error "short read happened"
14689 run_test 251 "Handling short read and write correctly"
14699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14700 remote_ost_nodsh && skip "remote OST with nodsh" && return
14701 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14702 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14703 skip "ldiskfs only test"
14707 # check lr_reader on OST0000
14709 dev=$(facet_device $tgt)
14710 out=$(do_facet $tgt $LR_READER $dev)
14711 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14713 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14714 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14715 error "Invalid uuid returned by $LR_READER on target $tgt"
14716 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14718 # check lr_reader -c on MDT0000
14720 dev=$(facet_device $tgt)
14721 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14722 echo "$LR_READER does not support additional options"
14725 out=$(do_facet $tgt $LR_READER -c $dev)
14726 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14728 num=$(echo "$out" | grep -c "mdtlov")
14729 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14730 error "Invalid number of mdtlov clients returned by $LR_READER"
14731 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14733 # check lr_reader -cr on MDT0000
14734 out=$(do_facet $tgt $LR_READER -cr $dev)
14735 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14737 echo "$out" | grep -q "^reply_data:$" ||
14738 error "$LR_READER should have returned 'reply_data' section"
14739 num=$(echo "$out" | grep -c "client_generation")
14740 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14742 run_test 252 "check lr_reader tool"
14744 test_253_fill_ost() {
14745 local size_mb #how many MB should we write to pass watermark
14746 local lwm=$3 #low watermark
14747 local free_10mb #10% of free space
14749 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14750 size_mb=$((free_kb / 1024 - lwm))
14751 free_10mb=$((free_kb / 10240))
14752 #If 10% of free space cross low watermark use it
14753 if (( free_10mb > size_mb )); then
14756 #At least we need to store 1.1 of difference between
14757 #free space and low watermark
14758 size_mb=$((size_mb + size_mb / 10))
14760 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14761 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14762 oflag=append conv=notrunc
14767 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14768 echo "OST still has $((free_kb / 1024)) mbytes free"
14775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14776 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14777 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14779 local ost_name=$($LFS osts |
14780 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14782 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14783 do_facet $SINGLEMDS $LCTL get_param -n \
14784 osp.$mdtosc_proc1.reserved_mb_high ||
14785 { skip "remote MDS does not support reserved_mb_high" &&
14790 wait_delete_completed
14793 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14794 osp.$mdtosc_proc1.reserved_mb_high)
14795 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14796 osp.$mdtosc_proc1.reserved_mb_low)
14797 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14799 if ! combined_mgs_mds ; then
14802 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14803 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14804 error "Adding $ost_name to pool failed"
14806 # Wait for client to see a OST at pool
14807 wait_update $HOSTNAME "$LCTL get_param -n
14808 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14809 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14810 error "Client can not see the pool"
14811 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14812 error "Setstripe failed"
14814 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14815 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14816 echo "OST still has $((blocks/1024)) mbytes free"
14818 local new_lwm=$((blocks/1024-10))
14819 do_facet $SINGLEMDS $LCTL set_param \
14820 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14821 do_facet $SINGLEMDS $LCTL set_param \
14822 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14824 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14826 #First enospc could execute orphan deletion so repeat.
14827 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14829 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14830 osp.$mdtosc_proc1.prealloc_status)
14831 echo "prealloc_status $oa_status"
14833 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14834 error "File creation should fail"
14835 #object allocation was stopped, but we still able to append files
14836 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14837 error "Append failed"
14838 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14840 wait_delete_completed
14844 for i in $(seq 10 12); do
14845 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14846 error "File creation failed after rm";
14849 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14850 osp.$mdtosc_proc1.prealloc_status)
14851 echo "prealloc_status $oa_status"
14853 if (( oa_status != 0 )); then
14854 error "Object allocation still disable after rm"
14856 do_facet $SINGLEMDS $LCTL set_param \
14857 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14858 do_facet $SINGLEMDS $LCTL set_param \
14859 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14862 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14863 error "Remove $ost_name from pool failed"
14864 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14865 error "Pool destroy fialed"
14867 if ! combined_mgs_mds ; then
14871 run_test 253 "Check object allocation limit"
14876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14877 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14878 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14879 { skip "MDS does not support changelog_size" && return; }
14881 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14882 echo "Registered as changelog user $cl_user"
14884 $LFS changelog_clear $MDT0 $cl_user 0
14886 local size1=$(do_facet mds1 \
14887 $LCTL get_param -n mdd.$MDT0.changelog_size)
14888 echo "Changelog size $size1"
14891 $LFS mkdir -i 0 $DIR/$tdir
14893 mkdir -p $DIR/$tdir/pics/2008/zachy
14894 touch $DIR/$tdir/pics/2008/zachy/timestamp
14895 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
14896 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14897 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14898 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14899 rm $DIR/$tdir/pics/desktop.jpg
14901 local size2=$(do_facet mds1 \
14902 $LCTL get_param -n mdd.$MDT0.changelog_size)
14903 echo "Changelog size after work $size2"
14905 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14907 if (( size2 <= size1 )); then
14908 error "Changelog size after work should be greater than original"
14912 run_test 254 "Check changelog size"
14919 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
14920 awk -F: '{print $2}' | grep $type > /dev/null
14921 if [ $? -ne 0 ]; then
14931 lfs ladvise -a willread $file > /dev/null 2>&1
14932 if [ $? -eq 0 ]; then
14936 lfs ladvise -a willread $file 2>&1 |
14937 grep "Inappropriate ioctl for device" > /dev/null
14938 if [ $? -eq 0 ]; then
14945 bc <<<"scale=2; ($1 - $2) * 100 / $2"
14948 # run a random read IO workload
14949 # usage: random_read_iops <filename> <filesize> <iosize>
14950 random_read_iops() {
14953 local iosize=${3:-4096}
14955 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
14956 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
14959 drop_file_oss_cache() {
14963 $LFS ladvise -a dontneed $file 2>/dev/null ||
14964 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
14967 ladvise_willread_performance()
14970 local average_origin=0
14971 local average_cache=0
14972 local average_ladvise=0
14974 for ((i = 1; i <= $repeat; i++)); do
14975 echo "Iter $i/$repeat: reading without willread hint"
14976 cancel_lru_locks osc
14977 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14978 local speed_origin=$(random_read_iops $DIR/$tfile $size)
14979 echo "Iter $i/$repeat: uncached speed: $speed_origin"
14980 average_origin=$(bc <<<"$average_origin + $speed_origin")
14982 cancel_lru_locks osc
14983 local speed_cache=$(random_read_iops $DIR/$tfile $size)
14984 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
14985 average_cache=$(bc <<<"$average_cache + $speed_cache")
14987 cancel_lru_locks osc
14988 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14989 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
14990 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
14991 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
14992 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
14994 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
14995 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
14996 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
14998 speedup_cache=$(percent $average_cache $average_origin)
14999 speedup_ladvise=$(percent $average_ladvise $average_origin)
15001 echo "Average uncached read: $average_origin"
15002 echo "Average speedup with OSS cached read: " \
15003 "$average_cache = +$speedup_cache%"
15004 echo "Average speedup with ladvise willread: " \
15005 "$average_ladvise = +$speedup_ladvise%"
15007 local lowest_speedup=20
15008 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
15009 echo "Speedup with OSS cached read less than $lowest_speedup%, " \
15010 "got $average_cache%. Skipping ladvise willread check."
15014 # the test won't work on ZFS until it supports 'ladvise dontneed', but
15015 # it is still good to run until then to exercise 'ladvise willread'
15016 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15017 [ "$(facet_fstype ost1)" = "zfs" ] &&
15018 echo "osd-zfs does not support dontneed or drop_caches" &&
15021 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
15022 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
15023 error_not_in_vm "Speedup with willread is less than " \
15024 "$lowest_speedup%, got $average_ladvise%"
15028 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15029 skip "lustre < 2.8.54 does not support ladvise " && return
15030 remote_ost_nodsh && skip "remote OST with nodsh" && return
15032 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
15034 ladvise_no_type willread $DIR/$tfile &&
15035 skip "willread ladvise is not supported" && return
15037 ladvise_no_ioctl $DIR/$tfile &&
15038 skip "ladvise ioctl is not supported" && return
15041 local size=$((size_mb * 1048576))
15042 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15043 error "dd to $DIR/$tfile failed"
15045 lfs ladvise -a willread $DIR/$tfile ||
15046 error "Ladvise failed with no range argument"
15048 lfs ladvise -a willread -s 0 $DIR/$tfile ||
15049 error "Ladvise failed with no -l or -e argument"
15051 lfs ladvise -a willread -e 1 $DIR/$tfile ||
15052 error "Ladvise failed with only -e argument"
15054 lfs ladvise -a willread -l 1 $DIR/$tfile ||
15055 error "Ladvise failed with only -l argument"
15057 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
15058 error "End offset should not be smaller than start offset"
15060 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
15061 error "End offset should not be equal to start offset"
15063 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
15064 error "Ladvise failed with overflowing -s argument"
15066 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
15067 error "Ladvise failed with overflowing -e argument"
15069 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
15070 error "Ladvise failed with overflowing -l argument"
15072 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
15073 error "Ladvise succeeded with conflicting -l and -e arguments"
15075 echo "Synchronous ladvise should wait"
15077 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
15078 do_nodes $(comma_list $(osts_nodes)) \
15079 $LCTL set_param fail_val=$delay fail_loc=0x237
15081 local start_ts=$SECONDS
15082 lfs ladvise -a willread $DIR/$tfile ||
15083 error "Ladvise failed with no range argument"
15084 local end_ts=$SECONDS
15085 local inteval_ts=$((end_ts - start_ts))
15087 if [ $inteval_ts -lt $(($delay - 1)) ]; then
15088 error "Synchronous advice didn't wait reply"
15091 echo "Asynchronous ladvise shouldn't wait"
15092 local start_ts=$SECONDS
15093 lfs ladvise -a willread -b $DIR/$tfile ||
15094 error "Ladvise failed with no range argument"
15095 local end_ts=$SECONDS
15096 local inteval_ts=$((end_ts - start_ts))
15098 if [ $inteval_ts -gt $(($delay / 2)) ]; then
15099 error "Asynchronous advice blocked"
15102 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
15103 ladvise_willread_performance
15105 run_test 255a "check 'lfs ladvise -a willread'"
15111 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
15115 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15116 skip "lustre < 2.8.54 does not support ladvise " && return
15117 remote_ost_nodsh && skip "remote OST with nodsh" && return
15119 lfs setstripe -c 1 -i 0 $DIR/$tfile
15121 ladvise_no_type dontneed $DIR/$tfile &&
15122 skip "dontneed ladvise is not supported" && return
15124 ladvise_no_ioctl $DIR/$tfile &&
15125 skip "ladvise ioctl is not supported" && return
15127 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15128 skip "lustre < 2.8.54 does not support ladvise" && return
15130 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15131 [ "$(facet_fstype ost1)" = "zfs" ] &&
15132 skip "zfs-osd does not support 'ladvise dontneed'" && return
15135 local size=$((size_mb * 1048576))
15136 # In order to prevent disturbance of other processes, only check 3/4
15137 # of the memory usage
15138 local kibibytes=$((size_mb * 1024 * 3 / 4))
15140 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15141 error "dd to $DIR/$tfile failed"
15143 local total=$(facet_meminfo ost1 MemTotal)
15144 echo "Total memory: $total KiB"
15146 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15147 local before_read=$(facet_meminfo ost1 Cached)
15148 echo "Cache used before read: $before_read KiB"
15150 lfs ladvise -a willread $DIR/$tfile ||
15151 error "Ladvise willread failed"
15152 local after_read=$(facet_meminfo ost1 Cached)
15153 echo "Cache used after read: $after_read KiB"
15155 lfs ladvise -a dontneed $DIR/$tfile ||
15156 error "Ladvise dontneed again failed"
15157 local no_read=$(facet_meminfo ost1 Cached)
15158 echo "Cache used after dontneed ladvise: $no_read KiB"
15160 if [ $total -lt $((before_read + kibibytes)) ]; then
15161 echo "Memory is too small, abort checking"
15165 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15166 error "Ladvise willread should use more memory" \
15167 "than $kibibytes KiB"
15170 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15171 error "Ladvise dontneed should release more memory" \
15172 "than $kibibytes KiB"
15175 run_test 255b "check 'lfs ladvise -a dontneed'"
15182 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15183 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15184 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
15185 skip "ldiskfs only test" && return
15187 mdt_dev=$(mdsdevname 1)
15189 cl_user=$(do_facet mds1 \
15190 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
15191 if [[ -n $cl_user ]]; then
15192 skip "active changelog user"
15196 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15197 echo "Registered as changelog user $cl_user"
15200 mkdir -p $DIR/$tdir
15202 $LFS changelog_clear $MDT0 $cl_user 0
15205 touch $DIR/$tdir/{1..10}
15208 stop mds1 || error "Fail to stop MDT."
15211 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
15213 #after mount new plainllog is used
15214 touch $DIR/$tdir/{11..19}
15215 local TEMP256FILE=$(mktemp TEMP256XXXXXX)
15216 cat_sl=$(do_facet mds1 \
15217 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15218 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15221 if (( cat_sl != 2 )); then
15222 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15223 error "Changelog catalog has wrong number of slots $cat_sl"
15226 $LFS changelog_clear $MDT0 $cl_user 0
15228 TEMP256FILE=$(mktemp TEMP256XXXXXX)
15229 cat_sl=$(do_facet mds1 \
15230 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15231 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15234 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15236 if (( cat_sl == 2 )); then
15237 error "Empty plain llog was not deleted from changelog catalog"
15239 if (( cat_sl != 1 )); then
15240 error "Active plain llog shouldn\`t be deleted from catalog"
15243 run_test 256 "Check llog delete for empty and not full state"
15246 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15247 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15248 skip "Need MDS version at least 2.8.55" && return
15250 test_mkdir -p $DIR/$tdir
15252 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15253 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15256 #define OBD_FAIL_MDS_XATTR_REP 0x161
15257 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15258 local facet=mds$((mdtidx + 1))
15259 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15260 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15262 stop $facet || error "stop MDS failed"
15263 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15264 error "start MDS fail"
15266 run_test 257 "xattr locks are not lost"
15268 # Verify we take the i_mutex when security requires it
15270 #define OBD_FAIL_IMUTEX_SEC 0x141c
15271 $LCTL set_param fail_loc=0x141c
15273 chmod u+s $DIR/$tfile
15274 chmod a+rwx $DIR/$tfile
15275 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15277 if [ $RC -ne 0 ]; then
15278 error "error, failed to take i_mutex, rc=$?"
15284 # Verify we do NOT take the i_mutex in the normal case
15286 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15287 $LCTL set_param fail_loc=0x141d
15290 chmod a+rw $DIR/$tfile
15291 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15293 if [ $RC -ne 0 ]; then
15294 error "error, took i_mutex unnecessarily, rc=$?"
15299 run_test 258b "verify i_mutex security behavior"
15302 #define OBD_FAIL_MDC_CLOSE 0x806
15303 $LCTL set_param fail_loc=0x80000806
15307 run_test 260 "Check mdc_close fail"
15310 remote_ost_nodsh && skip "remote OST with nodsh" && return
15311 [ $(lustre_version_code ost1) -lt $(version_code 2.10.1) ] &&
15312 skip "Need OST version >= 2.10.1" && return 0
15314 local file=$DIR/$tfile
15317 oss=$(comma_list $(osts_nodes))
15319 dd if=/dev/urandom of=$file bs=1M count=2 ||
15320 error "failed to create a file"
15321 cancel_lru_locks osc
15324 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
15325 error "failed to read a file"
15327 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
15328 $LCTL set_param fail_loc=0x8000031f
15330 cancel_lru_locks osc &
15333 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
15334 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
15335 #IO takes another lock, but matches the PENDING one
15336 #and places it to the IO RPC
15337 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
15338 error "failed to read a file with PENDING lock"
15340 run_test 275 "Read on a canceled duplicate lock"
15343 remote_ost_nodsh && skip "remote OST with nodsh" && return
15346 do_facet ost1 "(while true; do \
15347 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
15348 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
15351 for LOOP in $(seq 20); do
15353 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
15356 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
15357 rm $TMP/sanity_276_pid"
15359 run_test 276 "Race between mount and obd_statfs"
15361 cleanup_test_300() {
15365 test_striped_dir() {
15370 mkdir -p $DIR/$tdir
15372 SAVE_UMASK=$(umask)
15373 trap cleanup_test_300 RETURN EXIT
15375 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
15376 $DIR/$tdir/striped_dir ||
15377 error "set striped dir error"
15379 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
15380 [ "$mode" = "755" ] || error "expect 755 got $mode"
15382 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
15383 error "getdirstripe failed"
15384 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
15385 if [ "$stripe_count" != "2" ]; then
15386 error "1:stripe_count is $stripe_count, expect 2"
15388 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
15389 if [ "$stripe_count" != "2" ]; then
15390 error "2:stripe_count is $stripe_count, expect 2"
15393 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
15394 if [ "$stripe_index" != "$mdt_index" ]; then
15395 error "stripe_index is $stripe_index, expect $mdt_index"
15398 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15399 error "nlink error after create striped dir"
15401 mkdir $DIR/$tdir/striped_dir/a
15402 mkdir $DIR/$tdir/striped_dir/b
15404 stat $DIR/$tdir/striped_dir/a ||
15405 error "create dir under striped dir failed"
15406 stat $DIR/$tdir/striped_dir/b ||
15407 error "create dir under striped dir failed"
15409 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
15410 error "nlink error after mkdir"
15412 rmdir $DIR/$tdir/striped_dir/a
15413 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
15414 error "nlink error after rmdir"
15416 rmdir $DIR/$tdir/striped_dir/b
15417 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15418 error "nlink error after rmdir"
15420 chattr +i $DIR/$tdir/striped_dir
15421 createmany -o $DIR/$tdir/striped_dir/f 10 &&
15422 error "immutable flags not working under striped dir!"
15423 chattr -i $DIR/$tdir/striped_dir
15425 rmdir $DIR/$tdir/striped_dir ||
15426 error "rmdir striped dir error"
15434 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15435 skip "skipped for lustre < 2.7.0" && return
15436 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15437 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15439 test_striped_dir 0 || error "failed on striped dir on MDT0"
15440 test_striped_dir 1 || error "failed on striped dir on MDT0"
15442 run_test 300a "basic striped dir sanity test"
15445 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15446 skip "skipped for lustre < 2.7.0" && return
15447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15448 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15454 test_mkdir $DIR/$tdir || error "mkdir fail"
15455 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15456 error "set striped dir error"
15457 for ((i=0; i<10; i++)); do
15458 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
15460 touch $DIR/$tdir/striped_dir/file_$i ||
15461 error "touch error $i"
15462 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
15463 [ $mtime1 -eq $mtime2 ] &&
15464 error "mtime not change after create"
15466 rm -f $DIR/$tdir/striped_dir/file_$i ||
15467 error "unlink error $i"
15468 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
15469 [ $mtime2 -eq $mtime3 ] &&
15470 error "mtime did not change after unlink"
15474 run_test 300b "check ctime/mtime for striped dir"
15477 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15478 skip "skipped for lustre < 2.7.0" && return
15479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15480 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15483 mkdir -p $DIR/$tdir
15484 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
15485 error "set striped dir error"
15487 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
15488 error "chown striped dir failed"
15490 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
15491 error "create 5k files failed"
15493 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
15495 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
15499 run_test 300c "chown && check ls under striped directory"
15502 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15503 skip "skipped for lustre < 2.7.0" && return
15504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15505 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15509 mkdir -p $DIR/$tdir
15510 $SETSTRIPE -c 2 $DIR/$tdir
15512 #local striped directory
15513 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15514 error "set striped dir error"
15515 createmany -o $DIR/$tdir/striped_dir/f 10 ||
15516 error "create 10 files failed"
15518 #remote striped directory
15519 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
15520 error "set striped dir error"
15521 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
15522 error "create 10 files failed"
15524 for file in $(find $DIR/$tdir); do
15525 stripe_count=$($GETSTRIPE -c $file)
15526 [ $stripe_count -eq 2 ] ||
15527 error "wrong stripe $stripe_count for $file"
15532 run_test 300d "check default stripe under striped directory"
15535 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15536 skip "Need MDS version at least 2.7.55" && return
15537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15538 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15542 mkdir -p $DIR/$tdir
15544 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15545 error "set striped dir error"
15547 touch $DIR/$tdir/striped_dir/a
15548 touch $DIR/$tdir/striped_dir/b
15549 touch $DIR/$tdir/striped_dir/c
15551 mkdir $DIR/$tdir/striped_dir/dir_a
15552 mkdir $DIR/$tdir/striped_dir/dir_b
15553 mkdir $DIR/$tdir/striped_dir/dir_c
15555 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
15556 error "set striped adir under striped dir error"
15558 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
15559 error "set striped bdir under striped dir error"
15561 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
15562 error "set striped cdir under striped dir error"
15564 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
15565 error "rename dir under striped dir fails"
15567 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
15568 error "rename dir under different stripes fails"
15570 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
15571 error "rename file under striped dir should succeed"
15573 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
15574 error "rename dir under striped dir should succeed"
15578 run_test 300e "check rename under striped directory"
15581 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15582 skip "Need MDS version at least 2.7.55" && return
15583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15584 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15589 mkdir -p $DIR/$tdir
15591 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15592 error "set striped dir error"
15594 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
15595 error "set striped dir error"
15597 touch $DIR/$tdir/striped_dir/a
15598 mkdir $DIR/$tdir/striped_dir/dir_a
15599 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
15600 error "create striped dir under striped dir fails"
15602 touch $DIR/$tdir/striped_dir1/b
15603 mkdir $DIR/$tdir/striped_dir1/dir_b
15604 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
15605 error "create striped dir under striped dir fails"
15607 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
15608 error "rename dir under different striped dir should fail"
15610 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
15611 error "rename striped dir under diff striped dir should fail"
15613 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
15614 error "rename file under diff striped dirs fails"
15618 run_test 300f "check rename cross striped directory"
15620 test_300_check_default_striped_dir()
15623 local default_count=$2
15624 local default_index=$3
15627 local dir_stripe_index
15630 echo "checking $dirname $default_count $default_index"
15631 $LFS setdirstripe -D -c $default_count -i $default_index \
15632 -t all_char $DIR/$tdir/$dirname ||
15633 error "set default stripe on striped dir error"
15634 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
15635 [ $stripe_count -eq $default_count ] ||
15636 error "expect $default_count get $stripe_count for $dirname"
15638 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
15639 [ $stripe_index -eq $default_index ] ||
15640 error "expect $default_index get $stripe_index for $dirname"
15642 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
15643 error "create dirs failed"
15645 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
15646 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
15647 for dir in $(find $DIR/$tdir/$dirname/*); do
15648 stripe_count=$($LFS getdirstripe -c $dir)
15649 [ $stripe_count -eq $default_count ] ||
15650 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
15651 error "stripe count $default_count != $stripe_count for $dir"
15653 stripe_index=$($LFS getdirstripe -i $dir)
15654 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
15655 error "$stripe_index != $default_index for $dir"
15657 #check default stripe
15658 stripe_count=$($LFS getdirstripe -D -c $dir)
15659 [ $stripe_count -eq $default_count ] ||
15660 error "default count $default_count != $stripe_count for $dir"
15662 stripe_index=$($LFS getdirstripe -D -i $dir)
15663 [ $stripe_index -eq $default_index ] ||
15664 error "default index $default_index != $stripe_index for $dir"
15666 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
15670 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15671 skip "Need MDS version at least 2.7.55" && return
15672 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15678 mkdir $DIR/$tdir/normal_dir
15680 #Checking when client cache stripe index
15681 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
15682 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
15683 error "create striped_dir failed"
15685 mkdir $DIR/$tdir/striped_dir/dir1 ||
15686 error "create dir1 fails"
15687 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
15688 [ $stripe_index -eq 1 ] ||
15689 error "dir1 expect 1 got $stripe_index"
15691 $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
15692 error "create dir2 fails"
15693 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
15694 [ $stripe_index -eq 2 ] ||
15695 error "dir2 expect 2 got $stripe_index"
15697 #check default stripe count/stripe index
15698 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
15699 test_300_check_default_striped_dir normal_dir 1 0
15700 test_300_check_default_striped_dir normal_dir 2 1
15701 test_300_check_default_striped_dir normal_dir 2 -1
15703 #delete default stripe information
15704 echo "delete default stripeEA"
15705 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
15706 error "set default stripe on striped dir error"
15708 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
15709 for dir in $(find $DIR/$tdir/normal_dir/*); do
15710 stripe_count=$($LFS getdirstripe -c $dir)
15711 [ $stripe_count -eq 0 ] ||
15712 error "expect 1 get $stripe_count for $dir"
15713 stripe_index=$($LFS getdirstripe -i $dir)
15714 [ $stripe_index -eq 0 ] ||
15715 error "expect 0 get $stripe_index for $dir"
15718 run_test 300g "check default striped directory for normal directory"
15721 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15722 skip "Need MDS version at least 2.7.55" && return
15723 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15728 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
15729 $DIR/$tdir/striped_dir ||
15730 error "set striped dir error"
15732 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
15733 test_300_check_default_striped_dir striped_dir 1 0
15734 test_300_check_default_striped_dir striped_dir 2 1
15735 test_300_check_default_striped_dir striped_dir 2 -1
15737 #delete default stripe information
15738 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
15739 error "set default stripe on striped dir error"
15741 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
15742 for dir in $(find $DIR/$tdir/striped_dir/*); do
15743 stripe_count=$($LFS getdirstripe -c $dir)
15744 [ $stripe_count -eq 0 ] ||
15745 error "expect 1 get $stripe_count for $dir"
15748 run_test 300h "check default striped directory for striped directory"
15751 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15752 skip "Need MDS version at least 2.7.55" && return
15753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15754 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15760 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15761 error "set striped dir error"
15763 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15764 error "create files under striped dir failed"
15766 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
15767 error "set striped hashdir error"
15769 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
15770 error "create dir0 under hash dir failed"
15771 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
15772 error "create dir1 under hash dir failed"
15774 # unfortunately, we need to umount to clear dir layout cache for now
15775 # once we fully implement dir layout, we can drop this
15776 umount_client $MOUNT || error "umount failed"
15777 mount_client $MOUNT || error "mount failed"
15779 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
15780 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
15781 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
15783 #set the stripe to be unknown hash type
15784 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
15785 $LCTL set_param fail_loc=0x1901
15786 for ((i = 0; i < 10; i++)); do
15787 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
15788 error "stat f-$i failed"
15789 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
15792 touch $DIR/$tdir/striped_dir/f0 &&
15793 error "create under striped dir with unknown hash should fail"
15795 $LCTL set_param fail_loc=0
15797 umount_client $MOUNT || error "umount failed"
15798 mount_client $MOUNT || error "mount failed"
15802 run_test 300i "client handle unknown hash type striped directory"
15805 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15806 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15807 skip "Need MDS version at least 2.7.55" && return
15808 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15814 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
15815 $LCTL set_param fail_loc=0x1702
15816 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15817 error "set striped dir error"
15819 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15820 error "create files under striped dir failed"
15822 $LCTL set_param fail_loc=0
15824 rm -rf $DIR/$tdir || error "unlink striped dir fails"
15828 run_test 300j "test large update record"
15831 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15832 skip "Need MDS version at least 2.7.55" && return
15833 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15834 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15840 #define OBD_FAIL_LARGE_STRIPE 0x1703
15841 $LCTL set_param fail_loc=0x1703
15842 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
15843 error "set striped dir error"
15844 $LCTL set_param fail_loc=0
15846 $LFS getdirstripe $DIR/$tdir/striped_dir ||
15847 error "getstripeddir fails"
15848 rm -rf $DIR/$tdir/striped_dir ||
15849 error "unlink striped dir fails"
15853 run_test 300k "test large striped directory"
15856 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15857 skip "Need MDS version at least 2.7.55" && return
15858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15859 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15862 test_mkdir -p $DIR/$tdir/striped_dir
15863 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
15864 error "chown $RUNAS_ID failed"
15865 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
15866 error "set default striped dir failed"
15868 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
15869 $LCTL set_param fail_loc=0x80000158
15870 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
15872 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
15873 [ $stripe_index -eq 1 ] ||
15874 error "expect 1 get $stripe_index for $dir"
15876 run_test 300l "non-root user to create dir under striped dir with stale layout"
15879 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15880 skip "Need MDS version at least 2.7.55" && return
15881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15882 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
15884 mkdir -p $DIR/$tdir/striped_dir
15885 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
15886 error "set default stripes dir error"
15888 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
15890 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
15891 [ $stripe_count -eq 0 ] ||
15892 error "expect 0 get $stripe_count for a"
15894 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
15895 error "set default stripes dir error"
15897 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
15899 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
15900 [ $stripe_count -eq 0 ] ||
15901 error "expect 0 get $stripe_count for b"
15903 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
15904 error "set default stripes dir error"
15906 mkdir $DIR/$tdir/striped_dir/c &&
15907 error "default stripe_index is invalid, mkdir c should fails"
15909 rm -rf $DIR/$tdir || error "rmdir fails"
15911 run_test 300m "setstriped directory on single MDT FS"
15914 local list=$(comma_list $(mdts_nodes))
15917 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15921 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15922 skip "Need MDS version at least 2.7.55" && return
15923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15924 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15925 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15928 local list=$(comma_list $(mdts_nodes))
15930 trap cleanup_300n RETURN EXIT
15931 mkdir -p $DIR/$tdir
15932 chmod 777 $DIR/$tdir
15933 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
15934 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15935 error "create striped dir succeeds with gid=0"
15937 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15938 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
15939 error "create striped dir fails with gid=-1"
15941 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15942 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
15943 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15944 error "set default striped dir succeeds with gid=0"
15947 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15948 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
15949 error "set default striped dir fails with gid=-1"
15952 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15953 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
15954 error "create test_dir fails"
15955 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
15956 error "create test_dir1 fails"
15957 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
15958 error "create test_dir2 fails"
15961 run_test 300n "non-root user to create dir under striped dir with default EA"
15964 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15965 skip "Need MDS version at least 2.7.55" && return
15966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15967 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15971 mkdir -p $DIR/$tdir
15973 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
15974 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
15975 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
15976 skip "not enough free inodes $numfree1 $numfree2"
15980 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
15981 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
15982 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
15983 skip "not enough free space $numfree1 $numfree2"
15987 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
15988 error "setdirstripe fails"
15990 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
15991 error "create dirs fails"
15993 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
15994 ls $DIR/$tdir/striped_dir > /dev/null ||
15995 error "ls striped dir fails"
15996 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
15997 error "unlink big striped dir fails"
15999 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
16002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16003 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16004 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16006 mkdir -p $DIR/$tdir
16008 #define OBD_FAIL_OUT_ENOSPC 0x1704
16009 do_facet mds2 lctl set_param fail_loc=0x80001704
16010 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
16011 error "create striped directory should fail"
16013 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
16015 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
16018 run_test 300p "create striped directory without space"
16021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16022 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16024 local fd=$(free_fd)
16025 local cmd="exec $fd<$tdir"
16027 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
16030 trap "eval $cmd" EXIT
16031 cd $tdir || error "cd $tdir fails"
16032 rmdir ../$tdir || error "rmdir $tdir fails"
16033 mkdir local_dir && error "create dir succeeds"
16034 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
16038 run_test 300q "create remote directory under orphan directory"
16040 prepare_remote_file() {
16041 mkdir $DIR/$tdir/src_dir ||
16042 error "create remote source failed"
16044 cp /etc/hosts $DIR/$tdir/src_dir/a || error
16045 touch $DIR/$tdir/src_dir/a
16047 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
16048 error "create remote target dir failed"
16050 touch $DIR/$tdir/tgt_dir/b
16052 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
16053 error "rename dir cross MDT failed!"
16055 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
16056 error "src_child still exists after rename"
16058 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
16059 error "missing file(a) after rename"
16061 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
16062 error "diff after rename"
16066 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16068 local remote_file=$DIR/$tdir/tgt_dir/b
16070 mkdir -p $DIR/$tdir
16072 prepare_remote_file || error "prepare remote file failed"
16075 $OPENUNLINK $remote_file $remote_file || error
16076 $CHECKSTAT -a $remote_file || error
16078 run_test 310a "open unlink remote file"
16081 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16083 local remote_file=$DIR/$tdir/tgt_dir/b
16085 mkdir -p $DIR/$tdir
16087 prepare_remote_file || error "prepare remote file failed"
16089 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16090 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
16091 $CHECKSTAT -t file $remote_file || error "check file failed"
16093 run_test 310b "unlink remote file with multiple links while open"
16096 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
16097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16098 local remote_file=$DIR/$tdir/tgt_dir/b
16100 mkdir -p $DIR/$tdir
16102 prepare_remote_file || error "prepare remote file failed"
16104 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16105 multiop_bg_pause $remote_file O_uc ||
16106 error "mulitop failed for remote file"
16108 $MULTIOP $DIR/$tfile Ouc
16109 kill -USR1 $MULTIPID
16112 run_test 310c "open-unlink remote file with multiple links"
16116 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16117 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
16118 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
16119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16120 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16122 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16124 mkdir -p $DIR/$tdir
16125 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
16126 createmany -o $DIR/$tdir/$tfile. 1000
16128 # statfs data is not real time, let's just calculate it
16129 old_iused=$((old_iused + 1000))
16131 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
16132 osp.*OST0000*MDT0000.create_count")
16133 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
16134 osp.*OST0000*MDT0000.max_create_count")
16135 for idx in $(seq $MDSCOUNT); do
16136 do_facet mds$idx "lctl set_param -n \
16137 osp.*OST0000*MDT000?.max_create_count=0"
16140 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
16141 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
16142 [ $index -ne 0 ] || error "$tfile stripe index is 0"
16144 unlinkmany $DIR/$tdir/$tfile. 1000
16146 for idx in $(seq $MDSCOUNT); do
16147 do_facet mds$idx "lctl set_param -n \
16148 osp.*OST0000*MDT000?.max_create_count=$max_count"
16149 do_facet mds$idx "lctl set_param -n \
16150 osp.*OST0000*MDT000?.create_count=$count"
16154 for i in $(seq 120); do
16155 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16156 # system may be too busy to destroy all objs in time, use
16157 # a somewhat small value to not fail autotest
16158 [ $((old_iused - new_iused)) -gt 400 ] && break
16162 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
16163 [ $((old_iused - new_iused)) -gt 400 ] ||
16164 error "objs not destroyed after unlink"
16166 run_test 311 "disable OSP precreate, and unlink should destroy objs"
16173 local vdevdir=$(dirname $(facet_vdevice $ost))
16174 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
16175 local zfs_zapid=$(do_facet $ost $cmd |
16176 grep -w "/O/0/d$((objid%32))" -C 5 |
16177 awk '/Object/{getline; print $1}')
16178 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
16179 awk "/$objid = /"'{printf $3}')
16184 zfs_object_blksz() {
16188 local vdevdir=$(dirname $(facet_vdevice $ost))
16189 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
16190 local blksz=$(do_facet $ost $cmd $objid |
16191 awk '/dblk/{getline; printf $4}')
16193 case "${blksz: -1}" in
16194 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
16195 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
16202 test_312() { # LU-4856
16203 remote_ost_nodsh && skip "remote OST with nodsh" && return
16205 [ $(facet_fstype ost1) = "zfs" ] ||
16206 { skip "the test only applies to zfs" && return; }
16208 local max_blksz=$(do_facet ost1 \
16209 $ZFS get -p recordsize $(facet_device ost1) |
16210 awk '!/VALUE/{print $3}')
16211 local min_blksz=$(getconf PAGE_SIZE)
16213 # to make life a little bit easier
16214 $LFS mkdir -c 1 -i 0 $DIR/$tdir
16215 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16217 local tf=$DIR/$tdir/$tfile
16219 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16221 # Get ZFS object id
16222 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16224 # block size change by sequential over write
16226 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
16227 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
16229 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16230 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
16234 # block size change by sequential append write
16235 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
16236 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16237 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16239 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
16240 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
16241 oflag=sync conv=notrunc
16243 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16244 [ $blksz -eq $((2 * count * min_blksz)) ] ||
16245 error "blksz error, actual $blksz, " \
16246 "expected: 2 * $count * $min_blksz"
16252 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16253 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16255 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
16256 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16257 [ $blksz -eq $min_blksz ] ||
16258 error "blksz error: $blksz, expected: $min_blksz"
16260 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
16261 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16262 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
16264 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
16265 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16266 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
16268 run_test 312 "make sure ZFS adjusts its block size by write pattern"
16271 remote_ost_nodsh && skip "remote OST with nodsh" && return
16273 local file=$DIR/$tfile
16275 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
16277 # define OBD_FAIL_TGT_RCVD_EIO 0x720
16278 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16279 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
16280 error "write should failed"
16281 do_facet ost1 "$LCTL set_param fail_loc=0"
16284 run_test 313 "io should fail after last_rcvd update fail"
16287 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16289 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
16290 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16292 wait_delete_completed
16293 do_facet ost1 "$LCTL set_param fail_loc=0"
16295 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
16297 test_315() { # LU-618
16298 local file=$DIR/$tfile
16301 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
16302 $MULTIOP $file oO_RDONLY:r4096000_c &
16307 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
16310 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
16313 run_test 315 "read should be accounted"
16316 local read_write=$1
16317 if [ "$read_write" = "write" ]; then
16318 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
16319 elif [ "$read_write" = "read" ]; then
16320 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
16322 error "argument error"
16325 # turn off debug for performance testing
16326 local saved_debug=$($LCTL get_param -n debug)
16327 $LCTL set_param debug=0
16329 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
16331 # get ost1 size - lustre-OST0000
16332 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
16333 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
16334 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
16336 if [ "$read_write" = "read" ]; then
16337 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
16340 local start_time=$(date +%s.%N)
16341 $dd_cmd bs=1M count=$blocks oflag=sync ||
16342 error "real dd $read_write error"
16343 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
16345 if [ "$read_write" = "write" ]; then
16349 # define OBD_FAIL_OST_FAKE_RW 0x238
16350 do_facet ost1 $LCTL set_param fail_loc=0x238
16352 local start_time=$(date +%s.%N)
16353 $dd_cmd bs=1M count=$blocks oflag=sync ||
16354 error "fake dd $read_write error"
16355 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
16357 if [ "$read_write" = "write" ]; then
16359 cancel_lru_locks osc
16360 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
16361 error "$tfile size not $blocks MB"
16363 do_facet ost1 $LCTL set_param fail_loc=0
16365 echo "fake $read_write $duration_fake vs. normal $read_write" \
16366 "$duration in seconds"
16367 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
16368 error_not_in_vm "fake write is slower"
16370 $LCTL set_param -n debug="$saved_debug"
16373 test_399a() { # LU-7655 for OST fake write
16374 remote_ost_nodsh && skip "remote OST with nodsh" && return
16378 run_test 399a "fake write should not be slower than normal write"
16380 test_399b() { # LU-8726 for OST fake read
16381 remote_ost_nodsh && skip "remote OST with nodsh" && return
16383 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
16384 skip "ldiskfs only test" && return 0
16388 run_test 399b "fake read should not be slower than normal read"
16390 test_400a() { # LU-1606, was conf-sanity test_74
16391 local extra_flags=''
16392 local out=$TMP/$tfile
16393 local prefix=/usr/include/lustre
16396 if ! which $CC > /dev/null 2>&1; then
16397 skip_env "$CC is not installed"
16401 if ! [[ -d $prefix ]]; then
16402 # Assume we're running in tree and fixup the include path.
16403 extra_flags+=" -I$LUSTRE/../libcfs/include"
16404 extra_flags+=" -I$LUSTRE/include"
16405 extra_flags+=" -L$LUSTRE/utils"
16408 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
16409 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
16410 error "client api broken"
16414 run_test 400a "Lustre client api program can compile and link"
16416 test_400b() { # LU-1606, LU-5011
16418 local out=$TMP/$tfile
16419 local prefix=/usr/include/lustre
16421 # We use a hard coded prefix so that this test will not fail
16422 # when run in tree. There are headers in lustre/include/lustre/
16423 # that are not packaged (like lustre_idl.h) and have more
16424 # complicated include dependencies (like config.h and lnet/types.h).
16425 # Since this test about correct packaging we just skip them when
16426 # they don't exist (see below) rather than try to fixup cppflags.
16428 if ! which $CC > /dev/null 2>&1; then
16429 skip_env "$CC is not installed"
16433 for header in $prefix/*.h; do
16434 if ! [[ -f "$header" ]]; then
16438 if [[ "$(basename $header)" == liblustreapi.h ]]; then
16439 continue # liblustreapi.h is deprecated.
16442 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
16443 error "cannot compile '$header'"
16447 run_test 400b "packaged headers can be compiled"
16449 test_401a() { #LU-7437
16450 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
16451 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
16453 #count the number of parameters by "list_param -R"
16454 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
16455 #count the number of parameters by listing proc files
16456 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
16457 echo "proc_dirs='$proc_dirs'"
16458 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
16459 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
16462 [ $params -eq $procs ] ||
16463 error "found $params parameters vs. $procs proc files"
16465 # test the list_param -D option only returns directories
16466 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
16467 #count the number of parameters by listing proc directories
16468 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
16471 [ $params -eq $procs ] ||
16472 error "found $params parameters vs. $procs proc files"
16474 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
16477 local save=$($LCTL get_param -n jobid_var)
16480 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
16481 error "no error returned when setting bad parameters"
16483 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
16484 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
16486 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
16487 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
16488 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
16490 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
16493 local jobid_var_old=$($LCTL get_param -n jobid_var)
16494 local jobid_var_new
16496 $LCTL set_param jobid_var= &&
16497 error "no error returned for 'set_param a='"
16499 jobid_var_new=$($LCTL get_param -n jobid_var)
16500 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16501 error "jobid_var was changed by setting without value"
16503 $LCTL set_param jobid_var &&
16504 error "no error returned for 'set_param a'"
16506 jobid_var_new=$($LCTL get_param -n jobid_var)
16507 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16508 error "jobid_var was changed by setting without value"
16510 run_test 401c "Verify 'lctl set_param' without value fails in either format."
16513 local jobid_var_old=$($LCTL get_param -n jobid_var)
16514 local jobid_var_new
16515 local new_value="foo=bar"
16517 $LCTL set_param jobid_var=$new_value ||
16518 error "'set_param a=b' did not accept a value containing '='"
16520 jobid_var_new=$($LCTL get_param -n jobid_var)
16521 [[ "$jobid_var_new" == "$new_value" ]] ||
16522 error "'set_param a=b' failed on a value containing '='"
16524 # Reset the jobid_var to test the other format
16525 $LCTL set_param jobid_var=$jobid_var_old
16526 jobid_var_new=$($LCTL get_param -n jobid_var)
16527 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16528 error "failed to reset jobid_var"
16530 $LCTL set_param jobid_var $new_value ||
16531 error "'set_param a b' did not accept a value containing '='"
16533 jobid_var_new=$($LCTL get_param -n jobid_var)
16534 [[ "$jobid_var_new" == "$new_value" ]] ||
16535 error "'set_param a b' failed on a value containing '='"
16537 $LCTL set_param jobid_var $jobid_var_old
16538 jobid_var_new=$($LCTL get_param -n jobid_var)
16539 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16540 error "failed to reset jobid_var"
16542 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
16545 local server_version=$(lustre_version_code $SINGLEMDS)
16546 [[ $server_version -ge $(version_code 2.7.66) ]] ||
16547 [[ $server_version -ge $(version_code 2.7.18.4) &&
16548 $server_version -lt $(version_code 2.7.50) ]] ||
16549 [[ $server_version -ge $(version_code 2.7.2) &&
16550 $server_version -lt $(version_code 2.7.11) ]] ||
16551 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
16553 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16554 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
16555 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
16556 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
16557 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
16558 echo "Touch failed - OK"
16560 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
16563 local file1=$DIR/$tfile.1
16564 local file2=$DIR/$tfile.2
16565 local tfile=$TMP/$tfile
16567 rm -f $file1 $file2 $tfile
16572 # 30 sec OBD_TIMEOUT in ll_getattr()
16573 # right before populating st_nlink
16574 $LCTL set_param fail_loc=0x80001409
16575 stat -c %h $file1 > $tfile &
16577 # create an alias, drop all locks and reclaim the dentry
16579 cancel_lru_locks mdc
16580 cancel_lru_locks osc
16581 sysctl -w vm.drop_caches=2
16585 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
16587 rm -f $tfile $file1 $file2
16589 run_test 403 "i_nlink should not drop to zero due to aliasing"
16591 test_404() { # LU-6601
16592 local server_version=$(lustre_version_code $SINGLEMDS)
16593 [[ $server_version -ge $(version_code 2.8.53) ]] ||
16594 { skip "Need server version newer than 2.8.52"; return 0; }
16596 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16597 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
16598 awk '/osp .*-osc-MDT/ { print $4}')
16601 for osp in $mosps; do
16602 echo "Deactivate: " $osp
16603 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
16604 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16605 awk -vp=$osp '$4 == p { print $2 }')
16606 [ $stat = IN ] || {
16607 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16608 error "deactivate error"
16610 echo "Activate: " $osp
16611 do_facet $SINGLEMDS $LCTL --device %$osp activate
16612 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16613 awk -vp=$osp '$4 == p { print $2 }')
16614 [ $stat = UP ] || {
16615 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16616 error "activate error"
16620 run_test 404 "validate manual {de}activated works properly for OSPs"
16623 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
16624 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
16625 skip "Layout swap lock is not supported" && return
16627 check_swap_layouts_support && return 0
16629 test_mkdir -p $DIR/$tdir
16630 swap_lock_test -d $DIR/$tdir ||
16631 error "One layout swap locked test failed"
16633 run_test 405 "Various layout swap lock tests"
16636 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16637 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16638 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
16639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16640 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
16641 skip "Need MDS version at least 2.8.50" && return
16643 local def_stripe_count=$($GETSTRIPE -c $MOUNT)
16644 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
16645 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
16646 local def_pool=$($GETSTRIPE -p $MOUNT)
16647 local test_pool=$TESTNAME
16649 if ! combined_mgs_mds ; then
16652 pool_add $test_pool || error "pool_add failed"
16653 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
16654 error "pool_add_targets failed"
16656 # parent set default stripe count only, child will stripe from both
16657 # parent and fs default
16658 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
16659 error "setstripe $MOUNT failed"
16660 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
16661 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
16662 for i in $(seq 10); do
16663 local f=$DIR/$tdir/$tfile.$i
16664 touch $f || error "touch failed"
16665 local count=$($GETSTRIPE -c $f)
16666 [ $count -eq $OSTCOUNT ] ||
16667 error "$f stripe count $count != $OSTCOUNT"
16668 local offset=$($GETSTRIPE -i $f)
16669 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
16670 local size=$($GETSTRIPE -S $f)
16671 [ $size -eq $((def_stripe_size * 2)) ] ||
16672 error "$f stripe size $size != $((def_stripe_size * 2))"
16673 local pool=$($GETSTRIPE -p $f)
16674 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
16677 # change fs default striping, delete parent default striping, now child
16678 # will stripe from new fs default striping only
16679 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
16680 error "change $MOUNT default stripe failed"
16681 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
16682 for i in $(seq 11 20); do
16683 local f=$DIR/$tdir/$tfile.$i
16684 touch $f || error "touch $f failed"
16685 local count=$($GETSTRIPE -c $f)
16686 [ $count -eq 1 ] || error "$f stripe count $count != 1"
16687 local offset=$($GETSTRIPE -i $f)
16688 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
16689 local size=$($GETSTRIPE -S $f)
16690 [ $size -eq $def_stripe_size ] ||
16691 error "$f stripe size $size != $def_stripe_size"
16692 local pool=$($GETSTRIPE -p $f)
16693 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
16697 unlinkmany $DIR/$tdir/$tfile. 1 20
16699 # restore FS default striping
16700 if [ -z $def_pool ]; then
16701 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16702 -i $def_stripe_offset $MOUNT ||
16703 error "restore default striping failed"
16705 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16706 -i $def_stripe_offset -p $def_pool $MOUNT ||
16707 error "restore default striping with $def_pool failed"
16710 local f=$DIR/$tdir/$tfile
16711 pool_remove_all_targets $test_pool $f
16712 pool_remove $test_pool $f
16714 if ! combined_mgs_mds ; then
16718 run_test 406 "DNE support fs default striping"
16721 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16722 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16723 skip "Need MDS version at least 2.8.55" && return
16724 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16726 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
16727 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
16728 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
16729 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
16730 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
16732 #define OBD_FAIL_DT_TXN_STOP 0x2019
16733 for idx in $(seq $MDSCOUNT); do
16734 do_facet mds$idx "lctl set_param fail_loc=0x2019"
16736 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
16737 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
16738 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
16741 run_test 407 "transaction fail should cause operation fail"
16744 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
16746 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
16747 lctl set_param fail_loc=0x8000040a
16748 # let ll_prepare_partial_page() fail
16749 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
16753 # create at least 100 unused inodes so that
16754 # shrink_icache_memory(0) should not return 0
16755 touch $DIR/$tfile-{0..100}
16756 rm -f $DIR/$tfile-{0..100}
16759 echo 2 > /proc/sys/vm/drop_caches
16761 run_test 408 "drop_caches should not hang due to page leaks"
16765 [ $MDSCOUNT -lt 2 ] &&
16766 skip "We need at least 2 MDTs for this test" && return
16768 check_mount_and_prep
16770 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
16771 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
16772 touch $DIR/$tdir/guard || error "(2) Fail to create"
16774 local PREFIX=$(str_repeat 'A' 128)
16775 echo "Create 1K hard links start at $(date)"
16776 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16777 error "(3) Fail to hard link"
16779 echo "Links count should be right although linkEA overflow"
16780 stat $DIR/$tdir/guard || error "(4) Fail to stat"
16781 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
16782 [ $linkcount -eq 1001 ] ||
16783 error "(5) Unexpected hard links count: $linkcount"
16785 echo "List all links start at $(date)"
16786 ls -l $DIR/$tdir/foo > /dev/null ||
16787 error "(6) Fail to list $DIR/$tdir/foo"
16789 echo "Unlink hard links start at $(date)"
16790 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16791 error "(7) Fail to unlink"
16793 run_test 409 "Large amount of cross-MDTs hard links on the same file"
16797 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
16798 skip "Need client version at least 2.9.59" && return
16800 # Create a file, and stat it from the kernel
16801 local testfile=$DIR/$tfile
16804 local run_id=$RANDOM
16805 local my_ino=$(stat --format "%i" $testfile)
16807 # Try to insert the module. This will always fail as the
16808 # module is designed to not be inserted.
16809 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
16812 # Anything but success is a test failure
16814 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
16815 error "no inode match"
16817 run_test 410 "Test inode number returned from kernel thread"
16820 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16821 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16822 skip "Need server version at least 2.9.55" & exit 0
16823 start_full_debug_logging
16827 stop_full_debug_logging
16831 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16832 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16833 awk '/The barrier for/ { print $7 }')
16836 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
16841 barrier_expired() {
16844 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16845 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16846 awk '/will be expired/ { print $7 }')
16848 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
16857 echo "Start barrier_freeze at: $(date)"
16858 #define OBD_FAIL_BARRIER_DELAY 0x2202
16859 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16860 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
16863 local b_status=$(barrier_stat)
16864 echo "Got barrier status at: $(date)"
16865 [ "$b_status" = "'freezing_p1'" ] ||
16866 error "(1) unexpected barrier status $b_status"
16868 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16870 b_status=$(barrier_stat)
16871 [ "$b_status" = "'frozen'" ] ||
16872 error "(2) unexpected barrier status $b_status"
16874 local expired=$(barrier_expired)
16875 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
16876 sleep $((expired + 3))
16878 b_status=$(barrier_stat)
16879 [ "$b_status" = "'expired'" ] ||
16880 error "(3) unexpected barrier status $b_status"
16882 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
16883 error "(4) fail to freeze barrier"
16885 b_status=$(barrier_stat)
16886 [ "$b_status" = "'frozen'" ] ||
16887 error "(5) unexpected barrier status $b_status"
16889 echo "Start barrier_thaw at: $(date)"
16890 #define OBD_FAIL_BARRIER_DELAY 0x2202
16891 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16892 do_facet mgs $LCTL barrier_thaw $FSNAME &
16895 b_status=$(barrier_stat)
16896 echo "Got barrier status at: $(date)"
16897 [ "$b_status" = "'thawing'" ] ||
16898 error "(6) unexpected barrier status $b_status"
16900 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16902 b_status=$(barrier_stat)
16903 [ "$b_status" = "'thawed'" ] ||
16904 error "(7) unexpected barrier status $b_status"
16906 #define OBD_FAIL_BARRIER_FAILURE 0x2203
16907 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
16908 do_facet mgs $LCTL barrier_freeze $FSNAME
16910 b_status=$(barrier_stat)
16911 [ "$b_status" = "'failed'" ] ||
16912 error "(8) unexpected barrier status $b_status"
16914 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16915 do_facet mgs $LCTL barrier_thaw $FSNAME
16919 run_test 801a "write barrier user interfaces and stat machine"
16924 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16925 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
16926 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
16927 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
16928 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
16930 cancel_lru_locks mdc
16932 # 180 seconds should be long enough
16933 do_facet mgs $LCTL barrier_freeze $FSNAME 180
16935 local b_status=$(barrier_stat)
16936 [ "$b_status" = "'frozen'" ] ||
16937 error "(6) unexpected barrier status $b_status"
16939 mkdir $DIR/$tdir/d0/d10 &
16942 touch $DIR/$tdir/d1/f13 &
16945 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
16948 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
16951 rm -f $DIR/$tdir/d4/f12 &
16954 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
16956 # To guarantee taht the 'stat' is not blocked
16957 b_status=$(barrier_stat)
16958 [ "$b_status" = "'frozen'" ] ||
16959 error "(8) unexpected barrier status $b_status"
16961 # let above commands to run at background
16964 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
16965 ps -p $touch_pid || error "(10) touch should be blocked"
16966 ps -p $ln_pid || error "(11) link should be blocked"
16967 ps -p $mv_pid || error "(12) rename should be blocked"
16968 ps -p $rm_pid || error "(13) unlink should be blocked"
16970 b_status=$(barrier_stat)
16971 [ "$b_status" = "'frozen'" ] ||
16972 error "(14) unexpected barrier status $b_status"
16974 do_facet mgs $LCTL barrier_thaw $FSNAME
16975 b_status=$(barrier_stat)
16976 [ "$b_status" = "'thawed'" ] ||
16977 error "(15) unexpected barrier status $b_status"
16979 wait $mkdir_pid || error "(16) mkdir should succeed"
16980 wait $touch_pid || error "(17) touch should succeed"
16981 wait $ln_pid || error "(18) link should succeed"
16982 wait $mv_pid || error "(19) rename should succeed"
16983 wait $rm_pid || error "(20) unlink should succeed"
16987 run_test 801b "modification will be blocked by write barrier"
16990 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
16994 stop mds2 || error "(1) Fail to stop mds2"
16996 do_facet mgs $LCTL barrier_freeze $FSNAME 30
16998 local b_status=$(barrier_stat)
16999 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
17000 do_facet mgs $LCTL barrier_thaw $FSNAME
17001 error "(2) unexpected barrier status $b_status"
17004 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17005 error "(3) Fail to rescan barrier bitmap"
17007 do_facet mgs $LCTL barrier_freeze $FSNAME 10
17009 b_status=$(barrier_stat)
17010 [ "$b_status" = "'frozen'" ] ||
17011 error "(4) unexpected barrier status $b_status"
17013 do_facet mgs $LCTL barrier_thaw $FSNAME
17014 b_status=$(barrier_stat)
17015 [ "$b_status" = "'thawed'" ] ||
17016 error "(5) unexpected barrier status $b_status"
17018 local devname=$(mdsdevname 2)
17020 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
17022 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17023 error "(7) Fail to rescan barrier bitmap"
17027 run_test 801c "rescan barrier bitmap"
17029 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
17030 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
17031 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
17037 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
17038 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
17039 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
17045 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17046 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17047 skip "Need server version at least 2.9.55" & exit 0
17049 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17051 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
17052 error "(2) Fail to copy"
17054 trap cleanup_802 EXIT
17056 # sync by force before remount as readonly
17057 sync; sync_all_data; sleep 3; sync_all_data
17061 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
17062 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
17063 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
17065 echo "Mount the server as read only"
17066 setupall server_only || error "(3) Fail to start servers"
17068 echo "Mount client without ro should fail"
17069 mount_client $MOUNT &&
17070 error "(4) Mount client without 'ro' should fail"
17072 echo "Mount client with ro should succeed"
17073 mount_client $MOUNT ro ||
17074 error "(5) Mount client with 'ro' should succeed"
17076 echo "Modify should be refused"
17077 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
17079 echo "Read should be allowed"
17080 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
17081 error "(7) Read should succeed under ro mode"
17085 run_test 802 "simulate readonly device"
17088 do_facet $SINGLEMDS zfs set quota=$old $fsset
17089 unlinkmany $DIR/$tdir/f- 1000000
17094 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
17095 [ "$(facet_fstype mds1)" != "zfs" ] &&
17096 skip "ZFS specific test" && return
17097 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
17098 skip "netfree not implemented before 0.7" && return
17099 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
17100 { skip "Need MDS version at least 2.10.57" && return 0; }
17107 local pref="osd-zfs.lustre-MDT0000."
17109 # limit available space on MDS dataset to meet nospace issue
17110 # quickly. then ZFS 0.7.2 can use reserved space if asked
17111 # properly (using netfree flag in osd_declare_destroy()
17112 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
17113 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
17115 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
17116 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
17117 let "usedkb=usedkb-freekb"
17118 let "freekb=freekb/2"
17119 if let "freekb > 5000"; then
17122 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
17123 trap cleanup_805 EXIT
17125 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
17126 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
17127 rm -rf $DIR/$tdir || error "not able to remove"
17128 do_facet $SINGLEMDS zfs set quota=$old $fsset
17131 run_test 805 "ZFS can remove from full fs"
17137 lctl set_param fail_loc=0x411
17138 dd if=/dev/urandom of=$DIR/$tfile bs=10240 count=2
17139 ORIG=$(md5sum $DIR/$tfile)
17140 lctl set_param ldlm.namespaces.*osc*.lru_size=clear
17141 CSUM=$(md5sum $DIR/$tfile)
17142 if [ "$ORIG" != "$CSUM" ]; then
17143 error "$ORIG != $CSUM"
17146 run_test 810 "partial page writes on ZFS (LU-11663)"
17149 # tests that do cleanup/setup should be run at the end
17153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17155 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
17156 $LCTL set_param fail_loc=0x903
17158 cancel_lru_locks MGC
17160 FAIL_ON_ERROR=true cleanup
17161 FAIL_ON_ERROR=true setup
17163 run_test 900 "umount should not race with any mgc requeue thread"
17166 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
17167 check_and_cleanup_lustre
17168 if [ "$I_MOUNTED" != "yes" ]; then
17169 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true