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.11.56) ] &&
699 skip "lustre < 2.11.56 does not support migrate -m "
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
2010 save_layout_restore_at_exit $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"
2022 run_test 27A "check filesystem-wide default LOV EA values"
2024 test_27B() { # LU-2523
2025 test_mkdir -p $DIR/$tdir
2026 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2028 # open f1 with O_LOV_DELAY_CREATE
2030 # call setstripe ioctl on open file descriptor for f1
2032 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2036 # open f1 with O_LOV_DELAY_CREATE
2038 # call setstripe ioctl on open file descriptor for f1
2040 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2042 # Allow multiop to fail in imitation of NFS's busted semantics.
2045 run_test 27B "call setstripe on open unlinked file/rename victim"
2047 test_27C() { #LU-2871
2048 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2056 test_mkdir -p $DIR/$tdir
2058 for i in $(seq 0 $((OSTCOUNT - 1))); do
2059 # set stripe across all OSTs starting from OST$i
2060 $SETSTRIPE -i $i -c -1 $tfile$i
2061 # get striping information
2062 ost_idx=($($GETSTRIPE $tfile$i |
2063 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2067 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2068 error "${#ost_idx[@]} != $OSTCOUNT"
2070 for index in $(seq 0 $((OSTCOUNT - 1))); do
2072 for j in $(echo ${ost_idx[@]}); do
2073 if [ $index -eq $j ]; then
2079 error "Can not find $index in ${ost_idx[@]}"
2083 run_test 27C "check full striping across all OSTs"
2086 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2087 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2088 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2089 local POOL=${POOL:-testpool}
2091 local last_ost=$(($OSTCOUNT - 1))
2093 local ost_list=$(seq $first_ost $ost_step $last_ost)
2094 local ost_range="$first_ost $last_ost $ost_step"
2096 if ! combined_mgs_mds ; then
2100 test_mkdir -p $DIR/$tdir
2101 pool_add $POOL || error "pool_add failed"
2102 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2105 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2107 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2108 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2109 skip27D+=" -s 30,31"
2110 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2111 error "llapi_layout_test failed"
2113 destroy_test_pools || error "destroy test pools failed"
2115 if ! combined_mgs_mds ; then
2119 run_test 27D "validate llapi_layout API"
2121 # Verify that default_easize is increased from its initial value after
2122 # accessing a widely striped file.
2124 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2125 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2126 skip "client does not have LU-3338 fix" && return
2128 # 72 bytes is the minimum space required to store striping
2129 # information for a file striped across one OST:
2130 # (sizeof(struct lov_user_md_v3) +
2131 # sizeof(struct lov_user_ost_data_v1))
2133 $LCTL set_param -n llite.*.default_easize $min_easize ||
2134 error "lctl set_param failed"
2135 local easize=$($LCTL get_param -n llite.*.default_easize)
2137 [ $easize -eq $min_easize ] ||
2138 error "failed to set default_easize"
2140 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2141 error "setstripe failed"
2145 easize=$($LCTL get_param -n llite.*.default_easize)
2147 [ $easize -gt $min_easize ] ||
2148 error "default_easize not updated"
2150 run_test 27E "check that default extended attribute size properly increases"
2152 test_27F() { # LU-5346/LU-7975
2153 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2155 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2156 skip "Need MDS version at least 2.8.51" && return
2157 remote_ost_nodsh && skip "remote OST with nodsh" && return
2159 test_mkdir -p $DIR/$tdir
2161 $SETSTRIPE -c 2 $DIR/$tdir
2163 # stop all OSTs to reproduce situation for LU-7975 ticket
2164 for num in $(seq $OSTCOUNT); do
2168 # open/create f0 with O_LOV_DELAY_CREATE
2169 # truncate f0 to a non-0 size
2171 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2173 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2174 # open/write it again to force delayed layout creation
2175 cat /etc/hosts > $DIR/$tdir/f0 &
2179 for num in $(seq $OSTCOUNT); do
2180 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2181 error "ost$num failed to start"
2184 wait $catpid || error "cat failed"
2186 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2187 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2190 run_test 27F "Client resend delayed layout creation with non-zero size"
2192 test_27G() { #LU-10629
2193 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2194 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2195 local POOL=${POOL:-testpool}
2196 local ostrange="0 0 1"
2198 test_mkdir $DIR/$tdir
2199 pool_add $POOL || error "pool_add failed"
2200 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2201 $LFS setstripe -p $POOL $DIR/$tdir
2203 local pool=$($LFS getstripe -p $DIR/$tdir)
2205 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2207 $LFS setstripe -d $DIR/$tdir
2209 pool=$($LFS getstripe -p $DIR/$tdir)
2213 [ -z "$pool" ] || error "'$pool' is not empty"
2215 run_test 27G "Clear OST pool from stripe"
2217 # createtest also checks that device nodes are created and
2218 # then visible correctly (#2091)
2219 test_28() { # bug 2091
2221 $CREATETEST $DIR/d28/ct || error
2223 run_test 28 "create/mknod/mkdir with bad file types ============"
2226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2227 sync; sleep 1; sync # flush out any dirty pages from previous tests
2234 declare -i LOCKCOUNTORIG=0
2235 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2236 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2238 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2240 declare -i LOCKUNUSEDCOUNTORIG=0
2241 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2242 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2249 declare -i LOCKCOUNTCURRENT=0
2250 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2251 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2254 declare -i LOCKUNUSEDCOUNTCURRENT=0
2255 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2256 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2259 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2260 $LCTL set_param -n ldlm.dump_namespaces ""
2261 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2262 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2263 log "dumped log to $TMP/test_29.dk (bug 5793)"
2266 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2267 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2268 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2269 log "dumped log to $TMP/test_29.dk (bug 5793)"
2273 run_test 29 "IT_GETATTR regression ============================"
2275 test_30a() { # was test_30
2276 cp $(which ls) $DIR || cp /bin/ls $DIR
2280 run_test 30a "execute binary from Lustre (execve) =============="
2283 cp `which ls` $DIR || cp /bin/ls $DIR
2285 $RUNAS $DIR/ls / || error
2288 run_test 30b "execute binary from Lustre as non-root ==========="
2290 test_30c() { # b=22376
2291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2292 cp `which ls` $DIR || cp /bin/ls $DIR
2294 cancel_lru_locks mdc
2295 cancel_lru_locks osc
2296 $RUNAS $DIR/ls / || error
2299 run_test 30c "execute binary from Lustre without read perms ===="
2302 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2303 $CHECKSTAT -a $DIR/f31 || error
2305 run_test 31a "open-unlink file =================================="
2308 touch $DIR/f31 || error
2309 ln $DIR/f31 $DIR/f31b || error
2310 $MULTIOP $DIR/f31b Ouc || error
2311 $CHECKSTAT -t file $DIR/f31 || error
2313 run_test 31b "unlink file with multiple links while open ======="
2316 touch $DIR/f31 || error
2317 ln $DIR/f31 $DIR/f31c || error
2318 multiop_bg_pause $DIR/f31 O_uc || return 1
2320 $MULTIOP $DIR/f31c Ouc
2321 kill -USR1 $MULTIPID
2324 run_test 31c "open-unlink file with multiple links ============="
2327 opendirunlink $DIR/d31d $DIR/d31d || error
2328 $CHECKSTAT -a $DIR/d31d || error
2330 run_test 31d "remove of open directory ========================="
2332 test_31e() { # bug 2904
2333 openfilleddirunlink $DIR/d31e || error
2335 run_test 31e "remove of open non-empty directory ==============="
2337 test_31f() { # bug 4554
2338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2340 test_mkdir $DIR/d31f
2341 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2342 cp /etc/hosts $DIR/d31f
2344 $GETSTRIPE $DIR/d31f/hosts
2345 multiop_bg_pause $DIR/d31f D_c || return 1
2348 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2349 test_mkdir $DIR/d31f
2350 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2351 cp /etc/hosts $DIR/d31f
2353 $GETSTRIPE $DIR/d31f/hosts
2354 multiop_bg_pause $DIR/d31f D_c || return 1
2357 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2358 wait $MULTIPID || error "first opendir $MULTIPID failed"
2362 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2363 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2366 run_test 31f "remove of open directory with open-unlink file ==="
2369 echo "-- cross directory link --"
2370 test_mkdir -c1 $DIR/${tdir}ga
2371 test_mkdir -c1 $DIR/${tdir}gb
2372 touch $DIR/${tdir}ga/f
2373 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2374 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2375 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2376 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2377 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2379 run_test 31g "cross directory link==============="
2382 echo "-- cross directory link --"
2383 test_mkdir -c1 $DIR/${tdir}
2384 test_mkdir -c1 $DIR/${tdir}/dir
2385 touch $DIR/${tdir}/f
2386 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2387 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2388 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2389 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2390 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2392 run_test 31h "cross directory link under child==============="
2395 echo "-- cross directory link --"
2396 test_mkdir -c1 $DIR/$tdir
2397 test_mkdir -c1 $DIR/$tdir/dir
2398 touch $DIR/$tdir/dir/f
2399 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2400 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2401 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2402 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2403 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2405 run_test 31i "cross directory link under parent==============="
2408 test_mkdir -c1 -p $DIR/$tdir
2409 test_mkdir -c1 -p $DIR/$tdir/dir1
2410 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2411 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2412 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2413 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2416 run_test 31j "link for directory==============="
2419 test_mkdir -c1 -p $DIR/$tdir
2421 touch $DIR/$tdir/exist
2422 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2423 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2424 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2425 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2426 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2427 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2428 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2431 run_test 31k "link to file: the same, non-existing, dir==============="
2437 touch $DIR/d31m2/exist
2438 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2439 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2440 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2441 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2442 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2443 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2446 run_test 31m "link to file: the same, non-existing, dir==============="
2449 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2450 nlink=$(stat --format=%h $DIR/$tfile)
2451 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2453 local cmd="exec $fd<$DIR/$tfile"
2456 trap "eval $cmd" EXIT
2457 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2458 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2459 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2460 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2461 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2464 run_test 31n "check link count of unlinked file"
2467 local TEMPNAME=$(mktemp $1_XXXXXX)
2468 mlink $TEMPNAME $1 2> /dev/null &&
2469 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2473 test_31o() { # LU-2901
2474 test_mkdir -p $DIR/$tdir
2475 for LOOP in $(seq 100); do
2476 rm -f $DIR/$tdir/$tfile*
2477 for THREAD in $(seq 8); do
2478 link_one $DIR/$tdir/$tfile.$LOOP &
2481 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2482 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2483 error "$LINKS duplicate links to $tfile.$LOOP" &&
2487 run_test 31o "duplicate hard links with same filename"
2490 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2492 test_mkdir $DIR/$tdir
2493 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2494 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2496 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2497 error "open unlink test1 failed"
2498 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2499 error "open unlink test2 failed"
2501 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2502 error "test1 still exists"
2503 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2504 error "test2 still exists"
2506 run_test 31p "remove of open striped directory"
2508 cleanup_test32_mount() {
2511 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2512 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2513 losetup -d $loopdev || true
2519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2520 echo "== more mountpoints and symlinks ================="
2521 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2522 trap cleanup_test32_mount EXIT
2523 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2524 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2525 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2526 cleanup_test32_mount
2528 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2532 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2533 trap cleanup_test32_mount EXIT
2534 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2535 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2536 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2537 cleanup_test32_mount
2539 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2543 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2544 trap cleanup_test32_mount EXIT
2545 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2546 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2547 test_mkdir -p $DIR/$tdir/d2/test_dir
2548 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2549 cleanup_test32_mount
2551 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2555 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2556 trap cleanup_test32_mount EXIT
2557 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2558 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2559 test_mkdir -p $DIR/$tdir/d2/test_dir
2560 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2561 cleanup_test32_mount
2563 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2566 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2567 test_mkdir -p $DIR/d32e/tmp
2568 TMP_DIR=$DIR/d32e/tmp
2569 ln -s $DIR/d32e $TMP_DIR/symlink11
2570 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2571 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2572 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2574 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2577 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2578 test_mkdir -p $DIR/d32f/tmp
2579 TMP_DIR=$DIR/d32f/tmp
2580 ln -s $DIR/d32f $TMP_DIR/symlink11
2581 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2582 ls $DIR/d32f/tmp/symlink11 || error
2583 ls $DIR/d32f/symlink01 || error
2585 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2588 TMP_DIR=$DIR/$tdir/tmp
2589 test_mkdir -p $DIR/$tdir/tmp
2590 test_mkdir $DIR/${tdir}2
2591 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2592 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2593 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2594 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2595 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2596 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2598 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2601 rm -fr $DIR/$tdir $DIR/${tdir}2
2602 TMP_DIR=$DIR/$tdir/tmp
2603 test_mkdir -p $DIR/$tdir/tmp
2604 test_mkdir $DIR/${tdir}2
2605 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2606 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2607 ls $TMP_DIR/symlink12 || error
2608 ls $DIR/$tdir/symlink02 || error
2610 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2614 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2615 trap cleanup_test32_mount EXIT
2616 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2617 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2618 touch $DIR/$tdir/test_file
2619 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2620 cleanup_test32_mount
2622 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2626 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2627 trap cleanup_test32_mount EXIT
2628 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2629 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2630 touch $DIR/$tdir/test_file
2631 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2632 cleanup_test32_mount
2634 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2637 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2639 trap cleanup_test32_mount EXIT
2640 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2641 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2642 test_mkdir -p $DIR/$tdir/d2
2643 touch $DIR/$tdir/d2/test_file || error
2644 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2645 cleanup_test32_mount
2647 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2652 trap cleanup_test32_mount EXIT
2653 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2654 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2655 test_mkdir -p $DIR/$tdir/d2
2656 touch $DIR/$tdir/d2/test_file
2657 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2658 cleanup_test32_mount
2660 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2664 test_mkdir -p $DIR/d32m/tmp
2665 TMP_DIR=$DIR/d32m/tmp
2666 ln -s $DIR $TMP_DIR/symlink11
2667 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2668 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2669 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2671 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2675 test_mkdir -p $DIR/d32n/tmp
2676 TMP_DIR=$DIR/d32n/tmp
2677 ln -s $DIR $TMP_DIR/symlink11
2678 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2679 ls -l $DIR/d32n/tmp/symlink11 || error
2680 ls -l $DIR/d32n/symlink01 || error
2682 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2686 test_mkdir -p $DIR/d32o/tmp
2687 TMP_DIR=$DIR/d32o/tmp
2688 ln -s $DIR/$tfile $TMP_DIR/symlink12
2689 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2690 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2691 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2692 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2693 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2695 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2705 test_mkdir -p $DIR/d32p/tmp
2707 TMP_DIR=$DIR/d32p/tmp
2709 ln -s $DIR/$tfile $TMP_DIR/symlink12
2711 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2713 cat $DIR/d32p/tmp/symlink12 || error
2715 cat $DIR/d32p/symlink02 || error
2718 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2722 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2723 trap cleanup_test32_mount EXIT
2724 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2725 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2726 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2727 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2728 cleanup_test32_mount
2730 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2734 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2735 trap cleanup_test32_mount EXIT
2736 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2737 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2738 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2739 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2740 cleanup_test32_mount
2742 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2747 chmod 444 $DIR/$tfile
2748 chown $RUNAS_ID $DIR/$tfile
2750 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2753 run_test 33aa "write file with mode 444 (should return error) ===="
2757 test_mkdir -p $DIR/d33
2758 chown $RUNAS_ID $DIR/d33
2759 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2760 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2761 error "open RDWR" || true
2763 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2767 test_mkdir -p $DIR/d33
2768 chown $RUNAS_ID $DIR/d33
2769 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2771 run_test 33b "test open file with malformed flags (No panic)"
2774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2780 remote_ost_nodsh && skip "remote OST with nodsh" && return
2783 test_mkdir -p $DIR/d33
2784 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2787 for ostnum in $(seq $OSTCOUNT); do
2788 # test-framework's OST numbering is one-based, while Lustre's
2790 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2791 # Parsing llobdstat's output sucks; we could grep the /proc
2792 # path, but that's likely to not be as portable as using the
2793 # llobdstat utility. So we parse lctl output instead.
2794 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2795 obdfilter/$ostname/stats |
2796 awk '/^write_bytes/ {print $7}' )
2797 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2798 if (( ${write_bytes:-0} > 0 ))
2805 $all_zeros || return 0
2808 echo foo > $DIR/d33/bar
2812 # Total up write_bytes after writing. We'd better find non-zeros.
2813 for ostnum in $(seq $OSTCOUNT); do
2814 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2815 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2816 obdfilter/$ostname/stats |
2817 awk '/^write_bytes/ {print $7}' )
2818 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2819 if (( ${write_bytes:-0} > 0 ))
2828 for ostnum in $(seq $OSTCOUNT); do
2829 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2830 echo "Check that write_bytes is present in obdfilter/*/stats:"
2831 do_facet ost$ostnum lctl get_param -n \
2832 obdfilter/$ostname/stats
2834 error "OST not keeping write_bytes stats (b22312)"
2837 run_test 33c "test llobdstat and write_bytes"
2840 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2841 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2843 local remote_dir=$DIR/$tdir/remote_dir
2845 test_mkdir -p $DIR/$tdir
2846 $LFS mkdir -i $MDTIDX $remote_dir ||
2847 error "create remote directory failed"
2849 touch $remote_dir/$tfile
2850 chmod 444 $remote_dir/$tfile
2851 chown $RUNAS_ID $remote_dir/$tfile
2853 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2855 chown $RUNAS_ID $remote_dir
2856 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2857 error "create" || true
2858 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2859 error "open RDWR" || true
2860 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2862 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2865 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2869 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2870 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2871 mkdir $DIR/$tdir/local_dir
2873 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2874 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2875 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2877 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2878 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2880 rmdir $DIR/$tdir/* || error "rmdir failed"
2883 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2884 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2885 mkdir $DIR/$tdir/local_dir
2887 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2888 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2889 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2891 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2892 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2894 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2897 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2898 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2899 mkdir $DIR/$tdir/local_dir
2901 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2902 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2903 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2905 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2906 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2908 run_test 33e "mkdir and striped directory should have same mode"
2912 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2916 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2917 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2920 chmod go+rwx $DIR/$tdir
2921 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2922 trap cleanup_33f EXIT
2924 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2925 error "cannot create striped directory"
2927 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2928 error "cannot create files in striped directory"
2930 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2931 error "cannot remove files in striped directory"
2933 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2934 error "cannot remove striped directory"
2938 run_test 33f "nonroot user can create, access, and remove a striped directory"
2941 mkdir -p $DIR/$tdir/dir2
2943 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2945 [[ $err =~ "exists" ]] || error "Not exists error"
2947 run_test 33g "nonroot user create already existing root created file"
2949 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2952 $MCREATE $DIR/f34 || error
2953 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2954 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2955 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2956 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2958 run_test 34a "truncate file that has not been opened ==========="
2961 [ ! -f $DIR/f34 ] && test_34a
2962 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2963 $OPENFILE -f O_RDONLY $DIR/f34
2964 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2965 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2967 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2970 [ ! -f $DIR/f34 ] && test_34a
2971 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2972 $OPENFILE -f O_RDWR $DIR/f34
2973 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2974 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2976 run_test 34c "O_RDWR opening file-with-size works =============="
2979 [ ! -f $DIR/f34 ] && test_34a
2980 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2981 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2984 run_test 34d "write to sparse file ============================="
2988 $MCREATE $DIR/f34e || error
2989 $TRUNCATE $DIR/f34e 1000 || error
2990 $CHECKSTAT -s 1000 $DIR/f34e || error
2991 $OPENFILE -f O_RDWR $DIR/f34e
2992 $CHECKSTAT -s 1000 $DIR/f34e || error
2994 run_test 34e "create objects, some with size and some without =="
2996 test_34f() { # bug 6242, 6243
2997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3000 $MCREATE $DIR/f34f || error
3001 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3002 dd if=$DIR/f34f of=$TMP/f34f
3003 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3004 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3005 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3006 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3007 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3009 run_test 34f "read from a file with no objects until EOF ======="
3012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3013 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
3014 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
3015 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
3016 cancel_lru_locks osc
3017 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
3018 error "wrong size after lock cancel"
3020 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
3021 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
3022 error "expanding truncate failed"
3023 cancel_lru_locks osc
3024 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
3025 error "wrong expanded size after lock cancel"
3027 run_test 34g "truncate long file ==============================="
3030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3034 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
3035 sync # Flush the cache so that multiop below does not block on cache
3036 # flush when getting the group lock
3037 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3040 # Since just timed wait is not good enough, let's do a sync write
3041 # that way we are sure enough time for a roundtrip + processing
3042 # passed + 2 seconds of extra margin.
3043 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
3047 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3048 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3052 local nsz=`stat -c %s $DIR/$tfile`
3053 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3055 run_test 34h "ftruncate file under grouplock should not block"
3058 cp /bin/sh $DIR/f35a
3060 chown $RUNAS_ID $DIR/f35a
3061 $RUNAS $DIR/f35a && error || true
3064 run_test 35a "exec file with mode 444 (should return and not leak) ====="
3068 utime $DIR/f36 || error
3070 run_test 36a "MDS utime check (mknod, utime) ==================="
3074 utime $DIR/f36 || error
3076 run_test 36b "OST utime check (open, utime) ===================="
3081 chown $RUNAS_ID $DIR/d36
3082 $RUNAS utime $DIR/d36/f36 || error
3084 run_test 36c "non-root MDS utime check (mknod, utime) =========="
3087 [ ! -d $DIR/d36 ] && test_36c
3088 echo "" > $DIR/d36/f36
3089 $RUNAS utime $DIR/d36/f36 || error
3091 run_test 36d "non-root OST utime check (open, utime) ==========="
3094 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3095 test_mkdir -p $DIR/$tdir
3096 touch $DIR/$tdir/$tfile
3097 $RUNAS utime $DIR/$tdir/$tfile && \
3098 error "utime worked, expected failure" || true
3100 run_test 36e "utime on non-owned file (should return error) ===="
3104 local LANG_SAVE=$LANG
3105 local LC_LANG_SAVE=$LC_LANG
3106 export LANG=C LC_LANG=C # for date language
3108 DATESTR="Dec 20 2000"
3109 test_mkdir -p $DIR/$tdir
3110 lctl set_param fail_loc=$fl
3112 cp /etc/hosts $DIR/$tdir/$tfile
3113 sync & # write RPC generated with "current" inode timestamp, but delayed
3115 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3116 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3117 cancel_lru_locks osc
3118 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3120 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3121 echo "BEFORE: $LS_BEFORE" && \
3122 echo "AFTER : $LS_AFTER" && \
3123 echo "WANT : $DATESTR" && \
3124 error "$DIR/$tdir/$tfile timestamps changed" || true
3126 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3131 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3132 subr_36fh "0x80000214"
3134 run_test 36f "utime on file racing with OST BRW write =========="
3137 remote_ost_nodsh && skip "remote OST with nodsh" && return
3138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3143 test_mkdir -p $DIR/$tdir
3144 fmd_max_age=$(do_facet ost1 \
3145 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3148 fmd_before=$(do_facet ost1 \
3149 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3150 touch $DIR/$tdir/$tfile
3151 sleep $((fmd_max_age + 12))
3152 fmd_after=$(do_facet ost1 \
3153 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3155 echo "fmd_before: $fmd_before"
3156 echo "fmd_after: $fmd_after"
3157 [[ $fmd_after -gt $fmd_before ]] &&
3158 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3159 error "fmd didn't expire after ping" || true
3161 run_test 36g "filter mod data cache expiry ====================="
3164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3165 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3166 subr_36fh "0x80000227"
3168 run_test 36h "utime on file racing with OST BRW write =========="
3171 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3173 test_mkdir $DIR/$tdir
3174 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3176 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3177 local new_mtime=$((mtime + 200))
3179 #change Modify time of striped dir
3180 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3181 error "change mtime failed"
3183 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3185 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3187 run_test 36i "change mtime on striped directory"
3189 # test_37 - duplicate with tests 32q 32r
3192 local file=$DIR/$tfile
3194 openfile -f O_DIRECTORY $file
3197 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3198 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3200 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3202 test_39a() { # was test_39
3204 touch $DIR/${tfile}2
3205 # ls -l $DIR/$tfile $DIR/${tfile}2
3206 # ls -lu $DIR/$tfile $DIR/${tfile}2
3207 # ls -lc $DIR/$tfile $DIR/${tfile}2
3209 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3210 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3212 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3214 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3216 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3217 error "O_TRUNC didn't change timestamps"
3220 run_test 39a "mtime changed on create ==========================="
3223 test_mkdir -p -c1 $DIR/$tdir
3224 cp -p /etc/passwd $DIR/$tdir/fopen
3225 cp -p /etc/passwd $DIR/$tdir/flink
3226 cp -p /etc/passwd $DIR/$tdir/funlink
3227 cp -p /etc/passwd $DIR/$tdir/frename
3228 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3231 echo "aaaaaa" >> $DIR/$tdir/fopen
3232 echo "aaaaaa" >> $DIR/$tdir/flink
3233 echo "aaaaaa" >> $DIR/$tdir/funlink
3234 echo "aaaaaa" >> $DIR/$tdir/frename
3236 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3237 local link_new=`stat -c %Y $DIR/$tdir/flink`
3238 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3239 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3241 cat $DIR/$tdir/fopen > /dev/null
3242 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3243 rm -f $DIR/$tdir/funlink2
3244 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3246 for (( i=0; i < 2; i++ )) ; do
3247 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3248 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3249 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3250 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3252 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3253 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3254 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3255 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3257 cancel_lru_locks osc
3258 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3261 run_test 39b "mtime change on open, link, unlink, rename ======"
3263 # this should be set to past
3264 TEST_39_MTIME=`date -d "1 year ago" +%s`
3270 local mtime0=`stat -c %Y $DIR1/$tfile`
3272 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3273 local mtime1=`stat -c %Y $DIR1/$tfile`
3274 [ "$mtime1" = $TEST_39_MTIME ] || \
3275 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3278 echo hello >> $DIR1/$tfile
3280 local mtime2=`stat -c %Y $DIR1/$tfile`
3281 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3282 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3284 mv $DIR1/$tfile $DIR1/$tfile-1
3286 for (( i=0; i < 2; i++ )) ; do
3287 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3288 [ "$mtime2" = "$mtime3" ] || \
3289 error "mtime ($mtime2) changed (to $mtime3) on rename"
3291 cancel_lru_locks osc
3292 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3295 run_test 39c "mtime change on rename ==========================="
3299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3302 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3304 for (( i=0; i < 2; i++ )) ; do
3305 local mtime=`stat -c %Y $DIR1/$tfile`
3306 [ $mtime = $TEST_39_MTIME ] || \
3307 error "mtime($mtime) is not set to $TEST_39_MTIME"
3309 cancel_lru_locks osc
3310 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3313 run_test 39d "create, utime, stat =============================="
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3319 local mtime1=`stat -c %Y $DIR1/$tfile`
3321 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3323 for (( i=0; i < 2; i++ )) ; do
3324 local mtime2=`stat -c %Y $DIR1/$tfile`
3325 [ $mtime2 = $TEST_39_MTIME ] || \
3326 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3328 cancel_lru_locks osc
3329 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3332 run_test 39e "create, stat, utime, stat ========================"
3336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3338 mtime1=`stat -c %Y $DIR1/$tfile`
3341 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3343 for (( i=0; i < 2; i++ )) ; do
3344 local mtime2=`stat -c %Y $DIR1/$tfile`
3345 [ $mtime2 = $TEST_39_MTIME ] || \
3346 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3348 cancel_lru_locks osc
3349 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3352 run_test 39f "create, stat, sleep, utime, stat ================="
3356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3357 echo hello >> $DIR1/$tfile
3358 local mtime1=`stat -c %Y $DIR1/$tfile`
3361 chmod o+r $DIR1/$tfile
3363 for (( i=0; i < 2; i++ )) ; do
3364 local mtime2=`stat -c %Y $DIR1/$tfile`
3365 [ "$mtime1" = "$mtime2" ] || \
3366 error "lost mtime: $mtime2, should be $mtime1"
3368 cancel_lru_locks osc
3369 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3372 run_test 39g "write, chmod, stat ==============================="
3376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3381 echo hello >> $DIR1/$tfile
3382 local mtime1=`stat -c %Y $DIR1/$tfile`
3384 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3386 if [ "$d1" != "$d2" ]; then
3387 echo "write and touch not within one second"
3389 for (( i=0; i < 2; i++ )) ; do
3390 local mtime2=`stat -c %Y $DIR1/$tfile`
3391 [ "$mtime2" = $TEST_39_MTIME ] || \
3392 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3394 cancel_lru_locks osc
3395 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3399 run_test 39h "write, utime within one second, stat ============="
3402 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3406 echo hello >> $DIR1/$tfile
3407 local mtime1=`stat -c %Y $DIR1/$tfile`
3409 mv $DIR1/$tfile $DIR1/$tfile-1
3411 for (( i=0; i < 2; i++ )) ; do
3412 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3414 [ "$mtime1" = "$mtime2" ] || \
3415 error "lost mtime: $mtime2, should be $mtime1"
3417 cancel_lru_locks osc
3418 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3421 run_test 39i "write, rename, stat =============================="
3424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3425 start_full_debug_logging
3429 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3430 lctl set_param fail_loc=0x80000412
3431 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3432 error "multiop failed"
3434 local mtime1=`stat -c %Y $DIR1/$tfile`
3436 mv $DIR1/$tfile $DIR1/$tfile-1
3438 kill -USR1 $multipid
3439 wait $multipid || error "multiop close failed"
3441 for (( i=0; i < 2; i++ )) ; do
3442 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3443 [ "$mtime1" = "$mtime2" ] ||
3444 error "mtime is lost on close: $mtime2, " \
3447 cancel_lru_locks osc
3448 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3450 lctl set_param fail_loc=0
3451 stop_full_debug_logging
3453 run_test 39j "write, rename, close, stat ======================="
3456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3460 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3462 local mtime1=`stat -c %Y $DIR1/$tfile`
3464 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3466 kill -USR1 $multipid
3467 wait $multipid || error "multiop close failed"
3469 for (( i=0; i < 2; i++ )) ; do
3470 local mtime2=`stat -c %Y $DIR1/$tfile`
3472 [ "$mtime2" = $TEST_39_MTIME ] || \
3473 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3475 cancel_lru_locks osc
3476 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3479 run_test 39k "write, utime, close, stat ========================"
3481 # this should be set to future
3482 TEST_39_ATIME=`date -d "1 year" +%s`
3485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3486 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3487 local atime_diff=$(do_facet $SINGLEMDS \
3488 lctl get_param -n mdd.*MDT0000*.atime_diff)
3492 # test setting directory atime to future
3493 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3494 local atime=$(stat -c %X $DIR/$tdir)
3495 [ "$atime" = $TEST_39_ATIME ] ||
3496 error "atime is not set to future: $atime, $TEST_39_ATIME"
3498 # test setting directory atime from future to now
3499 local now=$(date +%s)
3500 touch -a -d @$now $DIR/$tdir
3502 atime=$(stat -c %X $DIR/$tdir)
3503 [ "$atime" -eq "$now" ] ||
3504 error "atime is not updated from future: $atime, $now"
3506 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3509 # test setting directory atime when now > dir atime + atime_diff
3510 local d1=$(date +%s)
3512 local d2=$(date +%s)
3513 cancel_lru_locks mdc
3514 atime=$(stat -c %X $DIR/$tdir)
3515 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3516 error "atime is not updated : $atime, should be $d2"
3518 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3521 # test not setting directory atime when now < dir atime + atime_diff
3523 cancel_lru_locks mdc
3524 atime=$(stat -c %X $DIR/$tdir)
3525 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3526 error "atime is updated to $atime, should remain $d1<atime<$d2"
3528 do_facet $SINGLEMDS \
3529 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3531 run_test 39l "directory atime update ==========================="
3534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3537 local far_past_mtime=$(date -d "May 29 1953" +%s)
3538 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3540 touch -m -d @$far_past_mtime $DIR1/$tfile
3541 touch -a -d @$far_past_atime $DIR1/$tfile
3543 for (( i=0; i < 2; i++ )) ; do
3544 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3545 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3546 error "atime or mtime set incorrectly"
3548 cancel_lru_locks osc
3549 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3552 run_test 39m "test atime and mtime before 1970"
3554 test_39n() { # LU-3832
3555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3556 local atime_diff=$(do_facet $SINGLEMDS \
3557 lctl get_param -n mdd.*MDT0000*.atime_diff)
3562 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3565 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3566 atime0=$(stat -c %X $DIR/$tfile)
3569 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3570 atime1=$(stat -c %X $DIR/$tfile)
3573 cancel_lru_locks mdc
3574 cancel_lru_locks osc
3575 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3576 atime2=$(stat -c %X $DIR/$tfile)
3578 do_facet $SINGLEMDS \
3579 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3581 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3582 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3584 run_test 39n "check that O_NOATIME is honored"
3587 TESTDIR=$DIR/$tdir/$tfile
3588 [ -e $TESTDIR ] && rm -rf $TESTDIR
3595 links2=$(stat -c %h .)
3596 [ $(($links1 + 2)) != $links2 ] &&
3597 error "wrong links count $(($links1 + 2)) != $links2"
3599 links3=$(stat -c %h .)
3600 [ $(($links1 + 1)) != $links3 ] &&
3601 error "wrong links count $links1 != $links3"
3604 run_test 39o "directory cached attributes updated after create ========"
3607 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3609 TESTDIR=$DIR/$tdir/$tfile
3610 [ -e $TESTDIR ] && rm -rf $TESTDIR
3611 test_mkdir -p $TESTDIR
3615 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3616 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3618 links2=$(stat -c %h .)
3619 [ $(($links1 + 2)) != $links2 ] &&
3620 error "wrong links count $(($links1 + 2)) != $links2"
3622 links3=$(stat -c %h .)
3623 [ $(($links1 + 1)) != $links3 ] &&
3624 error "wrong links count $links1 != $links3"
3627 run_test 39p "remote directory cached attributes updated after create ========"
3630 test_39q() { # LU-8041
3631 local testdir=$DIR/$tdir
3633 multiop_bg_pause $testdir D_c || error "multiop failed"
3635 cancel_lru_locks mdc
3636 kill -USR1 $multipid
3637 local atime=$(stat -c %X $testdir)
3638 [ "$atime" -ne 0 ] || error "atime is zero"
3640 run_test 39q "close won't zero out atime"
3643 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3644 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3645 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3646 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3647 error "$tfile is not 4096 bytes in size"
3649 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3653 small_write $DIR/f41 18
3655 run_test 41 "test small file write + fstat ====================="
3657 count_ost_writes() {
3658 lctl get_param -n osc.*.stats |
3659 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3660 END { printf("%0.0f", writes) }'
3667 BG_DIRTY_RATIO_SAVE=10
3668 MAX_BG_DIRTY_RATIO=25
3672 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3673 # dirty_ratio, dirty_background_ratio
3674 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3675 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3676 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3677 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3679 # if file not here, we are a 2.4 kernel
3680 kill -CONT `pidof kupdated`
3685 # setup the trap first, so someone cannot exit the test at the
3686 # exact wrong time and mess up a machine
3687 trap start_writeback EXIT
3688 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3689 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3690 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3691 sysctl -w vm.dirty_writeback_centisecs=0
3692 sysctl -w vm.dirty_writeback_centisecs=0
3693 # save and increase /proc/sys/vm/dirty_ratio
3694 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3695 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3696 # save and increase /proc/sys/vm/dirty_background_ratio
3697 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3698 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3700 # if file not here, we are a 2.4 kernel
3701 kill -STOP `pidof kupdated`
3705 # ensure that all stripes have some grant before we test client-side cache
3707 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3708 dd if=/dev/zero of=$i bs=4k count=1
3713 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3714 # file truncation, and file removal.
3716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3718 cancel_lru_locks osc
3720 sync; sleep 1; sync # just to be safe
3721 BEFOREWRITES=`count_ost_writes`
3722 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3723 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3724 AFTERWRITES=`count_ost_writes`
3725 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3726 error "$BEFOREWRITES < $AFTERWRITES"
3729 run_test 42a "ensure that we don't flush on close"
3732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3734 cancel_lru_locks osc
3737 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3738 BEFOREWRITES=$(count_ost_writes)
3739 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3740 AFTERWRITES=$(count_ost_writes)
3741 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3742 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3744 BEFOREWRITES=$(count_ost_writes)
3745 sync || error "sync: $?"
3746 AFTERWRITES=$(count_ost_writes)
3747 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3748 error "$BEFOREWRITES < $AFTERWRITES on sync"
3750 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3754 run_test 42b "test destroy of file with cached dirty data ======"
3756 # if these tests just want to test the effect of truncation,
3757 # they have to be very careful. consider:
3758 # - the first open gets a {0,EOF}PR lock
3759 # - the first write conflicts and gets a {0, count-1}PW
3760 # - the rest of the writes are under {count,EOF}PW
3761 # - the open for truncate tries to match a {0,EOF}PR
3762 # for the filesize and cancels the PWs.
3763 # any number of fixes (don't get {0,EOF} on open, match
3764 # composite locks, do smarter file size management) fix
3765 # this, but for now we want these tests to verify that
3766 # the cancellation with truncate intent works, so we
3767 # start the file with a full-file pw lock to match against
3768 # until the truncate.
3773 cancel_lru_locks osc
3775 # prime the file with 0,EOF PW to match
3779 # now the real test..
3780 dd if=/dev/zero of=$file bs=1024 count=100
3781 BEFOREWRITES=`count_ost_writes`
3782 $TRUNCATE $file $offset
3783 cancel_lru_locks osc
3784 AFTERWRITES=`count_ost_writes`
3789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3791 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3792 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3795 run_test 42c "test partial truncate of file with cached dirty data"
3798 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3800 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3801 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3804 run_test 42d "test complete truncate of file with cached dirty data"
3806 test_42e() { # bug22074
3807 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3808 local TDIR=$DIR/${tdir}e
3809 local pagesz=$(page_size)
3810 local pages=16 # hardcoded 16 pages, don't change it.
3811 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3812 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3816 test_mkdir -p $DIR/${tdir}e
3817 $SETSTRIPE -c 1 $TDIR
3818 createmany -o $TDIR/f $files
3820 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3822 # we assume that with $OSTCOUNT files, at least one of them will
3823 # be allocated on OST0.
3824 warmup_files=$((OSTCOUNT * max_dirty_mb))
3825 createmany -o $TDIR/w $warmup_files
3827 # write a large amount of data into one file and sync, to get good
3828 # avail_grant number from OST.
3829 for ((i=0; i<$warmup_files; i++)); do
3830 idx=$($GETSTRIPE -i $TDIR/w$i)
3831 [ $idx -ne 0 ] && continue
3832 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3835 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3837 $LCTL get_param $proc_osc0/cur_dirty_bytes
3838 $LCTL get_param $proc_osc0/cur_grant_bytes
3840 # create as much dirty pages as we can while not to trigger the actual
3841 # RPCs directly. but depends on the env, VFS may trigger flush during this
3842 # period, hopefully we are good.
3843 for ((i=0; i<$warmup_files; i++)); do
3844 idx=$($GETSTRIPE -i $TDIR/w$i)
3845 [ $idx -ne 0 ] && continue
3846 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3848 $LCTL get_param $proc_osc0/cur_dirty_bytes
3849 $LCTL get_param $proc_osc0/cur_grant_bytes
3851 # perform the real test
3852 $LCTL set_param $proc_osc0/rpc_stats 0
3853 for ((;i<$files; i++)); do
3854 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3855 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3858 $LCTL get_param $proc_osc0/rpc_stats
3861 local have_ppr=false
3862 $LCTL get_param $proc_osc0/rpc_stats |
3863 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3864 # skip lines until we are at the RPC histogram data
3865 [ "$PPR" == "pages" ] && have_ppr=true && continue
3866 $have_ppr || continue
3868 # we only want the percent stat for < 16 pages
3869 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3871 percent=$((percent + WPCT))
3872 if [[ $percent -gt 15 ]]; then
3873 error "less than 16-pages write RPCs" \
3880 run_test 42e "verify sub-RPC writes are not done synchronously"
3882 test_43A() { # was test_43
3883 test_mkdir -p $DIR/$tdir
3884 cp -p /bin/ls $DIR/$tdir/$tfile
3885 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3887 # give multiop a chance to open
3890 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3893 run_test 43A "execution of file opened for write should return -ETXTBSY"
3896 test_mkdir $DIR/$tdir
3897 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3898 cp -p multiop $DIR/$tdir/multiop
3899 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3900 error "multiop open $TMP/$tfile.junk failed"
3902 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3903 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3904 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3906 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3910 test_mkdir $DIR/$tdir
3911 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3912 cp -p multiop $DIR/$tdir/multiop
3913 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3914 error "multiop open $TMP/$tfile.junk failed"
3916 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3917 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3918 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3920 run_test 43b "truncate of file being executed should return -ETXTBSY"
3923 local testdir="$DIR/$tdir"
3926 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3927 ( cd $testdir && md5sum -c )
3929 run_test 43c "md5sum of copy into lustre"
3931 test_44A() { # was test_44
3932 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3933 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3934 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3936 run_test 44A "zero length read from a sparse stripe"
3939 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3941 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3942 [[ $nstripe -gt $OSTCOUNT ]] &&
3943 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3945 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3947 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3948 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3952 OFFSETS="0 $((stride/2)) $((stride-1))"
3953 for offset in $OFFSETS; do
3954 for i in $(seq 0 $((nstripe-1))); do
3955 local GLOBALOFFSETS=""
3957 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3958 local myfn=$DIR/d44a-$size
3959 echo "--------writing $myfn at $size"
3960 ll_sparseness_write $myfn $size ||
3961 error "ll_sparseness_write"
3962 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3963 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3964 error "ll_sparseness_verify $GLOBALOFFSETS"
3966 for j in $(seq 0 $((nstripe-1))); do
3968 size=$((((j + $nstripe )*$stride + $offset)))
3969 ll_sparseness_write $myfn $size ||
3970 error "ll_sparseness_write"
3971 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3973 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3974 error "ll_sparseness_verify $GLOBALOFFSETS"
3979 run_test 44a "test sparse pwrite ==============================="
3983 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3989 before=`dirty_osc_total`
3990 echo executing "\"$*\""
3992 after=`dirty_osc_total`
3993 echo before $before, after $after
3996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3998 # Obtain grants from OST if it supports it
3999 echo blah > ${f}_grant
4002 do_dirty_record "echo blah > $f"
4003 [[ $before -eq $after ]] && error "write wasn't cached"
4004 do_dirty_record "> $f"
4005 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4006 do_dirty_record "echo blah > $f"
4007 [[ $before -eq $after ]] && error "write wasn't cached"
4008 do_dirty_record "sync"
4009 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4010 do_dirty_record "echo blah > $f"
4011 [[ $before -eq $after ]] && error "write wasn't cached"
4012 do_dirty_record "cancel_lru_locks osc"
4013 [[ $before -gt $after ]] ||
4014 error "lock cancellation didn't lower dirty count"
4017 run_test 45 "osc io page accounting ============================"
4019 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4020 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4021 # objects offset and an assert hit when an rpc was built with 1023's mapped
4022 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4028 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4030 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
4031 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4035 run_test 46 "dirtying a previously written page ================"
4037 # test_47 is removed "Device nodes check" is moved to test_28
4039 test_48a() { # bug 2399
4040 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
4041 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
4042 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
4044 test_mkdir $DIR/$tdir
4046 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4047 test_mkdir $DIR/$tdir || error "recreate directory failed"
4048 touch foo || error "'touch foo' failed after recreating cwd"
4049 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
4050 touch .foo || error "'touch .foo' failed after recreating cwd"
4051 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
4052 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4053 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4054 cd . || error "'cd .' failed after recreating cwd"
4055 test_mkdir . && error "'mkdir .' worked after recreating cwd"
4056 rmdir . && error "'rmdir .' worked after recreating cwd"
4057 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4058 cd .. || error "'cd ..' failed after recreating cwd"
4060 run_test 48a "Access renamed working dir (should return errors)="
4062 test_48b() { # bug 2399
4064 test_mkdir $DIR/$tdir
4066 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4067 touch foo && error "'touch foo' worked after removing cwd"
4068 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4069 touch .foo && error "'touch .foo' worked after removing cwd"
4070 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4071 ls . > /dev/null && error "'ls .' worked after removing cwd"
4072 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4073 test_mkdir . && error "'mkdir .' worked after removing cwd"
4074 rmdir . && error "'rmdir .' worked after removing cwd"
4075 ln -s . foo && error "'ln -s .' worked after removing cwd"
4076 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4078 run_test 48b "Access removed working dir (should return errors)="
4080 test_48c() { # bug 2350
4081 #lctl set_param debug=-1
4084 test_mkdir -p $DIR/$tdir/dir
4086 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4087 $TRACE touch foo && error "touch foo worked after removing cwd"
4088 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4089 touch .foo && error "touch .foo worked after removing cwd"
4090 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
4091 $TRACE ls . && error "'ls .' worked after removing cwd"
4092 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4093 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
4094 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4095 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4096 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4098 run_test 48c "Access removed working subdir (should return errors)"
4100 test_48d() { # bug 2350
4101 #lctl set_param debug=-1
4104 test_mkdir -p $DIR/$tdir/dir
4106 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4107 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4108 $TRACE touch foo && error "'touch foo' worked after removing parent"
4109 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
4110 touch .foo && error "'touch .foo' worked after removing parent"
4111 test_mkdir .foo && error "mkdir .foo worked after removing parent"
4112 $TRACE ls . && error "'ls .' worked after removing parent"
4113 $TRACE ls .. && error "'ls ..' worked after removing parent"
4114 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
4115 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4116 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4119 run_test 48d "Access removed parent subdir (should return errors)"
4121 test_48e() { # bug 4134
4122 #lctl set_param debug=-1
4125 test_mkdir -p $DIR/$tdir/dir
4127 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4128 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4129 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4130 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4131 # On a buggy kernel addition of "touch foo" after cd .. will
4132 # produce kernel oops in lookup_hash_it
4133 touch ../foo && error "'cd ..' worked after recreate parent"
4135 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4137 run_test 48e "Access to recreated parent subdir (should return errors)"
4139 test_49() { # LU-1030
4140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4141 remote_ost_nodsh && skip "remote OST with nodsh" && return
4142 # get ost1 size - lustre-OST0000
4143 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4145 # write 800M at maximum
4146 [[ $ost1_size -lt 2 ]] && ost1_size=2
4147 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4149 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4150 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4153 # change max_pages_per_rpc while writing the file
4154 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4155 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4156 # loop until dd process exits
4157 while ps ax -opid | grep -wq $dd_pid; do
4158 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4159 sleep $((RANDOM % 5 + 1))
4161 # restore original max_pages_per_rpc
4162 $LCTL set_param $osc1_mppc=$orig_mppc
4163 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4165 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4169 test_mkdir $DIR/$tdir
4171 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4173 run_test 50 "special situations: /proc symlinks ==============="
4175 test_51a() { # was test_51
4176 # bug 1516 - create an empty entry right after ".." then split dir
4177 test_mkdir -c1 $DIR/$tdir
4178 touch $DIR/$tdir/foo
4179 $MCREATE $DIR/$tdir/bar
4181 createmany -m $DIR/$tdir/longfile 201
4183 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4184 $MCREATE $DIR/$tdir/longfile$FNUM
4189 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4191 run_test 51a "special situations: split htree with empty entry =="
4193 cleanup_print_lfs_df () {
4200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4201 local dir=$DIR/$tdir
4203 local nrdirs=$((65536 + 100))
4205 # cleanup the directory
4208 test_mkdir -p -c1 $dir
4212 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4213 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4214 [[ $numfree -lt $nrdirs ]] &&
4215 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4218 # need to check free space for the directories as well
4219 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4220 numfree=$(( blkfree / $(fs_inode_ksize) ))
4221 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4224 trap cleanup_print_lfs_df EXIT
4227 createmany -d $dir/d $nrdirs || {
4228 unlinkmany $dir/d $nrdirs
4229 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4233 nrdirs=$(ls -U $dir | wc -l)
4235 # unlink all but 100 subdirectories, then check it still works
4237 local delete=$((nrdirs - left))
4242 # for ldiskfs the nlink count should be 1, but this is OSD specific
4243 # and so this is listed for informational purposes only
4244 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4245 unlinkmany -d $dir/d $delete ||
4246 error "unlink of first $delete subdirs failed"
4248 echo "nlink between: $(stat -c %h $dir)"
4249 local found=$(ls -U $dir | wc -l)
4250 [ $found -ne $left ] &&
4251 error "can't find subdirs: found only $found, expected $left"
4253 unlinkmany -d $dir/d $delete $left ||
4254 error "unlink of second $left subdirs failed"
4255 # regardless of whether the backing filesystem tracks nlink accurately
4256 # or not, the nlink count shouldn't be more than "." and ".." here
4257 local after=$(stat -c %h $dir)
4258 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4259 echo "nlink after: $after"
4261 cleanup_print_lfs_df
4263 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4267 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4268 test_mkdir -p $DIR/$tdir
4269 createmany -o $DIR/$tdir/t- 1000
4270 $GETSTRIPE $DIR/$tdir > $TMP/$tfile
4271 for N in $(seq 0 $((OSTCOUNT - 1))); do
4272 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4273 END { printf("%0.0f", objs) }' $TMP/$tfile)
4274 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4275 '($1 == '$N') { objs += 1 } \
4276 END { printf("%0.0f", objs) }')
4277 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4279 unlinkmany $DIR/$tdir/t- 1000
4282 for N in $(seq 1 $((OSTCOUNT - 1))); do
4283 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4284 error "OST $N has less objects vs OST $NLAST" \
4285 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4286 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4287 error "OST $N has less objects vs OST $NLAST" \
4288 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4290 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4291 error "OST $N has less #0 objects vs OST $NLAST" \
4292 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4293 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4294 error "OST $N has less #0 objects vs OST $NLAST" \
4295 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4300 run_test 51d "check object distribution"
4303 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4304 skip "ldiskfs only test"
4308 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4309 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4311 touch $DIR/$tdir/d0/foo
4312 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4313 error "file exceed 65000 nlink limit!"
4314 unlinkmany $DIR/$tdir/d0/f- 65001
4317 run_test 51e "check file nlink limit"
4320 test_mkdir $DIR/$tdir
4323 local ulimit_old=$(ulimit -n)
4324 local spare=20 # number of spare fd's for scripts/libraries, etc.
4325 local mdt=$(lfs getstripe -M $DIR/$tdir)
4326 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4328 echo "MDT$mdt numfree=$numfree, max=$max"
4329 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4330 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4331 while ! ulimit -n $((numfree + spare)); do
4332 numfree=$((numfree * 3 / 4))
4334 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4336 echo "left ulimit at $ulimit_old"
4339 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4340 unlinkmany $DIR/$tdir/f $numfree
4341 error "create+open $numfree files in $DIR/$tdir failed"
4343 ulimit -n $ulimit_old
4345 # if createmany exits at 120s there will be fewer than $numfree files
4346 unlinkmany $DIR/$tdir/f $numfree || true
4348 run_test 51f "check many open files limit"
4351 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4352 test_mkdir -p $DIR/$tdir
4353 touch $DIR/$tdir/foo
4354 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4355 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4356 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4357 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4358 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4360 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4361 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4362 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4364 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4365 cp -r $DIR/$tdir $TMP/
4366 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4368 run_test 52a "append-only flag test (should return errors)"
4371 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4372 test_mkdir -p $DIR/$tdir
4373 touch $DIR/$tdir/foo
4374 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4375 cat test > $DIR/$tdir/foo && error "cat test worked"
4376 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4377 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4378 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4380 echo foo >> $DIR/$tdir/foo && error "echo worked"
4381 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4382 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4383 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4384 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4386 chattr -i $DIR/$tdir/foo || error "chattr failed"
4388 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4390 run_test 52b "immutable flag test (should return errors) ======="
4393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4394 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4395 remote_ost_nodsh && skip "remote OST with nodsh" && return
4408 local support_last_seq=true
4410 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4411 support_last_seq=false
4414 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4416 for value in $(do_facet $SINGLEMDS \
4417 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4418 param=$(echo ${value[0]} | cut -d "=" -f1)
4419 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4421 if $support_last_seq; then
4422 param_seq=$(echo $param |
4423 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4424 mds_last_seq=$(do_facet $SINGLEMDS \
4425 $LCTL get_param -n $param_seq)
4427 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4429 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4430 node=$(facet_active_host ost$((ostnum+1)))
4431 param="obdfilter.$ostname.last_id"
4432 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4433 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4434 ost_last_id=$ost_last
4436 if $support_last_seq; then
4437 ost_last_id=$(echo $ost_last |
4438 awk -F':' '{print $2}' |
4440 ost_last_seq=$(echo $ost_last |
4441 awk -F':' '{print $1}')
4442 [[ $ost_last_seq = $mds_last_seq ]] || continue
4445 if [[ $ost_last_id != $mds_last ]]; then
4446 error "$ost_last_id != $mds_last"
4453 $found || error "can not match last_seq/last_id for $mdtosc"
4456 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4459 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4461 $SOCKETSERVER $DIR/socket ||
4462 error "$SOCKETSERVER $DIR/socket failed: $?"
4463 $SOCKETCLIENT $DIR/socket ||
4464 error "$SOCKETCLIENT $DIR/socket failed: $?"
4465 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4467 run_test 54a "unix domain socket test =========================="
4473 dd if=/dev/zero of=$f bs=$(page_size) count=1
4475 run_test 54b "char device works in lustre ======================"
4478 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4479 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4480 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4482 for i in $(seq 3 7); do
4483 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4492 loopdev="$DIR/loop54c"
4495 $UMOUNT $DIR/$tdir || rc=$?
4496 losetup -d $loopdev || true
4497 losetup -d $LOOPDEV || true
4498 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4504 loopdev="$DIR/loop54c"
4507 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4508 trap cleanup_54c EXIT
4509 mknod $loopdev b 7 $LOOPNUM
4510 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4511 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4512 losetup $loopdev $DIR/$tfile ||
4513 error "can't set up $loopdev for $DIR/$tfile"
4514 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4515 test_mkdir -p $DIR/$tdir
4516 mount -t ext2 $loopdev $DIR/$tdir ||
4517 error "error mounting $loopdev on $DIR/$tdir"
4518 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4521 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4525 run_test 54c "block device works in lustre ====================="
4531 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4533 run_test 54d "fifo device works in lustre ======================"
4538 cp -aL /dev/console $f
4539 echo $string > $f || error "echo $string to $f failed"
4541 run_test 54e "console/tty device works in lustre ======================"
4543 #The test_55 used to be iopen test and it was removed by bz#24037.
4544 #run_test 55 "check iopen_connect_dentry() ======================"
4546 test_56a() { # was test_56
4549 test_mkdir -p $DIR/$tdir/dir
4551 NUMFILESx2=$(($NUMFILES * 2))
4552 for i in $(seq 1 $NUMFILES); do
4553 touch $DIR/$tdir/file$i
4554 touch $DIR/$tdir/dir/file$i
4557 # test lfs getstripe with --recursive
4558 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4559 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4560 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4561 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4562 [[ $FILENUM -eq $NUMFILES ]] ||
4563 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4564 echo "$GETSTRIPE --recursive passed."
4566 # test lfs getstripe with file instead of dir
4567 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4568 [[ $FILENUM -eq 1 ]] ||
4569 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4570 echo "$GETSTRIPE file1 passed."
4572 #test lfs getstripe with --verbose
4573 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4574 grep -c lmm_magic) -eq $NUMFILES ]] ||
4575 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4576 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4577 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4579 #test lfs getstripe with -v prints lmm_fid
4580 [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
4581 error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
4582 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
4583 error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
4584 echo "$GETSTRIPE --verbose passed."
4586 #check for FID information
4587 local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
4588 local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
4589 awk '/lmm_fid: / { print $2 }')
4590 local fid3=$($LFS path2fid $DIR/$tdir/file1)
4591 [ "$fid1" != "$fid2" ] &&
4592 error "getstripe --fid $fid1 != getstripe --verbose $fid2"
4593 [ "$fid1" != "$fid3" ] &&
4594 error "getstripe --fid $fid1 != lfs path2fid $fid3"
4595 echo "$GETSTRIPE --fid passed."
4597 #test lfs getstripe with --obd
4598 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4599 grep -q "unknown obduuid" ||
4600 error "$GETSTRIPE --obd wrong_uuid should return error message"
4602 [[ $OSTCOUNT -lt 2 ]] &&
4603 skip_env "skipping other $GETSTRIPE --obd test" && return
4606 OBDUUID=$(ostuuid_from_index $OSTIDX)
4607 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4608 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4609 [[ $FOUND -eq $FILENUM ]] ||
4610 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4611 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4612 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4613 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4614 error "$GETSTRIPE --obd: should not show file on other obd"
4615 echo "$GETSTRIPE --obd passed"
4617 run_test 56a "check $GETSTRIPE"
4620 test_mkdir $DIR/$tdir
4622 for i in $(seq 1 $NUMDIRS); do
4623 test_mkdir $DIR/$tdir/dir$i
4626 # test lfs getdirstripe default mode is non-recursion, which is
4627 # different from lfs getstripe
4628 dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
4629 [[ $dircnt -eq 1 ]] ||
4630 error "$LFS getdirstripe: found $dircnt, not 1"
4631 dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
4632 grep -c lmv_stripe_count)
4633 [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
4634 error "$LFS getdirstripe --recursive: found $dircnt, \
4635 not $((NUMDIRS + 1))"
4637 run_test 56b "check $LFS getdirstripe"
4641 local ost_name=$(ostname_from_index $ost_idx)
4643 local old_status=$(ost_dev_status $ost_idx)
4644 [[ -z "$old_status" ]] ||
4645 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4647 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4650 local new_status=$(ost_dev_status $ost_idx)
4651 [[ "$new_status" = "D" ]] ||
4652 error "OST $ost_name is in status of '$new_status', not 'D'"
4654 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4657 new_status=$(ost_dev_status $ost_idx)
4658 [[ -z "$new_status" ]] ||
4659 error "OST $ost_name is in status of '$new_status', not ''"
4661 run_test 56c "check 'lfs df' showing device status"
4666 local LOCAL_NUMFILES="$1"
4667 local LOCAL_NUMDIRS="$2"
4668 local MKDIR_PARAMS="$3"
4669 local DIR_STRIPE_PARAMS="$4"
4671 if [ ! -d "$TDIR" ] ; then
4672 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4673 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4674 for i in `seq 1 $LOCAL_NUMFILES` ; do
4677 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4678 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4679 for j in `seq 1 $LOCAL_NUMFILES` ; do
4680 touch $TDIR/dir$i/file$j
4686 setup_56_special() {
4690 if [ ! -e "$TDIR/loop1b" ] ; then
4691 for i in `seq 1 $LOCAL_NUMFILES` ; do
4692 mknod $TDIR/loop${i}b b 7 $i
4693 mknod $TDIR/null${i}c c 1 3
4694 ln -s $TDIR/file1 $TDIR/link${i}l
4696 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4697 mknod $TDIR/dir$i/loop${i}b b 7 $i
4698 mknod $TDIR/dir$i/null${i}c c 1 3
4699 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4708 setup_56 $NUMFILES $NUMDIRS
4710 EXPECTED=$(($NUMDIRS + 2))
4711 # test lfs find with -name
4712 for i in $(seq 1 $NUMFILES) ; do
4713 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4714 [ $NUMS -eq $EXPECTED ] ||
4715 error "lfs find -name \"*$i\" $TDIR wrong: "\
4716 "found $NUMS, expected $EXPECTED"
4719 run_test 56g "check lfs find -name ============================="
4725 setup_56 $NUMFILES $NUMDIRS
4727 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4728 # test lfs find with ! -name
4729 for i in $(seq 1 $NUMFILES) ; do
4730 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4731 [ $NUMS -eq $EXPECTED ] ||
4732 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4733 "found $NUMS, expected $EXPECTED"
4736 run_test 56h "check lfs find ! -name ============================="
4740 test_mkdir -p $DIR/$tdir
4741 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4742 CMD="$LFIND -ost $UUID $DIR/$tdir"
4744 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4746 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4750 setup_56_special $NUMFILES $NUMDIRS
4752 EXPECTED=$((NUMDIRS + 1))
4753 CMD="$LFIND -type d $TDIR"
4754 NUMS=$($CMD | wc -l)
4755 [ $NUMS -eq $EXPECTED ] ||
4756 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4758 run_test 56j "check lfs find -type d ============================="
4762 setup_56_special $NUMFILES $NUMDIRS
4764 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4765 CMD="$LFIND -type f $TDIR"
4766 NUMS=$($CMD | wc -l)
4767 [ $NUMS -eq $EXPECTED ] ||
4768 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4770 run_test 56k "check lfs find -type f ============================="
4774 setup_56_special $NUMFILES $NUMDIRS
4776 EXPECTED=$((NUMDIRS + NUMFILES))
4777 CMD="$LFIND -type b $TDIR"
4778 NUMS=$($CMD | wc -l)
4779 [ $NUMS -eq $EXPECTED ] ||
4780 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4782 run_test 56l "check lfs find -type b ============================="
4786 setup_56_special $NUMFILES $NUMDIRS
4788 EXPECTED=$((NUMDIRS + NUMFILES))
4789 CMD="$LFIND -type c $TDIR"
4790 NUMS=$($CMD | wc -l)
4791 [ $NUMS -eq $EXPECTED ] ||
4792 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4794 run_test 56m "check lfs find -type c ============================="
4798 setup_56_special $NUMFILES $NUMDIRS
4800 EXPECTED=$((NUMDIRS + NUMFILES))
4801 CMD="$LFIND -type l $TDIR"
4802 NUMS=$($CMD | wc -l)
4803 [ $NUMS -eq $EXPECTED ] ||
4804 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4806 run_test 56n "check lfs find -type l ============================="
4810 setup_56 $NUMFILES $NUMDIRS
4811 utime $TDIR/file1 > /dev/null || error "utime (1)"
4812 utime $TDIR/file2 > /dev/null || error "utime (2)"
4813 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4814 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4815 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4816 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4819 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4820 [ $NUMS -eq $EXPECTED ] || \
4821 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4824 CMD="$LFIND -mtime 0 $TDIR"
4825 NUMS=$($CMD | wc -l)
4826 [ $NUMS -eq $EXPECTED ] ||
4827 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4829 run_test 56o "check lfs find -mtime for old files =========================="
4832 [ $RUNAS_ID -eq $UID ] &&
4833 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4836 setup_56 $NUMFILES $NUMDIRS
4838 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4840 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4841 NUMS=$($CMD | wc -l)
4842 [ $NUMS -eq $EXPECTED ] || \
4843 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4845 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4846 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4847 NUMS=$($CMD | wc -l)
4848 [ $NUMS -eq $EXPECTED ] || \
4849 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4851 run_test 56p "check lfs find -uid and ! -uid ==============================="
4854 [ $RUNAS_ID -eq $UID ] &&
4855 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4858 setup_56 $NUMFILES $NUMDIRS
4860 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4863 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4864 NUMS=$($CMD | wc -l)
4865 [ $NUMS -eq $EXPECTED ] ||
4866 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4868 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4869 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4870 NUMS=$($CMD | wc -l)
4871 [ $NUMS -eq $EXPECTED ] ||
4872 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4874 run_test 56q "check lfs find -gid and ! -gid ==============================="
4878 setup_56 $NUMFILES $NUMDIRS
4881 CMD="$LFIND -size 0 -type f $TDIR"
4882 NUMS=$($CMD | wc -l)
4883 [ $NUMS -eq $EXPECTED ] ||
4884 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4886 CMD="$LFIND ! -size 0 -type f $TDIR"
4887 NUMS=$($CMD | wc -l)
4888 [ $NUMS -eq $EXPECTED ] ||
4889 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4890 echo "test" > $TDIR/$tfile
4891 echo "test2" > $TDIR/$tfile.2 && sync
4893 CMD="$LFIND -size 5 -type f $TDIR"
4894 NUMS=$($CMD | wc -l)
4895 [ $NUMS -eq $EXPECTED ] ||
4896 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4898 CMD="$LFIND -size +5 -type f $TDIR"
4899 NUMS=$($CMD | wc -l)
4900 [ $NUMS -eq $EXPECTED ] ||
4901 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4903 CMD="$LFIND -size +0 -type f $TDIR"
4904 NUMS=$($CMD | wc -l)
4905 [ $NUMS -eq $EXPECTED ] ||
4906 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4908 CMD="$LFIND ! -size -5 -type f $TDIR"
4909 NUMS=$($CMD | wc -l)
4910 [ $NUMS -eq $EXPECTED ] ||
4911 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4913 CMD="$LFIND -size -5 -type f $TDIR"
4914 NUMS=$($CMD | wc -l)
4915 [ $NUMS -eq $EXPECTED ] ||
4916 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4918 run_test 56r "check lfs find -size works =========================="
4920 test_56s() { # LU-611
4925 for i in $(seq 1 $NUMDIRS); do
4926 $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile
4929 CMD="$LFIND -c $OSTCOUNT $TDIR"
4930 NUMS=$($CMD | wc -l)
4931 [ $NUMS -eq $EXPECTED ] || {
4933 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4937 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4938 if [[ $OSTCOUNT -gt 1 ]]; then
4939 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4943 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4947 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4948 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4949 NUMS=$($CMD | wc -l)
4950 [ $NUMS -eq $EXPECTED ] || {
4952 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4955 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4956 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4957 NUMS=$($CMD | wc -l)
4958 [ $NUMS -eq $EXPECTED ] || {
4960 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4964 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4965 NUMS=$($CMD | wc -l)
4966 [ $NUMS -eq $EXPECTED ] || {
4968 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4971 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4972 NUMS=$($CMD | wc -l)
4973 [ $NUMS -eq $EXPECTED ] || {
4975 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4979 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4980 NUMS=$($CMD | wc -l)
4981 [ $NUMS -eq $EXPECTED ] || {
4983 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4986 run_test 56s "check lfs find -stripe-count works"
4988 test_56t() { # LU-611
4993 for i in $(seq 1 $NUMDIRS); do
4994 $SETSTRIPE -S 4M $TDIR/dir$i/$tfile
4997 CMD="$LFIND -S 4M $TDIR"
4998 NUMS=$($CMD | wc -l)
4999 [ $NUMS -eq $EXPECTED ] || {
5001 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5005 setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
5007 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
5009 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
5010 CMD="$LFIND -stripe-size 512k -type f $TDIR"
5011 NUMS=$($CMD | wc -l)
5012 [ $NUMS -eq $EXPECTED ] ||
5013 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5015 CMD="$LFIND -stripe-size +320k -type f $TDIR"
5016 NUMS=$($CMD | wc -l)
5017 [ $NUMS -eq $EXPECTED ] ||
5018 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5020 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
5021 CMD="$LFIND -stripe-size +200k -type f $TDIR"
5022 NUMS=$($CMD | wc -l)
5023 [ $NUMS -eq $EXPECTED ] ||
5024 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5026 CMD="$LFIND -stripe-size -640k -type f $TDIR"
5027 NUMS=$($CMD | wc -l)
5028 [ $NUMS -eq $EXPECTED ] ||
5029 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5032 CMD="$LFIND -stripe-size 256k -type f $TDIR"
5033 NUMS=$($CMD | wc -l)
5034 [ $NUMS -eq $EXPECTED ] ||
5035 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5037 CMD="$LFIND -stripe-size -320k -type f $TDIR"
5038 NUMS=$($CMD | wc -l)
5039 [ $NUMS -eq $EXPECTED ] ||
5040 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5043 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
5044 NUMS=$($CMD | wc -l)
5045 [ $NUMS -eq $EXPECTED ] ||
5046 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5048 run_test 56t "check lfs find -stripe-size works"
5050 test_56u() { # LU-611
5052 setup_56 $NUMFILES $NUMDIRS "-i 0"
5054 if [[ $OSTCOUNT -gt 1 ]]; then
5055 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
5061 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
5062 CMD="$LFIND -stripe-index 0 -type f $TDIR"
5063 NUMS=$($CMD | wc -l)
5064 [ $NUMS -eq $EXPECTED ] ||
5065 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5068 CMD="$LFIND -stripe-index 1 -type f $TDIR"
5069 NUMS=$($CMD | wc -l)
5070 [ $NUMS -eq $EXPECTED ] ||
5071 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5073 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
5074 NUMS=$($CMD | wc -l)
5075 [ $NUMS -eq $EXPECTED ] ||
5076 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5079 # This should produce an error and not return any files
5080 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
5081 NUMS=$($CMD 2>/dev/null | wc -l)
5082 [ $NUMS -eq $EXPECTED ] ||
5083 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5085 if [[ $OSTCOUNT -gt 1 ]]; then
5086 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
5087 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
5088 NUMS=$($CMD | wc -l)
5089 [ $NUMS -eq $EXPECTED ] ||
5090 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5093 run_test 56u "check lfs find -stripe-index works"
5100 setup_56 $NUMFILES $NUMDIRS
5102 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
5103 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
5105 for file in $($LFIND -mdt $UUID $TDIR); do
5106 file_mdt_idx=$($GETSTRIPE -M $file)
5107 [ $file_mdt_idx -eq $MDT_IDX ] ||
5108 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
5111 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5114 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5118 rm -rf $TDIR || error "remove $TDIR failed"
5119 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5122 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
5123 error "$GETSTRIPE -S -d $TDIR failed"
5124 stripe_size=${stripe_size%% *}
5126 local file_size=$((stripe_size * OSTCOUNT))
5127 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5128 local required_space=$((file_num * file_size))
5130 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5132 [[ $free_space -le $((required_space / 1024)) ]] &&
5133 skip_env "need $required_space bytes, have $free_space KB" &&
5137 local dd_count=$((file_size / dd_bs))
5139 # write data into the files
5143 for i in $(seq 1 $NUMFILES); do
5145 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5146 error "write data into $file failed"
5148 for i in $(seq 1 $NUMDIRS); do
5149 for j in $(seq 1 $NUMFILES); do
5150 file=$TDIR/dir$i/file$j
5151 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5152 error "write data into $file failed"
5156 # $LFS_MIGRATE will fail if hard link migration is unsupported
5157 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5158 createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 ||
5159 error "creating links to $TDIR/dir1/file1 failed"
5163 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5166 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
5168 eval $cmd || error "$cmd failed"
5170 check_stripe_count $TDIR/file1 $expected
5172 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5174 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5175 # OST 1 if it is on OST 0. This file is small enough to
5176 # be on only one stripe.
5177 file=$TDIR/migr_1_ost
5178 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5179 error "write data into $file failed"
5180 local obdidx=$($LFS getstripe -i $file)
5181 local oldmd5=$(md5sum $file)
5183 [[ $obdidx -eq 0 ]] && newobdidx=1
5184 cmd="$LFS migrate -i $newobdidx $file"
5186 eval $cmd || error "$cmd failed"
5187 local realobdix=$($LFS getstripe -i $file)
5188 local newmd5=$(md5sum $file)
5189 [[ $newobdidx -ne $realobdix ]] &&
5190 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
5191 [[ "$oldmd5" != "$newmd5" ]] &&
5192 error "md5sum differ: $oldmd5, $newmd5"
5196 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
5198 eval $cmd || error "$cmd failed"
5200 for j in $(seq 1 $NUMFILES); do
5201 check_stripe_count $TDIR/dir1/file$j $expected
5204 # lfs_migrate works with lfs find
5205 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
5206 $LFS_MIGRATE -y -c $expected"
5208 eval $cmd || error "$cmd failed"
5210 for i in $(seq 2 $NUMFILES); do
5211 check_stripe_count $TDIR/file$i $expected
5213 for i in $(seq 2 $NUMDIRS); do
5214 for j in $(seq 1 $NUMFILES); do
5215 check_stripe_count $TDIR/dir$i/file$j $expected
5219 run_test 56w "check lfs_migrate -c stripe_count works"
5222 check_swap_layouts_support && return 0
5223 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5225 local dir0=$DIR/$tdir
5226 local ref1=/etc/passwd
5227 local file1=$dir0/file1
5229 test_mkdir $dir0 || error "creating dir $dir0"
5230 $LFS setstripe -c 2 $file1
5232 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5233 stripe=$($LFS getstripe -c $file1)
5234 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5235 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5240 run_test 56x "lfs migration support"
5243 check_swap_layouts_support && return 0
5244 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5246 local dir0=$DIR/$tdir/$testnum
5247 test_mkdir -p $dir0 || error "creating dir $dir0"
5249 local ref1=/etc/passwd
5250 local file1=$dir0/file1
5252 $LFS setstripe -c 2 $file1
5254 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5255 local stripe=$($LFS getstripe -c $file1)
5256 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5257 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5262 run_test 56xa "lfs migration --block support"
5264 check_migrate_links() {
5266 local file1="$dir/file1"
5269 local total_count=$(($begin + $count - 1))
5270 local symlink_count=10
5273 if [ ! -f "$file1" ]; then
5274 echo -n "creating initial file..."
5275 $LFS setstripe -c 1 -S "512k" "$file1" ||
5276 error "cannot setstripe initial file"
5279 echo -n "creating symlinks..."
5280 for s in $(seq 1 $symlink_count); do
5281 ln -s "$file1" "$dir/slink$s" ||
5282 error "cannot create symlinks"
5286 echo -n "creating nonlinked files..."
5287 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5288 error "cannot create nonlinked files"
5293 if [ ! -f "$dir/file$total_count" ]; then
5294 echo -n "creating hard links $begin:$total_count..."
5295 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5296 /dev/null || error "cannot create hard links"
5300 echo -n "checking number of hard links listed in xattrs..."
5301 local fid=$($LFS getstripe -F "$file1")
5302 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5305 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5306 echo "hard link list has unexpected size, skipping test"
5309 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5310 error "link names should exceed xattrs size"
5313 echo -n "migrating files..."
5314 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5316 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5319 # make sure all links have been properly migrated
5320 echo -n "verifying files..."
5321 fid=$($LFS getstripe -F "$file1") ||
5322 error "cannot get fid for file $file1"
5323 for i in $(seq 2 $total_count); do
5324 local fid2=$($LFS getstripe -F $dir/file$i)
5325 [ "$fid2" == "$fid" ] ||
5326 error "migrated hard link has mismatched FID"
5329 # make sure hard links were properly detected, and migration was
5330 # performed only once for the entire link set; nonlinked files should
5332 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5333 local expected=$(($uniq_count + 1))
5334 [ "$actual" -eq "$expected" ] ||
5335 error "hard links individually migrated ($actual != $expected)"
5337 # make sure the correct number of hard links are present
5338 local hardlinks=$(stat -c '%h' "$file1")
5339 [ $hardlinks -eq $total_count ] ||
5340 error "num hard links $hardlinks != $total_count"
5347 local dir0="$DIR/$tdir"
5349 test_mkdir "$dir0" || error "cannot create dir $dir0"
5351 echo "testing lfs migrate mode when all links fit within xattrs"
5352 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 2 99
5354 echo "testing rsync mode when all links fit within xattrs"
5355 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 2 99
5357 echo "testing lfs migrate mode when all links do not fit within xattrs"
5358 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 101 100
5360 echo "testing rsync mode when all links do not fit within xattrs"
5361 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 101 100
5366 run_test 56xb "lfs migration hard link support"
5369 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5370 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5374 local dir0=$DIR/$tdir/$testnum
5375 test_mkdir -p $dir0 || error "creating dir $dir0"
5376 local f1=$dir0/file1
5377 local f2=$dir0/file2
5379 touch $f1 || error "creating std file $f1"
5380 $MULTIOP $f2 H2c || error "creating released file $f2"
5382 # a directory can be raid0, so ask only for files
5383 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5384 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5386 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5387 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5389 # only files can be released, so no need to force file search
5390 res=$($LFIND $dir0 -L released)
5391 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5393 res=$($LFIND $dir0 \! -L released)
5394 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5397 run_test 56y "lfs find -L raid0|released"
5399 test_56z() { # LU-4824
5400 # This checks to make sure 'lfs find' continues after errors
5401 # There are two classes of errors that should be caught:
5402 # - If multiple paths are provided, all should be searched even if one
5404 # - If errors are encountered during the search, it should not terminate
5407 test_mkdir $DIR/$tdir
5408 for i in d{0..9}; do
5409 test_mkdir $DIR/$tdir/$i
5411 touch $DIR/$tdir/d{0..9}/$tfile
5412 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5413 error "$LFS find did not return an error"
5414 # Make a directory unsearchable. This should NOT be the last entry in
5415 # directory order. Arbitrarily pick the 6th entry
5416 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5417 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5418 # The user should be able to see 10 directories and 9 files
5419 [ $count == 19 ] || error "$LFS find did not continue after error"
5421 run_test 56z "lfs find should continue after an error"
5423 test_56aa() { # LU-5937
5424 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5427 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5429 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5430 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5432 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5434 run_test 56aa "lfs find --size under striped dir"
5437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5438 # note test will not do anything if MDS is not local
5439 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5440 skip "ldiskfs only test"
5444 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5445 local MNTDEV="osd*.*MDT*.mntdev"
5446 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5447 [ -z "$DEV" ] && error "can't access $MNTDEV"
5448 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5449 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5450 error "can't access $DEV"
5451 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5452 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5456 run_test 57a "verify MDS filesystem created with large inodes =="
5459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5460 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5461 skip "ldiskfs only test"
5465 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5466 local dir=$DIR/$tdir
5470 local FILEN=$dir/f$FILECOUNT
5472 rm -rf $dir || error "removing $dir"
5473 test_mkdir -p -c1 $dir || error "creating $dir"
5474 local mdtidx=$($LFS getstripe -M $dir)
5475 local mdtname=MDT$(printf %04x $mdtidx)
5476 local facet=mds$((mdtidx + 1))
5478 echo "mcreating $FILECOUNT files"
5479 createmany -m $dir/f 1 $FILECOUNT || \
5480 error "creating files in $dir"
5482 # verify that files do not have EAs yet
5483 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5484 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5488 df $dir #make sure we get new statfs data
5489 local MDSFREE=$(do_facet $facet \
5490 lctl get_param -n osd*.*$mdtname.kbytesfree)
5491 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5492 echo "opening files to create objects/EAs"
5494 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5495 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5498 # verify that files have EAs now
5499 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5500 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5502 sleep 1 #make sure we get new statfs data
5504 local MDSFREE2=$(do_facet $facet \
5505 lctl get_param -n osd*.*$mdtname.kbytesfree)
5506 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5507 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5508 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5509 error "MDC before $MDCFREE != after $MDCFREE2"
5511 echo "MDC before $MDCFREE != after $MDCFREE2"
5512 echo "unable to confirm if MDS has large inodes"
5517 run_test 57b "default LOV EAs are stored inside large inodes ==="
5520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5521 [ -z "$(which wiretest 2>/dev/null)" ] &&
5522 skip_env "could not find wiretest" && return
5525 run_test 58 "verify cross-platform wire constants =============="
5528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5529 echo "touch 130 files"
5530 createmany -o $DIR/f59- 130
5532 unlinkmany $DIR/f59- 130
5534 # wait for commitment of removal
5535 wait_delete_completed
5537 run_test 59 "verify cancellation of llog records async ========="
5539 TEST60_HEAD="test_60 run $RANDOM"
5541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5542 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5543 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5544 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5545 skip_env "missing subtest run-llog.sh" && return
5547 log "$TEST60_HEAD - from kernel mode"
5548 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5549 do_facet mgs sh run-llog.sh
5550 do_facet mgs $LCTL dk > $TMP/$tfile
5552 # LU-6388: test llog_reader
5553 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5554 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5555 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5556 skip_env "missing llog_reader" && return
5557 local fstype=$(facet_fstype mgs)
5558 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5559 skip_env "Only for ldiskfs or zfs type mgs" && return
5561 local mntpt=$(facet_mntpt mgs)
5562 local mgsdev=$(mgsdevname 1)
5574 #get fid and record list
5575 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5577 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5579 #remount mgs as ldiskfs or zfs type
5580 stop mgs || error "stop mgs failed"
5581 mount_fstype mgs || error "remount mgs failed"
5582 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5585 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5586 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5591 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5593 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5595 echo "obj_file is $obj_file"
5596 do_facet mgs $llog_reader $obj_file
5598 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5599 awk '{ print $3 }' | sed -e "s/^type=//g")
5600 if [ $rec_type != $rec ]; then
5601 echo "FAILED test_60a wrong record type $rec_type," \
5607 #check obj path if record type is LLOG_LOGID_MAGIC
5608 if [ "$rec" == "1064553b" ]; then
5609 path=$(do_facet mgs $llog_reader $obj_file |
5610 grep "path=" | awk '{ print $NF }' |
5611 sed -e "s/^path=//g")
5612 if [ $obj_file != $mntpt/$path ]; then
5613 echo "FAILED test_60a wrong obj path" \
5614 "$montpt/$path, should be $obj_file"
5621 #restart mgs before "error", otherwise it will block the next test
5622 stop mgs || error "stop mgs failed"
5623 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5624 $pass || error "test failed, see FAILED test_60a messages for specifics"
5626 run_test 60a "llog_test run from kernel module and test llog_reader"
5628 test_60b() { # bug 6411
5629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5631 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5643 [[ $LLOG_COUNT -gt 100 ]] &&
5644 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5646 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5650 echo "create 5000 files"
5651 createmany -o $DIR/f60c- 5000
5652 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5653 lctl set_param fail_loc=0x80000137
5654 unlinkmany $DIR/f60c- 5000
5655 lctl set_param fail_loc=0
5657 run_test 60c "unlink file when mds full"
5660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5661 SAVEPRINTK=$(lctl get_param -n printk)
5663 # verify "lctl mark" is even working"
5664 MESSAGE="test message ID $RANDOM $$"
5665 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5666 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5668 lctl set_param printk=0 || error "set lnet.printk failed"
5669 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5670 MESSAGE="new test message ID $RANDOM $$"
5671 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5672 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5673 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5675 lctl set_param -n printk="$SAVEPRINTK"
5677 run_test 60d "test printk console message masking"
5680 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5681 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5683 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5684 do_facet mds1 lctl set_param fail_loc=0x15b
5687 run_test 60e "no space while new llog is being created"
5690 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5692 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5693 cancel_lru_locks osc
5694 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5697 run_test 61 "mmap() writes don't make sync hang ================"
5699 # bug 2330 - insufficient obd_match error checking causes LBUG
5701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5704 cancel_lru_locks osc
5705 lctl set_param fail_loc=0x405
5706 cat $f && error "cat succeeded, expect -EIO"
5707 lctl set_param fail_loc=0
5709 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5710 # match every page all of the time.
5711 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5713 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5714 # Though this test is irrelevant anymore, it helped to reveal some
5715 # other grant bugs (LU-4482), let's keep it.
5716 test_63a() { # was test_63
5717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5718 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5719 for i in `seq 10` ; do
5720 dd if=/dev/zero of=$DIR/f63 bs=8k &
5726 rm -f $DIR/f63 || true
5728 run_test 63a "Verify oig_wait interruption does not crash ======="
5730 # bug 2248 - async write errors didn't return to application on sync
5731 # bug 3677 - async write errors left page locked
5733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5735 lctl set_param debug=-1
5737 # ensure we have a grant to do async writes
5738 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5741 sync # sync lest earlier test intercept the fail_loc
5743 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5744 lctl set_param fail_loc=0x80000406
5745 $MULTIOP $DIR/$tfile Owy && \
5746 error "sync didn't return ENOMEM"
5747 sync; sleep 2; sync # do a real sync this time to flush page
5748 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5749 error "locked page left in cache after async error" || true
5752 run_test 63b "async write errors should be returned to fsync ==="
5755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5757 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5759 run_test 64a "verify filter grant calculations (in kernel) ====="
5762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5763 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5765 run_test 64b "check out-of-space detection on client ==========="
5768 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5770 run_test 64c "verify grant shrink ========================------"
5772 # this does exactly what osc_request.c:osc_announce_cached() does in
5773 # order to calculate max amount of grants to ask from server
5777 local page_size=$(get_page_size client)
5779 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
5780 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
5782 ((rpc_in_flight ++));
5783 nrpages=$((nrpages * rpc_in_flight))
5785 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
5787 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size))
5789 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
5790 local undirty=$((nrpages * page_size))
5792 local max_extent_pages
5793 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
5794 grep grant_max_extent_size | awk '{print $2}')
5795 max_extent_pages=$((max_extent_pages / page_size))
5796 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
5797 local grant_extent_tax
5798 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
5799 grep grant_extent_tax | awk '{print $2}')
5801 undirty=$((undirty + nrextents * grant_extent_tax))
5806 # this is size of unit for grant allocation. It should be equal to
5807 # what tgt_grant.c:tgt_grant_chunk() calculates
5811 local grant_extent_tax
5813 max_brw_size=$($LCTL get_param osc.${tgt}.import |
5814 grep max_brw_size | awk '{print $2}')
5816 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
5817 grep grant_extent_tax | awk '{print $2}')
5819 echo $(((max_brw_size + grant_extent_tax) * 2))
5823 [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
5824 skip "OST < 2.10.55 doesn't limit grants enough" && return 0
5826 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
5828 [[ $($LCTL get_param osc.${tgt}.import |
5829 grep "connect_flags:.*grant_param") ]] || \
5830 { skip "no grant_param connect flag"; return; }
5832 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
5834 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
5836 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
5838 $SETSTRIPE $DIR/$tfile -i 0 -c 1
5839 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
5844 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
5845 if [[ $cur_grant -gt $max_cur_granted ]]
5848 error "cur_grant $cur_grant > $max_cur_granted"
5851 [[ $? -ne 0 ]] && break;
5854 $LCTL set_param debug="$olddebug" 2> /dev/null || true
5856 run_test 64d "check grant limit exceed"
5858 # bug 1414 - set/get directories' stripe info
5860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5861 test_mkdir -p $DIR/$tdir
5863 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5865 run_test 65a "directory with no stripe info ===================="
5868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5869 test_mkdir -p $DIR/$tdir
5870 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5872 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5875 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5877 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5880 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5881 if [[ $OSTCOUNT -gt 1 ]]; then
5882 test_mkdir -p $DIR/$tdir
5883 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5885 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5886 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5888 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5891 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5895 test_mkdir -p $DIR/$tdir
5896 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5897 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5899 if [[ $STRIPECOUNT -le 0 ]]; then
5901 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5902 #LOV_MAX_STRIPE_COUNT is 2000
5903 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5905 sc=$(($STRIPECOUNT - 1))
5907 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5908 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5909 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5910 error "lverify failed"
5912 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5916 test_mkdir -p $DIR/$tdir
5918 $SETSTRIPE $DIR/$tdir || error "setstripe"
5919 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5920 error "no stripe info failed"
5922 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5924 run_test 65e "directory setstripe defaults ======================="
5927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5928 test_mkdir -p $DIR/${tdir}f
5929 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5931 run_test 65f "dir setstripe permission (should return error) ==="
5934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5935 test_mkdir -p $DIR/$tdir
5936 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5938 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5940 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5941 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5942 error "delete default stripe failed"
5944 run_test 65g "directory setstripe -d ==========================="
5947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5948 test_mkdir -p $DIR/$tdir
5949 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5951 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5953 test_mkdir -p $DIR/$tdir/dd1
5954 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5955 error "stripe info inherit failed"
5957 run_test 65h "directory stripe info inherit ===================="
5960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5962 save_layout_restore_at_exit $MOUNT
5964 # bug6367: set non-default striping on root directory
5965 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
5967 # bug12836: getstripe on -1 default directory striping
5968 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
5970 # bug12836: getstripe -v on -1 default directory striping
5971 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
5973 # bug12836: new find on -1 default directory striping
5974 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5976 run_test 65i "various tests to set root directory striping"
5978 test_65j() { # bug6367
5979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5983 # if we aren't already remounting for each test, do so for this test
5984 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5985 cleanup || error "failed to unmount"
5989 save_layout_restore_at_exit $MOUNT
5991 $LFS setstripe -d $MOUNT || error "setstripe failed"
5993 run_test 65j "set default striping on root directory (bug 6367)="
5995 test_65k() { # bug11679
5996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5997 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5998 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6000 local disable_precreate=true
6001 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
6002 disable_precreate=false
6004 echo "Check OST status: "
6005 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
6006 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
6008 for OSC in $MDS_OSCS; do
6009 echo $OSC "is active"
6010 do_facet $SINGLEMDS lctl --device %$OSC activate
6013 for INACTIVE_OSC in $MDS_OSCS; do
6014 local ost=$(osc_to_ost $INACTIVE_OSC)
6015 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
6016 lov.*md*.target_obd |
6017 awk -F: /$ost/'{ print $1 }' | head -n 1)
6020 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
6021 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
6023 echo "Deactivate: " $INACTIVE_OSC
6024 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
6026 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
6027 osp.$ost*MDT0000.create_count")
6028 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
6029 osp.$ost*MDT0000.max_create_count")
6030 $disable_precreate &&
6031 do_facet $SINGLEMDS "lctl set_param -n \
6032 osp.$ost*MDT0000.max_create_count=0"
6034 for idx in $(seq 0 $((OSTCOUNT - 1))); do
6035 [ -f $DIR/$tdir/$idx ] && continue
6036 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
6037 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
6038 error "setstripe $idx should succeed"
6039 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
6041 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
6044 do_facet $SINGLEMDS "lctl set_param -n \
6045 osp.$ost*MDT0000.max_create_count=$max_count"
6046 do_facet $SINGLEMDS "lctl set_param -n \
6047 osp.$ost*MDT0000.create_count=$count"
6048 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6049 echo $INACTIVE_OSC "is Activate"
6051 wait_osc_import_state mds ost$ostnum FULL
6054 run_test 65k "validate manual striping works properly with deactivated OSCs"
6056 test_65l() { # bug 12836
6057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6058 test_mkdir -p $DIR/$tdir/test_dir
6059 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
6060 $LFS find -mtime -1 $DIR/$tdir >/dev/null
6062 run_test 65l "lfs find on -1 stripe dir ========================"
6065 local layout=$(save_layout $MOUNT)
6066 $RUNAS $SETSTRIPE -c 2 $MOUNT && {
6067 restore_layout $MOUNT $layout
6068 error "setstripe should fail by non-root users"
6072 run_test 65m "normal user can't set filesystem default stripe"
6075 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.6) ]] ||
6076 skip "Need MDS version at least 2.10.6"
6077 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
6079 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
6080 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
6081 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
6083 local root_layout=$(save_layout $MOUNT)
6084 stack_trap "restore_layout $MOUNT $root_layout" EXIT
6086 # new subdirectory under root directory should not inherit
6087 # the default layout from root
6088 local dir1=$MOUNT/$tdir-1
6089 mkdir $dir1 || error "mkdir $dir1 failed"
6090 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
6091 error "$dir1 shouldn't have LOV EA"
6093 # delete the default layout on root directory
6094 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
6096 local dir2=$MOUNT/$tdir-2
6097 mkdir $dir2 || error "mkdir $dir2 failed"
6098 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
6099 error "$dir2 shouldn't have LOV EA"
6101 # set a new striping pattern on root directory
6102 local def_stripe_size=$($LFS getstripe -S $MOUNT)
6103 local new_def_stripe_size=$((def_stripe_size * 2))
6104 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
6105 error "set stripe size on $MOUNT failed"
6107 # new file created in $dir2 should inherit the new stripe size from
6108 # the filesystem default
6109 local file2=$dir2/$tfile-2
6110 touch $file2 || error "touch $file2 failed"
6112 local file2_stripe_size=$($LFS getstripe -S $file2)
6113 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
6114 error "$file2 didn't inherit stripe size $new_def_stripe_size"
6116 local dir3=$MOUNT/$tdir-3
6117 mkdir $dir3 || error "mkdir $dir3 failed"
6118 ! getfattr -n trusted.lov $dir3 &> /dev/null ||
6119 error "$dir3 shouldn't have LOV EA"
6121 # set OST pool on root directory
6122 local pool=$TESTNAME
6123 pool_add $pool || error "add $pool failed"
6124 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
6125 error "add targets to $pool failed"
6127 $LFS setstripe -p $pool $MOUNT ||
6128 error "set OST pool on $MOUNT failed"
6130 # new file created in $dir3 should inherit the pool from
6131 # the filesystem default
6132 local file3=$dir3/$tfile-3
6133 touch $file3 || error "touch $file3 failed"
6135 local file3_pool=$($LFS getstripe -p $file3)
6136 [[ "$file3_pool" = "$pool" ]] ||
6137 error "$file3 didn't inherit OST pool $pool"
6139 local dir4=$MOUNT/$tdir-4
6140 mkdir $dir4 || error "mkdir $dir4 failed"
6141 ! getfattr -n trusted.lov $dir4 &> /dev/null ||
6142 error "$dir4 shouldn't have LOV EA"
6144 # new file created in $dir4 should inherit the pool from
6145 # the filesystem default
6146 local file4=$dir4/$tfile-4
6147 touch $file4 || error "touch $file4 failed"
6149 local file4_pool=$($LFS getstripe -p $file4)
6150 [[ "$file4_pool" = "$pool" ]] ||
6151 error "$file4 didn't inherit OST pool $pool"
6153 # new subdirectory under non-root directory should inherit
6154 # the default layout from its parent directory
6155 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
6156 error "set directory layout on $dir4 failed"
6158 local dir5=$dir4/$tdir-5
6159 mkdir $dir5 || error "mkdir $dir5 failed"
6161 local dir4_layout=$(get_layout_param $dir4)
6162 local dir5_layout=$(get_layout_param $dir5)
6163 [[ "$dir4_layout" = "$dir5_layout" ]] ||
6164 error "$dir5 should inherit the default layout from $dir4"
6166 run_test 65n "don't inherit default layout from root for new subdirectories"
6168 # bug 2543 - update blocks count on client
6170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6172 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6173 sync; sync_all_data; sync; sync_all_data
6174 cancel_lru_locks osc
6175 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6176 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6178 run_test 66 "update inode blocks count on client ==============="
6181 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6185 swapon -s | awk '($1 == "'$1'") { print $4 }'
6188 # bug5265, obdfilter oa2dentry return -ENOENT
6189 # #define OBD_FAIL_SRV_ENOENT 0x217
6191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6192 remote_ost_nodsh && skip "remote OST with nodsh" && return
6195 $SETSTRIPE -c 1 -i 0 $f
6197 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6199 do_facet ost1 lctl set_param fail_loc=0x217
6200 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6201 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6203 do_facet ost1 lctl set_param fail_loc=0
6204 $DIRECTIO write $f 0 2 || error "write error"
6206 cancel_lru_locks osc
6207 $DIRECTIO read $f 0 1 || error "read error"
6209 do_facet ost1 lctl set_param fail_loc=0x217
6210 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6212 do_facet ost1 lctl set_param fail_loc=0
6215 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6218 test_mkdir -p $DIR/$tdir
6219 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6220 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6222 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6224 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6226 [ "$RUNAS_ID" = "$UID" ] &&
6227 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6229 # Check that testing environment is properly set up. Skip if not
6230 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
6231 skip_env "User $RUNAS_ID does not exist - skipping"
6235 chmod 777 $DIR/$tfile
6236 chmod ug+s $DIR/$tfile
6237 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6238 error "$RUNAS dd $DIR/$tfile failed"
6239 # See if we are still setuid/sgid
6240 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6241 error "S/gid is not dropped on write"
6242 # Now test that MDS is updated too
6243 cancel_lru_locks mdc
6244 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6245 error "S/gid is not dropped on MDS"
6248 run_test 72a "Test that remove suid works properly (bug5695) ===="
6250 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6253 [ "$RUNAS_ID" = "$UID" ] && \
6254 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6255 [ "$RUNAS_ID" -eq 0 ] && \
6256 skip_env "RUNAS_ID = 0 -- skipping" && return
6258 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6259 # Check that testing environment is properly set up. Skip if not
6260 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
6261 skip_env "User $RUNAS_ID does not exist - skipping"
6264 touch $DIR/${tfile}-f{g,u}
6265 test_mkdir $DIR/${tfile}-dg
6266 test_mkdir $DIR/${tfile}-du
6267 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6268 chmod g+s $DIR/${tfile}-{f,d}g
6269 chmod u+s $DIR/${tfile}-{f,d}u
6270 for perm in 777 2777 4777; do
6271 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6272 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6273 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6274 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6278 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6280 # bug 3462 - multiple simultaneous MDC requests
6282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6283 test_mkdir $DIR/d73-1
6284 test_mkdir $DIR/d73-2
6285 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6288 lctl set_param fail_loc=0x80000129
6289 $MULTIOP $DIR/d73-1/f73-2 Oc &
6291 lctl set_param fail_loc=0
6293 $MULTIOP $DIR/d73-2/f73-3 Oc &
6297 wait $pid1 || return 1
6301 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6302 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6303 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6307 run_test 73 "multiple MDC requests (should not deadlock)"
6309 test_74a() { # bug 6149, 6184
6310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6311 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6313 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6314 # will spin in a tight reconnection loop
6316 $LCTL set_param fail_loc=0x8000030e
6317 # get any lock that won't be difficult - lookup works.
6319 $LCTL set_param fail_loc=0
6323 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6325 test_74b() { # bug 13310
6326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6327 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6329 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6330 # will spin in a tight reconnection loop
6331 $LCTL set_param fail_loc=0x8000030e
6332 # get a "difficult" lock
6334 $LCTL set_param fail_loc=0
6338 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6341 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6342 #define OBD_FAIL_LDLM_NEW_LOCK
6343 $LCTL set_param fail_loc=0x319
6344 touch $DIR/$tfile && error "touch successful"
6345 $LCTL set_param fail_loc=0
6348 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6351 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6354 test_76() { # Now for bug 20433, added originally in bug 1443
6355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6356 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6357 cancel_lru_locks osc
6358 BEFORE_INODES=$(num_inodes)
6359 echo "before inodes: $BEFORE_INODES"
6361 [ "$SLOW" = "no" ] && COUNT=100
6362 for i in $(seq $COUNT); do
6366 cancel_lru_locks osc
6367 AFTER_INODES=$(num_inodes)
6368 echo "after inodes: $AFTER_INODES"
6370 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6372 AFTER_INODES=$(num_inodes)
6374 echo "wait $wait seconds inodes: $AFTER_INODES"
6375 if [ $wait -gt 30 ]; then
6376 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6380 run_test 76 "confirm clients recycle inodes properly ===="
6386 # Note: in sptlrpc modes which enable its own bulk checksum, the
6387 # original crc32_le bulk checksum will be automatically disabled,
6388 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6389 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6390 # In this case set_checksums() will not be no-op, because sptlrpc
6391 # bulk checksum will be enabled all through the test.
6393 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6394 lctl set_param -n osc.*.checksums $1
6398 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6399 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6400 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6401 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6404 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6405 log "set checksum type to $1"
6408 F77_TMP=$TMP/f77-temp
6411 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6412 error "error writing to $F77_TMP"
6415 test_77a() { # bug 10889
6416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6417 $GSS && skip "could not run with gss" && return
6418 [ ! -f $F77_TMP ] && setup_f77
6420 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6424 run_test 77a "normal checksum read/write operation"
6426 test_77b() { # bug 10889
6427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6428 $GSS && skip "could not run with gss" && return
6429 [ ! -f $F77_TMP ] && setup_f77
6430 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6431 $LCTL set_param fail_loc=0x80000409
6434 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6435 error "dd error: $?"
6436 $LCTL set_param fail_loc=0
6438 for algo in $CKSUM_TYPES; do
6439 cancel_lru_locks osc
6440 set_checksum_type $algo
6441 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6442 $LCTL set_param fail_loc=0x80000408
6443 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6444 $LCTL set_param fail_loc=0
6447 set_checksum_type $ORIG_CSUM_TYPE
6450 run_test 77b "checksum error on client write, read"
6455 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6457 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6458 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6459 $check_ost && [ -n $ost_file_prefix ] &&
6460 do_facet ost1 rm -f ${ost_file_prefix}\*
6464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6465 $GSS && skip "could not run with gss" && return
6468 local osc_file_prefix
6470 local check_ost=false
6471 local ost_file_prefix
6477 # ensure corruption will occur on first OSS/OST
6478 $LFS setstripe -i 0 $DIR/$tfile
6480 [ ! -f $F77_TMP ] && setup_f77
6481 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6482 error "dd write error: $?"
6483 fid=$($LFS path2fid $DIR/$tfile)
6485 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6488 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6489 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6491 echo "OSS do not support bulk pages dump upon error"
6494 osc_file_prefix=$($LCTL get_param -n debug_path)
6495 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6497 trap cleanup_77c EXIT
6500 # enable bulk pages dump upon error on Client
6501 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6502 # enable bulk pages dump upon error on OSS
6504 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6506 # flush Client cache to allow next read to reach OSS
6507 cancel_lru_locks osc
6509 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6510 $LCTL set_param fail_loc=0x80000408
6511 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6512 $LCTL set_param fail_loc=0
6516 # check cksum dump on Client
6517 osc_file=$(ls ${osc_file_prefix}*)
6518 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6519 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6520 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6521 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6522 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6524 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6525 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6526 error "dump content does not match on Client"
6528 $check_ost || { skip "No need to check cksum dump on OSS"; return 0; }
6530 # check cksum dump on OSS
6531 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6532 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6533 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6534 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6535 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6536 error "dump content does not match on OSS"
6540 run_test 77c "checksum error on client read with debug"
6542 test_77d() { # bug 10889
6543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6544 $GSS && skip "could not run with gss" && return
6545 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6546 $LCTL set_param fail_loc=0x80000409
6548 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6549 error "direct write: rc=$?"
6550 $LCTL set_param fail_loc=0
6553 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6554 $LCTL set_param fail_loc=0x80000408
6556 cancel_lru_locks osc
6557 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6558 error "direct read: rc=$?"
6559 $LCTL set_param fail_loc=0
6562 run_test 77d "checksum error on OST direct write, read"
6564 test_77f() { # bug 10889
6565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6566 $GSS && skip "could not run with gss" && return
6568 for algo in $CKSUM_TYPES; do
6569 cancel_lru_locks osc
6570 set_checksum_type $algo
6571 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6572 $LCTL set_param fail_loc=0x409
6573 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6574 error "direct write succeeded"
6575 $LCTL set_param fail_loc=0
6577 set_checksum_type $ORIG_CSUM_TYPE
6580 run_test 77f "repeat checksum error on write (expect error)"
6582 test_77g() { # bug 10889
6583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6584 $GSS && skip "could not run with gss" && return
6585 remote_ost_nodsh && skip "remote OST with nodsh" && return
6587 [ ! -f $F77_TMP ] && setup_f77
6589 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6590 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6591 do_facet ost1 lctl set_param fail_loc=0x8000021a
6593 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6594 error "write error: rc=$?"
6595 do_facet ost1 lctl set_param fail_loc=0
6598 cancel_lru_locks osc
6599 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6600 do_facet ost1 lctl set_param fail_loc=0x8000021b
6602 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6603 do_facet ost1 lctl set_param fail_loc=0
6606 run_test 77g "checksum error on OST write, read"
6608 test_77j() { # bug 13805
6609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6610 $GSS && skip "could not run with gss" && return
6611 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6612 lctl set_param fail_loc=0x40c
6613 remount_client $MOUNT
6614 lctl set_param fail_loc=0
6615 # wait async osc connect to finish and reflect updated state value
6617 for (( i=0; i < OSTCOUNT; i++ )) ; do
6618 wait_osc_import_state client ost$((i+1)) FULL
6621 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6622 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6623 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6624 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6626 remount_client $MOUNT
6628 run_test 77j "client only supporting ADLER32"
6630 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6639 test_78() { # bug 10901
6640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6641 remote_ost || { skip_env "local OST" && return; }
6644 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6645 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6646 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6647 echo "MemTotal: $MEMTOTAL"
6649 # reserve 256MB of memory for the kernel and other running processes,
6650 # and then take 1/2 of the remaining memory for the read/write buffers.
6651 if [ $MEMTOTAL -gt 512 ] ;then
6652 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6654 # for those poor memory-starved high-end clusters...
6655 MEMTOTAL=$((MEMTOTAL / 2))
6657 echo "Mem to use for directio: $MEMTOTAL"
6659 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6660 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6661 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6662 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6664 echo "Smallest OST: $SMALLESTOST"
6665 [[ $SMALLESTOST -lt 10240 ]] &&
6666 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6668 trap cleanup_test_78 EXIT
6670 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6671 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6673 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6674 echo "File size: $F78SIZE"
6675 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6676 for i in $(seq 1 $NSEQ); do
6677 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6678 echo directIO rdwr round $i of $NSEQ
6679 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6684 run_test 78 "handle large O_DIRECT writes correctly ============"
6686 test_79() { # bug 12743
6687 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6688 wait_delete_completed
6690 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6691 BKFREE=$(calc_osc_kbytes kbytesfree)
6692 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6694 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6695 DFTOTAL=`echo $STRING | cut -d, -f1`
6696 DFUSED=`echo $STRING | cut -d, -f2`
6697 DFAVAIL=`echo $STRING | cut -d, -f3`
6698 DFFREE=$(($DFTOTAL - $DFUSED))
6700 ALLOWANCE=$((64 * $OSTCOUNT))
6702 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6703 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6704 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6706 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6707 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6708 error "df free($DFFREE) mismatch OST free($BKFREE)"
6710 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6711 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6712 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6715 run_test 79 "df report consistency check ======================="
6717 test_80() { # bug 10718
6718 remote_ost_nodsh && skip "remote OST with nodsh" && return
6719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6720 # relax strong synchronous semantics for slow backends like ZFS
6721 local soc="obdfilter.*.sync_on_lock_cancel"
6722 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6724 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6725 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6726 facet_active_host $host; done | sort -u)
6727 do_nodes $hosts lctl set_param $soc=never
6730 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6732 local BEFORE=`date +%s`
6733 cancel_lru_locks osc
6734 local AFTER=`date +%s`
6735 local DIFF=$((AFTER-BEFORE))
6736 if [ $DIFF -gt 1 ] ; then
6737 error "elapsed for 1M@1T = $DIFF"
6740 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6744 run_test 80 "Page eviction is equally fast at high offsets too ===="
6746 test_81a() { # LU-456
6747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6748 remote_ost_nodsh && skip "remote OST with nodsh" && return
6749 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6750 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6751 do_facet ost1 lctl set_param fail_loc=0x80000228
6753 # write should trigger a retry and success
6754 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6755 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6757 if [ $RC -ne 0 ] ; then
6758 error "write should success, but failed for $RC"
6761 run_test 81a "OST should retry write when get -ENOSPC ==============="
6763 test_81b() { # LU-456
6764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6765 remote_ost_nodsh && skip "remote OST with nodsh" && return
6766 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6767 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6768 do_facet ost1 lctl set_param fail_loc=0x228
6770 # write should retry several times and return -ENOSPC finally
6771 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6772 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6775 if [ $RC -ne $ENOSPC ] ; then
6776 error "dd should fail for -ENOSPC, but succeed."
6779 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6781 test_82() { # LU-1031
6782 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6786 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6788 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6790 kill -USR1 $MULTIPID2
6792 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6793 error "First grouplock does not block second one"
6795 echo "Second grouplock blocks first one"
6797 kill -USR1 $MULTIPID1
6801 run_test 82 "Basic grouplock test ==============================="
6804 local sfile="/boot/System.map-$(uname -r)"
6805 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6806 $LCTL set_param fail_loc=0x140d
6807 cp $sfile $DIR/$tfile || error "write failed"
6808 diff -c $sfile $DIR/$tfile || error "files are different"
6809 $LCTL set_param fail_loc=0
6812 run_test 83 "Short write in ptask ==============================="
6815 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6817 test_mkdir -p $DIR/d99cvsroot
6818 chown $RUNAS_ID $DIR/d99cvsroot
6819 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6822 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6825 run_test 99a "cvs init ========================================="
6828 [ -z "$(which cvs 2>/dev/null)" ] &&
6829 skip_env "could not find cvs" && return
6830 [ ! -d $DIR/d99cvsroot ] && test_99a
6832 # some versions of cvs import exit(1) when asked to import links or
6833 # files they can't read. ignore those files.
6834 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6835 ! -perm /4 -printf '-I %f\n')
6836 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6837 d99reposname vtag rtag
6839 run_test 99b "cvs import ======================================="
6842 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6843 [ ! -d $DIR/d99cvsroot ] && test_99b
6845 test_mkdir -p $DIR/d99reposname
6846 chown $RUNAS_ID $DIR/d99reposname
6847 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6849 run_test 99c "cvs checkout ====================================="
6852 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6853 [ ! -d $DIR/d99cvsroot ] && test_99c
6854 cd $DIR/d99reposname
6856 $RUNAS cvs add -m 'addmsg' foo99
6858 run_test 99d "cvs add =========================================="
6861 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6862 [ ! -d $DIR/d99cvsroot ] && test_99c
6863 cd $DIR/d99reposname
6866 run_test 99e "cvs update ======================================="
6869 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6870 [ ! -d $DIR/d99cvsroot ] && test_99d
6871 cd $DIR/d99reposname
6872 $RUNAS cvs commit -m 'nomsg' foo99
6873 rm -fr $DIR/d99cvsroot
6875 run_test 99f "cvs commit ======================================="
6878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6879 [[ "$NETTYPE" =~ tcp ]] ||
6880 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
6883 remote_ost_nodsh && skip "remote OST with nodsh" && return
6884 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6886 { skip "useless for local single node setup" && return; }
6888 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6889 [ "$PROT" != "tcp" ] && continue
6890 RPORT=$(echo $REMOTE | cut -d: -f2)
6891 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6894 LPORT=`echo $LOCAL | cut -d: -f2`
6895 if [ $LPORT -ge 1024 ]; then
6896 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6898 error_exit "local: $LPORT > 1024, remote: $RPORT"
6901 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6903 run_test 100 "check local port using privileged port ==========="
6905 function get_named_value()
6914 echo $line | sed "s/^$tag[ ]*//"
6921 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6922 awk '/^max_cached_mb/ { print $2 }')
6925 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6931 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
6935 local cache_limit=32
6937 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6938 trap cleanup_101a EXIT
6939 $LCTL set_param -n llite.*.read_ahead_stats 0
6940 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6943 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6945 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6946 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6949 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6950 get_named_value 'read but discarded' | cut -d" " -f1); do
6951 discard=$(($discard + $s))
6955 if [[ $(($discard * 10)) -gt $nreads ]]; then
6956 $LCTL get_param osc.*-osc*.rpc_stats
6957 $LCTL get_param llite.*.read_ahead_stats
6958 error "too many ($discard) discarded pages"
6960 rm -f $DIR/$tfile || true
6962 run_test 101a "check read-ahead for random reads ================"
6965 test_mkdir -p $DIR/$tdir
6966 local STRIPE_SIZE=$1
6967 local FILE_LENGTH=$2
6970 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6972 local list=$(comma_list $(osts_nodes))
6973 set_osd_param $list '' read_cache_enable 0
6974 set_osd_param $list '' writethrough_cache_enable 0
6976 trap cleanup_test101bc EXIT
6977 # prepare the read-ahead file
6978 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6980 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6981 count=$FILE_SIZE_MB 2> /dev/null
6985 cleanup_test101bc() {
6990 local list=$(comma_list $(osts_nodes))
6991 set_osd_param $list '' read_cache_enable 1
6992 set_osd_param $list '' writethrough_cache_enable 1
6996 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
7001 local STRIPE_SIZE=$2
7002 local FILE_LENGTH=$3
7003 local RA_INC=1048576
7004 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
7005 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
7006 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
7007 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
7008 get_named_value 'read but discarded' |
7009 cut -d" " -f1 | calc_total)
7010 if [[ $DISCARD -gt $discard_limit ]]; then
7011 $LCTL get_param llite.*.read_ahead_stats
7012 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
7014 echo "Read-ahead success for size ${READ_SIZE}"
7019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7020 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7021 local STRIPE_SIZE=1048576
7022 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
7023 if [ $SLOW == "yes" ]; then
7024 local FILE_LENGTH=$((STRIDE_SIZE * 64))
7026 local FILE_LENGTH=$((STRIDE_SIZE * 8))
7029 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
7031 # prepare the read-ahead file
7032 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7033 cancel_lru_locks osc
7034 for BIDX in 2 4 8 16 32 64 128 256
7036 local BSIZE=$((BIDX*4096))
7037 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
7038 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
7039 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
7040 $LCTL set_param -n llite.*.read_ahead_stats 0
7041 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
7042 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
7043 cancel_lru_locks osc
7044 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
7049 run_test 101b "check stride-io mode read-ahead ================="
7052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7053 local STRIPE_SIZE=1048576
7054 local FILE_LENGTH=$((STRIPE_SIZE*100))
7058 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7060 cancel_lru_locks osc
7061 $LCTL set_param osc.*.rpc_stats 0
7062 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
7063 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
7064 local stats=$($LCTL get_param -n $osc_rpc_stats)
7065 local lines=$(echo "$stats" | awk 'END {print NR;}')
7068 if [ $lines -le 20 ]; then
7071 for size in 1 2 4 8; do
7072 local rpc=$(echo "$stats" |
7073 awk '($1 == "'$size':") {print $2; exit; }')
7075 error "Small $((size*4))k read IO $rpc !"
7077 echo "$osc_rpc_stats check passed!"
7082 run_test 101c "check stripe_size aligned read-ahead ================="
7085 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
7086 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
7090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7091 local file=$DIR/$tfile
7092 local sz_MB=${FILESIZE_101d:-500}
7093 local ra_MB=${READAHEAD_MB:-40}
7095 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
7096 [ $free_MB -lt $sz_MB ] &&
7097 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
7099 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
7100 $SETSTRIPE -c -1 $file || error "setstripe failed"
7102 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
7103 echo Cancel LRU locks on lustre client to flush the client cache
7104 cancel_lru_locks osc
7106 echo Disable read-ahead
7107 local old_READAHEAD=$(set_read_ahead 0)
7109 echo Reading the test file $file with read-ahead disabled
7110 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7112 echo Cancel LRU locks on lustre client to flush the client cache
7113 cancel_lru_locks osc
7114 echo Enable read-ahead with ${ra_MB}MB
7115 set_read_ahead $ra_MB
7117 echo Reading the test file $file with read-ahead enabled
7118 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7120 echo "read-ahead disabled time read $raOFF"
7121 echo "read-ahead enabled time read $raON"
7123 set_read_ahead $old_READAHEAD
7125 wait_delete_completed
7127 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
7128 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
7130 run_test 101d "file read with and without read-ahead enabled"
7133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7134 local file=$DIR/$tfile
7135 local size_KB=500 #KB
7139 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
7140 local need_KB=$((count * size_KB))
7141 [[ $free_KB -le $need_KB ]] &&
7142 skip_env "Need free space $need_KB, have $free_KB" && return
7144 echo "Creating $count ${size_KB}K test files"
7145 for ((i = 0; i < $count; i++)); do
7146 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
7149 echo "Cancel LRU locks on lustre client to flush the client cache"
7150 cancel_lru_locks osc
7152 echo "Reset readahead stats"
7153 $LCTL set_param -n llite.*.read_ahead_stats 0
7155 for ((i = 0; i < $count; i++)); do
7156 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
7159 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7160 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7162 for ((i = 0; i < $count; i++)); do
7163 rm -rf $file.$i 2>/dev/null
7166 #10000 means 20% reads are missing in readahead
7167 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7169 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7172 which iozone || { skip "no iozone installed" && return; }
7174 local old_debug=$($LCTL get_param debug)
7175 old_debug=${old_debug#*=}
7176 $LCTL set_param debug="reada mmap"
7178 # create a test file
7179 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7181 echo Cancel LRU locks on lustre client to flush the client cache
7182 cancel_lru_locks osc
7184 echo Reset readahead stats
7185 $LCTL set_param -n llite.*.read_ahead_stats 0
7187 echo mmap read the file with small block size
7188 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7191 echo checking missing pages
7192 $LCTL get_param llite.*.read_ahead_stats
7193 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7194 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7196 $LCTL set_param debug="$old_debug"
7197 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7200 run_test 101f "check mmap read performance"
7202 test_101g_brw_size_test() {
7204 local pages=$((mb * 1048576 / $(page_size)))
7206 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7207 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7208 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7209 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7213 $LCTL set_param -n osc.*.rpc_stats=0
7215 # 10 RPCs should be enough for the test
7217 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
7218 { error "dd write ${mb} MB blocks failed"; return 3; }
7219 cancel_lru_locks osc
7220 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
7221 { error "dd write ${mb} MB blocks failed"; return 4; }
7223 # calculate number of full-sized read and write RPCs
7224 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7225 sed -n '/pages per rpc/,/^$/p' |
7226 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7227 END { print reads,writes }'))
7228 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7230 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7238 local osts=$(get_facets OST)
7239 local list=$(comma_list $(osts_nodes))
7240 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7241 local brw_size="obdfilter.*.brw_size"
7242 local ostver=$(lustre_version_code ost1)
7244 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7246 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7247 if [ $ostver -ge $(version_code 2.8.52) ] ||
7248 [ $ostver -ge $(version_code 2.7.17) -a \
7249 $ostver -lt $(version_code 2.7.50) ]; then
7250 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7251 if [[ $orig_mb -lt 16 ]]; then
7252 save_lustre_params $osts "$brw_size" > $p
7253 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7254 error "set 16MB RPC size failed"
7256 echo "remount client to enable new RPC size"
7257 remount_client $MOUNT || error "remount_client failed"
7260 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7261 # should be able to set brw_size=12, but no rpc_stats for that
7262 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7265 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7267 if [[ $orig_mb -lt 16 ]]; then
7268 restore_lustre_params < $p
7269 remount_client $MOUNT || error "remount_client restore failed"
7272 rm -f $p $DIR/$tfile
7274 run_test 101g "Big bulk(4/16 MiB) readahead"
7277 test_mkdir $DIR/$tdir
7278 chown $RUNAS_ID $DIR/$tdir
7281 STRIPE_COUNT=$OSTCOUNT
7282 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7284 trap cleanup_test102 EXIT
7286 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7288 for num in 1 2 3 4; do
7289 for count in $(seq 1 $STRIPE_COUNT); do
7290 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7291 local size=`expr $STRIPE_SIZE \* $num`
7292 local file=file"$num-$idx-$count"
7293 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7299 $1 tar cf $TMP/f102.tar $tdir --xattrs
7305 rm -rf $DIR/d0.sanity/d102
7309 local testfile=$DIR/$tfile
7313 [ "$UID" != 0 ] && skip_env "must run as root" && return
7314 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7315 skip_env "must have user_xattr" && return
7317 [ -z "$(which setfattr 2>/dev/null)" ] &&
7318 skip_env "could not find setfattr" && return
7320 echo "set/get xattr..."
7321 setfattr -n trusted.name1 -v value1 $testfile ||
7322 error "setfattr -n trusted.name1=value1 $testfile failed"
7323 getfattr -n trusted.name1 $testfile 2> /dev/null |
7324 grep "trusted.name1=.value1" ||
7325 error "$testfile missing trusted.name1=value1"
7327 setfattr -n user.author1 -v author1 $testfile ||
7328 error "setfattr -n user.author1=author1 $testfile failed"
7329 getfattr -n user.author1 $testfile 2> /dev/null |
7330 grep "user.author1=.author1" ||
7331 error "$testfile missing trusted.author1=author1"
7334 setfattr -n trusted.name2 -v value2 $testfile ||
7335 error "$testfile unable to set trusted.name2"
7336 setfattr -n trusted.name3 -v value3 $testfile ||
7337 error "$testfile unable to set trusted.name3"
7338 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7339 grep "trusted.name" | wc -l) -eq 3 ] ||
7340 error "$testfile missing 3 trusted.name xattrs"
7342 setfattr -n user.author2 -v author2 $testfile ||
7343 error "$testfile unable to set user.author2"
7344 setfattr -n user.author3 -v author3 $testfile ||
7345 error "$testfile unable to set user.author3"
7346 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7347 grep "user.author" | wc -l) -eq 3 ] ||
7348 error "$testfile missing 3 user.author xattrs"
7350 echo "remove xattr..."
7351 setfattr -x trusted.name1 $testfile ||
7352 error "$testfile error deleting trusted.name1"
7353 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7354 error "$testfile did not delete trusted.name1 xattr"
7356 setfattr -x user.author1 $testfile ||
7357 error "$testfile error deleting user.author1"
7358 echo "set lustre special xattr ..."
7359 $LFS setstripe -c1 $testfile
7360 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7361 awk -F "=" '/trusted.lov/ { print $2 }' )
7362 setfattr -n "trusted.lov" -v $lovea $testfile ||
7363 error "$testfile doesn't ignore setting trusted.lov again"
7364 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7365 error "$testfile allow setting invalid trusted.lov"
7368 run_test 102a "user xattr test =================================="
7371 [ -z "$(which setfattr 2>/dev/null)" ] &&
7372 skip_env "could not find setfattr" && return
7374 # b10930: get/set/list trusted.lov xattr
7375 echo "get/set/list trusted.lov xattr ..."
7376 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7377 local testfile=$DIR/$tfile
7378 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7379 error "setstripe failed"
7380 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7381 error "getstripe failed"
7382 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7383 error "can't get trusted.lov from $testfile"
7385 local testfile2=${testfile}2
7386 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7387 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7390 setfattr -n trusted.lov -v $value $testfile2
7391 local stripe_size=$($GETSTRIPE -S $testfile2)
7392 local stripe_count=$($GETSTRIPE -c $testfile2)
7393 [[ $stripe_size -eq 65536 ]] ||
7394 error "stripe size $stripe_size != 65536"
7395 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7396 error "stripe count $stripe_count != $STRIPECOUNT"
7399 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7402 [ -z "$(which setfattr 2>/dev/null)" ] &&
7403 skip_env "could not find setfattr" && return
7405 # b10930: get/set/list lustre.lov xattr
7406 echo "get/set/list lustre.lov xattr ..."
7407 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7408 test_mkdir $DIR/$tdir
7409 chown $RUNAS_ID $DIR/$tdir
7410 local testfile=$DIR/$tdir/$tfile
7411 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7412 error "setstripe failed"
7413 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7414 error "getstripe failed"
7415 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7416 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7418 local testfile2=${testfile}2
7419 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7420 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7422 $RUNAS $MCREATE $testfile2
7423 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7424 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7425 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7426 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7427 [ $stripe_count -eq $STRIPECOUNT ] ||
7428 error "stripe count $stripe_count != $STRIPECOUNT"
7430 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7432 compare_stripe_info1() {
7433 local stripe_index_all_zero=true
7435 for num in 1 2 3 4; do
7436 for count in $(seq 1 $STRIPE_COUNT); do
7437 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7438 local size=$((STRIPE_SIZE * num))
7439 local file=file"$num-$offset-$count"
7440 stripe_size=$($LFS getstripe -S $PWD/$file)
7441 [[ $stripe_size -ne $size ]] &&
7442 error "$file: size $stripe_size != $size"
7443 stripe_count=$($LFS getstripe -c $PWD/$file)
7444 # allow fewer stripes to be created, ORI-601
7445 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7446 error "$file: count $stripe_count != $count"
7447 stripe_index=$($LFS getstripe -i $PWD/$file)
7448 [[ $stripe_index -ne 0 ]] &&
7449 stripe_index_all_zero=false
7453 $stripe_index_all_zero &&
7454 error "all files are being extracted starting from OST index 0"
7458 have_xattrs_include() {
7459 tar --help | grep -q xattrs-include &&
7460 echo --xattrs-include="lustre.*"
7464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7465 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7466 local xinc=$(have_xattrs_include)
7468 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7470 compare_stripe_info1
7472 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
7475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7476 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7477 local xinc=$(have_xattrs_include)
7479 test_mkdir $DIR/$tdir.restore
7481 tar cf - --xattrs $tdir | tar xf - \
7482 -C $DIR/$tdir.restore --xattrs $xinc
7483 cd $DIR/$tdir.restore/$tdir
7484 compare_stripe_info1
7486 run_test 102f "tar copy files, not keep osts ==========="
7489 local xsize=${1:-1024} # in bytes
7490 local file=$DIR/$tfile
7492 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7493 skip "must have user_xattr" && return 0
7494 [ -z "$(which setfattr 2>/dev/null)" ] &&
7495 skip_env "could not find setfattr" && return 0
7496 [ -z "$(which getfattr 2>/dev/null)" ] &&
7497 skip_env "could not find getfattr" && return 0
7501 local value="$(generate_string $xsize)"
7503 local xbig=trusted.big
7504 log "save $xbig on $file"
7505 setfattr -n $xbig -v $value $file ||
7506 error "saving $xbig on $file failed"
7508 local orig=$(get_xattr_value $xbig $file)
7509 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7511 local xsml=trusted.sml
7512 log "save $xsml on $file"
7513 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7515 local new=$(get_xattr_value $xbig $file)
7516 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7518 log "grow $xsml on $file"
7519 setfattr -n $xsml -v "$value" $file ||
7520 error "growing $xsml on $file failed"
7522 new=$(get_xattr_value $xbig $file)
7523 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7524 log "$xbig still valid after growing $xsml"
7529 test_102h() { # bug 15777
7532 run_test 102h "grow xattr from inside inode to external block"
7535 large_xattr_enabled || { skip "ea_inode feature disabled" && return; }
7536 grow_xattr $(max_xattr_size)
7538 run_test 102ha "grow xattr from inside inode to external inode"
7540 test_102i() { # bug 17038
7541 [ -z "$(which getfattr 2>/dev/null)" ] &&
7542 skip "could not find getfattr" && return
7544 ln -s $DIR/$tfile $DIR/${tfile}link
7545 getfattr -n trusted.lov $DIR/$tfile ||
7546 error "lgetxattr on $DIR/$tfile failed"
7547 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7548 grep -i "no such attr" ||
7549 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7550 rm -f $DIR/$tfile $DIR/${tfile}link
7552 run_test 102i "lgetxattr test on symbolic link ============"
7555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7556 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7557 local xinc=$(have_xattrs_include)
7558 setup_test102 "$RUNAS"
7559 chown $RUNAS_ID $DIR/$tdir
7560 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7562 compare_stripe_info1 "$RUNAS"
7564 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7567 [ -z "$(which setfattr 2>/dev/null)" ] &&
7568 skip "could not find setfattr" && return
7570 # b22187 just check that does not crash for regular file.
7571 setfattr -n trusted.lov $DIR/$tfile
7572 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
7573 local test_kdir=$DIR/$tdir
7574 test_mkdir $test_kdir
7575 local default_size=`$GETSTRIPE -S $test_kdir`
7576 local default_count=`$GETSTRIPE -c $test_kdir`
7577 local default_offset=`$GETSTRIPE -i $test_kdir`
7578 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7579 error 'dir setstripe failed'
7580 setfattr -n trusted.lov $test_kdir
7581 local stripe_size=`$GETSTRIPE -S $test_kdir`
7582 local stripe_count=`$GETSTRIPE -c $test_kdir`
7583 local stripe_offset=`$GETSTRIPE -i $test_kdir`
7584 [ $stripe_size -eq $default_size ] ||
7585 error "stripe size $stripe_size != $default_size"
7586 [ $stripe_count -eq $default_count ] ||
7587 error "stripe count $stripe_count != $default_count"
7588 [ $stripe_offset -eq $default_offset ] ||
7589 error "stripe offset $stripe_offset != $default_offset"
7590 rm -rf $DIR/$tfile $test_kdir
7592 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7595 [ -z "$(which getfattr 2>/dev/null)" ] &&
7596 skip "could not find getfattr" && return
7598 # LU-532 trusted. xattr is invisible to non-root
7599 local testfile=$DIR/$tfile
7603 echo "listxattr as user..."
7604 chown $RUNAS_ID $testfile
7605 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7606 grep -q "trusted" &&
7607 error "$testfile trusted xattrs are user visible"
7611 run_test 102l "listxattr size test =================================="
7613 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7614 local path=$DIR/$tfile
7617 listxattr_size_check $path || error "listattr_size_check $path failed"
7619 run_test 102m "Ensure listxattr fails on small bufffer ========"
7623 getxattr() { # getxattr path name
7624 # Return the base64 encoding of the value of xattr name on path.
7628 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7630 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7632 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7634 getfattr --absolute-names --encoding=base64 --name=$name $path |
7635 awk -F= -v name=$name '$1 == name {
7636 print substr($0, index($0, "=") + 1);
7640 test_102n() { # LU-4101 mdt: protect internal xattrs
7641 [ -z "$(which setfattr 2>/dev/null)" ] &&
7642 skip "could not find setfattr" && return
7643 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7645 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7649 local file0=$DIR/$tfile.0
7650 local file1=$DIR/$tfile.1
7651 local xattr0=$TMP/$tfile.0
7652 local xattr1=$TMP/$tfile.1
7653 local namelist="lov lma lmv link fid version som hsm"
7657 rm -rf $file0 $file1 $xattr0 $xattr1
7660 # Get 'before' xattrs of $file1.
7661 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7663 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7664 namelist+=" lfsck_namespace"
7665 for name in $namelist; do
7666 # Try to copy xattr from $file0 to $file1.
7667 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7669 setfattr --name=trusted.$name --value="$value" $file1 ||
7670 error "setxattr 'trusted.$name' failed"
7672 # Try to set a garbage xattr.
7673 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7675 if [[ x$name == "xlov" ]]; then
7676 setfattr --name=trusted.lov --value="$value" $file1 &&
7677 error "setxattr invalid 'trusted.lov' success"
7679 setfattr --name=trusted.$name --value="$value" $file1 ||
7680 error "setxattr invalid 'trusted.$name' failed"
7683 # Try to remove the xattr from $file1. We don't care if this
7684 # appears to succeed or fail, we just don't want there to be
7685 # any changes or crashes.
7686 setfattr --remove=$trusted.$name $file1 2> /dev/null
7689 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7692 # Try to copy xattr from $file0 to $file1.
7693 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7695 setfattr --name=trusted.$name --value="$value" $file1 ||
7696 error "setxattr 'trusted.$name' failed"
7698 # Try to set a garbage xattr.
7699 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7701 setfattr --name=trusted.$name --value="$value" $file1 ||
7702 error "setxattr 'trusted.$name' failed"
7704 # Try to remove the xattr from $file1. We don't care if this
7705 # appears to succeed or fail, we just don't want there to be
7706 # any changes or crashes.
7707 setfattr --remove=$trusted.$name $file1 2> /dev/null
7710 # Get 'after' xattrs of file1.
7711 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7713 if ! diff $xattr0 $xattr1; then
7714 error "before and after xattrs of '$file1' differ"
7717 rm -rf $file0 $file1 $xattr0 $xattr1
7721 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7723 test_102p() { # LU-4703 setxattr did not check ownership
7724 local testfile=$DIR/$tfile
7726 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7727 skip "MDS needs to be at least 2.5.56" && return
7731 echo "setfacl as user..."
7732 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7733 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7735 echo "setfattr as user..."
7736 setfacl -m "u:$RUNAS_ID:---" $testfile
7737 $RUNAS setfattr -x system.posix_acl_access $testfile
7738 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7740 run_test 102p "check setxattr(2) correctly fails without permission"
7743 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7744 skip "MDS needs to be at least 2.6.92" && return
7745 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7747 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7750 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7751 skip "MDS needs to be at least 2.6.93" && return
7752 touch $DIR/$tfile || error "touch"
7753 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7754 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7755 rm $DIR/$tfile || error "rm"
7758 mkdir -p $DIR/$tdir || error "mkdir"
7759 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7760 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7761 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7762 error "$testfile error deleting user.author1"
7763 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7764 grep "user.$(basename $tdir)" &&
7765 error "$tdir did not delete user.$(basename $tdir)"
7766 rmdir $DIR/$tdir || error "rmdir"
7769 test_mkdir $DIR/$tdir || error "make striped dir"
7770 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7771 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7772 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7773 error "$testfile error deleting user.author1"
7774 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7775 grep "user.$(basename $tdir)" &&
7776 error "$tdir did not delete user.$(basename $tdir)"
7777 rmdir $DIR/$tdir || error "rm striped dir"
7779 run_test 102r "set EAs with empty values"
7782 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
7783 skip "MDS needs to be at least 2.11.52"
7785 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
7787 save_lustre_params client "llite.*.xattr_cache" > $save
7789 for cache in 0 1; do
7790 lctl set_param llite.*.xattr_cache=$cache
7793 touch $DIR/$tfile || error "touch"
7794 for prefix in lustre security system trusted user; do
7795 # Note getxattr() may fail with 'Operation not
7796 # supported' or 'No such attribute' depending
7797 # on prefix and cache.
7798 getfattr -n $prefix.n102s $DIR/$tfile &&
7799 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
7803 restore_lustre_params < $save
7805 run_test 102s "getting nonexistent xattrs should fail"
7809 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7814 [ "$UID" != 0 ] && skip_env "must run as root" && return
7815 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7816 skip "must have acl enabled" && return
7817 [ -z "$(which setfacl 2>/dev/null)" ] &&
7818 skip_env "could not find setfacl" && return
7819 $GSS && skip "could not run under gss" && return
7820 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7822 gpasswd -a daemon bin # LU-5641
7823 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7825 declare -a identity_old
7827 for num in $(seq $MDSCOUNT); do
7828 switch_identity $num true || identity_old[$num]=$?
7836 echo "performing cp ..."
7837 run_acl_subtest cp || error "run_acl_subtest cp failed"
7838 echo "performing getfacl-noacl..."
7839 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7840 echo "performing misc..."
7841 run_acl_subtest misc || error "misc test failed"
7842 echo "performing permissions..."
7843 run_acl_subtest permissions || error "permissions failed"
7844 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7845 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7846 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7847 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7849 echo "performing permissions xattr..."
7850 run_acl_subtest permissions_xattr ||
7851 error "permissions_xattr failed"
7853 echo "performing setfacl..."
7854 run_acl_subtest setfacl || error "setfacl test failed"
7856 # inheritance test got from HP
7857 echo "performing inheritance..."
7858 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7859 chmod +x make-tree || error "chmod +x failed"
7860 run_acl_subtest inheritance || error "inheritance test failed"
7863 echo "LU-974 ignore umask when acl is enabled..."
7864 run_acl_subtest 974 || error "LU-974 umask test failed"
7865 if [ $MDSCOUNT -ge 2 ]; then
7866 run_acl_subtest 974_remote ||
7867 error "LU-974 umask test failed under remote dir"
7870 echo "LU-2561 newly created file is same size as directory..."
7871 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7872 run_acl_subtest 2561 || error "LU-2561 test failed"
7874 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7877 run_acl_subtest 4924 || error "LU-4924 test failed"
7882 for num in $(seq $MDSCOUNT); do
7883 if [ "${identity_old[$num]}" = 1 ]; then
7884 switch_identity $num false || identity_old[$num]=$?
7888 run_test 103a "acl test ========================================="
7891 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7893 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7894 local mountopts=$MDS_MOUNT_OPTS
7896 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7900 stop $SINGLEMDS || error "failed to stop MDT."
7902 if [ -z "$MDS_MOUNT_OPTS" ]; then
7903 MDS_MOUNT_OPTS="-o noacl"
7905 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7907 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7908 error "failed to start MDT."
7909 MDS_MOUNT_OPTS=$mountopts
7913 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7917 stop $SINGLEMDS || error "failed to stop MDT."
7919 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7920 error "failed to start MDT."
7925 run_test 103b "MDS mount option 'noacl'"
7929 cp -rp $DIR/$tdir $DIR/$tdir.bak
7931 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7932 error "$DIR/$tdir shouldn't contain default ACL"
7933 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7934 error "$DIR/$tdir.bak shouldn't contain default ACL"
7937 run_test 103c "'cp -rp' won't set empty acl"
7940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7942 lfs df || error "lfs df failed"
7943 lfs df -ih || error "lfs df -ih failed"
7944 lfs df -h $DIR || error "lfs df -h $DIR failed"
7945 lfs df -i $DIR || error "lfs df -i $DIR failed"
7946 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7947 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7949 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7950 lctl --device %$OSC deactivate
7951 lfs df || error "lfs df with deactivated OSC failed"
7952 lctl --device %$OSC activate
7953 # wait the osc back to normal
7954 wait_osc_import_state client ost FULL
7956 lfs df || error "lfs df with reactivated OSC failed"
7959 run_test 104a "lfs df [-ih] [path] test ========================="
7962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7963 [ $RUNAS_ID -eq $UID ] &&
7964 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7966 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7967 grep "Permission denied" | wc -l)))
7968 if [ $denied_cnt -ne 0 ]; then
7969 error "lfs check servers test failed"
7972 run_test 104b "$RUNAS lfs check servers test ===================="
7975 # doesn't work on 2.4 kernels
7977 if $(flock_is_enabled); then
7978 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7980 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7984 run_test 105a "flock when mounted without -o flock test ========"
7988 if $(flock_is_enabled); then
7989 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7991 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7995 run_test 105b "fcntl when mounted without -o flock test ========"
7999 if $(flock_is_enabled); then
8000 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
8002 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
8006 run_test 105c "lockf when mounted without -o flock test ========"
8008 test_105d() { # bug 15924
8009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8010 test_mkdir -p $DIR/$tdir
8011 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
8012 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
8013 $LCTL set_param fail_loc=0x80000315
8014 flocks_test 2 $DIR/$tdir
8016 run_test 105d "flock race (should not freeze) ========"
8018 test_105e() { # bug 22660 && 22040
8019 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
8021 flocks_test 3 $DIR/$tfile
8023 run_test 105e "Two conflicting flocks from same process ======="
8025 test_106() { #bug 10921
8026 test_mkdir -p $DIR/$tdir
8027 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
8028 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
8030 run_test 106 "attempt exec of dir followed by chown of that dir"
8033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8040 local save_pattern=$(sysctl -n kernel.core_pattern)
8041 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
8042 sysctl -w kernel.core_pattern=$file
8043 sysctl -w kernel.core_uses_pid=0
8051 kill -s 11 $SLEEPPID
8053 if [ -e $file ]; then
8054 size=`stat -c%s $file`
8055 [ $size -eq 0 ] && error "Fail to create core file $file"
8057 error "Fail to create core file $file"
8060 sysctl -w kernel.core_pattern=$save_pattern
8061 sysctl -w kernel.core_uses_pid=$save_uses_pid
8064 run_test 107 "Coredump on SIG"
8067 test_mkdir -p $DIR/$tdir
8068 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
8069 error "mkdir with 255 char failed"
8070 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
8071 error "mkdir with 256 char should fail, but did not"
8072 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
8073 error "create with 255 char failed"
8074 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
8075 error "create with 256 char should fail, but did not"
8080 run_test 110 "filename length checking"
8083 # Purpose: To verify dynamic thread (OSS) creation.
8086 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8087 remote_ost_nodsh && skip "remote OST with nodsh" && return
8089 # Lustre does not stop service threads once they are started.
8090 # Reset number of running threads to default.
8095 local save_params="$TMP/sanity-$TESTNAME.parameters"
8097 # Get ll_ost_io count before I/O
8098 OSTIO_pre=$(do_facet ost1 \
8099 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
8100 # Exit if lustre is not running (ll_ost_io not running).
8101 [ -z "$OSTIO_pre" ] && error "no OSS threads"
8103 echo "Starting with $OSTIO_pre threads"
8104 local thread_max=$((OSTIO_pre * 2))
8105 local rpc_in_flight=$((thread_max * 2))
8106 # Number of I/O Process proposed to be started.
8108 local facets=$(get_facets OST)
8110 save_lustre_params client \
8111 "osc.*OST*.max_rpcs_in_flight" > $save_params
8112 save_lustre_params $facets \
8113 "ost.OSS.ost_io.threads_max" >> $save_params
8115 # Set in_flight to $rpc_in_flight
8116 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
8117 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
8118 nfiles=${rpc_in_flight}
8119 # Set ost thread_max to $thread_max
8121 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
8123 # 5 Minutes should be sufficient for max number of OSS
8124 # threads(thread_max) to be created.
8128 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
8130 for i in $(seq $nfiles); do
8131 local file=$DIR/$tdir/${tfile}-$i
8132 $LFS setstripe -c -1 -i 0 $file
8133 ($WTL $file $timeout)&
8136 # I/O Started - Wait for thread_started to reach thread_max or report
8137 # error if thread_started is more than thread_max.
8138 echo "Waiting for thread_started to reach thread_max"
8139 local thread_started=0
8140 local end_time=$((SECONDS + timeout))
8142 while [ $SECONDS -le $end_time ] ; do
8144 # Get ost i/o thread_started count.
8145 thread_started=$(do_facet ost1 \
8147 ost.OSS.ost_io.threads_started | cut -d= -f2")
8148 # Break out if thread_started is equal/greater than thread_max
8149 if [[ $thread_started -ge $thread_max ]]; then
8150 echo ll_ost_io thread_started $thread_started, \
8151 equal/greater than thread_max $thread_max
8157 # Cleanup - We have the numbers, Kill i/o jobs if running.
8158 jobcount=($(jobs -p))
8159 for i in $(seq 0 $((${#jobcount[@]}-1)))
8161 kill -9 ${jobcount[$i]}
8162 if [ $? -ne 0 ] ; then
8164 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8168 # Cleanup files left by WTL binary.
8169 for i in $(seq $nfiles); do
8170 local file=$DIR/$tdir/${tfile}-$i
8172 if [ $? -ne 0 ] ; then
8173 echo "Warning: Failed to delete file $file"
8177 restore_lustre_params <$save_params
8178 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8180 # Error out if no new thread has started or Thread started is greater
8182 if [[ $thread_started -le $OSTIO_pre ||
8183 $thread_started -gt $thread_max ]]; then
8184 error "ll_ost_io: thread_started $thread_started" \
8185 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
8186 "No new thread started or thread started greater " \
8190 run_test 115 "verify dynamic thread creation===================="
8193 wait_delete_completed
8194 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8195 echo "OST kbytes available: ${AVAIL[@]}"
8200 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8201 #echo OST $i: ${AVAIL[i]}kb
8202 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8206 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8211 echo "Min free space: OST $MINI: $MINV"
8212 echo "Max free space: OST $MAXI: $MAXV"
8215 test_116a() { # was previously test_116()
8216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8217 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8219 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8221 echo -n "Free space priority "
8222 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
8227 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
8228 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
8230 trap simple_cleanup_common EXIT
8233 # Check if we need to generate uneven OSTs
8234 test_mkdir -p $DIR/$tdir/OST${MINI}
8235 local FILL=$((MINV / 4))
8236 local DIFF=$((MAXV - MINV))
8237 local DIFF2=$((DIFF * 100 / MINV))
8239 local threshold=$(do_facet $SINGLEMDS \
8240 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
8241 threshold=${threshold%%%}
8242 echo -n "Check for uneven OSTs: "
8243 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
8245 if [[ $DIFF2 -gt $threshold ]]; then
8247 echo "Don't need to fill OST$MINI"
8249 # generate uneven OSTs. Write 2% over the QOS threshold value
8251 DIFF=$((threshold - DIFF2 + 2))
8252 DIFF2=$((MINV * DIFF / 100))
8253 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
8254 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
8255 error "setstripe failed"
8256 DIFF=$((DIFF2 / 2048))
8258 while [ $i -lt $DIFF ]; do
8260 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8261 bs=2M count=1 2>/dev/null
8270 DIFF=$((MAXV - MINV))
8271 DIFF2=$((DIFF * 100 / MINV))
8272 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8273 if [ $DIFF2 -gt $threshold ]; then
8276 echo "failed - QOS mode won't be used"
8277 skip "QOS imbalance criteria not met"
8278 simple_cleanup_common
8287 # now fill using QOS
8288 $SETSTRIPE -c 1 $DIR/$tdir
8289 FILL=$((FILL / 200))
8290 if [ $FILL -gt 600 ]; then
8293 echo "writing $FILL files to QOS-assigned OSTs"
8295 while [ $i -lt $FILL ]; do
8297 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8301 echo "wrote $i 200k files"
8305 echo "Note: free space may not be updated, so measurements might be off"
8307 DIFF2=$((MAXV - MINV))
8308 echo "free space delta: orig $DIFF final $DIFF2"
8309 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8310 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8311 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8312 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8313 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8314 if [[ $DIFF -gt 0 ]]; then
8315 FILL=$((DIFF2 * 100 / DIFF - 100))
8316 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8319 # Figure out which files were written where
8320 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8321 awk '/'$MINI1': / {print $2; exit}')
8323 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8324 echo "$MINC files created on smaller OST $MINI1"
8325 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8326 awk '/'$MAXI1': / {print $2; exit}')
8328 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8329 echo "$MAXC files created on larger OST $MAXI1"
8330 if [[ $MINC -gt 0 ]]; then
8331 FILL=$((MAXC * 100 / MINC - 100))
8332 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8334 [[ $MAXC -gt $MINC ]] ||
8335 error_ignore LU-9 "stripe QOS didn't balance free space"
8336 simple_cleanup_common
8338 run_test 116a "stripe QOS: free space balance ==================="
8340 test_116b() { # LU-2093
8341 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8342 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8344 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8345 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8346 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8347 [ -z "$old_rr" ] && skip "no QOS" && return 0
8348 do_facet $SINGLEMDS lctl set_param \
8349 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8351 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8352 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8353 do_facet $SINGLEMDS lctl set_param fail_loc=0
8355 do_facet $SINGLEMDS lctl set_param \
8356 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8358 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8360 test_117() # bug 10891
8362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8363 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8364 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8365 lctl set_param fail_loc=0x21e
8366 > $DIR/$tfile || error "truncate failed"
8367 lctl set_param fail_loc=0
8368 echo "Truncate succeeded."
8371 run_test 117 "verify osd extend =========="
8373 NO_SLOW_RESENDCOUNT=4
8374 export OLD_RESENDCOUNT=""
8375 set_resend_count () {
8376 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8377 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8378 lctl set_param -n $PROC_RESENDCOUNT $1
8379 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8382 # for reduce test_118* time (b=14842)
8383 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8385 # Reset async IO behavior after error case
8387 FILE=$DIR/reset_async
8389 # Ensure all OSCs are cleared
8390 $SETSTRIPE -c -1 $FILE
8391 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8396 test_118a() #bug 11710
8398 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8401 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8402 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8403 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8405 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8406 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8411 run_test 118a "verify O_SYNC works =========="
8415 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8416 remote_ost_nodsh && skip "remote OST with nodsh" && return
8420 #define OBD_FAIL_SRV_ENOENT 0x217
8421 set_nodes_failloc "$(osts_nodes)" 0x217
8422 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8424 set_nodes_failloc "$(osts_nodes)" 0
8425 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8426 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8429 if [[ $RC -eq 0 ]]; then
8430 error "Must return error due to dropped pages, rc=$RC"
8434 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8435 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8439 echo "Dirty pages not leaked on ENOENT"
8441 # Due to the above error the OSC will issue all RPCs syncronously
8442 # until a subsequent RPC completes successfully without error.
8443 $MULTIOP $DIR/$tfile Ow4096yc
8448 run_test 118b "Reclaim dirty pages on fatal error =========="
8452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8454 # for 118c, restore the original resend count, LU-1940
8455 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8456 set_resend_count $OLD_RESENDCOUNT
8457 remote_ost_nodsh && skip "remote OST with nodsh" && return
8461 #define OBD_FAIL_OST_EROFS 0x216
8462 set_nodes_failloc "$(osts_nodes)" 0x216
8464 # multiop should block due to fsync until pages are written
8465 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8469 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8470 error "Multiop failed to block on fsync, pid=$MULTIPID"
8473 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8475 if [[ $WRITEBACK -eq 0 ]]; then
8476 error "No page in writeback, writeback=$WRITEBACK"
8479 set_nodes_failloc "$(osts_nodes)" 0
8482 if [[ $RC -ne 0 ]]; then
8483 error "Multiop fsync failed, rc=$RC"
8486 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8487 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8489 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8490 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8494 echo "Dirty pages flushed via fsync on EROFS"
8497 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8499 # continue to use small resend count to reduce test_118* time (b=14842)
8500 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8505 remote_ost_nodsh && skip "remote OST with nodsh" && return
8509 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8510 set_nodes_failloc "$(osts_nodes)" 0x214
8511 # multiop should block due to fsync until pages are written
8512 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8516 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8517 error "Multiop failed to block on fsync, pid=$MULTIPID"
8520 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8522 if [[ $WRITEBACK -eq 0 ]]; then
8523 error "No page in writeback, writeback=$WRITEBACK"
8526 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8527 set_nodes_failloc "$(osts_nodes)" 0
8529 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8530 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8532 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8533 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8537 echo "Dirty pages gaurenteed flushed via fsync"
8540 run_test 118d "Fsync validation inject a delay of the bulk =========="
8543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8546 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8547 lctl set_param fail_loc=0x8000040a
8549 # Should simulate EINVAL error which is fatal
8550 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8552 if [[ $RC -eq 0 ]]; then
8553 error "Must return error due to dropped pages, rc=$RC"
8556 lctl set_param fail_loc=0x0
8558 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8559 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8560 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8562 if [[ $LOCKED -ne 0 ]]; then
8563 error "Locked pages remain in cache, locked=$LOCKED"
8566 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8567 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8571 echo "No pages locked after fsync"
8576 run_test 118f "Simulate unrecoverable OSC side error =========="
8579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8582 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8583 lctl set_param fail_loc=0x406
8585 # simulate local -ENOMEM
8586 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8589 lctl set_param fail_loc=0
8590 if [[ $RC -eq 0 ]]; then
8591 error "Must return error due to dropped pages, rc=$RC"
8594 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8595 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8596 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8598 if [[ $LOCKED -ne 0 ]]; then
8599 error "Locked pages remain in cache, locked=$LOCKED"
8602 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8603 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8607 echo "No pages locked after fsync"
8612 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8616 remote_ost_nodsh && skip "remote OST with nodsh" && return
8620 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8621 set_nodes_failloc "$(osts_nodes)" 0x20e
8622 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8623 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8626 set_nodes_failloc "$(osts_nodes)" 0
8627 if [[ $RC -eq 0 ]]; then
8628 error "Must return error due to dropped pages, rc=$RC"
8631 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8632 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8633 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8635 if [[ $LOCKED -ne 0 ]]; then
8636 error "Locked pages remain in cache, locked=$LOCKED"
8639 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8640 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8644 echo "No pages locked after fsync"
8648 run_test 118h "Verify timeout in handling recoverables errors =========="
8650 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8654 remote_ost_nodsh && skip "remote OST with nodsh" && return
8658 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8659 set_nodes_failloc "$(osts_nodes)" 0x20e
8661 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8662 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8665 set_nodes_failloc "$(osts_nodes)" 0
8669 if [[ $RC -ne 0 ]]; then
8670 error "got error, but should be not, rc=$RC"
8673 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8674 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8675 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8676 if [[ $LOCKED -ne 0 ]]; then
8677 error "Locked pages remain in cache, locked=$LOCKED"
8680 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8681 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8685 echo "No pages locked after fsync"
8689 run_test 118i "Fix error before timeout in recoverable error =========="
8691 [ "$SLOW" = "no" ] && set_resend_count 4
8694 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8695 remote_ost_nodsh && skip "remote OST with nodsh" && return
8699 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8700 set_nodes_failloc "$(osts_nodes)" 0x220
8702 # return -EIO from OST
8703 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8705 set_nodes_failloc "$(osts_nodes)" 0x0
8706 if [[ $RC -eq 0 ]]; then
8707 error "Must return error due to dropped pages, rc=$RC"
8710 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8711 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8712 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8713 if [[ $LOCKED -ne 0 ]]; then
8714 error "Locked pages remain in cache, locked=$LOCKED"
8717 # in recoverable error on OST we want resend and stay until it finished
8718 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8719 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8723 echo "No pages locked after fsync"
8727 run_test 118j "Simulate unrecoverable OST side error =========="
8731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8732 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8734 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8735 set_nodes_failloc "$(osts_nodes)" 0x20e
8736 test_mkdir -p $DIR/$tdir
8738 for ((i=0;i<10;i++)); do
8739 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8740 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8747 set_nodes_failloc "$(osts_nodes)" 0
8750 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8756 test_mkdir -p $DIR/$tdir
8757 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8760 run_test 118l "fsync dir ========="
8762 test_118m() # LU-3066
8764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8765 test_mkdir -p $DIR/$tdir
8766 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8769 run_test 118m "fdatasync dir ========="
8771 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8773 test_119a() # bug 11737
8775 BSIZE=$((512 * 1024))
8776 directio write $DIR/$tfile 0 1 $BSIZE
8777 # We ask to read two blocks, which is more than a file size.
8778 # directio will indicate an error when requested and actual
8779 # sizes aren't equeal (a normal situation in this case) and
8780 # print actual read amount.
8781 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8782 if [ "$NOB" != "$BSIZE" ]; then
8783 error "read $NOB bytes instead of $BSIZE"
8787 run_test 119a "Short directIO read must return actual read amount"
8789 test_119b() # bug 11737
8791 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8793 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8794 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8796 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8797 error "direct read failed"
8800 run_test 119b "Sparse directIO read must return actual read amount"
8802 test_119c() # bug 13099
8805 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8806 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8809 run_test 119c "Testing for direct read hitting hole"
8811 test_119d() # bug 15950
8813 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8814 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8815 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8817 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8818 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8819 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8820 lctl set_param fail_loc=0x40d
8821 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8824 cat $DIR/$tfile > /dev/null &
8825 lctl set_param fail_loc=0
8828 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8830 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8831 error "the read rpcs have not completed in 2s"
8833 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8835 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8839 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8840 test_mkdir -p $DIR/$tdir
8841 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8842 skip "no early lock cancel on server" && return 0
8844 lru_resize_disable mdc
8845 lru_resize_disable osc
8846 cancel_lru_locks mdc
8847 # asynchronous object destroy at MDT could cause bl ast to client
8848 cancel_lru_locks osc
8850 stat $DIR/$tdir > /dev/null
8851 can1=$(do_facet $SINGLEMDS \
8852 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8853 awk '/ldlm_cancel/ {print $2}')
8854 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8855 awk '/ldlm_bl_callback/ {print $2}')
8856 test_mkdir -c1 $DIR/$tdir/d1
8857 can2=$(do_facet $SINGLEMDS \
8858 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8859 awk '/ldlm_cancel/ {print $2}')
8860 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8861 awk '/ldlm_bl_callback/ {print $2}')
8862 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8863 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8864 lru_resize_enable mdc
8865 lru_resize_enable osc
8867 run_test 120a "Early Lock Cancel: mkdir test"
8870 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8871 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8872 test_mkdir $DIR/$tdir
8873 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8874 skip "no early lock cancel on server" && return 0
8875 lru_resize_disable mdc
8876 lru_resize_disable osc
8877 cancel_lru_locks mdc
8878 stat $DIR/$tdir > /dev/null
8879 can1=$(do_facet $SINGLEMDS \
8880 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8881 awk '/ldlm_cancel/ {print $2}')
8882 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8883 awk '/ldlm_bl_callback/ {print $2}')
8885 can2=$(do_facet $SINGLEMDS \
8886 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8887 awk '/ldlm_cancel/ {print $2}')
8888 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8889 awk '/ldlm_bl_callback/ {print $2}')
8890 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8891 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8892 lru_resize_enable mdc
8893 lru_resize_enable osc
8895 run_test 120b "Early Lock Cancel: create test"
8898 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8899 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8900 test_mkdir -c1 $DIR/$tdir
8901 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8902 skip "no early lock cancel on server" && return 0
8903 lru_resize_disable mdc
8904 lru_resize_disable osc
8905 test_mkdir -p -c1 $DIR/$tdir/d1
8906 test_mkdir -p -c1 $DIR/$tdir/d2
8907 touch $DIR/$tdir/d1/f1
8908 cancel_lru_locks mdc
8909 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8910 can1=$(do_facet $SINGLEMDS \
8911 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8912 awk '/ldlm_cancel/ {print $2}')
8913 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8914 awk '/ldlm_bl_callback/ {print $2}')
8915 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8916 can2=$(do_facet $SINGLEMDS \
8917 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8918 awk '/ldlm_cancel/ {print $2}')
8919 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8920 awk '/ldlm_bl_callback/ {print $2}')
8921 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8922 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8923 lru_resize_enable mdc
8924 lru_resize_enable osc
8926 run_test 120c "Early Lock Cancel: link test"
8929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8930 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8931 test_mkdir -p -c1 $DIR/$tdir
8932 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8933 skip "no early lock cancel on server" && return 0
8934 lru_resize_disable mdc
8935 lru_resize_disable osc
8937 cancel_lru_locks mdc
8938 stat $DIR/$tdir > /dev/null
8939 can1=$(do_facet $SINGLEMDS \
8940 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8941 awk '/ldlm_cancel/ {print $2}')
8942 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8943 awk '/ldlm_bl_callback/ {print $2}')
8944 chmod a+x $DIR/$tdir
8945 can2=$(do_facet $SINGLEMDS \
8946 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8947 awk '/ldlm_cancel/ {print $2}')
8948 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8949 awk '/ldlm_bl_callback/ {print $2}')
8950 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8951 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8952 lru_resize_enable mdc
8953 lru_resize_enable osc
8955 run_test 120d "Early Lock Cancel: setattr test"
8958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8959 ! $($LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_can) &&
8960 skip "no early lock cancel on server" && return 0
8961 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8962 local dlmtrace_set=false
8964 test_mkdir -p -c1 $DIR/$tdir
8965 lru_resize_disable mdc
8966 lru_resize_disable osc
8967 ! $LCTL get_param debug | grep -q dlmtrace &&
8968 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8969 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8970 cancel_lru_locks mdc
8971 cancel_lru_locks osc
8972 dd if=$DIR/$tdir/f1 of=/dev/null
8973 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8974 # XXX client can not do early lock cancel of OST lock
8975 # during unlink (LU-4206), so cancel osc lock now.
8977 cancel_lru_locks osc
8978 can1=$(do_facet $SINGLEMDS \
8979 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8980 awk '/ldlm_cancel/ {print $2}')
8981 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8982 awk '/ldlm_bl_callback/ {print $2}')
8983 unlink $DIR/$tdir/f1
8985 can2=$(do_facet $SINGLEMDS \
8986 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8987 awk '/ldlm_cancel/ {print $2}')
8988 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8989 awk '/ldlm_bl_callback/ {print $2}')
8990 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8991 $LCTL dk $TMP/cancel.debug.txt
8992 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8993 $LCTL dk $TMP/blocking.debug.txt
8994 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8995 lru_resize_enable mdc
8996 lru_resize_enable osc
8998 run_test 120e "Early Lock Cancel: unlink test"
9001 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9002 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
9003 skip "no early lock cancel on server" && return 0
9004 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9005 test_mkdir -p -c1 $DIR/$tdir
9006 lru_resize_disable mdc
9007 lru_resize_disable osc
9008 test_mkdir -p -c1 $DIR/$tdir/d1
9009 test_mkdir -p -c1 $DIR/$tdir/d2
9010 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
9011 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
9012 cancel_lru_locks mdc
9013 cancel_lru_locks osc
9014 dd if=$DIR/$tdir/d1/f1 of=/dev/null
9015 dd if=$DIR/$tdir/d2/f2 of=/dev/null
9016 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
9017 # XXX client can not do early lock cancel of OST lock
9018 # during rename (LU-4206), so cancel osc lock now.
9020 cancel_lru_locks osc
9021 can1=$(do_facet $SINGLEMDS \
9022 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9023 awk '/ldlm_cancel/ {print $2}')
9024 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9025 awk '/ldlm_bl_callback/ {print $2}')
9026 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9028 can2=$(do_facet $SINGLEMDS \
9029 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9030 awk '/ldlm_cancel/ {print $2}')
9031 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9032 awk '/ldlm_bl_callback/ {print $2}')
9033 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9034 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9035 lru_resize_enable mdc
9036 lru_resize_enable osc
9038 run_test 120f "Early Lock Cancel: rename test"
9041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9042 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
9043 skip "no early lock cancel on server" && return 0
9044 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9045 lru_resize_disable mdc
9046 lru_resize_disable osc
9048 echo create $count files
9049 test_mkdir -p $DIR/$tdir
9050 cancel_lru_locks mdc
9051 cancel_lru_locks osc
9054 can0=$(do_facet $SINGLEMDS \
9055 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9056 awk '/ldlm_cancel/ {print $2}')
9057 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9058 awk '/ldlm_bl_callback/ {print $2}')
9059 createmany -o $DIR/$tdir/f $count
9061 can1=$(do_facet $SINGLEMDS \
9062 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9063 awk '/ldlm_cancel/ {print $2}')
9064 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9065 awk '/ldlm_bl_callback/ {print $2}')
9067 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
9068 echo rm $count files
9071 can2=$(do_facet $SINGLEMDS \
9072 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9073 awk '/ldlm_cancel/ {print $2}')
9074 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9075 awk '/ldlm_bl_callback/ {print $2}')
9077 echo total: $count removes in $((t2-t1))
9078 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
9080 # wait for commitment of removal
9081 lru_resize_enable mdc
9082 lru_resize_enable osc
9084 run_test 120g "Early Lock Cancel: performance test"
9086 test_121() { #bug #10589
9087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9089 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
9090 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
9091 lctl set_param fail_loc=0x310
9092 cancel_lru_locks osc > /dev/null
9093 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
9094 lctl set_param fail_loc=0
9095 [[ $reads -eq $writes ]] ||
9096 error "read $reads blocks, must be $writes blocks"
9098 run_test 121 "read cancel race ========="
9100 test_123a() { # was test 123, statahead(bug 11401)
9101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9103 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
9104 log "testing on UP system. Performance may be not as good as expected."
9109 test_mkdir -p $DIR/$tdir
9110 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
9111 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
9113 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
9114 createmany -o $DIR/$tdir/$tfile $j $((i - j))
9116 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9117 lctl set_param -n llite.*.statahead_max 0
9118 lctl get_param llite.*.statahead_max
9119 cancel_lru_locks mdc
9120 cancel_lru_locks osc
9122 time ls -l $DIR/$tdir | wc -l
9124 delta=$((etime - stime))
9125 log "ls $i files without statahead: $delta sec"
9126 lctl set_param llite.*.statahead_max=$max
9128 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9129 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
9130 cancel_lru_locks mdc
9131 cancel_lru_locks osc
9133 time ls -l $DIR/$tdir | wc -l
9135 delta_sa=$((etime - stime))
9136 log "ls $i files with statahead: $delta_sa sec"
9137 lctl get_param -n llite.*.statahead_stats
9138 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9140 [[ $swrong -lt $ewrong ]] &&
9141 log "statahead was stopped, maybe too many locks held!"
9142 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
9144 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9145 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9146 lctl set_param -n llite.*.statahead_max 0
9147 lctl get_param llite.*.statahead_max
9148 cancel_lru_locks mdc
9149 cancel_lru_locks osc
9151 time ls -l $DIR/$tdir | wc -l
9153 delta=$((etime - stime))
9154 log "ls $i files again without statahead: $delta sec"
9155 lctl set_param llite.*.statahead_max=$max
9156 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9157 if [ $SLOWOK -eq 0 ]; then
9158 error "ls $i files is slower with statahead!"
9160 log "ls $i files is slower with statahead!"
9166 [ $delta -gt 20 ] && break
9167 [ $delta -gt 8 ] && MULT=$((50 / delta))
9168 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
9176 delta=$((etime - stime))
9177 log "rm -r $DIR/$tdir/: $delta seconds"
9179 lctl get_param -n llite.*.statahead_stats
9181 run_test 123a "verify statahead work"
9183 test_123b () { # statahead(bug 15027)
9184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9185 test_mkdir -p $DIR/$tdir
9186 createmany -o $DIR/$tdir/$tfile-%d 1000
9188 cancel_lru_locks mdc
9189 cancel_lru_locks osc
9191 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
9192 lctl set_param fail_loc=0x80000803
9193 ls -lR $DIR/$tdir > /dev/null
9195 lctl set_param fail_loc=0x0
9196 lctl get_param -n llite.*.statahead_stats
9201 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
9204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9205 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9206 skip "no lru resize on server" && return 0
9208 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9210 log "create $NR files at $DIR/$tdir"
9211 createmany -o $DIR/$tdir/f $NR ||
9212 error "failed to create $NR files in $DIR/$tdir"
9214 cancel_lru_locks mdc
9215 ls -l $DIR/$tdir > /dev/null
9219 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
9220 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
9221 LRU_SIZE=$($LCTL get_param -n $PARAM)
9222 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
9223 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
9225 log "NS=$(basename $NSDIR)"
9230 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9231 skip "Not enough cached locks created!"
9238 # We know that lru resize allows one client to hold $LIMIT locks
9239 # for 10h. After that locks begin to be killed by client.
9241 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9243 if [ $LIMIT -lt $LRU_SIZE ]; then
9244 skip "Limit is too small $LIMIT"
9248 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9249 # killing locks. Some time was spent for creating locks. This means
9250 # that up to the moment of sleep finish we must have killed some of
9251 # them (10-100 locks). This depends on how fast ther were created.
9252 # Many of them were touched in almost the same moment and thus will
9253 # be killed in groups.
9254 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9256 # Use $LRU_SIZE_B here to take into account real number of locks
9257 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9258 local LRU_SIZE_B=$LRU_SIZE
9260 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9261 log "OLD_LVF=$OLD_LVF"
9262 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9264 # Let's make sure that we really have some margin. Client checks
9265 # cached locks every 10 sec.
9267 log "Sleep ${SLEEP} sec"
9269 while ((SEC<$SLEEP)); do
9273 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9277 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9278 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9280 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9281 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9282 unlinkmany $DIR/$tdir/f $NR
9286 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9287 log "unlink $NR files at $DIR/$tdir"
9288 unlinkmany $DIR/$tdir/f $NR
9290 run_test 124a "lru resize ======================================="
9292 get_max_pool_limit()
9294 local limit=$($LCTL get_param \
9295 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9298 if [[ $l -gt $max ]]; then
9306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9307 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9308 skip "no lru resize on server" && return 0
9310 LIMIT=$(get_max_pool_limit)
9312 NR=$(($(default_lru_size)*20))
9313 if [[ $NR -gt $LIMIT ]]; then
9314 log "Limit lock number by $LIMIT locks"
9318 IFree=$(mdsrate_inodes_available)
9319 if [ $IFree -lt $NR ]; then
9320 log "Limit lock number by $IFree inodes"
9324 lru_resize_disable mdc
9325 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
9326 error "failed to create $DIR/$tdir/disable_lru_resize"
9328 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9329 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9330 cancel_lru_locks mdc
9333 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9336 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9339 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9343 nolruresize_delta=$((etime-stime))
9344 log "ls -la time: $nolruresize_delta seconds"
9345 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9346 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9348 lru_resize_enable mdc
9349 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
9350 error "failed to create $DIR/$tdir/enable_lru_resize"
9352 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9353 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9354 cancel_lru_locks mdc
9357 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9360 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9363 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9367 lruresize_delta=$((etime-stime))
9368 log "ls -la time: $lruresize_delta seconds"
9369 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9371 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9372 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9373 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9374 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9376 log "lru resize performs the same with no lru resize"
9378 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9380 run_test 124b "lru resize (performance test) ======================="
9383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9384 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9385 skip "no lru resize on server" && return 0
9387 # cache ununsed locks on client
9389 cancel_lru_locks mdc
9390 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9391 createmany -o $DIR/$tdir/f $nr ||
9392 error "failed to create $nr files in $DIR/$tdir"
9393 ls -l $DIR/$tdir > /dev/null
9395 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9396 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9397 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9398 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9399 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9401 # set lru_max_age to 1 sec
9402 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9403 echo "sleep $((recalc_p * 2)) seconds..."
9404 sleep $((recalc_p * 2))
9406 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9407 # restore lru_max_age
9408 $LCTL set_param -n $nsdir.lru_max_age $max_age
9409 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9410 unlinkmany $DIR/$tdir/f $nr
9412 run_test 124c "LRUR cancel very aged locks"
9414 test_125() { # 13358
9415 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9416 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
9417 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9418 test_mkdir -p $DIR/d125 || error "mkdir failed"
9419 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
9420 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
9421 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
9423 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9425 test_126() { # bug 12829/13455
9426 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9427 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
9428 $GSS && skip "must run as gss disabled" && return
9430 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9431 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9433 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9435 run_test 126 "check that the fsgid provided by the client is taken into account"
9437 test_127a() { # bug 15521
9438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9439 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9440 $LCTL set_param osc.*.stats=0
9441 FSIZE=$((2048 * 1024))
9442 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9443 cancel_lru_locks osc
9444 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9446 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9447 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9448 echo "got $COUNT $NAME"
9449 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9450 eval $NAME=$COUNT || error "Wrong proc format"
9453 read_bytes|write_bytes)
9454 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9455 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9456 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9457 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9458 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9459 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9460 error "sumsquare is too small: $SUMSQ"
9461 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9462 error "sumsquare is too big: $SUMSQ"
9466 done < $DIR/${tfile}.tmp
9468 #check that we actually got some stats
9469 [ "$read_bytes" ] || error "Missing read_bytes stats"
9470 [ "$write_bytes" ] || error "Missing write_bytes stats"
9471 [ "$read_bytes" != 0 ] || error "no read done"
9472 [ "$write_bytes" != 0 ] || error "no write done"
9474 run_test 127a "verify the client stats are sane"
9476 test_127b() { # bug LU-333
9477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9478 $LCTL set_param llite.*.stats=0
9479 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9480 # perform 2 reads and writes so MAX is different from SUM.
9481 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9482 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9483 cancel_lru_locks osc
9484 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9485 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9487 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9488 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9489 echo "got $COUNT $NAME"
9490 eval $NAME=$COUNT || error "Wrong proc format"
9494 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9495 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9496 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9497 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9500 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9501 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9502 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9503 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9507 done < $TMP/${tfile}.tmp
9509 #check that we actually got some stats
9510 [ "$read_bytes" ] || error "Missing read_bytes stats"
9511 [ "$write_bytes" ] || error "Missing write_bytes stats"
9512 [ "$read_bytes" != 0 ] || error "no read done"
9513 [ "$write_bytes" != 0 ] || error "no write done"
9515 rm -f $TMP/${tfile}.tmp
9517 run_test 127b "verify the llite client stats are sane"
9519 test_128() { # bug 15212
9521 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9526 result=$(grep error $TMP/$tfile.log)
9527 rm -f $DIR/$tfile $TMP/$tfile.log
9529 error "consecutive find's under interactive lfs failed"
9531 run_test 128 "interactive lfs for 2 consecutive find's"
9538 local ldproc=/proc/fs/ldiskfs
9539 local facets=$(get_facets MDS)
9541 for facet in ${facets//,/ }; do
9542 canondev=$(ldiskfs_canon \
9543 *.$(convert_facet2label $facet).mntdev $facet)
9544 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9545 ldproc=/sys/fs/ldiskfs
9546 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9547 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9552 local facets=$(get_facets MDS)
9553 for facet in ${facets//,/ }; do
9554 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9560 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9561 { skip "Need MDS version with at least 2.5.56"; return 0; }
9563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9564 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9565 skip "ldiskfs only test"
9568 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9571 local has_warning=false
9576 # block size of mds1
9577 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9578 set_dir_limits $maxsize $maxsize
9579 local dirsize=$(stat -c%s "$DIR/$tdir")
9581 while [[ $dirsize -le $maxsize ]]; do
9582 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9584 if ! $has_warning; then
9585 check_mds_dmesg '"is approaching"' && has_warning=true
9588 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9589 # EFBIG for previous versions included in ldiskfs series
9590 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9592 echo "return code $rc received as expected"
9594 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9595 error_exit "create failed w/o dir size limit"
9597 check_mds_dmesg '"has reached"' ||
9598 error_exit "reached message should be output"
9600 [ $has_warning = "false" ] &&
9601 error_exit "warning message should be output"
9603 dirsize=$(stat -c%s "$DIR/$tdir")
9605 [[ $dirsize -ge $maxsize ]] && return 0
9606 error_exit "current dir size $dirsize, " \
9607 "previous limit $maxsize"
9608 elif [ $rc -ne 0 ]; then
9610 error_exit "return $rc received instead of expected " \
9611 "$EFBIG or $ENOSPC, files in dir $dirsize"
9613 nfiles=$((nfiles + 1))
9614 dirsize=$(stat -c%s "$DIR/$tdir")
9618 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9620 run_test 129 "test directory size limit ========================"
9629 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9630 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9633 trap cleanup_130 EXIT RETURN
9635 local fm_file=$DIR/$tfile
9636 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9637 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9638 error "dd failed for $fm_file"
9640 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9641 filefrag -ves $fm_file
9643 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9644 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9645 [ $RC != 0 ] && error "filefrag $fm_file failed"
9647 filefrag_op=$(filefrag -ve $fm_file |
9648 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9649 lun=$($GETSTRIPE -i $fm_file)
9651 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9654 for line in $filefrag_op
9656 frag_lun=`echo $line | cut -d: -f5`
9657 ext_len=`echo $line | cut -d: -f4`
9658 if (( $frag_lun != $lun )); then
9660 error "FIEMAP on 1-stripe file($fm_file) failed"
9663 (( tot_len += ext_len ))
9666 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9668 error "FIEMAP on 1-stripe file($fm_file) failed;"
9674 echo "FIEMAP on single striped file succeeded"
9676 run_test 130a "FIEMAP (1-stripe file)"
9679 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9681 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9682 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9685 trap cleanup_130 EXIT RETURN
9687 local fm_file=$DIR/$tfile
9688 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9689 error "setstripe on $fm_file"
9690 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9691 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9693 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9694 error "dd failed on $fm_file"
9696 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9697 filefrag_op=$(filefrag -ve $fm_file |
9698 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9700 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9701 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9706 for line in $filefrag_op
9708 frag_lun=$(echo $line | cut -d: -f5 |
9709 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9710 ext_len=$(echo $line | cut -d: -f4)
9711 if (( $frag_lun != $last_lun )); then
9712 if (( tot_len != 1024 )); then
9714 error "FIEMAP on $fm_file failed; returned " \
9715 "len $tot_len for OST $last_lun instead of 1024"
9722 (( tot_len += ext_len ))
9725 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9727 error "FIEMAP on $fm_file failed; returned wrong number of " \
9728 "luns or wrong len for OST $last_lun"
9734 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9736 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9739 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9741 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9742 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9745 trap cleanup_130 EXIT RETURN
9747 local fm_file=$DIR/$tfile
9748 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9749 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9750 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9752 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9753 error "dd failed on $fm_file"
9755 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9756 filefrag_op=$(filefrag -ve $fm_file |
9757 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9759 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9760 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9765 for line in $filefrag_op
9767 frag_lun=$(echo $line | cut -d: -f5 |
9768 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9769 ext_len=$(echo $line | cut -d: -f4)
9770 if (( $frag_lun != $last_lun )); then
9771 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9772 if (( logical != 512 )); then
9774 error "FIEMAP on $fm_file failed; returned " \
9775 "logical start for lun $logical instead of 512"
9778 if (( tot_len != 512 )); then
9780 error "FIEMAP on $fm_file failed; returned " \
9781 "len $tot_len for OST $last_lun instead of 1024"
9788 (( tot_len += ext_len ))
9791 if (( num_luns != 2 || tot_len != 512 )); then
9793 error "FIEMAP on $fm_file failed; returned wrong number of " \
9794 "luns or wrong len for OST $last_lun"
9800 echo "FIEMAP on 2-stripe file with hole succeeded"
9802 run_test 130c "FIEMAP (2-stripe file with hole)"
9805 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9807 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9808 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9811 trap cleanup_130 EXIT RETURN
9813 local fm_file=$DIR/$tfile
9814 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9815 error "setstripe on $fm_file"
9816 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9817 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9819 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
9820 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
9821 error "dd failed on $fm_file"
9823 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9824 filefrag_op=$(filefrag -ve $fm_file |
9825 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9827 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9828 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9833 for line in $filefrag_op
9835 frag_lun=$(echo $line | cut -d: -f5 |
9836 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9837 ext_len=$(echo $line | cut -d: -f4)
9838 if (( $frag_lun != $last_lun )); then
9839 if (( tot_len != 1024 )); then
9841 error "FIEMAP on $fm_file failed; returned " \
9842 "len $tot_len for OST $last_lun instead of 1024"
9849 (( tot_len += ext_len ))
9852 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
9854 error "FIEMAP on $fm_file failed; returned wrong number of " \
9855 "luns or wrong len for OST $last_lun"
9861 echo "FIEMAP on N-stripe file succeeded"
9863 run_test 130d "FIEMAP (N-stripe file)"
9866 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9868 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9869 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9871 trap cleanup_130 EXIT RETURN
9873 local fm_file=$DIR/$tfile
9874 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9875 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9876 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9879 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9880 for ((i = 0; i < $NUM_BLKS; i++))
9882 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9885 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9886 filefrag_op=$(filefrag -ve $fm_file |
9887 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9889 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9890 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9895 for line in $filefrag_op
9897 frag_lun=$(echo $line | cut -d: -f5 |
9898 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9899 ext_len=$(echo $line | cut -d: -f4)
9900 if (( $frag_lun != $last_lun )); then
9901 if (( tot_len != $EXPECTED_LEN )); then
9903 error "FIEMAP on $fm_file failed; returned " \
9904 "len $tot_len for OST $last_lun instead " \
9912 (( tot_len += ext_len ))
9915 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9917 error "FIEMAP on $fm_file failed; returned wrong number " \
9918 "of luns or wrong len for OST $last_lun"
9924 echo "FIEMAP with continuation calls succeeded"
9926 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9928 # Test for writev/readv
9930 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
9931 error "writev test failed"
9932 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
9933 error "readv failed"
9936 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9939 local fsize=$((524288 + 1048576 + 1572864))
9940 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
9941 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9942 error "append writev test failed"
9944 ((fsize += 1572864 + 1048576))
9945 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
9946 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9947 error "append writev test failed"
9950 run_test 131b "test append writev"
9953 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9956 run_test 131c "test read/write on file w/o objects"
9959 rwv -f $DIR/$tfile -w -n 1 1572864
9960 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9961 if [ "$NOB" != 1572864 ]; then
9962 error "Short read filed: read $NOB bytes instead of 1572864"
9966 run_test 131d "test short read"
9969 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9970 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9971 error "read hitting hole failed"
9974 run_test 131e "test read hitting hole"
9983 mds*) res=$(do_facet $facet \
9984 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9986 ost*) res=$(do_facet $facet \
9987 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9989 *) error "Wrong facet '$facet'" ;;
9992 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9993 # if the argument $3 is zero, it means any stat increment is ok.
9994 if [[ $want -gt 0 ]]; then
9995 local count=$(echo $res | awk '{ print $2 }')
9996 [[ $count -ne $want ]] &&
9997 error "The $op counter on $facet is $count, not $want"
10002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10003 remote_ost_nodsh && skip "remote OST with nodsh" && return
10004 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10006 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10007 { skip "MDS doesn't support rename stats"; return; }
10008 local testdir=$DIR/${tdir}/stats_testdir
10009 mkdir -p $DIR/${tdir}
10012 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10013 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10015 # verify mdt stats first.
10016 mkdir ${testdir} || error "mkdir failed"
10017 check_stats $SINGLEMDS "mkdir" 1
10018 touch ${testdir}/${tfile} || error "touch failed"
10019 check_stats $SINGLEMDS "open" 1
10020 check_stats $SINGLEMDS "close" 1
10021 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
10022 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
10023 check_stats $SINGLEMDS "mknod" 2
10025 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
10026 check_stats $SINGLEMDS "unlink" 1
10027 rm -f ${testdir}/${tfile} || error "file remove failed"
10028 check_stats $SINGLEMDS "unlink" 2
10030 # remove working dir and check mdt stats again.
10031 rmdir ${testdir} || error "rmdir failed"
10032 check_stats $SINGLEMDS "rmdir" 1
10034 local testdir1=$DIR/${tdir}/stats_testdir1
10035 mkdir -p ${testdir}
10036 mkdir -p ${testdir1}
10037 touch ${testdir1}/test1
10038 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
10039 check_stats $SINGLEMDS "crossdir_rename" 1
10041 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
10042 check_stats $SINGLEMDS "samedir_rename" 1
10044 rm -rf $DIR/${tdir}
10046 run_test 133a "Verifying MDT stats ========================================"
10049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10050 remote_ost_nodsh && skip "remote OST with nodsh" && return
10051 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10052 local testdir=$DIR/${tdir}/stats_testdir
10053 mkdir -p ${testdir} || error "mkdir failed"
10054 touch ${testdir}/${tfile} || error "touch failed"
10055 cancel_lru_locks mdc
10058 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10059 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10061 # extra mdt stats verification.
10062 chmod 444 ${testdir}/${tfile} || error "chmod failed"
10063 check_stats $SINGLEMDS "setattr" 1
10064 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10065 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
10067 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
10068 check_stats $SINGLEMDS "getattr" 1
10070 $LFS df || error "lfs failed"
10071 check_stats $SINGLEMDS "statfs" 1
10073 rm -rf $DIR/${tdir}
10075 run_test 133b "Verifying extra MDT stats =================================="
10078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10079 remote_ost_nodsh && skip "remote OST with nodsh" && return
10080 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10081 local testdir=$DIR/${tdir}/stats_testdir
10082 test_mkdir -p ${testdir} || error "mkdir failed"
10084 # verify obdfilter stats.
10085 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10087 cancel_lru_locks osc
10088 wait_delete_completed
10091 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10092 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10094 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
10096 cancel_lru_locks osc
10097 check_stats ost1 "write" 1
10099 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
10100 check_stats ost1 "read" 1
10102 > ${testdir}/${tfile} || error "truncate failed"
10103 check_stats ost1 "punch" 1
10105 rm -f ${testdir}/${tfile} || error "file remove failed"
10106 wait_delete_completed
10107 check_stats ost1 "destroy" 1
10109 rm -rf $DIR/${tdir}
10111 run_test 133c "Verifying OST stats ========================================"
10118 while [ $value -ge 2 ]; do
10123 if [ $orig -gt $order ]; then
10131 local size=('K' 'M' 'G' 'T');
10133 local size_string=$value
10135 while [ $value -ge 1024 ]; do
10136 if [ $i -gt 3 ]; then
10137 #T is the biggest unit we get here, if that is bigger,
10139 size_string=${value}T
10142 value=$((value >> 10))
10143 if [ $value -lt 1024 ]; then
10144 size_string=${value}${size[$i]}
10153 get_rename_size() {
10155 local context=${2:-.}
10156 local sample=$(do_facet $SINGLEMDS $LCTL \
10157 get_param mdt.$FSNAME-MDT0000.rename_stats |
10158 grep -A1 $context |
10159 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
10164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10165 remote_ost_nodsh && skip "remote OST with nodsh" && return
10166 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10167 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10168 { skip "MDS doesn't support rename stats"; return; }
10170 local testdir1=$DIR/${tdir}/stats_testdir1
10171 local testdir2=$DIR/${tdir}/stats_testdir2
10172 mkdir -p $DIR/${tdir}
10174 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10176 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
10177 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
10179 createmany -o $testdir1/test 512 || error "createmany failed"
10181 # check samedir rename size
10182 mv ${testdir1}/test0 ${testdir1}/test_0
10184 local testdir1_size=$(ls -l $DIR/${tdir} |
10185 awk '/stats_testdir1/ {print $5}')
10186 local testdir2_size=$(ls -l $DIR/${tdir} |
10187 awk '/stats_testdir2/ {print $5}')
10189 testdir1_size=$(order_2 $testdir1_size)
10190 testdir2_size=$(order_2 $testdir2_size)
10192 testdir1_size=$(size_in_KMGT $testdir1_size)
10193 testdir2_size=$(size_in_KMGT $testdir2_size)
10195 echo "source rename dir size: ${testdir1_size}"
10196 echo "target rename dir size: ${testdir2_size}"
10198 local cmd="do_facet $SINGLEMDS $LCTL "
10199 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
10201 eval $cmd || error "$cmd failed"
10202 local samedir=$($cmd | grep 'same_dir')
10203 local same_sample=$(get_rename_size $testdir1_size)
10204 [ -z "$samedir" ] && error "samedir_rename_size count error"
10205 [[ $same_sample -eq 1 ]] ||
10206 error "samedir_rename_size error $same_sample"
10207 echo "Check same dir rename stats success"
10209 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10211 # check crossdir rename size
10212 mv ${testdir1}/test_0 ${testdir2}/test_0
10214 testdir1_size=$(ls -l $DIR/${tdir} |
10215 awk '/stats_testdir1/ {print $5}')
10216 testdir2_size=$(ls -l $DIR/${tdir} |
10217 awk '/stats_testdir2/ {print $5}')
10219 testdir1_size=$(order_2 $testdir1_size)
10220 testdir2_size=$(order_2 $testdir2_size)
10222 testdir1_size=$(size_in_KMGT $testdir1_size)
10223 testdir2_size=$(size_in_KMGT $testdir2_size)
10225 echo "source rename dir size: ${testdir1_size}"
10226 echo "target rename dir size: ${testdir2_size}"
10228 eval $cmd || error "$cmd failed"
10229 local crossdir=$($cmd | grep 'crossdir')
10230 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10231 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10232 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10233 [[ $src_sample -eq 1 ]] ||
10234 error "crossdir_rename_size error $src_sample"
10235 [[ $tgt_sample -eq 1 ]] ||
10236 error "crossdir_rename_size error $tgt_sample"
10237 echo "Check cross dir rename stats success"
10238 rm -rf $DIR/${tdir}
10240 run_test 133d "Verifying rename_stats ========================================"
10243 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10244 remote_ost_nodsh && skip "remote OST with nodsh" && return
10245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10246 local testdir=$DIR/${tdir}/stats_testdir
10247 local ctr f0 f1 bs=32768 count=42 sum
10249 mkdir -p ${testdir} || error "mkdir failed"
10251 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10253 for ctr in {write,read}_bytes; do
10255 cancel_lru_locks osc
10257 do_facet ost1 $LCTL set_param -n \
10258 "obdfilter.*.exports.clear=clear"
10260 if [ $ctr = write_bytes ]; then
10262 f1=${testdir}/${tfile}
10264 f0=${testdir}/${tfile}
10268 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10271 cancel_lru_locks osc
10273 sum=$(do_facet ost1 $LCTL get_param \
10274 "obdfilter.*.exports.*.stats" |
10275 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10276 $1 == ctr { sum += $7 }
10277 END { printf("%0.0f", sum) }')
10279 if ((sum != bs * count)); then
10280 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10284 rm -rf $DIR/${tdir}
10286 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10288 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10291 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10292 remote_ost_nodsh && skip "remote OST with nodsh" && return
10293 # First without trusting modes.
10294 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10295 echo "proc_dirs='$proc_dirs'"
10296 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10297 find $proc_dirs -exec cat '{}' \; &> /dev/null
10299 # Second verifying readability.
10300 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10302 # eventually, this can also be replaced with "lctl get_param -R",
10303 # but not until that option is always available on the server
10305 for facet in mds1 ost1; do
10306 local facet_proc_dirs=$(do_facet $facet \
10307 \\\ls -d $proc_regexp 2>/dev/null)
10308 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10309 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10310 do_facet $facet find $facet_proc_dirs \
10311 ! -name req_history \
10312 -exec cat '{}' \\\; &> /dev/null
10314 do_facet $facet find $facet_proc_dirs \
10315 ! -name req_history \
10317 -exec cat '{}' \\\; &> /dev/null ||
10318 error "proc file read failed"
10321 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
10324 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10325 remote_ost_nodsh && skip "remote OST with nodsh" && return
10326 # Second verifying writability.
10327 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10328 echo "proc_dirs='$proc_dirs'"
10329 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10332 -not -name force_lbug \
10333 -not -name changelog_mask \
10334 -exec badarea_io '{}' \; &> /dev/null ||
10335 error "find $proc_dirs failed"
10338 for facet in mds1 ost1; do
10339 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10340 skip "Too old lustre on $facet" && continue
10341 local facet_proc_dirs=$(do_facet $facet \
10342 \\\ls -d $proc_regexp 2> /dev/null)
10343 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10344 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10345 do_facet $facet find $facet_proc_dirs \
10347 -not -name force_lbug \
10348 -not -name changelog_mask \
10349 -exec badarea_io '{}' \\\; &> /dev/null ||
10350 error "$facet find $facet_proc_dirs failed"
10353 # remount the FS in case writes/reads /proc break the FS
10354 cleanup || error "failed to unmount"
10355 setup || error "failed to setup"
10358 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
10361 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10362 remote_ost_nodsh && skip "remote OST with nodsh" && return
10363 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10364 skip "Need MDS version at least 2.9.54" && return
10367 for facet in client mds1 ost1; do
10368 local facet_proc_dirs=$(do_facet $facet \
10369 \\\ls -d $proc_regexp 2> /dev/null)
10370 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10371 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10372 # Get the list of files that are missing the terminating newline
10373 local missing=($(do_facet $facet \
10374 find ${facet_proc_dirs} -type f \| \
10375 while read F\; do \
10376 awk -v FS='\v' -v RS='\v\v' \
10377 "'END { if(NR>0 && \
10378 \\\$NF !~ /.*\\\n\$/) \
10379 print FILENAME}'" \
10382 [ ${#missing[*]} -eq 0 ] ||
10383 error "files do not end with newline: ${missing[*]}"
10386 run_test 133h "Proc files should end with newlines"
10389 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10390 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10391 skip "Need MDS version at least 2.7.54" && return
10393 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10394 cancel_lru_locks mdc
10396 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10397 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10398 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10401 createmany -o $DIR/$tdir/f $nr ||
10402 error "failed to create $nr files in $DIR/$tdir"
10403 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10405 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10406 do_facet mds1 $LCTL set_param fail_loc=0x327
10407 do_facet mds1 $LCTL set_param fail_val=500
10410 echo "sleep 10 seconds ..."
10412 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10414 do_facet mds1 $LCTL set_param fail_loc=0
10415 do_facet mds1 $LCTL set_param fail_val=0
10416 [ $lck_cnt -lt $unused ] ||
10417 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10420 unlinkmany $DIR/$tdir/f $nr
10422 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10425 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10426 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10427 skip "Need MDS version at least 2.7.54" && return
10429 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10430 cancel_lru_locks mdc
10432 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10433 ldlm.lock_reclaim_threshold_mb)
10434 # disable reclaim temporarily
10435 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10437 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10438 do_facet mds1 $LCTL set_param fail_loc=0x328
10439 do_facet mds1 $LCTL set_param fail_val=500
10441 $LCTL set_param debug=+trace
10444 createmany -o $DIR/$tdir/f $nr &
10445 local create_pid=$!
10447 echo "Sleep $TIMEOUT seconds ..."
10449 if ! ps -p $create_pid > /dev/null 2>&1; then
10450 do_facet mds1 $LCTL set_param fail_loc=0
10451 do_facet mds1 $LCTL set_param fail_val=0
10452 do_facet mds1 $LCTL set_param \
10453 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10454 error "createmany finished incorrectly!"
10456 do_facet mds1 $LCTL set_param fail_loc=0
10457 do_facet mds1 $LCTL set_param fail_val=0
10458 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10459 wait $create_pid || return 1
10461 unlinkmany $DIR/$tdir/f $nr
10463 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10465 test_140() { #bug-17379
10466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10467 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
10468 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10469 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10471 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10472 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10474 while i=`expr $i + 1`; do
10475 test_mkdir -p $i || error "Creating dir $i"
10476 cd $i || error "Changing to $i"
10477 ln -s ../stat stat || error "Creating stat symlink"
10478 # Read the symlink until ELOOP present,
10479 # not LBUGing the system is considered success,
10480 # we didn't overrun the stack.
10481 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10482 [ $ret -ne 0 ] && {
10483 if [ $ret -eq 40 ]; then
10486 error "Open stat symlink"
10492 echo "The symlink depth = $i"
10493 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10494 error "Invalid symlink depth"
10496 # Test recursive symlink
10497 ln -s symlink_self symlink_self
10498 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10499 echo "open symlink_self returns $ret"
10500 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10502 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10506 local TF="$TMP/$tfile"
10508 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10510 cancel_lru_locks osc
10511 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10512 remount_client $MOUNT
10514 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10517 $TRUNCATE $DIR/$tfile 6000
10518 cancel_lru_locks osc
10519 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10522 echo "12345" >>$DIR/$tfile
10523 cancel_lru_locks osc
10524 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10527 echo "12345" >>$DIR/$tfile
10528 cancel_lru_locks osc
10529 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10534 run_test 150 "truncate/append tests"
10536 #LU-2902 roc_hit was not able to read all values from lproc
10537 function roc_hit_init() {
10538 local list=$(comma_list $(osts_nodes))
10539 local dir=$DIR/$tdir-check
10540 local file=$dir/file
10546 #use setstripe to do a write to every ost
10547 for i in $(seq 0 $((OSTCOUNT-1))); do
10548 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10549 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10550 idx=$(printf %04x $i)
10551 BEFORE=$(get_osd_param $list *OST*$idx stats |
10552 awk '$1 == "cache_access" {sum += $7}
10553 END { printf("%0.0f", sum) }')
10555 cancel_lru_locks osc
10556 cat $file >/dev/null
10558 AFTER=$(get_osd_param $list *OST*$idx stats |
10559 awk '$1 == "cache_access" {sum += $7}
10560 END { printf("%0.0f", sum) }')
10562 echo BEFORE:$BEFORE AFTER:$AFTER
10563 if ! let "AFTER - BEFORE == 4"; then
10565 error "roc_hit is not safe to use"
10573 function roc_hit() {
10574 local list=$(comma_list $(osts_nodes))
10575 echo $(get_osd_param $list '' stats |
10576 awk '$1 == "cache_hit" {sum += $7}
10577 END { printf("%0.0f", sum) }')
10580 function set_cache() {
10583 if [ "$2" == "off" ]; then
10586 local list=$(comma_list $(osts_nodes))
10587 set_osd_param $list '' $1_cache_enable $on
10589 cancel_lru_locks osc
10593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10594 remote_ost_nodsh && skip "remote OST with nodsh" && return
10597 local list=$(comma_list $(osts_nodes))
10599 # check whether obdfilter is cache capable at all
10600 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10601 echo "not cache-capable obdfilter"
10605 # check cache is enabled on all obdfilters
10606 if get_osd_param $list '' read_cache_enable | grep 0; then
10607 echo "oss cache is disabled"
10611 set_osd_param $list '' writethrough_cache_enable 1
10613 # check write cache is enabled on all obdfilters
10614 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10615 echo "oss write cache is NOT enabled"
10621 #define OBD_FAIL_OBD_NO_LRU 0x609
10622 do_nodes $list $LCTL set_param fail_loc=0x609
10624 # pages should be in the case right after write
10625 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10628 local BEFORE=$(roc_hit)
10629 cancel_lru_locks osc
10630 cat $DIR/$tfile >/dev/null
10631 local AFTER=$(roc_hit)
10633 do_nodes $list $LCTL set_param fail_loc=0
10635 if ! let "AFTER - BEFORE == CPAGES"; then
10636 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10639 # the following read invalidates the cache
10640 cancel_lru_locks osc
10641 set_osd_param $list '' read_cache_enable 0
10642 cat $DIR/$tfile >/dev/null
10644 # now data shouldn't be found in the cache
10646 cancel_lru_locks osc
10647 cat $DIR/$tfile >/dev/null
10649 if let "AFTER - BEFORE != 0"; then
10650 error "IN CACHE: before: $BEFORE, after: $AFTER"
10653 set_osd_param $list '' read_cache_enable 1
10656 run_test 151 "test cache on oss and controls ==============================="
10659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10660 local TF="$TMP/$tfile"
10662 # simulate ENOMEM during write
10663 #define OBD_FAIL_OST_NOMEM 0x226
10664 lctl set_param fail_loc=0x80000226
10665 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10667 sync || error "sync failed"
10668 lctl set_param fail_loc=0
10670 # discard client's cache
10671 cancel_lru_locks osc
10673 # simulate ENOMEM during read
10674 lctl set_param fail_loc=0x80000226
10675 cmp $TF $DIR/$tfile || error "cmp failed"
10676 lctl set_param fail_loc=0
10680 run_test 152 "test read/write with enomem ============================"
10683 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10685 run_test 153 "test if fdatasync does not crash ======================="
10687 dot_lustre_fid_permission_check() {
10689 local ffid=$MOUNT/.lustre/fid/$fid
10692 echo "stat fid $fid"
10693 stat $ffid > /dev/null || error "stat $ffid failed."
10694 echo "touch fid $fid"
10695 touch $ffid || error "touch $ffid failed."
10696 echo "write to fid $fid"
10697 cat /etc/hosts > $ffid || error "write $ffid failed."
10698 echo "read fid $fid"
10699 diff /etc/hosts $ffid || error "read $ffid failed."
10700 echo "append write to fid $fid"
10701 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10702 echo "rename fid $fid"
10703 mv $ffid $test_dir/$tfile.1 &&
10704 error "rename $ffid to $tfile.1 should fail."
10705 touch $test_dir/$tfile.1
10706 mv $test_dir/$tfile.1 $ffid &&
10707 error "rename $tfile.1 to $ffid should fail."
10708 rm -f $test_dir/$tfile.1
10709 echo "truncate fid $fid"
10710 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10711 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10712 echo "link fid $fid"
10713 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10715 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10716 echo "setfacl fid $fid"
10717 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10718 echo "getfacl fid $fid"
10719 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10721 echo "unlink fid $fid"
10722 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10723 echo "mknod fid $fid"
10724 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10726 fid=[0xf00000400:0x1:0x0]
10727 ffid=$MOUNT/.lustre/fid/$fid
10729 echo "stat non-exist fid $fid"
10730 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10731 echo "write to non-exist fid $fid"
10732 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10733 echo "link new fid $fid"
10734 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10736 mkdir -p $test_dir/$tdir
10737 touch $test_dir/$tdir/$tfile
10738 fid=$($LFS path2fid $test_dir/$tdir)
10741 error "error: could not get fid for $test_dir/$dir/$tfile."
10743 ffid=$MOUNT/.lustre/fid/$fid
10746 ls $ffid > /dev/null || error "ls $ffid failed."
10747 echo "touch $fid/$tfile.1"
10748 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10750 echo "touch $MOUNT/.lustre/fid/$tfile"
10751 touch $MOUNT/.lustre/fid/$tfile && \
10752 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10754 echo "setxattr to $MOUNT/.lustre/fid"
10755 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10757 echo "listxattr for $MOUNT/.lustre/fid"
10758 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10760 echo "delxattr from $MOUNT/.lustre/fid"
10761 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10763 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10764 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10765 error "touch invalid fid should fail."
10767 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10768 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10769 error "touch non-normal fid should fail."
10771 echo "rename $tdir to $MOUNT/.lustre/fid"
10772 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10773 error "rename to $MOUNT/.lustre/fid should fail."
10775 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10777 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10778 local new_obf_mode=777
10780 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10781 chmod $new_obf_mode $DIR/.lustre/fid ||
10782 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10784 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10785 [ $obf_mode -eq $new_obf_mode ] ||
10786 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10788 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10789 chmod $old_obf_mode $DIR/.lustre/fid ||
10790 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10793 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10794 fid=$($LFS path2fid $test_dir/$tfile-2)
10796 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10798 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10799 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10800 error "create lov data thru .lustre failed"
10802 echo "cp /etc/passwd $test_dir/$tfile-2"
10803 cp /etc/passwd $test_dir/$tfile-2 ||
10804 error "copy to $test_dir/$tfile-2 failed."
10805 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10806 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10807 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10809 rm -rf $test_dir/tfile.lnk
10810 rm -rf $test_dir/$tfile-2
10814 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10815 skip "Need MDS version at least 2.4.1" && return
10817 local tf=$DIR/$tfile
10820 local fid=$($LFS path2fid $tf)
10821 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10823 # check that we get the same pathname back
10824 local found=$($LFS fid2path $MOUNT "$fid")
10825 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10826 [ "$found" == "$tf" ] ||
10827 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10829 run_test 154A "lfs path2fid and fid2path basic checks"
10832 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10833 skip "Need MDS version at least 2.4.1" && return
10835 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10836 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10837 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10838 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10840 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10841 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10843 # check that we get the same pathname
10844 echo "PFID: $PFID, name: $name"
10845 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10846 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10847 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10848 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10850 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10852 run_test 154B "verify the ll_decode_linkea tool"
10855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10856 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10857 { skip "Need MDS version at least 2.2.51"; return 0; }
10858 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10859 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10861 cp /etc/hosts $DIR/$tfile
10863 fid=$($LFS path2fid $DIR/$tfile)
10865 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10867 dot_lustre_fid_permission_check "$fid" $DIR ||
10868 error "dot lustre permission check $fid failed"
10870 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10872 touch $MOUNT/.lustre/file &&
10873 error "creation is not allowed under .lustre"
10875 mkdir $MOUNT/.lustre/dir &&
10876 error "mkdir is not allowed under .lustre"
10880 run_test 154a "Open-by-FID"
10883 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10884 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10885 { skip "Need MDS version at least 2.2.51"; return 0; }
10886 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10888 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10890 local remote_dir=$DIR/$tdir/remote_dir
10894 mkdir -p $DIR/$tdir
10895 $LFS mkdir -i $MDTIDX $remote_dir ||
10896 error "create remote directory failed"
10898 cp /etc/hosts $remote_dir/$tfile
10900 fid=$($LFS path2fid $remote_dir/$tfile)
10902 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10904 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10905 error "dot lustre permission check $fid failed"
10908 run_test 154b "Open-by-FID for remote directory"
10911 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10912 skip "Need MDS version at least 2.4.1" && return
10914 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10915 local FID1=$($LFS path2fid $DIR/$tfile.1)
10916 local FID2=$($LFS path2fid $DIR/$tfile.2)
10917 local FID3=$($LFS path2fid $DIR/$tfile.3)
10920 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10921 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10922 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10924 [ "$FID" = "${!want}" ] ||
10925 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10929 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10931 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10932 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10936 run_test 154c "lfs path2fid and fid2path multiple arguments"
10939 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10940 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10941 skip "Need MDS version at least 2.5.53" && return
10943 if remote_mds; then
10944 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10948 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10955 local fid=$($LFS path2fid $DIR/$tfile)
10958 cmd="exec $fd<$DIR/$tfile"
10960 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10961 echo "$fid_list" | grep "$fid"
10964 cmd="exec $fd>/dev/null"
10966 if [ $rc -ne 0 ]; then
10967 error "FID $fid not found in open files list $fid_list"
10970 run_test 154d "Verify open file fid"
10974 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10975 skip "Need MDS version at least 2.6.50" && return
10977 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10978 error ".lustre returned by readdir"
10981 run_test 154e ".lustre is not returned by readdir"
10984 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10985 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10986 test_mkdir -p -c1 $DIR/$tdir/d
10987 # test dirs inherit from its stripe
10988 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10989 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10990 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10991 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10994 # get fid of parents
10995 local FID0=$($LFS path2fid $DIR/$tdir/d)
10996 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10997 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10998 local FID3=$($LFS path2fid $DIR)
11000 # check that path2fid --parents returns expected <parent_fid>/name
11001 # 1) test for a directory (single parent)
11002 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
11003 [ "$parent" == "$FID0/foo1" ] ||
11004 error "expected parent: $FID0/foo1, got: $parent"
11006 # 2) test for a file with nlink > 1 (multiple parents)
11007 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
11008 echo "$parent" | grep -F "$FID1/$tfile" ||
11009 error "$FID1/$tfile not returned in parent list"
11010 echo "$parent" | grep -F "$FID2/link" ||
11011 error "$FID2/link not returned in parent list"
11013 # 3) get parent by fid
11014 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
11015 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11016 echo "$parent" | grep -F "$FID1/$tfile" ||
11017 error "$FID1/$tfile not returned in parent list (by fid)"
11018 echo "$parent" | grep -F "$FID2/link" ||
11019 error "$FID2/link not returned in parent list (by fid)"
11021 # 4) test for entry in root directory
11022 parent=$($LFS path2fid --parents $DIR/f)
11023 echo "$parent" | grep -F "$FID3/f" ||
11024 error "$FID3/f not returned in parent list"
11026 # 5) test it on root directory
11027 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
11028 error "$MOUNT should not have parents"
11030 # enable xattr caching and check that linkea is correctly updated
11031 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11032 save_lustre_params client "llite.*.xattr_cache" > $save
11033 lctl set_param llite.*.xattr_cache 1
11035 # 6.1) linkea update on rename
11036 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
11038 # get parents by fid
11039 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11040 # foo1 should no longer be returned in parent list
11041 echo "$parent" | grep -F "$FID1" &&
11042 error "$FID1 should no longer be in parent list"
11043 # the new path should appear
11044 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
11045 error "$FID2/$tfile.moved is not in parent list"
11047 # 6.2) linkea update on unlink
11048 rm -f $DIR/$tdir/d/foo2/link
11049 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11050 # foo2/link should no longer be returned in parent list
11051 echo "$parent" | grep -F "$FID2/link" &&
11052 error "$FID2/link should no longer be in parent list"
11056 restore_lustre_params < $save
11059 run_test 154f "get parent fids by reading link ea"
11063 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
11064 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
11065 { skip "Need MDS version at least 2.6.92"; return 0; }
11066 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11068 mkdir -p $DIR/$tdir
11069 llapi_fid_test -d $DIR/$tdir
11071 run_test 154g "various llapi FID tests"
11073 test_155_small_load() {
11074 local temp=$TMP/$tfile
11075 local file=$DIR/$tfile
11077 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
11078 error "dd of=$temp bs=6096 count=1 failed"
11080 cancel_lru_locks osc
11081 cmp $temp $file || error "$temp $file differ"
11083 $TRUNCATE $temp 6000
11084 $TRUNCATE $file 6000
11085 cmp $temp $file || error "$temp $file differ (truncate1)"
11087 echo "12345" >>$temp
11088 echo "12345" >>$file
11089 cmp $temp $file || error "$temp $file differ (append1)"
11091 echo "12345" >>$temp
11092 echo "12345" >>$file
11093 cmp $temp $file || error "$temp $file differ (append2)"
11099 test_155_big_load() {
11100 remote_ost_nodsh && skip "remote OST with nodsh" && return
11101 local temp=$TMP/$tfile
11102 local file=$DIR/$tfile
11105 local cache_size=$(do_facet ost$((MAXI+1)) \
11106 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
11107 local large_file_size=$((cache_size * 2))
11109 echo "OSS cache size: $cache_size KB"
11110 echo "Large file size: $large_file_size KB"
11112 [ $MAXV -le $large_file_size ] && \
11113 skip_env "max available OST size needs > $large_file_size KB" && \
11116 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
11118 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
11119 error "dd of=$temp bs=$large_file_size count=1k failed"
11122 cancel_lru_locks osc
11123 cmp $temp $file || error "$temp $file differ"
11129 save_writethrough() {
11130 local facets=$(get_facets OST)
11132 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
11133 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
11137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11138 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11139 save_writethrough $p
11142 set_cache writethrough on
11143 test_155_small_load
11144 restore_lustre_params < $p
11147 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
11150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11151 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11152 save_writethrough $p
11155 set_cache writethrough off
11156 test_155_small_load
11157 restore_lustre_params < $p
11160 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
11163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11164 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11165 save_writethrough $p
11168 set_cache writethrough on
11169 test_155_small_load
11170 restore_lustre_params < $p
11173 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
11176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11177 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11178 save_writethrough $p
11181 set_cache writethrough off
11182 test_155_small_load
11183 restore_lustre_params < $p
11186 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
11189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11190 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11191 save_writethrough $p
11194 set_cache writethrough on
11196 restore_lustre_params < $p
11199 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11203 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11204 save_writethrough $p
11207 set_cache writethrough off
11209 restore_lustre_params < $p
11212 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11216 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11217 save_writethrough $p
11220 set_cache writethrough on
11222 restore_lustre_params < $p
11225 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11229 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11230 save_writethrough $p
11233 set_cache writethrough off
11235 restore_lustre_params < $p
11238 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11241 remote_ost_nodsh && skip "remote OST with nodsh" && return
11242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11246 local file="$DIR/$tfile"
11247 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11249 [ "$(facet_fstype ost1)" = "zfs" -a \
11250 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11251 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
11254 save_writethrough $p
11257 log "Turn on read and write cache"
11259 set_cache writethrough on
11261 log "Write data and read it back."
11262 log "Read should be satisfied from the cache."
11263 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11265 cancel_lru_locks osc
11266 cat $file >/dev/null
11268 if ! let "AFTER - BEFORE == CPAGES"; then
11269 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11271 log "cache hits:: before: $BEFORE, after: $AFTER"
11274 log "Read again; it should be satisfied from the cache."
11276 cancel_lru_locks osc
11277 cat $file >/dev/null
11279 if ! let "AFTER - BEFORE == CPAGES"; then
11280 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11282 log "cache hits:: before: $BEFORE, after: $AFTER"
11285 log "Turn off the read cache and turn on the write cache"
11287 set_cache writethrough on
11289 log "Read again; it should be satisfied from the cache."
11291 cancel_lru_locks osc
11292 cat $file >/dev/null
11294 if ! let "AFTER - BEFORE == CPAGES"; then
11295 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11297 log "cache hits:: before: $BEFORE, after: $AFTER"
11300 log "Read again; it should not be satisfied from the cache."
11302 cancel_lru_locks osc
11303 cat $file >/dev/null
11305 if ! let "AFTER - BEFORE == 0"; then
11306 error "IN CACHE: before: $BEFORE, after: $AFTER"
11308 log "cache hits:: before: $BEFORE, after: $AFTER"
11311 log "Write data and read it back."
11312 log "Read should be satisfied from the cache."
11313 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11315 cancel_lru_locks osc
11316 cat $file >/dev/null
11318 if ! let "AFTER - BEFORE == CPAGES"; then
11319 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11321 log "cache hits:: before: $BEFORE, after: $AFTER"
11324 log "Read again; it should not be satisfied from the cache."
11326 cancel_lru_locks osc
11327 cat $file >/dev/null
11329 if ! let "AFTER - BEFORE == 0"; then
11330 error "IN CACHE: before: $BEFORE, after: $AFTER"
11332 log "cache hits:: before: $BEFORE, after: $AFTER"
11335 log "Turn off read and write cache"
11337 set_cache writethrough off
11339 log "Write data and read it back"
11340 log "It should not be satisfied from the cache."
11342 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11343 cancel_lru_locks osc
11345 cat $file >/dev/null
11347 if ! let "AFTER - BEFORE == 0"; then
11348 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11350 log "cache hits:: before: $BEFORE, after: $AFTER"
11353 log "Turn on the read cache and turn off the write cache"
11355 set_cache writethrough off
11357 log "Write data and read it back"
11358 log "It should not be satisfied from the cache."
11360 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11362 cancel_lru_locks osc
11363 cat $file >/dev/null
11365 if ! let "AFTER - BEFORE == 0"; then
11366 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11368 log "cache hits:: before: $BEFORE, after: $AFTER"
11371 log "Read again; it should be satisfied from the cache."
11373 cancel_lru_locks osc
11374 cat $file >/dev/null
11376 if ! let "AFTER - BEFORE == CPAGES"; then
11377 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11379 log "cache hits:: before: $BEFORE, after: $AFTER"
11383 restore_lustre_params < $p
11386 run_test 156 "Verification of tunables"
11389 cleanup_changelog () {
11391 echo "Deregistering changelog client $CL_USER"
11392 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11396 if [[ $MDSCOUNT -gt 1 ]]; then
11397 error_ignore bz17935 $*
11405 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11407 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11409 if [ $MASK -eq 1 ]; then
11410 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11412 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11416 changelog_extract_field() {
11420 local identifier=$4
11422 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11423 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11429 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11430 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11431 { skip "Need MDS version at least 2.2.0"; return; }
11433 local CL_USERS="mdd.$MDT0.changelog_users"
11434 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11435 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11436 changelog_register -n)
11437 echo "Registered as changelog user $CL_USER"
11438 trap cleanup_changelog EXIT
11439 $GET_CL_USERS | grep -q $CL_USER ||
11440 error "User $CL_USER not found in changelog_users"
11443 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11444 touch $DIR/$tdir/pics/2008/zachy/timestamp
11445 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11446 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11447 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11448 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11449 rm $DIR/$tdir/pics/desktop.jpg
11451 $LFS changelog $MDT0 | tail -5
11453 echo "verifying changelog mask"
11454 changelog_chmask "MKDIR"
11455 changelog_chmask "CLOSE"
11457 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11458 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11460 changelog_chmask "MKDIR"
11461 changelog_chmask "CLOSE"
11463 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11464 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11466 $LFS changelog $MDT0
11467 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11468 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11469 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11470 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11473 echo "verifying target fid"
11474 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11475 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11476 [ "$fidc" == "$fidf" ] ||
11477 err17935 "fid in changelog $fidc != file fid $fidf"
11478 echo "verifying parent fid"
11479 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11480 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11481 [ "$fidc" == "$fidf" ] ||
11482 err17935 "pfid in changelog $fidc != dir fid $fidf"
11484 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11485 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11486 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11487 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11488 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11489 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11491 MIN_REC=$($GET_CL_USERS |
11492 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11493 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11494 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11495 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11496 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11498 # LU-3446 changelog index reset on MDT restart
11499 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11500 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11501 $LFS changelog_clear $MDT0 $CL_USER 0
11502 stop $SINGLEMDS || error "Fail to stop MDT."
11503 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11504 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11505 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11506 [ $CUR_REC1 == $CUR_REC2 ] ||
11507 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11509 echo "verifying user deregister"
11511 $GET_CL_USERS | grep -q $CL_USER &&
11512 error "User $CL_USER still in changelog_users"
11514 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11515 if [ $CL_USER -eq 0 ]; then
11516 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11517 touch $DIR/$tdir/chloe
11518 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11519 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11520 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11522 echo "$CL_USER other changelog users; can't verify off"
11525 run_test 160a "changelog sanity"
11527 test_160b() { # LU-3587
11528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11529 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11530 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11531 { skip "Need MDS version at least 2.2.0"; return; }
11533 local CL_USERS="mdd.$MDT0.changelog_users"
11534 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11535 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11536 changelog_register -n)
11537 echo "Registered as changelog user $CL_USER"
11538 trap cleanup_changelog EXIT
11539 $GET_CL_USERS | grep -q $CL_USER ||
11540 error "User $CL_USER not found in changelog_users"
11542 local LONGNAME1=$(str_repeat a 255)
11543 local LONGNAME2=$(str_repeat b 255)
11546 echo "creating very long named file"
11547 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11548 echo "moving very long named file"
11549 mv $LONGNAME1 $LONGNAME2
11551 $LFS changelog $MDT0 | grep RENME
11555 run_test 160b "Verify that very long rename doesn't crash in changelog"
11558 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11561 local server_version=$(lustre_version_code $SINGLEMDS)
11563 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11564 [[ $server_version -gt $(version_code 2.5.1) &&
11565 $server_version -lt $(version_code 2.5.50) ]] ||
11566 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11569 # Registration step
11570 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11571 changelog_register -n)
11572 trap cleanup_changelog EXIT
11575 mkdir -p $DIR/$tdir
11576 $MCREATE $DIR/$tdir/foo_160c
11577 changelog_chmask "TRUNC"
11578 $TRUNCATE $DIR/$tdir/foo_160c 200
11579 changelog_chmask "TRUNC"
11580 $TRUNCATE $DIR/$tdir/foo_160c 199
11581 $LFS changelog $MDT0
11582 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11583 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11584 $LFS changelog_clear $MDT0 $CL_USER 0
11586 # Deregistration step
11589 run_test 160c "verify that changelog log catch the truncate event"
11592 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11595 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
11596 skip "lustre < 2.11.56 does not support migrate -m "
11598 local server_version=$(lustre_version_code mds1)
11599 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11601 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11602 { skip "Need MDS version at least 2.7.60+"; return; }
11603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11605 # Registration step
11606 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11607 changelog_register -n)
11609 trap cleanup_changelog EXIT
11610 mkdir -p $DIR/$tdir/migrate_dir
11611 $LFS changelog_clear $MDT0 $CL_USER 0
11613 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11614 $LFS changelog $MDT0
11615 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11616 $LFS changelog_clear $MDT0 $CL_USER 0
11617 [ $MIGRATES -eq 1 ] ||
11618 error "MIGRATE changelog mask count $MIGRATES != 1"
11620 # Deregistration step
11623 run_test 160d "verify that changelog log catch the migrate event"
11626 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11629 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11630 changelog_register -n)
11631 echo "Registered as changelog user $CL_USER"
11632 trap cleanup_changelog EXIT
11634 # Delete a future user (expect fail)
11635 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11638 if [ $rc -eq 0 ]; then
11639 error "Deleted non-existant user cl77"
11640 elif [ $rc -ne 2 ]; then
11641 error "changelog_deregister failed with $rc, " \
11642 "expected 2 (ENOENT)"
11645 # Clear to a bad index (1 billion should be safe)
11646 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11649 if [ $rc -eq 0 ]; then
11650 error "Successfully cleared to invalid CL index"
11651 elif [ $rc -ne 22 ]; then
11652 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11655 run_test 160e "changelog negative testing"
11658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11659 test_mkdir -p -c1 $DIR/$tdir
11660 cp /etc/hosts $DIR/$tdir/$tfile
11661 test_mkdir -c1 $DIR/$tdir/foo1
11662 test_mkdir -c1 $DIR/$tdir/foo2
11663 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11664 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11665 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11666 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11667 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11668 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11669 $LFS fid2path $DIR $FID
11670 err17935 "bad link ea"
11673 rm $DIR/$tdir/foo2/zachary
11675 rm $DIR/$tdir/foo2/thor
11677 rm $DIR/$tdir/$tfile
11679 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11680 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11682 $LFS fid2path $DIR $FID
11683 err17935 "bad link rename"
11685 rm $DIR/$tdir/foo2/maggie
11688 local longname=filename_avg_len_is_thirty_two_
11689 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11690 error "failed to hardlink many files"
11691 links=$($LFS fid2path $DIR $FID | wc -l)
11692 echo -n "${links}/1000 links in link EA"
11693 [[ $links -gt 60 ]] ||
11694 err17935 "expected at least 60 links in link EA"
11695 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11696 error "failed to unlink many hardlinks"
11698 run_test 161a "link ea sanity"
11701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11702 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11704 local remote_dir=$DIR/$tdir/remote_dir
11706 mkdir -p $DIR/$tdir
11707 $LFS mkdir -i $MDTIDX $remote_dir ||
11708 error "create remote directory failed"
11710 cp /etc/hosts $remote_dir/$tfile
11711 mkdir -p $remote_dir/foo1
11712 mkdir -p $remote_dir/foo2
11713 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11714 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11715 ln $remote_dir/$tfile $remote_dir/foo1/luna
11716 ln $remote_dir/$tfile $remote_dir/foo2/thor
11718 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11720 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11721 $LFS fid2path $DIR $FID
11722 err17935 "bad link ea"
11725 rm $remote_dir/foo2/zachary
11727 rm $remote_dir/foo2/thor
11729 rm $remote_dir/$tfile
11731 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11732 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11733 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11734 $LFS fid2path $DIR $FID
11735 err17935 "bad link rename"
11737 rm $remote_dir/foo2/maggie
11740 local longname=filename_avg_len_is_thirty_two_
11741 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11742 error "failed to hardlink many files"
11743 links=$($LFS fid2path $DIR $FID | wc -l)
11744 echo -n "${links}/1000 links in link EA"
11745 [[ ${links} -gt 60 ]] ||
11746 err17935 "expected at least 60 links in link EA"
11747 unlinkmany $remote_dir/foo2/$longname 1000 ||
11748 error "failed to unlink many hardlinks"
11750 run_test 161b "link ea sanity under remote directory"
11753 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11755 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11756 skip "Need MDS version at least 2.1.5" && return
11758 # define CLF_RENAME_LAST 0x0001
11759 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11760 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11761 changelog_register -n)
11763 trap cleanup_changelog EXIT
11765 mkdir -p $DIR/$tdir
11766 touch $DIR/$tdir/foo_161c
11767 touch $DIR/$tdir/bar_161c
11768 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11769 $LFS changelog $MDT0 | grep RENME
11770 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11772 $LFS changelog_clear $MDT0 $CL_USER 0
11773 if [ x$flags != "x0x1" ]; then
11774 error "flag $flags is not 0x1"
11776 echo "rename overwrite a target having nlink = 1," \
11777 "changelog record has flags of $flags"
11779 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11780 touch $DIR/$tdir/foo_161c
11781 touch $DIR/$tdir/bar_161c
11782 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11783 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11784 $LFS changelog $MDT0 | grep RENME
11785 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11786 $LFS changelog_clear $MDT0 $CL_USER 0
11787 if [ x$flags != "x0x0" ]; then
11788 error "flag $flags is not 0x0"
11790 echo "rename overwrite a target having nlink > 1," \
11791 "changelog record has flags of $flags"
11793 # rename doesn't overwrite a target (changelog flag 0x0)
11794 touch $DIR/$tdir/foo_161c
11795 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11796 $LFS changelog $MDT0 | grep RENME
11797 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11798 $LFS changelog_clear $MDT0 $CL_USER 0
11799 if [ x$flags != "x0x0" ]; then
11800 error "flag $flags is not 0x0"
11802 echo "rename doesn't overwrite a target," \
11803 "changelog record has flags of $flags"
11805 # define CLF_UNLINK_LAST 0x0001
11806 # unlink a file having nlink = 1 (changelog flag 0x1)
11807 rm -f $DIR/$tdir/foo2_161c
11808 $LFS changelog $MDT0 | grep UNLNK
11809 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11810 $LFS changelog_clear $MDT0 $CL_USER 0
11811 if [ x$flags != "x0x1" ]; then
11812 error "flag $flags is not 0x1"
11814 echo "unlink a file having nlink = 1," \
11815 "changelog record has flags of $flags"
11817 # unlink a file having nlink > 1 (changelog flag 0x0)
11818 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11819 rm -f $DIR/$tdir/foobar_161c
11820 $LFS changelog $MDT0 | grep UNLNK
11821 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11822 $LFS changelog_clear $MDT0 $CL_USER 0
11823 if [ x$flags != "x0x0" ]; then
11824 error "flag $flags is not 0x0"
11826 echo "unlink a file having nlink > 1," \
11827 "changelog record has flags of $flags"
11830 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11837 # cleanup previous run
11838 rm -rf $DIR/$tdir/$tfile
11840 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11841 changelog_register -n)
11842 [[ $? -eq 0 ]] || error "changelog_register failed"
11844 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11845 # interfer with $MOUNT/.lustre/fid/ access
11847 [[ $? -eq 0 ]] || error "mkdir failed"
11849 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11850 $LCTL set_param fail_loc=0x8000140c
11852 $LCTL set_param fail_val=5
11855 echo foofoo > $DIR/$tdir/$tfile &
11858 # wait for create to be delayed
11862 [[ $? -eq 0 ]] || error "create should be blocked"
11864 local tempfile=$(mktemp)
11865 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11866 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11867 # some delay may occur during ChangeLog publishing and file read just
11868 # above, that could allow file write to happen finally
11869 [[ -s $tempfile ]] && echo "file should be empty"
11871 $LCTL set_param fail_loc=0
11874 [[ $? -eq 0 ]] || error "create failed"
11876 $LFS changelog_clear $MDT0 $user 0
11877 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11879 run_test 161d "create with concurrent .lustre/fid access"
11886 local path=$(${LFS} fid2path $*)
11887 # Remove the '//' indicating a remote directory
11888 path=$(echo $path | sed 's#//#/#g')
11891 if [ $RC -ne 0 ]; then
11892 err17935 "path looked up of $expected failed. Error $RC"
11894 elif [ "${path}" != "${expected}" ]; then
11895 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11898 echo "fid $fid resolves to path $path (expected $expected)"
11901 test_162a() { # was test_162
11902 # Make changes to filesystem
11903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11904 test_mkdir -p -c1 $DIR/$tdir/d2
11905 touch $DIR/$tdir/d2/$tfile
11906 touch $DIR/$tdir/d2/x1
11907 touch $DIR/$tdir/d2/x2
11908 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11909 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11911 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11912 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11913 error "check path $tdir/d2/$tfile failed"
11916 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11917 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11918 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11919 error "check path $tdir/d2/p/q/r/slink failed"
11921 # softlink to wrong file
11922 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11923 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11924 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11925 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11928 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11929 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11930 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11931 # fid2path dir/fsname should both work
11932 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11933 error "check path $tdir/d2/a/b/c/new_file failed"
11934 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11935 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11937 # hardlink count: check that there are 2 links
11938 # Doesnt work with CMD yet: 17935
11939 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11940 err17935 "expected 2 links"
11942 # hardlink indexing: remove the first link
11943 rm $DIR/$tdir/d2/p/q/r/hlink
11944 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11945 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11949 run_test 162a "path lookup sanity"
11952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11953 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11956 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11957 error "create striped dir failed"
11959 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11960 tail -n 1 | awk '{print $2}')
11961 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11963 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11964 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11967 for ((i=0;i<5;i++)); do
11968 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11969 error "get fid for f$i failed"
11970 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11971 error "check path $tdir/striped_dir/f$i failed"
11973 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11974 error "get fid for d$i failed"
11975 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11976 error "check path $tdir/striped_dir/d$i failed"
11981 run_test 162b "striped directory path lookup sanity"
11983 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11985 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11986 skip "Need MDS version at least 2.7.51" && return
11987 test_mkdir $DIR/$tdir.local
11988 test_mkdir $DIR/$tdir.remote
11989 local lpath=$tdir.local
11990 local rpath=$tdir.remote
11992 for ((i = 0; i <= 101; i++)); do
11995 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11996 error "get fid for local directory $DIR/$lpath failed"
11997 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11998 error "check path for local directory $DIR/$lpath failed"
12001 test_mkdir $DIR/$rpath
12002 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
12003 error "get fid for remote directory $DIR/$rpath failed"
12004 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
12005 error "check path for remote directory $DIR/$rpath failed"
12010 run_test 162c "fid2path works with paths 100 or more directories deep"
12013 # do directio so as not to populate the page cache
12014 log "creating a 10 Mb file"
12015 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12016 log "starting reads"
12017 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12018 log "truncating the file"
12019 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12021 kill %+ || true # reads might have finished
12022 echo "wait until dd is finished"
12024 log "removing the temporary file"
12025 rm -rf $DIR/$tfile || error "tmp file removal failed"
12027 run_test 169 "parallel read and truncate should not deadlock"
12030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12031 $LCTL clear # bug 18514
12032 $LCTL debug_daemon start $TMP/${tfile}_log_good
12034 $LCTL debug_daemon stop
12035 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
12036 error "sed failed to read log_good"
12038 $LCTL debug_daemon start $TMP/${tfile}_log_good
12040 $LCTL debug_daemon stop
12042 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
12043 error "lctl df log_bad failed"
12045 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12046 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12048 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
12049 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
12051 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
12052 error "bad_line good_line1 good_line2 are empty"
12054 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12055 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
12056 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12058 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
12059 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12060 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12062 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
12063 error "bad_line_new good_line_new are empty"
12065 local expected_good=$((good_line1 + good_line2*2))
12067 rm -f $TMP/${tfile}*
12068 # LU-231, short malformed line may not be counted into bad lines
12069 if [ $bad_line -ne $bad_line_new ] &&
12070 [ $bad_line -ne $((bad_line_new - 1)) ]; then
12071 error "expected $bad_line bad lines, but got $bad_line_new"
12075 if [ $expected_good -ne $good_line_new ]; then
12076 error "expected $expected_good good lines, but got $good_line_new"
12081 run_test 170 "test lctl df to handle corrupted log ====================="
12083 test_171() { # bug20592
12084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12085 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
12086 $LCTL set_param fail_loc=0x50e
12087 $LCTL set_param fail_val=3000
12088 multiop_bg_pause $DIR/$tfile O_s || true
12090 kill -USR1 $MULTIPID
12094 if dmesg | grep "recursive fault"; then
12095 error "caught a recursive fault"
12097 $LCTL set_param fail_loc=0
12100 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
12102 # it would be good to share it with obdfilter-survey/iokit-libecho code
12103 setup_obdecho_osc () {
12106 local obdfilter_name=$2
12107 echo "Creating new osc for $obdfilter_name on $ost_nid"
12108 # make sure we can find loopback nid
12109 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
12111 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
12112 ${obdfilter_name}_osc_UUID || rc=2; }
12113 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
12114 ${obdfilter_name}_UUID $ost_nid || rc=3; }
12118 cleanup_obdecho_osc () {
12119 local obdfilter_name=$1
12120 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
12121 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
12128 local pages=${3:-64}
12133 local obd_size=$(get_obd_size $node $OBD)
12134 local page_size=$(get_page_size $node)
12135 if [[ -n "$obd_size" ]]; then
12136 local new_count=$((obd_size / (pages * page_size / 1024)))
12137 [[ $new_count -ge $count ]] || count=$new_count
12140 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
12141 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
12143 if [ $rc -eq 0 ]; then
12144 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
12145 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
12147 echo "New object id is $id"
12148 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
12150 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
12151 "test_brw $count w v $pages $id" || rc=4; }
12152 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
12154 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
12155 "cleanup" || rc=5; }
12156 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
12157 "detach" || rc=6; }
12158 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
12163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12164 remote_ost_nodsh && skip "remote OST with nodsh" && return
12166 local rmmod_local=0
12168 if ! module_loaded obdecho; then
12169 load_module obdecho/obdecho
12173 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
12174 local host=$(lctl get_param -n osc.$osc.import |
12175 awk '/current_connection:/ {print $2}' )
12176 local target=$(lctl get_param -n osc.$osc.import |
12177 awk '/target:/ {print $2}' )
12178 target=${target%_UUID}
12180 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
12181 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
12182 [[ -n $target ]] && cleanup_obdecho_osc $target
12183 [ $rmmod_local -eq 1 ] && rmmod obdecho
12186 run_test 180a "test obdecho on osc"
12189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12190 remote_ost_nodsh && skip "remote OST with nodsh" && return
12192 local rmmod_remote=0
12194 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12195 rmmod_remote=true || error "failed to load module obdecho"
12196 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
12197 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12198 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12201 run_test 180b "test obdecho directly on obdfilter"
12203 test_180c() { # LU-2598
12204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12205 remote_ost_nodsh && skip "remote OST with nodsh" && return
12206 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12207 skip "Need MDS version at least 2.4.0" && return
12210 local rmmod_remote=false
12211 local pages=16384 # 64MB bulk I/O RPC size
12214 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12215 rmmod_remote=true || error "failed to load module obdecho"
12217 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
12219 if [ -n "$target" ]; then
12220 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12222 echo "there is no obdfilter target on ost1"
12225 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12228 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12230 test_181() { # bug 22177
12231 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12232 # create enough files to index the directory
12233 createmany -o $DIR/$tdir/foobar 4000
12234 # print attributes for debug purpose
12237 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12239 # remove the files & current working dir
12240 unlinkmany $DIR/$tdir/foobar 4000
12242 kill -USR1 $MULTIPID
12244 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12247 run_test 181 "Test open-unlinked dir ========================"
12253 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12255 $LCTL set_param mdc.*.rpc_stats=clear
12257 for (( i = 0; i < $tcount; i++ )) ; do
12258 mkdir $DIR/$tdir/$i
12261 for (( i = 0; i < $tcount; i++ )) ; do
12262 createmany -o $DIR/$tdir/$i/f- $fcount &
12266 for (( i = 0; i < $tcount; i++ )) ; do
12267 unlinkmany $DIR/$tdir/$i/f- $fcount &
12271 $LCTL get_param mdc.*.rpc_stats
12275 run_test 182 "Test parallel modify metadata operations ================"
12277 test_183() { # LU-2275
12278 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12279 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12280 skip "Need MDS version at least 2.3.56" && return
12282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12283 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12284 echo aaa > $DIR/$tdir/$tfile
12286 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12287 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12289 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12290 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12292 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12294 # Flush negative dentry cache
12295 touch $DIR/$tdir/$tfile
12297 # We are not checking for any leaked references here, they'll
12298 # become evident next time we do cleanup with module unload.
12301 run_test 183 "No crash or request leak in case of strange dispositions ========"
12303 # test suite 184 is for LU-2016, LU-2017
12305 check_swap_layouts_support && return 0
12307 dir0=$DIR/$tdir/$testnum
12308 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
12313 $SETSTRIPE -c1 $file1
12315 $SETSTRIPE -c2 $file2
12317 gen1=$($GETSTRIPE -g $file1)
12318 gen2=$($GETSTRIPE -g $file2)
12320 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12321 gen=$($GETSTRIPE -g $file1)
12322 [[ $gen1 != $gen ]] ||
12323 "Layout generation on $file1 does not change"
12324 gen=$($GETSTRIPE -g $file2)
12325 [[ $gen2 != $gen ]] ||
12326 "Layout generation on $file2 does not change"
12328 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12329 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12331 run_test 184a "Basic layout swap"
12334 check_swap_layouts_support && return 0
12336 dir0=$DIR/$tdir/$testnum
12337 mkdir -p $dir0 || error "creating dir $dir0"
12344 $SETSTRIPE -c1 $file1
12345 $SETSTRIPE -c2 $file2
12346 $SETSTRIPE -c1 $file3
12347 chown $RUNAS_ID $file3
12348 gen1=$($GETSTRIPE -g $file1)
12349 gen2=$($GETSTRIPE -g $file2)
12351 $LFS swap_layouts $dir1 $dir2 &&
12352 error "swap of directories layouts should fail"
12353 $LFS swap_layouts $dir1 $file1 &&
12354 error "swap of directory and file layouts should fail"
12355 $RUNAS $LFS swap_layouts $file1 $file2 &&
12356 error "swap of file we cannot write should fail"
12357 $LFS swap_layouts $file1 $file3 &&
12358 error "swap of file with different owner should fail"
12359 /bin/true # to clear error code
12361 run_test 184b "Forbidden layout swap (will generate errors)"
12364 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12365 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12366 check_swap_layouts_support && return 0
12368 local dir0=$DIR/$tdir/$testnum
12369 mkdir -p $dir0 || error "creating dir $dir0"
12371 local ref1=$dir0/ref1
12372 local ref2=$dir0/ref2
12373 local file1=$dir0/file1
12374 local file2=$dir0/file2
12375 # create a file large enough for the concurrent test
12376 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12377 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12378 echo "ref file size: ref1($(stat -c %s $ref1))," \
12379 "ref2($(stat -c %s $ref2))"
12382 dd if=$ref1 of=$file1 bs=16k &
12385 # Make sure dd starts to copy file
12386 while [ ! -f $file1 ]; do sleep 0.1; done
12388 $LFS swap_layouts $file1 $file2
12391 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12392 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12394 # how many bytes copied before swapping layout
12395 local copied=$(stat -c %s $file2)
12396 local remaining=$(stat -c %s $ref1)
12397 remaining=$((remaining - copied))
12398 echo "Copied $copied bytes before swapping layout..."
12400 cmp -n $copied $file1 $ref2 | grep differ &&
12401 error "Content mismatch [0, $copied) of ref2 and file1"
12402 cmp -n $copied $file2 $ref1 ||
12403 error "Content mismatch [0, $copied) of ref1 and file2"
12404 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12405 error "Content mismatch [$copied, EOF) of ref1 and file1"
12408 rm -f $ref1 $ref2 $file1 $file2
12410 run_test 184c "Concurrent write and layout swap"
12413 check_swap_layouts_support && return 0
12414 [ -z "$(which getfattr 2>/dev/null)" ] &&
12415 skip "no getfattr command" && return 0
12417 local file1=$DIR/$tdir/$tfile-1
12418 local file2=$DIR/$tdir/$tfile-2
12419 local file3=$DIR/$tdir/$tfile-3
12423 mkdir -p $DIR/$tdir
12424 touch $file1 || error "create $file1 failed"
12425 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12426 error "create $file2 failed"
12427 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12428 error "create $file3 failed"
12429 lovea1=$(get_layout_param $file1)
12431 $LFS swap_layouts $file2 $file3 ||
12432 error "swap $file2 $file3 layouts failed"
12433 $LFS swap_layouts $file1 $file2 ||
12434 error "swap $file1 $file2 layouts failed"
12436 lovea2=$(get_layout_param $file2)
12439 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12441 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12442 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12444 run_test 184d "allow stripeless layouts swap"
12447 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12448 { skip "Need MDS version at least 2.6.94"; return 0; }
12449 check_swap_layouts_support && return 0
12450 [ -z "$(which getfattr 2>/dev/null)" ] &&
12451 skip "no getfattr command" && return 0
12453 local file1=$DIR/$tdir/$tfile-1
12454 local file2=$DIR/$tdir/$tfile-2
12455 local file3=$DIR/$tdir/$tfile-3
12458 mkdir -p $DIR/$tdir
12459 touch $file1 || error "create $file1 failed"
12460 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12461 error "create $file2 failed"
12462 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12463 error "create $file3 failed"
12465 $LFS swap_layouts $file1 $file2 ||
12466 error "swap $file1 $file2 layouts failed"
12468 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12469 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12471 echo 123 > $file1 || error "Should be able to write into $file1"
12473 $LFS swap_layouts $file1 $file3 ||
12474 error "swap $file1 $file3 layouts failed"
12476 echo 123 > $file1 || error "Should be able to write into $file1"
12478 rm -rf $file1 $file2 $file3
12480 run_test 184e "Recreate layout after stripeless layout swaps"
12482 test_185() { # LU-2441
12483 # LU-3553 - no volatile file support in old servers
12484 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12485 { skip "Need MDS version at least 2.3.60"; return 0; }
12487 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12488 touch $DIR/$tdir/spoo
12489 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12490 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12491 error "cannot create/write a volatile file"
12492 [ "$FILESET" == "" ] &&
12493 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12494 error "FID is still valid after close"
12496 multiop_bg_pause $DIR/$tdir vVw4096_c
12503 # assume that the next FID for this client is sequential, since stdout
12504 # is unfortunately eaten by multiop_bg_pause
12505 local n=$((${fidv[1]} + 1))
12506 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12507 if [ "$FILESET" == "" ]; then
12508 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12509 error "FID is missing before close"
12511 kill -USR1 $multi_pid
12512 # 1 second delay, so if mtime change we will see it
12514 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12515 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12517 run_test 185 "Volatile file support"
12520 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12521 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12522 skip "Need MDS version at least 2.3.0" && return
12524 local dir0=$DIR/$tdir/$testnum
12525 mkdir -p $dir0 || error "creating dir $dir0"
12527 local file=$dir0/file1
12528 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12529 local dv1=$($LFS data_version $file)
12530 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12531 local dv2=$($LFS data_version $file)
12532 [[ $dv1 != $dv2 ]] ||
12533 error "data version did not change on write $dv1 == $dv2"
12538 run_test 187a "Test data version change"
12541 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12542 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12543 skip "Need MDS version at least 2.3.0" && return
12545 local dir0=$DIR/$tdir/$testnum
12546 mkdir -p $dir0 || error "creating dir $dir0"
12548 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12549 [[ ${DV[0]} != ${DV[1]} ]] ||
12550 error "data version did not change on write"\
12551 " ${DV[0]} == ${DV[1]}"
12556 run_test 187b "Test data version change on volatile file"
12559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12560 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12561 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12563 local POOL=${POOL:-cea1}
12564 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12565 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12568 local last_ost=$(($OSTCOUNT - 1))
12570 local ost_list=$(seq $first_ost $ost_step $last_ost)
12571 local ost_range="$first_ost $last_ost $ost_step"
12572 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12573 local file_dir=$POOL_ROOT/file_tst
12574 local subdir=$test_path/subdir
12577 if ! combined_mgs_mds ; then
12582 # former test_200a test_200b
12583 pool_add $POOL || { rc=$? ; break; }
12584 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12585 # former test_200c test_200d
12586 mkdir -p $test_path
12587 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12588 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12590 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12591 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12592 || { rc=$? ; break; }
12593 # former test_200e test_200f
12594 local files=$((OSTCOUNT*3))
12595 pool_alloc_files $POOL $test_path $files "$ost_list" \
12596 || { rc=$? ; break; }
12597 pool_create_files $POOL $file_dir $files "$ost_list" \
12598 || { rc=$? ; break; }
12599 # former test_200g test_200h
12600 pool_lfs_df $POOL || { rc=$? ; break; }
12601 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12603 # former test_201a test_201b test_201c
12604 pool_remove_first_target $POOL || { rc=$? ; break; }
12606 local f=$test_path/$tfile
12607 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12608 pool_remove $POOL $f || { rc=$? ; break; }
12614 if ! combined_mgs_mds ; then
12619 run_test 200 "OST pools"
12621 # usage: default_attr <count | size | offset>
12623 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12626 # usage: check_default_stripe_attr
12627 check_default_stripe_attr() {
12628 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12631 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12633 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12637 error "unknown getstripe attr '$1'"
12640 [ $ACTUAL != $EXPECTED ] &&
12641 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12645 test_mkdir -p $DIR/$tdir
12646 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12648 check_default_stripe_attr --stripe-count
12649 check_default_stripe_attr --stripe-size
12650 check_default_stripe_attr --stripe-index
12654 run_test 204a "Print default stripe attributes ================="
12657 test_mkdir -p $DIR/$tdir
12658 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12660 check_default_stripe_attr --stripe-size
12661 check_default_stripe_attr --stripe-index
12665 run_test 204b "Print default stripe size and offset ==========="
12668 test_mkdir -p $DIR/$tdir
12669 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12671 check_default_stripe_attr --stripe-count
12672 check_default_stripe_attr --stripe-index
12676 run_test 204c "Print default stripe count and offset ==========="
12679 test_mkdir -p $DIR/$tdir
12680 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12682 check_default_stripe_attr --stripe-count
12683 check_default_stripe_attr --stripe-size
12687 run_test 204d "Print default stripe count and size ============="
12690 test_mkdir -p $DIR/$tdir
12691 $SETSTRIPE -d $DIR/$tdir
12693 check_default_stripe_attr --stripe-count --raw
12694 check_default_stripe_attr --stripe-size --raw
12695 check_default_stripe_attr --stripe-index --raw
12699 run_test 204e "Print raw stripe attributes ================="
12702 test_mkdir -p $DIR/$tdir
12703 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12705 check_default_stripe_attr --stripe-size --raw
12706 check_default_stripe_attr --stripe-index --raw
12710 run_test 204f "Print raw stripe size and offset ==========="
12713 test_mkdir -p $DIR/$tdir
12714 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12716 check_default_stripe_attr --stripe-count --raw
12717 check_default_stripe_attr --stripe-index --raw
12721 run_test 204g "Print raw stripe count and offset ==========="
12724 test_mkdir -p $DIR/$tdir
12725 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12727 check_default_stripe_attr --stripe-count --raw
12728 check_default_stripe_attr --stripe-size --raw
12732 run_test 204h "Print raw stripe count and size ============="
12734 # Figure out which job scheduler is being used, if any,
12735 # or use a fake one
12736 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12737 JOBENV=SLURM_JOB_ID
12738 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12740 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12742 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12743 JOBENV=LOADL_STEP_ID
12744 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12747 $LCTL list_param jobid_name > /dev/null 2>&1
12748 if [ $? -eq 0 ]; then
12755 verify_jobstats() {
12760 # we don't really need to clear the stats for this test to work, since each
12761 # command has a unique jobid, but it makes debugging easier if needed.
12762 # for facet in $facets; do
12763 # local dev=$(convert_facet2label $facet)
12764 # # clear old jobstats
12765 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12768 # use a new JobID for each test, or we might see an old one
12769 [ "$JOBENV" = "FAKE_JOBID" ] &&
12770 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12774 [ "$JOBENV" = "nodelocal" ] && {
12775 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12776 $LCTL set_param jobid_name=$FAKE_JOBID
12780 log "Test: ${cmd[*]}"
12781 log "Using JobID environment variable $JOBENV=$JOBVAL"
12783 if [ $JOBENV = "FAKE_JOBID" ]; then
12784 FAKE_JOBID=$JOBVAL ${cmd[*]}
12789 # all files are created on OST0000
12790 for facet in $facets; do
12791 local stats="*.$(convert_facet2label $facet).job_stats"
12792 if [ $(do_facet $facet lctl get_param $stats |
12793 grep -c $JOBVAL) -ne 1 ]; then
12794 do_facet $facet lctl get_param $stats
12795 error "No jobstats for $JOBVAL found on $facet::$stats"
12802 NEW_JOBENV=${1:-$OLD_JOBENV}
12803 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12804 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12809 do_facet $SINGLEMDS \
12810 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12811 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12815 test_205() { # Job stats
12816 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12817 { skip "Need MDS version with at least 2.7.1"; return 0; }
12819 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12820 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12821 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12822 remote_ost_nodsh && skip "remote OST with nodsh" && return
12824 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12825 skip "Server doesn't support jobstats" && return 0
12826 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12828 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12829 if [ $OLD_JOBENV != $JOBENV ]; then
12830 jobstats_set $JOBENV
12831 trap cleanup_205 EXIT
12834 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12835 echo "Registered as changelog user $CL_USER"
12837 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12838 lctl get_param -n mdt.*.job_cleanup_interval)
12839 local interval_new=5
12840 do_facet $SINGLEMDS \
12841 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12842 local start=$SECONDS
12846 cmd="mkdir $DIR/$tdir"
12847 verify_jobstats "$cmd" "$SINGLEMDS"
12849 cmd="rmdir $DIR/$tdir"
12850 verify_jobstats "$cmd" "$SINGLEMDS"
12851 # mkdir on secondary MDT
12852 if [ $MDSCOUNT -gt 1 ]; then
12853 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12854 verify_jobstats "$cmd" "mds2"
12857 cmd="mknod $DIR/$tfile c 1 3"
12858 verify_jobstats "$cmd" "$SINGLEMDS"
12860 cmd="rm -f $DIR/$tfile"
12861 verify_jobstats "$cmd" "$SINGLEMDS"
12862 # create all files on OST0000 so verify_jobstats can find OST stats
12864 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12865 verify_jobstats "$cmd" "$SINGLEMDS"
12867 cmd="touch $DIR/$tfile"
12868 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12870 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12871 verify_jobstats "$cmd" "ost1"
12873 cancel_lru_locks osc
12874 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12875 verify_jobstats "$cmd" "ost1"
12877 cmd="$TRUNCATE $DIR/$tfile 0"
12878 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12880 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12881 verify_jobstats "$cmd" "$SINGLEMDS"
12882 # jobstats expiry - sleep until old stats should be expired
12883 local left=$((interval_new + 5 - (SECONDS - start)))
12884 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12885 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12887 cmd="mkdir $DIR/$tdir.expire"
12888 verify_jobstats "$cmd" "$SINGLEMDS"
12889 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12890 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12892 # Ensure that jobid are present in changelog (if supported by MDS)
12893 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12895 $LFS changelog $MDT0 | tail -9
12896 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12897 [ $jobids -eq 9 ] ||
12898 error "Wrong changelog jobid count $jobids != 9"
12902 jobstats_set $JOBENV
12904 $LFS changelog $MDT0 | tail -1
12905 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12906 [ $jobids -eq 0 ] ||
12907 error "Unexpected jobids when jobid_var=$JOBENV"
12912 run_test 205 "Verify job stats"
12914 # LU-1480, LU-1773 and LU-1657
12916 mkdir -p $DIR/$tdir
12917 $SETSTRIPE -c -1 $DIR/$tdir
12918 #define OBD_FAIL_LOV_INIT 0x1403
12919 $LCTL set_param fail_loc=0xa0001403
12920 $LCTL set_param fail_val=1
12921 touch $DIR/$tdir/$tfile || true
12923 run_test 206 "fail lov_init_raid0() doesn't lbug"
12926 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12927 local fsz=`stat -c %s $DIR/$tfile`
12928 cancel_lru_locks mdc
12930 # do not return layout in getattr intent
12931 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12932 $LCTL set_param fail_loc=0x170
12933 local sz=`stat -c %s $DIR/$tfile`
12935 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12939 run_test 207a "can refresh layout at glimpse"
12942 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12943 local cksum=`md5sum $DIR/$tfile`
12944 local fsz=`stat -c %s $DIR/$tfile`
12945 cancel_lru_locks mdc
12946 cancel_lru_locks osc
12948 # do not return layout in getattr intent
12949 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12950 $LCTL set_param fail_loc=0x171
12952 # it will refresh layout after the file is opened but before read issues
12953 echo checksum is "$cksum"
12954 echo "$cksum" |md5sum -c --quiet || error "file differs"
12958 run_test 207b "can refresh layout at open"
12961 # FIXME: in this test suite, only RD lease is used. This is okay
12962 # for now as only exclusive open is supported. After generic lease
12963 # is done, this test suite should be revised. - Jinshan
12965 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12966 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12967 { skip "Need MDS version at least 2.4.52"; return 0; }
12969 echo "==== test 1: verify get lease work"
12970 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12972 echo "==== test 2: verify lease can be broken by upcoming open"
12973 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12977 $MULTIOP $DIR/$tfile oO_RDONLY:c
12978 kill -USR1 $PID && wait $PID || error "break lease error"
12980 echo "==== test 3: verify lease can't be granted if an open already exists"
12981 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12985 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12986 kill -USR1 $PID && wait $PID || error "open file error"
12988 echo "==== test 4: lease can sustain over recovery"
12989 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12995 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12997 echo "==== test 5: lease broken can't be regained by replay"
12998 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13002 # open file to break lease and then recovery
13003 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
13006 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
13010 run_test 208 "Exclusive open"
13013 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
13014 skip_env "must have disp_stripe" && return
13017 sync; sleep 5; sync;
13019 echo 3 > /proc/sys/vm/drop_caches
13020 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13022 # open/close 500 times
13023 for i in $(seq 500); do
13027 echo 3 > /proc/sys/vm/drop_caches
13028 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13030 echo "before: $req_before, after: $req_after"
13031 [ $((req_after - req_before)) -ge 300 ] &&
13032 error "open/close requests are not freed"
13035 run_test 209 "read-only open/close requests should be freed promptly"
13039 size=$((size % 8192 + 1))
13040 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
13041 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
13042 rm -f $DIR/f212 $DIR/f212.xyz
13044 run_test 212 "Sendfile test ============================================"
13047 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
13048 cancel_lru_locks osc
13049 lctl set_param fail_loc=0x8000040f
13050 # generate a read lock
13051 cat $DIR/$tfile > /dev/null
13052 # write to the file, it will try to cancel the above read lock.
13053 cat /etc/hosts >> $DIR/$tfile
13055 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
13057 test_214() { # for bug 20133
13058 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
13059 for (( i=0; i < 340; i++ )) ; do
13060 touch $DIR/$tdir/d214c/a$i
13063 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
13064 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
13065 ls $DIR/d214c || error "ls $DIR/d214c failed"
13066 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
13067 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
13069 run_test 214 "hash-indexed directory test - bug 20133"
13071 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
13072 create_lnet_proc_files() {
13073 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
13074 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
13076 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
13077 rm -f "$TMP/lnet_$1.sys_tmp"
13080 # counterpart of create_lnet_proc_files
13081 remove_lnet_proc_files() {
13082 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
13085 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13086 # 3rd arg as regexp for body
13087 check_lnet_proc_stats() {
13088 local l=$(cat "$TMP/lnet_$1" |wc -l)
13089 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
13091 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
13094 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13095 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
13096 # optional and can be regexp for 2nd line (lnet.routes case)
13097 check_lnet_proc_entry() {
13098 local blp=2 # blp stands for 'position of 1st line of body'
13099 [ -z "$5" ] || blp=3 # lnet.routes case
13101 local l=$(cat "$TMP/lnet_$1" |wc -l)
13102 # subtracting one from $blp because the body can be empty
13103 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
13105 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
13106 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
13108 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
13109 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
13111 # bail out if any unexpected line happened
13112 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
13113 [ "$?" != 0 ] || error "$2 misformatted"
13116 test_215() { # for bugs 18102, 21079, 21517
13117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13118 local N='(0|[1-9][0-9]*)' # non-negative numeric
13119 local P='[1-9][0-9]*' # positive numeric
13120 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
13121 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
13122 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
13123 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
13125 local L1 # regexp for 1st line
13126 local L2 # regexp for 2nd line (optional)
13127 local BR # regexp for the rest (body)
13129 # lnet.stats should look as 11 space-separated non-negative numerics
13130 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
13131 create_lnet_proc_files "stats"
13132 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
13133 remove_lnet_proc_files "stats"
13135 # lnet.routes should look like this:
13136 # Routing disabled/enabled
13137 # net hops priority state router
13138 # where net is a string like tcp0, hops > 0, priority >= 0,
13139 # state is up/down,
13140 # router is a string like 192.168.1.1@tcp2
13141 L1="^Routing (disabled|enabled)$"
13142 L2="^net +hops +priority +state +router$"
13143 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
13144 create_lnet_proc_files "routes"
13145 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
13146 remove_lnet_proc_files "routes"
13148 # lnet.routers should look like this:
13149 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
13150 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
13151 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
13152 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
13153 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
13154 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
13155 create_lnet_proc_files "routers"
13156 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
13157 remove_lnet_proc_files "routers"
13159 # lnet.peers should look like this:
13160 # nid refs state last max rtr min tx min queue
13161 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
13162 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
13163 # numeric (0 or >0 or <0), queue >= 0.
13164 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
13165 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
13166 create_lnet_proc_files "peers"
13167 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
13168 remove_lnet_proc_files "peers"
13170 # lnet.buffers should look like this:
13171 # pages count credits min
13172 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
13173 L1="^pages +count +credits +min$"
13174 BR="^ +$N +$N +$I +$I$"
13175 create_lnet_proc_files "buffers"
13176 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
13177 remove_lnet_proc_files "buffers"
13179 # lnet.nis should look like this:
13180 # nid status alive refs peer rtr max tx min
13181 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
13182 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
13183 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
13184 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
13185 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
13186 create_lnet_proc_files "nis"
13187 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
13188 remove_lnet_proc_files "nis"
13190 # can we successfully write to lnet.stats?
13191 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
13192 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
13194 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
13196 test_216() { # bug 20317
13197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13198 remote_ost_nodsh && skip "remote OST with nodsh" && return
13201 local facets=$(get_facets OST)
13202 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13204 save_lustre_params client "osc.*.contention_seconds" > $p
13205 save_lustre_params $facets \
13206 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13207 save_lustre_params $facets \
13208 "ldlm.namespaces.filter-*.contended_locks" >> $p
13209 save_lustre_params $facets \
13210 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13211 clear_stats osc.*.osc_stats
13213 # agressive lockless i/o settings
13214 do_nodes $(comma_list $(osts_nodes)) \
13215 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13216 ldlm.namespaces.filter-*.contended_locks=0 \
13217 ldlm.namespaces.filter-*.contention_seconds=60"
13218 lctl set_param -n osc.*.contention_seconds=60
13220 $DIRECTIO write $DIR/$tfile 0 10 4096
13221 $CHECKSTAT -s 40960 $DIR/$tfile
13223 # disable lockless i/o
13224 do_nodes $(comma_list $(osts_nodes)) \
13225 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13226 ldlm.namespaces.filter-*.contended_locks=32 \
13227 ldlm.namespaces.filter-*.contention_seconds=0"
13228 lctl set_param -n osc.*.contention_seconds=0
13229 clear_stats osc.*.osc_stats
13231 dd if=/dev/zero of=$DIR/$tfile count=0
13232 $CHECKSTAT -s 0 $DIR/$tfile
13234 restore_lustre_params <$p
13238 run_test 216 "check lockless direct write updates file size and kms correctly"
13240 test_217() { # bug 22430
13241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13245 for node in $(nodes_list); do
13246 nid=$(host_nids_address $node $NETTYPE)
13247 if [[ $nid = *-* ]] ; then
13248 echo "lctl ping $(h2nettype $nid)"
13249 lctl ping $(h2nettype $nid)
13251 echo "skipping $node (no hyphen detected)"
13255 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13258 # do directio so as not to populate the page cache
13259 log "creating a 10 Mb file"
13260 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13261 log "starting reads"
13262 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13263 log "truncating the file"
13264 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13266 kill %+ || true # reads might have finished
13267 echo "wait until dd is finished"
13269 log "removing the temporary file"
13270 rm -rf $DIR/$tfile || error "tmp file removal failed"
13272 run_test 218 "parallel read and truncate should not deadlock ======================="
13275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13276 # write one partial page
13277 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13278 # set no grant so vvp_io_commit_write will do sync write
13279 $LCTL set_param fail_loc=0x411
13280 # write a full page at the end of file
13281 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13283 $LCTL set_param fail_loc=0
13284 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13285 $LCTL set_param fail_loc=0x411
13286 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13289 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13290 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13292 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13294 test_220() { #LU-325
13295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13296 remote_ost_nodsh && skip "remote OST with nodsh" && return
13297 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13298 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13301 # create on MDT0000 so the last_id and next_id are correct
13303 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13307 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13308 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13309 osc.$mdtosc_proc1.prealloc_last_id)
13310 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13311 osc.$mdtosc_proc1.prealloc_next_id)
13315 if ! combined_mgs_mds ; then
13319 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13320 #define OBD_FAIL_OST_ENOINO 0x229
13321 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13322 create_pool $FSNAME.$TESTNAME || return 1
13323 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13325 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13327 MDSOBJS=$((last_id - next_id))
13328 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13330 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13331 echo "OST still has $count kbytes free"
13333 echo "create $MDSOBJS files @next_id..."
13334 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13336 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13337 osc.$mdtosc_proc1.prealloc_last_id)
13338 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13339 osc.$mdtosc_proc1.prealloc_next_id)
13341 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13346 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13347 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13349 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
13350 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
13351 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
13352 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
13353 echo "unlink $MDSOBJS files @$next_id..."
13354 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
13356 if ! combined_mgs_mds ; then
13360 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13363 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13364 dd if=`which date` of=$MOUNT/date oflag=sync
13365 chmod +x $MOUNT/date
13367 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13368 $LCTL set_param fail_loc=0x80001401
13370 $MOUNT/date > /dev/null
13373 run_test 221 "make sure fault and truncate race to not cause OOM"
13376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13378 test_mkdir -p $DIR/$tdir
13379 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13380 createmany -o $DIR/$tdir/$tfile 10
13381 cancel_lru_locks mdc
13382 cancel_lru_locks osc
13383 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13384 $LCTL set_param fail_loc=0x31a
13385 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13386 $LCTL set_param fail_loc=0
13389 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
13392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13394 test_mkdir -p $DIR/$tdir
13395 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13396 createmany -o $DIR/$tdir/$tfile 10
13397 cancel_lru_locks mdc
13398 cancel_lru_locks osc
13399 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13400 $LCTL set_param fail_loc=0x31a
13401 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13402 $LCTL set_param fail_loc=0
13404 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
13407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13409 test_mkdir -p $DIR/$tdir
13410 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13411 createmany -o $DIR/$tdir/$tfile 10
13412 cancel_lru_locks mdc
13413 cancel_lru_locks osc
13414 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13415 $LCTL set_param fail_loc=0x31b
13416 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13417 $LCTL set_param fail_loc=0
13420 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13422 test_224a() { # LU-1039, MRP-303
13423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13424 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13425 $LCTL set_param fail_loc=0x508
13426 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13427 $LCTL set_param fail_loc=0
13430 run_test 224a "Don't panic on bulk IO failure"
13432 test_224b() { # LU-1039, MRP-303
13433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13434 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13435 cancel_lru_locks osc
13436 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13437 $LCTL set_param fail_loc=0x515
13438 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13439 $LCTL set_param fail_loc=0
13442 run_test 224b "Don't panic on bulk IO failure"
13444 test_224c() { # LU-6441
13445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13446 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13448 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13449 save_writethrough $p
13450 set_cache writethrough on
13452 local pages_per_rpc=$($LCTL get_param \
13453 osc.*.max_pages_per_rpc)
13454 local at_max=$($LCTL get_param -n at_max)
13455 local timeout=$($LCTL get_param -n timeout)
13456 local test_at="$LCTL get_param -n at_max"
13457 local param_at="$FSNAME.sys.at_max"
13458 local test_timeout="$LCTL get_param -n timeout"
13459 local param_timeout="$FSNAME.sys.timeout"
13461 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13463 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13464 error "conf_param at_max=0 failed"
13465 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13466 error "conf_param timeout=5 failed"
13468 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13469 do_facet ost1 $LCTL set_param fail_loc=0x520
13470 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13471 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13473 do_facet ost1 $LCTL set_param fail_loc=0
13475 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13476 error "conf_param at_max=$at_max failed"
13477 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13478 $timeout || error "conf_param timeout=$timeout failed"
13480 $LCTL set_param -n $pages_per_rpc
13481 restore_lustre_params < $p
13484 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13486 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13489 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13490 if [ -z ${MDSSURVEY} ]; then
13491 skip_env "mds-survey not found" && return
13494 [ $MDSCOUNT -ge 2 ] &&
13495 skip "skipping now for more than one MDT" && return
13497 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13498 { skip "Need MDS version at least 2.2.51"; return; }
13500 local mds=$(facet_host $SINGLEMDS)
13501 local target=$(do_nodes $mds 'lctl dl' | \
13502 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13504 local cmd1="file_count=1000 thrhi=4"
13505 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13506 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13507 local cmd="$cmd1 $cmd2 $cmd3"
13509 rm -f ${TMP}/mds_survey*
13511 eval $cmd || error "mds-survey with zero-stripe failed"
13512 cat ${TMP}/mds_survey*
13513 rm -f ${TMP}/mds_survey*
13515 run_test 225a "Metadata survey sanity with zero-stripe"
13518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13520 if [ -z ${MDSSURVEY} ]; then
13521 skip_env "mds-survey not found" && return
13523 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13524 { skip "Need MDS version at least 2.2.51"; return; }
13526 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13527 skip_env "Need to mount OST to test" && return
13530 local mds=$(facet_host $SINGLEMDS)
13531 local target=$(do_nodes $mds 'lctl dl' | \
13532 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13534 local cmd1="file_count=1000 thrhi=4"
13535 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13536 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13537 local cmd="$cmd1 $cmd2 $cmd3"
13539 rm -f ${TMP}/mds_survey*
13541 eval $cmd || error "mds-survey with stripe_count failed"
13542 cat ${TMP}/mds_survey*
13543 rm -f ${TMP}/mds_survey*
13545 run_test 225b "Metadata survey sanity with stripe_count = 1"
13547 mcreate_path2fid () {
13553 local path=$DIR/$tdir/$name
13558 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13559 error "cannot create $desc"
13561 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13563 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13565 fid_path=$($LFS fid2path $MOUNT $fid)
13567 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13569 [ "$path" == "$fid_path" ] ||
13570 error "fid2path returned $fid_path, expected $path"
13572 echo "pass with $path and $fid"
13577 mkdir -p $DIR/$tdir
13579 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13580 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13581 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13582 mcreate_path2fid 0040666 0 0 dir "directory"
13583 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13584 mcreate_path2fid 0100666 0 0 file "regular file"
13585 mcreate_path2fid 0120666 0 0 link "symbolic link"
13586 mcreate_path2fid 0140666 0 0 sock "socket"
13588 run_test 226a "call path2fid and fid2path on files of all type"
13591 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13595 mkdir -p $DIR/$tdir
13596 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13597 error "create remote directory failed"
13598 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13599 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13600 "character special file (null)"
13601 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13602 "character special file (no device)"
13603 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13604 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13605 "block special file (loop)"
13606 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13607 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13608 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13610 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13612 # LU-1299 Executing or running ldd on a truncated executable does not
13613 # cause an out-of-memory condition.
13615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13616 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13617 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13618 chmod +x $MOUNT/date
13620 $MOUNT/date > /dev/null
13621 ldd $MOUNT/date > /dev/null
13624 run_test 227 "running truncated executable does not cause OOM"
13626 # LU-1512 try to reuse idle OI blocks
13628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13629 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13630 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13631 skip "ldiskfs only test" && return
13633 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13634 local myDIR=$DIR/$tdir
13637 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13638 $LCTL set_param fail_loc=0x80001002
13639 createmany -o $myDIR/t- 10000
13640 $LCTL set_param fail_loc=0
13641 # The guard is current the largest FID holder
13643 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13645 local IDX=$(($SEQ % 64))
13647 do_facet $SINGLEMDS sync
13648 # Make sure journal flushed.
13650 local blk1=$(do_facet $SINGLEMDS \
13651 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13652 grep Blockcount | awk '{print $4}')
13654 # Remove old files, some OI blocks will become idle.
13655 unlinkmany $myDIR/t- 10000
13656 # Create new files, idle OI blocks should be reused.
13657 createmany -o $myDIR/t- 2000
13658 do_facet $SINGLEMDS sync
13659 # Make sure journal flushed.
13661 local blk2=$(do_facet $SINGLEMDS \
13662 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13663 grep Blockcount | awk '{print $4}')
13665 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13667 run_test 228a "try to reuse idle OI blocks"
13670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13671 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13672 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13673 skip "ldiskfs only test" && return
13675 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13676 local myDIR=$DIR/$tdir
13679 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13680 $LCTL set_param fail_loc=0x80001002
13681 createmany -o $myDIR/t- 10000
13682 $LCTL set_param fail_loc=0
13683 # The guard is current the largest FID holder
13685 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13687 local IDX=$(($SEQ % 64))
13689 do_facet $SINGLEMDS sync
13690 # Make sure journal flushed.
13692 local blk1=$(do_facet $SINGLEMDS \
13693 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13694 grep Blockcount | awk '{print $4}')
13696 # Remove old files, some OI blocks will become idle.
13697 unlinkmany $myDIR/t- 10000
13700 stop $SINGLEMDS || error "Fail to stop MDT."
13702 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13704 df $MOUNT || error "Fail to df."
13705 # Create new files, idle OI blocks should be reused.
13706 createmany -o $myDIR/t- 2000
13707 do_facet $SINGLEMDS sync
13708 # Make sure journal flushed.
13710 local blk2=$(do_facet $SINGLEMDS \
13711 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13712 grep Blockcount | awk '{print $4}')
13714 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13716 run_test 228b "idle OI blocks can be reused after MDT restart"
13720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13721 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13722 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13723 skip "ldiskfs only test" && return
13725 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13726 local myDIR=$DIR/$tdir
13729 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13730 $LCTL set_param fail_loc=0x80001002
13731 # 20000 files can guarantee there are index nodes in the OI file
13732 createmany -o $myDIR/t- 20000
13733 $LCTL set_param fail_loc=0
13734 # The guard is current the largest FID holder
13736 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13738 local IDX=$(($SEQ % 64))
13740 do_facet $SINGLEMDS sync
13741 # Make sure journal flushed.
13743 local blk1=$(do_facet $SINGLEMDS \
13744 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13745 grep Blockcount | awk '{print $4}')
13747 # Remove old files, some OI blocks will become idle.
13748 unlinkmany $myDIR/t- 20000
13750 # The OI file should become empty now
13752 # Create new files, idle OI blocks should be reused.
13753 createmany -o $myDIR/t- 2000
13754 do_facet $SINGLEMDS sync
13755 # Make sure journal flushed.
13757 local blk2=$(do_facet $SINGLEMDS \
13758 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13759 grep Blockcount | awk '{print $4}')
13761 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13763 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13765 test_229() { # LU-2482, LU-3448
13766 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13767 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13770 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13774 # Create a file with a released layout and stripe count 2.
13775 $MULTIOP $DIR/$tfile H2c ||
13776 error "failed to create file with released layout"
13778 $GETSTRIPE -v $DIR/$tfile
13780 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13781 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
13783 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13784 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13785 stat $DIR/$tfile || error "failed to stat released file"
13787 chown $RUNAS_ID $DIR/$tfile ||
13788 error "chown $RUNAS_ID $DIR/$tfile failed"
13790 chgrp $RUNAS_ID $DIR/$tfile ||
13791 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13793 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13794 rm $DIR/$tfile || error "failed to remove released file"
13796 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13800 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13803 test_mkdir $DIR/$tdir
13804 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13805 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13806 [ $mdt_idx -ne 0 ] &&
13807 error "create local directory on wrong MDT $mdt_idx"
13809 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13810 error "create remote directory failed"
13811 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13812 [ $mdt_idx -ne $MDTIDX ] &&
13813 error "create remote directory on wrong MDT $mdt_idx"
13815 createmany -o $DIR/$tdir/test_230/t- 10 ||
13816 error "create files on remote directory failed"
13817 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13818 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13819 rm -r $DIR/$tdir || error "unlink remote directory failed"
13821 run_test 230a "Create remote directory and files under the remote directory"
13824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13825 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13832 local migrate_dir=$DIR/$tdir/migrate_dir
13833 local other_dir=$DIR/$tdir/other_dir
13835 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
13836 skip "lustre < 2.11.56 does not support migrate -m "
13838 test_mkdir $DIR/$tdir
13839 test_mkdir -i0 -c1 $migrate_dir
13840 test_mkdir -i0 -c1 $other_dir
13841 for ((i=0; i<10; i++)); do
13842 mkdir -p $migrate_dir/dir_${i}
13843 createmany -o $migrate_dir/dir_${i}/f 10 ||
13844 error "create files under remote dir failed $i"
13847 cp /etc/passwd $migrate_dir/$tfile
13848 cp /etc/passwd $other_dir/$tfile
13849 chattr +SAD $migrate_dir
13850 chattr +SAD $migrate_dir/$tfile
13852 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13853 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13854 local old_dir_mode=$(stat -c%f $migrate_dir)
13855 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13857 mkdir -p $migrate_dir/dir_default_stripe2
13858 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13859 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13861 mkdir -p $other_dir
13862 ln $migrate_dir/$tfile $other_dir/luna
13863 ln $migrate_dir/$tfile $migrate_dir/sofia
13864 ln $other_dir/$tfile $migrate_dir/david
13865 ln -s $migrate_dir/$tfile $other_dir/zachary
13866 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13867 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13869 $LFS migrate -m $MDTIDX $migrate_dir ||
13870 error "fails on migrating remote dir to MDT1"
13872 echo "migratate to MDT1, then checking.."
13873 for ((i = 0; i < 10; i++)); do
13874 for file in $(find $migrate_dir/dir_${i}); do
13875 mdt_index=$($LFS getstripe -M $file)
13876 [ $mdt_index == $MDTIDX ] ||
13877 error "$file is not on MDT${MDTIDX}"
13881 # the multiple link file should still in MDT0
13882 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13883 [ $mdt_index == 0 ] ||
13884 error "$file is not on MDT${MDTIDX}"
13886 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13887 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13888 error " expect $old_dir_flag get $new_dir_flag"
13890 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13891 [ "$old_file_flag" = "$new_file_flag" ] ||
13892 error " expect $old_file_flag get $new_file_flag"
13894 local new_dir_mode=$(stat -c%f $migrate_dir)
13895 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13896 error "expect mode $old_dir_mode get $new_dir_mode"
13898 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13899 [ "$old_file_mode" = "$new_file_mode" ] ||
13900 error "expect mode $old_file_mode get $new_file_mode"
13902 diff /etc/passwd $migrate_dir/$tfile ||
13903 error "$tfile different after migration"
13905 diff /etc/passwd $other_dir/luna ||
13906 error "luna different after migration"
13908 diff /etc/passwd $migrate_dir/sofia ||
13909 error "sofia different after migration"
13911 diff /etc/passwd $migrate_dir/david ||
13912 error "david different after migration"
13914 diff /etc/passwd $other_dir/zachary ||
13915 error "zachary different after migration"
13917 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13918 error "${tfile}_ln different after migration"
13920 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13921 error "${tfile}_ln_other different after migration"
13923 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13924 [ $stripe_count = 2 ] ||
13925 error "dir strpe_count $d != 2 after migration."
13927 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13928 [ $stripe_count = 2 ] ||
13929 error "file strpe_count $d != 2 after migration."
13931 #migrate back to MDT0
13934 $LFS migrate -m $MDTIDX $migrate_dir ||
13935 error "fails on migrating remote dir to MDT0"
13937 echo "migrate back to MDT0, checking.."
13938 for file in $(find $migrate_dir); do
13939 mdt_index=$($LFS getstripe -M $file)
13940 [ $mdt_index == $MDTIDX ] ||
13941 error "$file is not on MDT${MDTIDX}"
13944 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13945 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13946 error " expect $old_dir_flag get $new_dir_flag"
13948 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13949 [ "$old_file_flag" = "$new_file_flag" ] ||
13950 error " expect $old_file_flag get $new_file_flag"
13952 local new_dir_mode=$(stat -c%f $migrate_dir)
13953 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13954 error "expect mode $old_dir_mode get $new_dir_mode"
13956 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13957 [ "$old_file_mode" = "$new_file_mode" ] ||
13958 error "expect mode $old_file_mode get $new_file_mode"
13960 diff /etc/passwd ${migrate_dir}/$tfile ||
13961 error "$tfile different after migration"
13963 diff /etc/passwd ${other_dir}/luna ||
13964 error "luna different after migration"
13966 diff /etc/passwd ${migrate_dir}/sofia ||
13967 error "sofia different after migration"
13969 diff /etc/passwd ${other_dir}/zachary ||
13970 error "zachary different after migration"
13972 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13973 error "${tfile}_ln different after migration"
13975 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13976 error "${tfile}_ln_other different after migration"
13978 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13979 [ $stripe_count = 2 ] ||
13980 error "dir strpe_count $d != 2 after migration."
13982 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13983 [ $stripe_count = 2 ] ||
13984 error "file strpe_count $d != 2 after migration."
13986 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13988 run_test 230b "migrate directory"
13991 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13992 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13993 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13997 local migrate_dir=$DIR/$tdir/migrate_dir
13999 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
14000 skip "lustre < 2.11.56 does not support migrate -m "
14002 #If migrating directory fails in the middle, all entries of
14003 #the directory is still accessiable.
14004 test_mkdir $DIR/$tdir
14005 test_mkdir -i0 -c1 $migrate_dir
14007 createmany -o $migrate_dir/f 10 ||
14008 error "create files under ${migrate_dir} failed"
14010 #failed after migrating 5 entries
14011 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
14012 do_facet mds1 lctl set_param fail_loc=0x20001801
14013 do_facet mds1 lctl set_param fail_val=5
14014 local t=$(ls $migrate_dir | wc -l)
14015 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
14016 error "migrate should fail after 5 entries"
14018 mkdir $migrate_dir/dir &&
14019 error "mkdir succeeds under migrating directory"
14020 touch $migrate_dir/file &&
14021 error "touch file succeeds under migrating directory"
14023 local u=$(ls $migrate_dir | wc -l)
14024 [ "$u" == "$t" ] || error "$u != $t during migration"
14026 for file in $(find $migrate_dir); do
14027 stat $file || error "stat $file failed"
14030 do_facet mds1 lctl set_param fail_loc=0
14031 do_facet mds1 lctl set_param fail_val=0
14033 $LFS migrate -m $MDTIDX $migrate_dir ||
14034 error "migrate open files should failed with open files"
14036 echo "Finish migration, then checking.."
14037 for file in $(find $migrate_dir); do
14038 mdt_index=$($LFS getstripe -M $file)
14039 [ $mdt_index == $MDTIDX ] ||
14040 error "$file is not on MDT${MDTIDX}"
14043 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14045 run_test 230c "check directory accessiblity if migration is failed"
14048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14049 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14052 local migrate_dir=$DIR/$tdir/migrate_dir
14056 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
14057 skip "lustre < 2.11.56 does not support migrate -m "
14059 test_mkdir $DIR/$tdir
14060 test_mkdir -i0 -c1 $migrate_dir
14062 for ((i=0; i<100; i++)); do
14063 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
14064 createmany -o $migrate_dir/dir_${i}/f 100 ||
14065 error "create files under remote dir failed $i"
14068 $LFS migrate -m $MDTIDX $migrate_dir ||
14069 error "migrate remote dir error"
14071 echo "Finish migration, then checking.."
14072 for file in $(find $migrate_dir); do
14073 mdt_index=$($LFS getstripe -M $file)
14074 [ $mdt_index == $MDTIDX ] ||
14075 error "$file is not on MDT${MDTIDX}"
14078 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14080 run_test 230d "check migrate big directory"
14083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14085 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
14086 skip "lustre < 2.11.56 does not support migrate -m "
14093 mkdir -p $DIR/$tdir
14094 mkdir $DIR/$tdir/migrate_dir
14095 mkdir $DIR/$tdir/other_dir
14096 touch $DIR/$tdir/migrate_dir/a
14097 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
14098 ls $DIR/$tdir/other_dir
14100 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14101 error "migrate dir fails"
14103 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14104 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14106 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14107 [ $mdt_index == 0 ] || error "a is not on MDT0"
14109 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
14110 error "migrate dir fails"
14112 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
14113 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
14115 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14116 [ $mdt_index == 1 ] || error "a is not on MDT1"
14118 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
14119 [ $mdt_index == 1 ] || error "b is not on MDT1"
14121 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14122 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
14124 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
14126 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14128 run_test 230e "migrate mulitple local link files"
14131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14132 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14136 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
14137 skip "lustre < 2.11.56 does not support migrate -m "
14139 mkdir -p $DIR/$tdir
14140 mkdir $DIR/$tdir/migrate_dir
14141 $LFS mkdir -i1 $DIR/$tdir/other_dir
14142 touch $DIR/$tdir/migrate_dir/a
14143 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
14144 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
14145 ls $DIR/$tdir/other_dir
14147 # a should be migrated to MDT1, since no other links on MDT0
14148 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14149 error "#1 migrate dir fails"
14150 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14151 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14152 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14153 [ $mdt_index == 1 ] || error "a is not on MDT1"
14155 # a should stay on MDT1, because it is a mulitple link file
14156 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14157 error "#2 migrate dir fails"
14158 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14159 [ $mdt_index == 1 ] || error "a is not on MDT1"
14161 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14162 error "#3 migrate dir fails"
14164 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14165 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
14166 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
14168 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
14169 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
14171 # a should be migrated to MDT0, since no other links on MDT1
14172 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14173 error "#4 migrate dir fails"
14174 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14175 [ $mdt_index == 0 ] || error "a is not on MDT0"
14177 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14179 run_test 230f "migrate mulitple remote link files"
14182 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14183 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14185 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
14186 skip "lustre < 2.11.56 does not support migrate -m "
14188 mkdir -p $DIR/$tdir/migrate_dir
14190 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
14191 error "migrating dir to non-exist MDT succeeds"
14194 run_test 230g "migrate dir to non-exist MDT"
14197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14198 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14199 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
14200 skip "lustre < 2.11.56 does not support migrate -m "
14204 mkdir -p $DIR/$tdir/migrate_dir
14206 $LFS migrate -m1 $DIR &&
14207 error "migrating mountpoint1 should fail"
14209 $LFS migrate -m1 $DIR/$tdir/.. &&
14210 error "migrating mountpoint2 should fail"
14212 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
14213 error "migrating $tdir fail"
14215 mdt_index=$($LFS getstripe -M $DIR/$tdir)
14216 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14218 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14219 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14222 run_test 230h "migrate .. and root"
14225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14226 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14228 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
14229 skip "lustre < 2.11.56 does not support migrate -m "
14231 mkdir -p $DIR/$tdir/migrate_dir
14233 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
14234 error "migration fails with a tailing slash"
14236 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14237 error "migration fails with two tailing slashes"
14239 run_test 230i "lfs migrate -m tolerates trailing slashes"
14243 # For simplicity this test assumes that max_pages_per_rpc
14244 # is the same across all OSCs
14245 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14246 local bulk_size=$((max_pages * 4096))
14247 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14250 mkdir -p $DIR/$tdir
14251 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14252 error "failed to set stripe with -S ${brw_size}M option"
14254 # clear the OSC stats
14255 $LCTL set_param osc.*.stats=0 &>/dev/null
14258 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14259 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14260 oflag=direct &>/dev/null || error "dd failed"
14262 sync; sleep 1; sync # just to be safe
14263 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14264 if [ x$nrpcs != "x1" ]; then
14265 $LCTL get_param osc.*.stats
14266 error "found $nrpcs ost_write RPCs, not 1 as expected"
14270 # Drop the OSC cache, otherwise we will read from it
14271 cancel_lru_locks osc
14273 # clear the OSC stats
14274 $LCTL set_param osc.*.stats=0 &>/dev/null
14276 # Client reads $bulk_size.
14277 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14278 iflag=direct &>/dev/null || error "dd failed"
14280 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14281 if [ x$nrpcs != "x1" ]; then
14282 $LCTL get_param osc.*.stats
14283 error "found $nrpcs ost_read RPCs, not 1 as expected"
14286 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14289 mkdir -p $DIR/$tdir
14291 for i in {0..1023}; do
14292 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14293 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14294 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14298 run_test 231b "must not assert on fully utilized OST request buffer"
14301 mkdir -p $DIR/$tdir
14302 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14303 $LCTL set_param fail_loc=0x31c
14305 # ignore dd failure
14306 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
14308 $LCTL set_param fail_loc=0
14309 umount_client $MOUNT || error "umount failed"
14310 mount_client $MOUNT || error "mount failed"
14312 run_test 232 "failed lock should not block umount"
14315 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14316 { skip "Need MDS version at least 2.3.64"; return; }
14317 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14319 local fid=$($LFS path2fid $MOUNT)
14320 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14321 error "cannot access $MOUNT using its FID '$fid'"
14323 run_test 233a "checking that OBF of the FS root succeeds"
14326 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14327 { skip "Need MDS version at least 2.5.90"; return; }
14328 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14330 local fid=$($LFS path2fid $MOUNT/.lustre)
14331 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14332 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14334 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14335 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14336 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14338 run_test 233b "checking that OBF of the FS .lustre succeeds"
14341 local p="$TMP/sanityN-$TESTNAME.parameters"
14342 save_lustre_params client "llite.*.xattr_cache" > $p
14343 lctl set_param llite.*.xattr_cache 1 ||
14344 { skip "xattr cache is not supported"; return 0; }
14346 mkdir -p $DIR/$tdir || error "mkdir failed"
14347 touch $DIR/$tdir/$tfile || error "touch failed"
14348 # OBD_FAIL_LLITE_XATTR_ENOMEM
14349 $LCTL set_param fail_loc=0x1405
14350 # output of the form: attr 2 4 44 3 fc13 x86_64
14351 V=($(IFS=".-" rpm -q attr))
14352 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
14353 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
14354 # attr pre-2.4.44-7 had a bug with rc
14355 # LU-3703 - SLES 11 and FC13 clients have older attr
14356 getfattr -n user.attr $DIR/$tdir/$tfile &&
14357 error "getfattr should have failed with ENOMEM"
14359 skip "LU-3703: attr version $(getfattr --version) too old"
14361 $LCTL set_param fail_loc=0x0
14364 restore_lustre_params < $p
14367 run_test 234 "xattr cache should not crash on ENOMEM"
14370 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14371 skip "Need MDS version at least 2.4.52" && return
14372 flock_deadlock $DIR/$tfile
14377 124) error "process hangs on a deadlock"
14379 *) error "error executing flock_deadlock $DIR/$tfile"
14383 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14387 check_swap_layouts_support && return 0
14388 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
14390 local ref1=/etc/passwd
14391 local ref2=/etc/group
14392 local file1=$DIR/$tdir/f1
14393 local file2=$DIR/$tdir/f2
14395 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14396 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14397 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14398 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14399 local fd=$(free_fd)
14400 local cmd="exec $fd<>$file2"
14403 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14404 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14407 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14412 run_test 236 "Layout swap on open unlinked file"
14414 # test to verify file handle related system calls
14415 # (name_to_handle_at/open_by_handle_at)
14416 # The new system calls are supported in glibc >= 2.14.
14419 echo "Test file_handle syscalls" > $DIR/$tfile ||
14420 error "write failed"
14421 check_fhandle_syscalls $DIR/$tfile ||
14422 error "check_fhandle_syscalls failed"
14424 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14426 # LU-4659 linkea consistency
14428 local server_version=$(lustre_version_code $SINGLEMDS)
14430 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14431 [[ $server_version -gt $(version_code 2.5.1) &&
14432 $server_version -lt $(version_code 2.5.50) ]] ||
14433 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14436 ln $DIR/$tfile $DIR/$tfile.lnk
14437 touch $DIR/$tfile.new
14438 mv $DIR/$tfile.new $DIR/$tfile
14439 local fid1=$($LFS path2fid $DIR/$tfile)
14440 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14441 local path1=$($LFS fid2path $FSNAME "$fid1")
14442 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14443 local path2=$($LFS fid2path $FSNAME "$fid2")
14444 [ $tfile.lnk == $path2 ] ||
14445 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14448 run_test 238 "Verify linkea consistency"
14451 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14452 skip "Need MDS version at least 2.5.60" && return
14453 local list=$(comma_list $(mdts_nodes))
14455 mkdir -p $DIR/$tdir
14456 createmany -o $DIR/$tdir/f- 5000
14457 unlinkmany $DIR/$tdir/f- 5000
14458 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.1) ] &&
14459 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14460 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14461 osp.*MDT*.sync_in_flight" | calc_sum)
14462 [ "$changes" -eq 0 ] || error "$changes not synced"
14464 run_test 239 "osp_sync test"
14466 test_239a() { #LU-5297
14467 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14469 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14470 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14471 chgrp $RUNAS_GID $DIR/$tfile
14472 wait_delete_completed
14474 run_test 239a "process invalid osp sync record correctly"
14476 test_239b() { #LU-5297
14477 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14479 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14480 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14481 chgrp $RUNAS_GID $DIR/$tfile1
14482 wait_delete_completed
14483 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14485 chgrp $RUNAS_GID $DIR/$tfile2
14486 wait_delete_completed
14488 run_test 239b "process osp sync record with ENOMEM error correctly"
14491 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14492 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14494 mkdir -p $DIR/$tdir
14496 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14497 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14498 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14499 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14501 umount_client $MOUNT || error "umount failed"
14502 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14503 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14504 mount_client $MOUNT || error "failed to mount client"
14506 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14507 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14509 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14512 for LOOP in $(seq $1); do
14513 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14514 cancel_lru_locks osc || true
14519 for LOOP in $(seq $1); do
14520 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14521 iflag=direct 2>/dev/null
14525 test_241a() { # was test_241
14526 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14528 cancel_lru_locks osc
14529 test_241_bio 1000 &
14534 run_test 241a "bio vs dio"
14537 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14539 test_241_dio 1000 &
14544 run_test 241b "dio vs dio"
14547 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14548 mkdir -p $DIR/$tdir
14549 touch $DIR/$tdir/$tfile
14551 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14552 do_facet mds1 lctl set_param fail_loc=0x105
14553 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14555 do_facet mds1 lctl set_param fail_loc=0
14556 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14558 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14562 test_mkdir -p $DIR/$tdir
14563 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14565 run_test 243 "various group lock tests"
14569 test_mkdir -p $DIR/$tdir
14570 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14571 sendfile_grouplock $DIR/$tdir/$tfile || \
14572 error "sendfile+grouplock failed"
14575 run_test 244 "sendfile with group lock tests"
14578 local flagname="multi_mod_rpcs"
14579 local connect_data_name="max_mod_rpcs"
14582 # check if multiple modify RPCs flag is set
14583 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14584 grep "connect_flags:")
14587 echo "$out" | grep -qw $flagname
14588 if [ $? -ne 0 ]; then
14589 echo "connect flag $flagname is not set"
14593 # check if multiple modify RPCs data is set
14594 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14597 echo "$out" | grep -qw $connect_data_name ||
14598 error "import should have connect data $connect_data_name"
14600 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14602 test_246() { # LU-7371
14603 remote_ost_nodsh && skip "remote OST with nodsh" && return
14604 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14605 skip "Need OST version >= 2.7.62" && return 0
14606 do_facet ost1 $LCTL set_param fail_val=4095
14607 #define OBD_FAIL_OST_READ_SIZE 0x234
14608 do_facet ost1 $LCTL set_param fail_loc=0x234
14609 $LFS setstripe $DIR/$tfile -i 0 -c 1
14610 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14611 cancel_lru_locks $FSNAME-OST0000
14612 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14614 run_test 246 "Read file of size 4095 should return right length"
14617 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14619 { skip "Fileset feature is not supported"; return; }
14621 local submount=${MOUNT}_$tdir
14624 mkdir -p $submount || error "mkdir $submount failed"
14625 FILESET="$FILESET/$tdir" mount_client $submount ||
14626 error "mount $submount failed"
14627 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14628 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14629 error "read $MOUNT/$tdir/$tfile failed"
14630 umount_client $submount || error "umount $submount failed"
14633 run_test 247a "mount subdir as fileset"
14636 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14637 { skip "Fileset feature is not supported"; return; }
14639 local submount=${MOUNT}_$tdir
14641 rm -rf $MOUNT/$tdir
14642 mkdir -p $submount || error "mkdir $submount failed"
14644 FILESET="$FILESET/$tdir" mount_client $submount &&
14645 error "mount $submount should fail"
14648 run_test 247b "mount subdir that dose not exist"
14651 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14652 { skip "Fileset feature is not supported"; return; }
14654 local submount=${MOUNT}_$tdir
14656 mkdir -p $MOUNT/$tdir/dir1
14657 mkdir -p $submount || error "mkdir $submount failed"
14658 FILESET="$FILESET/$tdir" mount_client $submount ||
14659 error "mount $submount failed"
14660 local fid=$($LFS path2fid $MOUNT/)
14661 $LFS fid2path $submount $fid && error "fid2path should fail"
14662 umount_client $submount || error "umount $submount failed"
14665 run_test 247c "running fid2path outside root"
14668 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14669 { skip "Fileset feature is not supported"; return; }
14671 local submount=${MOUNT}_$tdir
14673 mkdir -p $MOUNT/$tdir/dir1
14674 mkdir -p $submount || error "mkdir $submount failed"
14675 FILESET="$FILESET/$tdir" mount_client $submount ||
14676 error "mount $submount failed"
14677 local fid=$($LFS path2fid $submount/dir1)
14678 $LFS fid2path $submount $fid || error "fid2path should succeed"
14679 umount_client $submount || error "umount $submount failed"
14682 run_test 247d "running fid2path inside root"
14686 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14688 { skip "Fileset feature is not supported"; return; }
14690 local submount=${MOUNT}_$tdir
14693 mkdir -p $submount || error "mkdir $submount failed"
14694 FILESET="$FILESET/.." mount_client $submount &&
14695 error "mount $submount should fail"
14698 run_test 247e "mount .. as fileset"
14701 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14702 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14704 # create a large file for fast read verification
14705 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14707 # make sure the file is created correctly
14708 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14709 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14711 echo "Test 1: verify that fast read is 4 times faster on cache read"
14713 # small read with fast read enabled
14714 $LCTL set_param -n llite.*.fast_read=1
14715 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14716 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14717 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14718 # small read with fast read disabled
14719 $LCTL set_param -n llite.*.fast_read=0
14720 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14721 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14722 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14724 # verify that fast read is 4 times faster for cache read
14725 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14726 error_not_in_vm "fast read was not 4 times faster: " \
14727 "$t_fast vs $t_slow"
14729 echo "Test 2: verify the performance between big and small read"
14730 $LCTL set_param -n llite.*.fast_read=1
14732 # 1k non-cache read
14733 cancel_lru_locks osc
14734 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14735 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14736 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14738 # 1M non-cache read
14739 cancel_lru_locks osc
14740 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14741 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14742 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14744 # verify that big IO is not 4 times faster than small IO
14745 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14746 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14748 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14751 run_test 248 "fast read verification"
14753 test_249() { # LU-7890
14755 $SETSTRIPE -c 1 $DIR/$tfile
14757 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14758 skip "Need at least version 2.8.54"
14760 # Offset 2T == 4k * 512M
14761 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14762 error "dd to 2T offset failed"
14764 run_test 249 "Write above 2T file size"
14767 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14768 && skip "no 16TB file size limit on ZFS" && return
14770 $SETSTRIPE -c 1 $DIR/$tfile
14771 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14772 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14773 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14774 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14775 conv=notrunc,fsync && error "append succeeded"
14778 run_test 250 "Write above 16T limit"
14781 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14783 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14784 #Skip once - writing the first stripe will succeed
14785 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14786 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14787 error "short write happened"
14789 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14790 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14791 error "short read happened"
14795 run_test 251 "Handling short read and write correctly"
14805 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14806 remote_ost_nodsh && skip "remote OST with nodsh" && return
14807 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14808 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14809 skip "ldiskfs only test"
14813 # check lr_reader on OST0000
14815 dev=$(facet_device $tgt)
14816 out=$(do_facet $tgt $LR_READER $dev)
14817 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14819 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14820 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14821 error "Invalid uuid returned by $LR_READER on target $tgt"
14822 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14824 # check lr_reader -c on MDT0000
14826 dev=$(facet_device $tgt)
14827 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14828 echo "$LR_READER does not support additional options"
14831 out=$(do_facet $tgt $LR_READER -c $dev)
14832 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14834 num=$(echo "$out" | grep -c "mdtlov")
14835 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14836 error "Invalid number of mdtlov clients returned by $LR_READER"
14837 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14839 # check lr_reader -cr on MDT0000
14840 out=$(do_facet $tgt $LR_READER -cr $dev)
14841 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14843 echo "$out" | grep -q "^reply_data:$" ||
14844 error "$LR_READER should have returned 'reply_data' section"
14845 num=$(echo "$out" | grep -c "client_generation")
14846 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14848 run_test 252 "check lr_reader tool"
14850 test_253_fill_ost() {
14851 local size_mb #how many MB should we write to pass watermark
14852 local lwm=$3 #low watermark
14853 local free_10mb #10% of free space
14855 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14856 size_mb=$((free_kb / 1024 - lwm))
14857 free_10mb=$((free_kb / 10240))
14858 #If 10% of free space cross low watermark use it
14859 if (( free_10mb > size_mb )); then
14862 #At least we need to store 1.1 of difference between
14863 #free space and low watermark
14864 size_mb=$((size_mb + size_mb / 10))
14866 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14867 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14868 oflag=append conv=notrunc
14873 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14874 echo "OST still has $((free_kb / 1024)) mbytes free"
14881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14882 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14883 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14885 local ost_name=$($LFS osts |
14886 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14888 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14889 do_facet $SINGLEMDS $LCTL get_param -n \
14890 osp.$mdtosc_proc1.reserved_mb_high ||
14891 { skip "remote MDS does not support reserved_mb_high" &&
14896 wait_delete_completed
14899 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14900 osp.$mdtosc_proc1.reserved_mb_high)
14901 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14902 osp.$mdtosc_proc1.reserved_mb_low)
14903 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14905 if ! combined_mgs_mds ; then
14908 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14909 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14910 error "Adding $ost_name to pool failed"
14912 # Wait for client to see a OST at pool
14913 wait_update $HOSTNAME "$LCTL get_param -n
14914 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14915 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14916 error "Client can not see the pool"
14917 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14918 error "Setstripe failed"
14920 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14921 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14922 echo "OST still has $((blocks/1024)) mbytes free"
14924 local new_lwm=$((blocks/1024-10))
14925 do_facet $SINGLEMDS $LCTL set_param \
14926 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14927 do_facet $SINGLEMDS $LCTL set_param \
14928 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14930 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14932 #First enospc could execute orphan deletion so repeat.
14933 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14935 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14936 osp.$mdtosc_proc1.prealloc_status)
14937 echo "prealloc_status $oa_status"
14939 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14940 error "File creation should fail"
14941 #object allocation was stopped, but we still able to append files
14942 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14943 error "Append failed"
14944 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14946 wait_delete_completed
14950 for i in $(seq 10 12); do
14951 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14952 error "File creation failed after rm";
14955 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14956 osp.$mdtosc_proc1.prealloc_status)
14957 echo "prealloc_status $oa_status"
14959 if (( oa_status != 0 )); then
14960 error "Object allocation still disable after rm"
14962 do_facet $SINGLEMDS $LCTL set_param \
14963 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14964 do_facet $SINGLEMDS $LCTL set_param \
14965 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14968 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14969 error "Remove $ost_name from pool failed"
14970 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14971 error "Pool destroy fialed"
14973 if ! combined_mgs_mds ; then
14977 run_test 253 "Check object allocation limit"
14982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14983 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14984 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14985 { skip "MDS does not support changelog_size" && return; }
14987 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14988 echo "Registered as changelog user $cl_user"
14990 $LFS changelog_clear $MDT0 $cl_user 0
14992 local size1=$(do_facet mds1 \
14993 $LCTL get_param -n mdd.$MDT0.changelog_size)
14994 echo "Changelog size $size1"
14997 $LFS mkdir -i 0 $DIR/$tdir
14999 mkdir -p $DIR/$tdir/pics/2008/zachy
15000 touch $DIR/$tdir/pics/2008/zachy/timestamp
15001 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
15002 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15003 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15004 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15005 rm $DIR/$tdir/pics/desktop.jpg
15007 local size2=$(do_facet mds1 \
15008 $LCTL get_param -n mdd.$MDT0.changelog_size)
15009 echo "Changelog size after work $size2"
15011 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15013 if (( size2 <= size1 )); then
15014 error "Changelog size after work should be greater than original"
15018 run_test 254 "Check changelog size"
15025 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
15026 awk -F: '{print $2}' | grep $type > /dev/null
15027 if [ $? -ne 0 ]; then
15037 lfs ladvise -a willread $file > /dev/null 2>&1
15038 if [ $? -eq 0 ]; then
15042 lfs ladvise -a willread $file 2>&1 |
15043 grep "Inappropriate ioctl for device" > /dev/null
15044 if [ $? -eq 0 ]; then
15051 bc <<<"scale=2; ($1 - $2) * 100 / $2"
15054 # run a random read IO workload
15055 # usage: random_read_iops <filename> <filesize> <iosize>
15056 random_read_iops() {
15059 local iosize=${3:-4096}
15061 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
15062 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
15065 drop_file_oss_cache() {
15069 $LFS ladvise -a dontneed $file 2>/dev/null ||
15070 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
15073 ladvise_willread_performance()
15076 local average_origin=0
15077 local average_cache=0
15078 local average_ladvise=0
15080 for ((i = 1; i <= $repeat; i++)); do
15081 echo "Iter $i/$repeat: reading without willread hint"
15082 cancel_lru_locks osc
15083 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15084 local speed_origin=$(random_read_iops $DIR/$tfile $size)
15085 echo "Iter $i/$repeat: uncached speed: $speed_origin"
15086 average_origin=$(bc <<<"$average_origin + $speed_origin")
15088 cancel_lru_locks osc
15089 local speed_cache=$(random_read_iops $DIR/$tfile $size)
15090 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
15091 average_cache=$(bc <<<"$average_cache + $speed_cache")
15093 cancel_lru_locks osc
15094 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15095 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
15096 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
15097 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
15098 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
15100 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
15101 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
15102 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
15104 speedup_cache=$(percent $average_cache $average_origin)
15105 speedup_ladvise=$(percent $average_ladvise $average_origin)
15107 echo "Average uncached read: $average_origin"
15108 echo "Average speedup with OSS cached read: " \
15109 "$average_cache = +$speedup_cache%"
15110 echo "Average speedup with ladvise willread: " \
15111 "$average_ladvise = +$speedup_ladvise%"
15113 local lowest_speedup=20
15114 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
15115 echo "Speedup with OSS cached read less than $lowest_speedup%, " \
15116 "got $average_cache%. Skipping ladvise willread check."
15120 # the test won't work on ZFS until it supports 'ladvise dontneed', but
15121 # it is still good to run until then to exercise 'ladvise willread'
15122 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15123 [ "$(facet_fstype ost1)" = "zfs" ] &&
15124 echo "osd-zfs does not support dontneed or drop_caches" &&
15127 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
15128 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
15129 error_not_in_vm "Speedup with willread is less than " \
15130 "$lowest_speedup%, got $average_ladvise%"
15134 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15135 skip "lustre < 2.8.54 does not support ladvise " && return
15136 remote_ost_nodsh && skip "remote OST with nodsh" && return
15138 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
15140 ladvise_no_type willread $DIR/$tfile &&
15141 skip "willread ladvise is not supported" && return
15143 ladvise_no_ioctl $DIR/$tfile &&
15144 skip "ladvise ioctl is not supported" && return
15147 local size=$((size_mb * 1048576))
15148 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15149 error "dd to $DIR/$tfile failed"
15151 lfs ladvise -a willread $DIR/$tfile ||
15152 error "Ladvise failed with no range argument"
15154 lfs ladvise -a willread -s 0 $DIR/$tfile ||
15155 error "Ladvise failed with no -l or -e argument"
15157 lfs ladvise -a willread -e 1 $DIR/$tfile ||
15158 error "Ladvise failed with only -e argument"
15160 lfs ladvise -a willread -l 1 $DIR/$tfile ||
15161 error "Ladvise failed with only -l argument"
15163 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
15164 error "End offset should not be smaller than start offset"
15166 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
15167 error "End offset should not be equal to start offset"
15169 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
15170 error "Ladvise failed with overflowing -s argument"
15172 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
15173 error "Ladvise failed with overflowing -e argument"
15175 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
15176 error "Ladvise failed with overflowing -l argument"
15178 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
15179 error "Ladvise succeeded with conflicting -l and -e arguments"
15181 echo "Synchronous ladvise should wait"
15183 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
15184 do_nodes $(comma_list $(osts_nodes)) \
15185 $LCTL set_param fail_val=$delay fail_loc=0x237
15187 local start_ts=$SECONDS
15188 lfs ladvise -a willread $DIR/$tfile ||
15189 error "Ladvise failed with no range argument"
15190 local end_ts=$SECONDS
15191 local inteval_ts=$((end_ts - start_ts))
15193 if [ $inteval_ts -lt $(($delay - 1)) ]; then
15194 error "Synchronous advice didn't wait reply"
15197 echo "Asynchronous ladvise shouldn't wait"
15198 local start_ts=$SECONDS
15199 lfs ladvise -a willread -b $DIR/$tfile ||
15200 error "Ladvise failed with no range argument"
15201 local end_ts=$SECONDS
15202 local inteval_ts=$((end_ts - start_ts))
15204 if [ $inteval_ts -gt $(($delay / 2)) ]; then
15205 error "Asynchronous advice blocked"
15208 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
15209 ladvise_willread_performance
15211 run_test 255a "check 'lfs ladvise -a willread'"
15217 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
15221 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15222 skip "lustre < 2.8.54 does not support ladvise " && return
15223 remote_ost_nodsh && skip "remote OST with nodsh" && return
15225 lfs setstripe -c 1 -i 0 $DIR/$tfile
15227 ladvise_no_type dontneed $DIR/$tfile &&
15228 skip "dontneed ladvise is not supported" && return
15230 ladvise_no_ioctl $DIR/$tfile &&
15231 skip "ladvise ioctl is not supported" && return
15233 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15234 skip "lustre < 2.8.54 does not support ladvise" && return
15236 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15237 [ "$(facet_fstype ost1)" = "zfs" ] &&
15238 skip "zfs-osd does not support 'ladvise dontneed'" && return
15241 local size=$((size_mb * 1048576))
15242 # In order to prevent disturbance of other processes, only check 3/4
15243 # of the memory usage
15244 local kibibytes=$((size_mb * 1024 * 3 / 4))
15246 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15247 error "dd to $DIR/$tfile failed"
15249 local total=$(facet_meminfo ost1 MemTotal)
15250 echo "Total memory: $total KiB"
15252 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15253 local before_read=$(facet_meminfo ost1 Cached)
15254 echo "Cache used before read: $before_read KiB"
15256 lfs ladvise -a willread $DIR/$tfile ||
15257 error "Ladvise willread failed"
15258 local after_read=$(facet_meminfo ost1 Cached)
15259 echo "Cache used after read: $after_read KiB"
15261 lfs ladvise -a dontneed $DIR/$tfile ||
15262 error "Ladvise dontneed again failed"
15263 local no_read=$(facet_meminfo ost1 Cached)
15264 echo "Cache used after dontneed ladvise: $no_read KiB"
15266 if [ $total -lt $((before_read + kibibytes)) ]; then
15267 echo "Memory is too small, abort checking"
15271 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15272 error "Ladvise willread should use more memory" \
15273 "than $kibibytes KiB"
15276 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15277 error "Ladvise dontneed should release more memory" \
15278 "than $kibibytes KiB"
15281 run_test 255b "check 'lfs ladvise -a dontneed'"
15288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15289 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15290 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
15291 skip "ldiskfs only test" && return
15293 mdt_dev=$(mdsdevname 1)
15295 cl_user=$(do_facet mds1 \
15296 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
15297 if [[ -n $cl_user ]]; then
15298 skip "active changelog user"
15302 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15303 echo "Registered as changelog user $cl_user"
15306 mkdir -p $DIR/$tdir
15308 $LFS changelog_clear $MDT0 $cl_user 0
15311 touch $DIR/$tdir/{1..10}
15314 stop mds1 || error "Fail to stop MDT."
15317 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
15319 #after mount new plainllog is used
15320 touch $DIR/$tdir/{11..19}
15321 local TEMP256FILE=$(mktemp TEMP256XXXXXX)
15322 cat_sl=$(do_facet mds1 \
15323 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15324 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15327 if (( cat_sl != 2 )); then
15328 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15329 error "Changelog catalog has wrong number of slots $cat_sl"
15332 $LFS changelog_clear $MDT0 $cl_user 0
15334 TEMP256FILE=$(mktemp TEMP256XXXXXX)
15335 cat_sl=$(do_facet mds1 \
15336 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15337 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15340 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15342 if (( cat_sl == 2 )); then
15343 error "Empty plain llog was not deleted from changelog catalog"
15345 if (( cat_sl != 1 )); then
15346 error "Active plain llog shouldn\`t be deleted from catalog"
15349 run_test 256 "Check llog delete for empty and not full state"
15352 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15353 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15354 skip "Need MDS version at least 2.8.55" && return
15356 test_mkdir -p $DIR/$tdir
15358 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15359 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15362 #define OBD_FAIL_MDS_XATTR_REP 0x161
15363 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15364 local facet=mds$((mdtidx + 1))
15365 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15366 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15368 stop $facet || error "stop MDS failed"
15369 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15370 error "start MDS fail"
15372 run_test 257 "xattr locks are not lost"
15374 # Verify we take the i_mutex when security requires it
15376 #define OBD_FAIL_IMUTEX_SEC 0x141c
15377 $LCTL set_param fail_loc=0x141c
15379 chmod u+s $DIR/$tfile
15380 chmod a+rwx $DIR/$tfile
15381 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15383 if [ $RC -ne 0 ]; then
15384 error "error, failed to take i_mutex, rc=$?"
15390 # Verify we do NOT take the i_mutex in the normal case
15392 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15393 $LCTL set_param fail_loc=0x141d
15396 chmod a+rw $DIR/$tfile
15397 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15399 if [ $RC -ne 0 ]; then
15400 error "error, took i_mutex unnecessarily, rc=$?"
15405 run_test 258b "verify i_mutex security behavior"
15408 #define OBD_FAIL_MDC_CLOSE 0x806
15409 $LCTL set_param fail_loc=0x80000806
15413 run_test 260 "Check mdc_close fail"
15416 remote_ost_nodsh && skip "remote OST with nodsh" && return
15417 [ $(lustre_version_code ost1) -lt $(version_code 2.10.1) ] &&
15418 skip "Need OST version >= 2.10.1" && return 0
15420 local file=$DIR/$tfile
15423 oss=$(comma_list $(osts_nodes))
15425 dd if=/dev/urandom of=$file bs=1M count=2 ||
15426 error "failed to create a file"
15427 cancel_lru_locks osc
15430 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
15431 error "failed to read a file"
15433 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
15434 $LCTL set_param fail_loc=0x8000031f
15436 cancel_lru_locks osc &
15439 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
15440 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
15441 #IO takes another lock, but matches the PENDING one
15442 #and places it to the IO RPC
15443 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
15444 error "failed to read a file with PENDING lock"
15446 run_test 275 "Read on a canceled duplicate lock"
15449 remote_ost_nodsh && skip "remote OST with nodsh" && return
15452 do_facet ost1 "(while true; do \
15453 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
15454 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
15457 for LOOP in $(seq 20); do
15459 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
15462 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
15463 rm $TMP/sanity_276_pid"
15465 run_test 276 "Race between mount and obd_statfs"
15467 cleanup_test_300() {
15471 test_striped_dir() {
15476 mkdir -p $DIR/$tdir
15478 SAVE_UMASK=$(umask)
15479 trap cleanup_test_300 RETURN EXIT
15481 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
15482 $DIR/$tdir/striped_dir ||
15483 error "set striped dir error"
15485 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
15486 [ "$mode" = "755" ] || error "expect 755 got $mode"
15488 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
15489 error "getdirstripe failed"
15490 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
15491 if [ "$stripe_count" != "2" ]; then
15492 error "1:stripe_count is $stripe_count, expect 2"
15494 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
15495 if [ "$stripe_count" != "2" ]; then
15496 error "2:stripe_count is $stripe_count, expect 2"
15499 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
15500 if [ "$stripe_index" != "$mdt_index" ]; then
15501 error "stripe_index is $stripe_index, expect $mdt_index"
15504 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15505 error "nlink error after create striped dir"
15507 mkdir $DIR/$tdir/striped_dir/a
15508 mkdir $DIR/$tdir/striped_dir/b
15510 stat $DIR/$tdir/striped_dir/a ||
15511 error "create dir under striped dir failed"
15512 stat $DIR/$tdir/striped_dir/b ||
15513 error "create dir under striped dir failed"
15515 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
15516 error "nlink error after mkdir"
15518 rmdir $DIR/$tdir/striped_dir/a
15519 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
15520 error "nlink error after rmdir"
15522 rmdir $DIR/$tdir/striped_dir/b
15523 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15524 error "nlink error after rmdir"
15526 chattr +i $DIR/$tdir/striped_dir
15527 createmany -o $DIR/$tdir/striped_dir/f 10 &&
15528 error "immutable flags not working under striped dir!"
15529 chattr -i $DIR/$tdir/striped_dir
15531 rmdir $DIR/$tdir/striped_dir ||
15532 error "rmdir striped dir error"
15540 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15541 skip "skipped for lustre < 2.7.0" && return
15542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15543 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15545 test_striped_dir 0 || error "failed on striped dir on MDT0"
15546 test_striped_dir 1 || error "failed on striped dir on MDT0"
15548 run_test 300a "basic striped dir sanity test"
15551 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15552 skip "skipped for lustre < 2.7.0" && return
15553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15554 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15560 test_mkdir $DIR/$tdir || error "mkdir fail"
15561 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15562 error "set striped dir error"
15563 for ((i=0; i<10; i++)); do
15564 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
15566 touch $DIR/$tdir/striped_dir/file_$i ||
15567 error "touch error $i"
15568 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
15569 [ $mtime1 -eq $mtime2 ] &&
15570 error "mtime not change after create"
15572 rm -f $DIR/$tdir/striped_dir/file_$i ||
15573 error "unlink error $i"
15574 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
15575 [ $mtime2 -eq $mtime3 ] &&
15576 error "mtime did not change after unlink"
15580 run_test 300b "check ctime/mtime for striped dir"
15583 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15584 skip "skipped for lustre < 2.7.0" && return
15585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15586 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15589 mkdir -p $DIR/$tdir
15590 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
15591 error "set striped dir error"
15593 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
15594 error "chown striped dir failed"
15596 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
15597 error "create 5k files failed"
15599 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
15601 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
15605 run_test 300c "chown && check ls under striped directory"
15608 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15609 skip "skipped for lustre < 2.7.0" && return
15610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15611 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15615 mkdir -p $DIR/$tdir
15616 $SETSTRIPE -c 2 $DIR/$tdir
15618 #local striped directory
15619 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15620 error "set striped dir error"
15621 createmany -o $DIR/$tdir/striped_dir/f 10 ||
15622 error "create 10 files failed"
15624 #remote striped directory
15625 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
15626 error "set striped dir error"
15627 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
15628 error "create 10 files failed"
15630 for file in $(find $DIR/$tdir); do
15631 stripe_count=$($GETSTRIPE -c $file)
15632 [ $stripe_count -eq 2 ] ||
15633 error "wrong stripe $stripe_count for $file"
15638 run_test 300d "check default stripe under striped directory"
15641 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15642 skip "Need MDS version at least 2.7.55" && return
15643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15644 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15648 mkdir -p $DIR/$tdir
15650 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15651 error "set striped dir error"
15653 touch $DIR/$tdir/striped_dir/a
15654 touch $DIR/$tdir/striped_dir/b
15655 touch $DIR/$tdir/striped_dir/c
15657 mkdir $DIR/$tdir/striped_dir/dir_a
15658 mkdir $DIR/$tdir/striped_dir/dir_b
15659 mkdir $DIR/$tdir/striped_dir/dir_c
15661 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
15662 error "set striped adir under striped dir error"
15664 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
15665 error "set striped bdir under striped dir error"
15667 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
15668 error "set striped cdir under striped dir error"
15670 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
15671 error "rename dir under striped dir fails"
15673 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
15674 error "rename dir under different stripes fails"
15676 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
15677 error "rename file under striped dir should succeed"
15679 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
15680 error "rename dir under striped dir should succeed"
15684 run_test 300e "check rename under striped directory"
15687 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15688 skip "Need MDS version at least 2.7.55" && return
15689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15690 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15695 mkdir -p $DIR/$tdir
15697 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15698 error "set striped dir error"
15700 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
15701 error "set striped dir error"
15703 touch $DIR/$tdir/striped_dir/a
15704 mkdir $DIR/$tdir/striped_dir/dir_a
15705 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
15706 error "create striped dir under striped dir fails"
15708 touch $DIR/$tdir/striped_dir1/b
15709 mkdir $DIR/$tdir/striped_dir1/dir_b
15710 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
15711 error "create striped dir under striped dir fails"
15713 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
15714 error "rename dir under different striped dir should fail"
15716 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
15717 error "rename striped dir under diff striped dir should fail"
15719 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
15720 error "rename file under diff striped dirs fails"
15724 run_test 300f "check rename cross striped directory"
15726 test_300_check_default_striped_dir()
15729 local default_count=$2
15730 local default_index=$3
15733 local dir_stripe_index
15736 echo "checking $dirname $default_count $default_index"
15737 $LFS setdirstripe -D -c $default_count -i $default_index \
15738 -t all_char $DIR/$tdir/$dirname ||
15739 error "set default stripe on striped dir error"
15740 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
15741 [ $stripe_count -eq $default_count ] ||
15742 error "expect $default_count get $stripe_count for $dirname"
15744 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
15745 [ $stripe_index -eq $default_index ] ||
15746 error "expect $default_index get $stripe_index for $dirname"
15748 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
15749 error "create dirs failed"
15751 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
15752 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
15753 for dir in $(find $DIR/$tdir/$dirname/*); do
15754 stripe_count=$($LFS getdirstripe -c $dir)
15755 [ $stripe_count -eq $default_count ] ||
15756 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
15757 error "stripe count $default_count != $stripe_count for $dir"
15759 stripe_index=$($LFS getdirstripe -i $dir)
15760 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
15761 error "$stripe_index != $default_index for $dir"
15763 #check default stripe
15764 stripe_count=$($LFS getdirstripe -D -c $dir)
15765 [ $stripe_count -eq $default_count ] ||
15766 error "default count $default_count != $stripe_count for $dir"
15768 stripe_index=$($LFS getdirstripe -D -i $dir)
15769 [ $stripe_index -eq $default_index ] ||
15770 error "default index $default_index != $stripe_index for $dir"
15772 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
15776 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15777 skip "Need MDS version at least 2.7.55" && return
15778 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15784 mkdir $DIR/$tdir/normal_dir
15786 #Checking when client cache stripe index
15787 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
15788 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
15789 error "create striped_dir failed"
15791 mkdir $DIR/$tdir/striped_dir/dir1 ||
15792 error "create dir1 fails"
15793 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
15794 [ $stripe_index -eq 1 ] ||
15795 error "dir1 expect 1 got $stripe_index"
15797 $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
15798 error "create dir2 fails"
15799 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
15800 [ $stripe_index -eq 2 ] ||
15801 error "dir2 expect 2 got $stripe_index"
15803 #check default stripe count/stripe index
15804 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
15805 test_300_check_default_striped_dir normal_dir 1 0
15806 test_300_check_default_striped_dir normal_dir 2 1
15807 test_300_check_default_striped_dir normal_dir 2 -1
15809 #delete default stripe information
15810 echo "delete default stripeEA"
15811 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
15812 error "set default stripe on striped dir error"
15814 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
15815 for dir in $(find $DIR/$tdir/normal_dir/*); do
15816 stripe_count=$($LFS getdirstripe -c $dir)
15817 [ $stripe_count -eq 0 ] ||
15818 error "expect 1 get $stripe_count for $dir"
15819 stripe_index=$($LFS getdirstripe -i $dir)
15820 [ $stripe_index -eq 0 ] ||
15821 error "expect 0 get $stripe_index for $dir"
15824 run_test 300g "check default striped directory for normal directory"
15827 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15828 skip "Need MDS version at least 2.7.55" && return
15829 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15834 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
15835 $DIR/$tdir/striped_dir ||
15836 error "set striped dir error"
15838 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
15839 test_300_check_default_striped_dir striped_dir 1 0
15840 test_300_check_default_striped_dir striped_dir 2 1
15841 test_300_check_default_striped_dir striped_dir 2 -1
15843 #delete default stripe information
15844 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
15845 error "set default stripe on striped dir error"
15847 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
15848 for dir in $(find $DIR/$tdir/striped_dir/*); do
15849 stripe_count=$($LFS getdirstripe -c $dir)
15850 [ $stripe_count -eq 0 ] ||
15851 error "expect 1 get $stripe_count for $dir"
15854 run_test 300h "check default striped directory for striped directory"
15857 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15858 skip "Need MDS version at least 2.7.55" && return
15859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15860 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15866 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15867 error "set striped dir error"
15869 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15870 error "create files under striped dir failed"
15872 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
15873 error "set striped hashdir error"
15875 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
15876 error "create dir0 under hash dir failed"
15877 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
15878 error "create dir1 under hash dir failed"
15880 # unfortunately, we need to umount to clear dir layout cache for now
15881 # once we fully implement dir layout, we can drop this
15882 umount_client $MOUNT || error "umount failed"
15883 mount_client $MOUNT || error "mount failed"
15885 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
15886 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
15887 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
15889 #set the stripe to be unknown hash type
15890 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
15891 $LCTL set_param fail_loc=0x1901
15892 for ((i = 0; i < 10; i++)); do
15893 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
15894 error "stat f-$i failed"
15895 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
15898 touch $DIR/$tdir/striped_dir/f0 &&
15899 error "create under striped dir with unknown hash should fail"
15901 $LCTL set_param fail_loc=0
15903 umount_client $MOUNT || error "umount failed"
15904 mount_client $MOUNT || error "mount failed"
15908 run_test 300i "client handle unknown hash type striped directory"
15911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15912 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15913 skip "Need MDS version at least 2.7.55" && return
15914 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15920 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
15921 $LCTL set_param fail_loc=0x1702
15922 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15923 error "set striped dir error"
15925 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15926 error "create files under striped dir failed"
15928 $LCTL set_param fail_loc=0
15930 rm -rf $DIR/$tdir || error "unlink striped dir fails"
15934 run_test 300j "test large update record"
15937 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15938 skip "Need MDS version at least 2.7.55" && return
15939 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15940 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15946 #define OBD_FAIL_LARGE_STRIPE 0x1703
15947 $LCTL set_param fail_loc=0x1703
15948 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
15949 error "set striped dir error"
15950 $LCTL set_param fail_loc=0
15952 $LFS getdirstripe $DIR/$tdir/striped_dir ||
15953 error "getstripeddir fails"
15954 rm -rf $DIR/$tdir/striped_dir ||
15955 error "unlink striped dir fails"
15959 run_test 300k "test large striped directory"
15962 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15963 skip "Need MDS version at least 2.7.55" && return
15964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15965 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15968 test_mkdir -p $DIR/$tdir/striped_dir
15969 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
15970 error "chown $RUNAS_ID failed"
15971 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
15972 error "set default striped dir failed"
15974 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
15975 $LCTL set_param fail_loc=0x80000158
15976 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
15978 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
15979 [ $stripe_index -eq 1 ] ||
15980 error "expect 1 get $stripe_index for $dir"
15982 run_test 300l "non-root user to create dir under striped dir with stale layout"
15985 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15986 skip "Need MDS version at least 2.7.55" && return
15987 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15988 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
15990 mkdir -p $DIR/$tdir/striped_dir
15991 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
15992 error "set default stripes dir error"
15994 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
15996 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
15997 [ $stripe_count -eq 0 ] ||
15998 error "expect 0 get $stripe_count for a"
16000 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
16001 error "set default stripes dir error"
16003 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
16005 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
16006 [ $stripe_count -eq 0 ] ||
16007 error "expect 0 get $stripe_count for b"
16009 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
16010 error "set default stripes dir error"
16012 mkdir $DIR/$tdir/striped_dir/c &&
16013 error "default stripe_index is invalid, mkdir c should fails"
16015 rm -rf $DIR/$tdir || error "rmdir fails"
16017 run_test 300m "setstriped directory on single MDT FS"
16020 local list=$(comma_list $(mdts_nodes))
16023 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16027 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16028 skip "Need MDS version at least 2.7.55" && return
16029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16030 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16031 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16034 local list=$(comma_list $(mdts_nodes))
16036 trap cleanup_300n RETURN EXIT
16037 mkdir -p $DIR/$tdir
16038 chmod 777 $DIR/$tdir
16039 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
16040 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16041 error "create striped dir succeeds with gid=0"
16043 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16044 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
16045 error "create striped dir fails with gid=-1"
16047 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16048 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
16049 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16050 error "set default striped dir succeeds with gid=0"
16053 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16054 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
16055 error "set default striped dir fails with gid=-1"
16058 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16059 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
16060 error "create test_dir fails"
16061 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
16062 error "create test_dir1 fails"
16063 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
16064 error "create test_dir2 fails"
16067 run_test 300n "non-root user to create dir under striped dir with default EA"
16070 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16071 skip "Need MDS version at least 2.7.55" && return
16072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16073 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16077 mkdir -p $DIR/$tdir
16079 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
16080 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
16081 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
16082 skip "not enough free inodes $numfree1 $numfree2"
16086 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
16087 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
16088 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
16089 skip "not enough free space $numfree1 $numfree2"
16093 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
16094 error "setdirstripe fails"
16096 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
16097 error "create dirs fails"
16099 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
16100 ls $DIR/$tdir/striped_dir > /dev/null ||
16101 error "ls striped dir fails"
16102 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
16103 error "unlink big striped dir fails"
16105 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
16108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16109 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16110 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16112 mkdir -p $DIR/$tdir
16114 #define OBD_FAIL_OUT_ENOSPC 0x1704
16115 do_facet mds2 lctl set_param fail_loc=0x80001704
16116 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
16117 error "create striped directory should fail"
16119 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
16121 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
16124 run_test 300p "create striped directory without space"
16127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16128 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16130 local fd=$(free_fd)
16131 local cmd="exec $fd<$tdir"
16133 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
16136 trap "eval $cmd" EXIT
16137 cd $tdir || error "cd $tdir fails"
16138 rmdir ../$tdir || error "rmdir $tdir fails"
16139 mkdir local_dir && error "create dir succeeds"
16140 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
16144 run_test 300q "create remote directory under orphan directory"
16147 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16148 skip "Need MDS version at least 2.7.55" && return
16149 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16153 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
16154 error "set striped dir error"
16156 $LFS getdirstripe $DIR/$tdir/striped_dir ||
16157 error "getstripeddir fails"
16160 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
16161 awk '/lmv_stripe_count:/ { print $2 }')
16163 [ $MDSCOUNT -ne $stripe_count ] &&
16164 error "wrong stripe count $stripe_count expected $MDSCOUNT"
16166 rm -rf $DIR/$tdir/striped_dir ||
16167 error "unlink striped dir fails"
16169 run_test 300r "test -1 striped directory"
16171 prepare_remote_file() {
16172 mkdir $DIR/$tdir/src_dir ||
16173 error "create remote source failed"
16175 cp /etc/hosts $DIR/$tdir/src_dir/a || error
16176 touch $DIR/$tdir/src_dir/a
16178 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
16179 error "create remote target dir failed"
16181 touch $DIR/$tdir/tgt_dir/b
16183 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
16184 error "rename dir cross MDT failed!"
16186 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
16187 error "src_child still exists after rename"
16189 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
16190 error "missing file(a) after rename"
16192 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
16193 error "diff after rename"
16197 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16199 local remote_file=$DIR/$tdir/tgt_dir/b
16201 mkdir -p $DIR/$tdir
16203 prepare_remote_file || error "prepare remote file failed"
16206 $OPENUNLINK $remote_file $remote_file || error
16207 $CHECKSTAT -a $remote_file || error
16209 run_test 310a "open unlink remote file"
16212 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16214 local remote_file=$DIR/$tdir/tgt_dir/b
16216 mkdir -p $DIR/$tdir
16218 prepare_remote_file || error "prepare remote file failed"
16220 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16221 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
16222 $CHECKSTAT -t file $remote_file || error "check file failed"
16224 run_test 310b "unlink remote file with multiple links while open"
16227 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
16228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16229 local remote_file=$DIR/$tdir/tgt_dir/b
16231 mkdir -p $DIR/$tdir
16233 prepare_remote_file || error "prepare remote file failed"
16235 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16236 multiop_bg_pause $remote_file O_uc ||
16237 error "mulitop failed for remote file"
16239 $MULTIOP $DIR/$tfile Ouc
16240 kill -USR1 $MULTIPID
16243 run_test 310c "open-unlink remote file with multiple links"
16247 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16248 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
16249 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
16250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16251 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16253 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16254 local mdts=$(comma_list $(mdts_nodes))
16256 mkdir -p $DIR/$tdir
16257 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
16258 createmany -o $DIR/$tdir/$tfile. 1000
16260 # statfs data is not real time, let's just calculate it
16261 old_iused=$((old_iused + 1000))
16263 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
16264 osp.*OST0000*MDT0000.create_count")
16265 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
16266 osp.*OST0000*MDT0000.max_create_count")
16267 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
16269 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
16270 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
16271 [ $index -ne 0 ] || error "$tfile stripe index is 0"
16273 unlinkmany $DIR/$tdir/$tfile. 1000
16275 do_nodes $mdts "$LCTL set_param -n \
16276 osp.*OST0000*.max_create_count=$max_count"
16277 [ $(lustre_version_code $facet) -lt $(version_code 2.11.56) ] &&
16278 do_nodes $mdts "$LCTL set_param -n \
16279 osp.*OST0000*.create_count=$count"
16280 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
16281 grep "=0" && error "create_count is zero"
16284 for i in $(seq 120); do
16285 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16286 # system may be too busy to destroy all objs in time, use
16287 # a somewhat small value to not fail autotest
16288 [ $((old_iused - new_iused)) -gt 400 ] && break
16292 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
16293 [ $((old_iused - new_iused)) -gt 400 ] ||
16294 error "objs not destroyed after unlink"
16296 run_test 311 "disable OSP precreate, and unlink should destroy objs"
16303 local vdevdir=$(dirname $(facet_vdevice $ost))
16304 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
16305 local zfs_zapid=$(do_facet $ost $cmd |
16306 grep -w "/O/0/d$((objid%32))" -C 5 |
16307 awk '/Object/{getline; print $1}')
16308 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
16309 awk "/$objid = /"'{printf $3}')
16314 zfs_object_blksz() {
16318 local vdevdir=$(dirname $(facet_vdevice $ost))
16319 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
16320 local blksz=$(do_facet $ost $cmd $objid |
16321 awk '/dblk/{getline; printf $4}')
16323 case "${blksz: -1}" in
16324 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
16325 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
16332 test_312() { # LU-4856
16333 remote_ost_nodsh && skip "remote OST with nodsh" && return
16335 [ $(facet_fstype ost1) = "zfs" ] ||
16336 { skip "the test only applies to zfs" && return; }
16338 local max_blksz=$(do_facet ost1 \
16339 $ZFS get -p recordsize $(facet_device ost1) |
16340 awk '!/VALUE/{print $3}')
16341 local min_blksz=$(getconf PAGE_SIZE)
16343 # to make life a little bit easier
16344 $LFS mkdir -c 1 -i 0 $DIR/$tdir
16345 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16347 local tf=$DIR/$tdir/$tfile
16349 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16351 # Get ZFS object id
16352 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16354 # block size change by sequential over write
16356 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
16357 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
16359 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16360 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
16364 # block size change by sequential append write
16365 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
16366 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16367 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16369 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
16370 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
16371 oflag=sync conv=notrunc
16373 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16374 [ $blksz -eq $((2 * count * min_blksz)) ] ||
16375 error "blksz error, actual $blksz, " \
16376 "expected: 2 * $count * $min_blksz"
16382 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16383 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16385 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
16386 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16387 [ $blksz -eq $min_blksz ] ||
16388 error "blksz error: $blksz, expected: $min_blksz"
16390 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
16391 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16392 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
16394 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
16395 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16396 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
16398 run_test 312 "make sure ZFS adjusts its block size by write pattern"
16401 remote_ost_nodsh && skip "remote OST with nodsh" && return
16403 local file=$DIR/$tfile
16405 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
16407 # define OBD_FAIL_TGT_RCVD_EIO 0x720
16408 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16409 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
16410 error "write should failed"
16411 do_facet ost1 "$LCTL set_param fail_loc=0"
16414 run_test 313 "io should fail after last_rcvd update fail"
16417 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16419 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
16420 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16422 wait_delete_completed
16423 do_facet ost1 "$LCTL set_param fail_loc=0"
16425 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
16427 test_315() { # LU-618
16428 local file=$DIR/$tfile
16431 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
16432 $MULTIOP $file oO_RDONLY:r4096000_c &
16437 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
16440 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
16443 run_test 315 "read should be accounted"
16446 local read_write=$1
16447 if [ "$read_write" = "write" ]; then
16448 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
16449 elif [ "$read_write" = "read" ]; then
16450 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
16452 error "argument error"
16455 # turn off debug for performance testing
16456 local saved_debug=$($LCTL get_param -n debug)
16457 $LCTL set_param debug=0
16459 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
16461 # get ost1 size - lustre-OST0000
16462 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
16463 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
16464 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
16466 if [ "$read_write" = "read" ]; then
16467 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
16470 local start_time=$(date +%s.%N)
16471 $dd_cmd bs=1M count=$blocks oflag=sync ||
16472 error "real dd $read_write error"
16473 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
16475 if [ "$read_write" = "write" ]; then
16479 # define OBD_FAIL_OST_FAKE_RW 0x238
16480 do_facet ost1 $LCTL set_param fail_loc=0x238
16482 local start_time=$(date +%s.%N)
16483 $dd_cmd bs=1M count=$blocks oflag=sync ||
16484 error "fake dd $read_write error"
16485 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
16487 if [ "$read_write" = "write" ]; then
16489 cancel_lru_locks osc
16490 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
16491 error "$tfile size not $blocks MB"
16493 do_facet ost1 $LCTL set_param fail_loc=0
16495 echo "fake $read_write $duration_fake vs. normal $read_write" \
16496 "$duration in seconds"
16497 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
16498 error_not_in_vm "fake write is slower"
16500 $LCTL set_param -n debug="$saved_debug"
16503 test_399a() { # LU-7655 for OST fake write
16504 remote_ost_nodsh && skip "remote OST with nodsh" && return
16508 run_test 399a "fake write should not be slower than normal write"
16510 test_399b() { # LU-8726 for OST fake read
16511 remote_ost_nodsh && skip "remote OST with nodsh" && return
16513 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
16514 skip "ldiskfs only test" && return 0
16518 run_test 399b "fake read should not be slower than normal read"
16520 test_400a() { # LU-1606, was conf-sanity test_74
16521 local extra_flags=''
16522 local out=$TMP/$tfile
16523 local prefix=/usr/include/lustre
16526 if ! which $CC > /dev/null 2>&1; then
16527 skip_env "$CC is not installed"
16531 if ! [[ -d $prefix ]]; then
16532 # Assume we're running in tree and fixup the include path.
16533 extra_flags+=" -I$LUSTRE/../libcfs/include"
16534 extra_flags+=" -I$LUSTRE/include"
16535 extra_flags+=" -L$LUSTRE/utils"
16538 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
16539 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
16540 error "client api broken"
16544 run_test 400a "Lustre client api program can compile and link"
16546 test_400b() { # LU-1606, LU-5011
16548 local out=$TMP/$tfile
16549 local prefix=/usr/include/lustre
16551 # We use a hard coded prefix so that this test will not fail
16552 # when run in tree. There are headers in lustre/include/lustre/
16553 # that are not packaged (like lustre_idl.h) and have more
16554 # complicated include dependencies (like config.h and lnet/types.h).
16555 # Since this test about correct packaging we just skip them when
16556 # they don't exist (see below) rather than try to fixup cppflags.
16558 if ! which $CC > /dev/null 2>&1; then
16559 skip_env "$CC is not installed"
16563 for header in $prefix/*.h; do
16564 if ! [[ -f "$header" ]]; then
16568 if [[ "$(basename $header)" == liblustreapi.h ]]; then
16569 continue # liblustreapi.h is deprecated.
16572 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
16573 error "cannot compile '$header'"
16577 run_test 400b "packaged headers can be compiled"
16579 test_401a() { #LU-7437
16580 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
16581 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
16583 #count the number of parameters by "list_param -R"
16584 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
16585 #count the number of parameters by listing proc files
16586 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
16587 echo "proc_dirs='$proc_dirs'"
16588 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
16589 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
16592 [ $params -eq $procs ] ||
16593 error "found $params parameters vs. $procs proc files"
16595 # test the list_param -D option only returns directories
16596 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
16597 #count the number of parameters by listing proc directories
16598 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
16601 [ $params -eq $procs ] ||
16602 error "found $params parameters vs. $procs proc files"
16604 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
16607 local save=$($LCTL get_param -n jobid_var)
16610 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
16611 error "no error returned when setting bad parameters"
16613 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
16614 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
16616 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
16617 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
16618 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
16620 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
16623 local jobid_var_old=$($LCTL get_param -n jobid_var)
16624 local jobid_var_new
16626 $LCTL set_param jobid_var= &&
16627 error "no error returned for 'set_param a='"
16629 jobid_var_new=$($LCTL get_param -n jobid_var)
16630 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16631 error "jobid_var was changed by setting without value"
16633 $LCTL set_param jobid_var &&
16634 error "no error returned for 'set_param a'"
16636 jobid_var_new=$($LCTL get_param -n jobid_var)
16637 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16638 error "jobid_var was changed by setting without value"
16640 run_test 401c "Verify 'lctl set_param' without value fails in either format."
16643 local jobid_var_old=$($LCTL get_param -n jobid_var)
16644 local jobid_var_new
16645 local new_value="foo=bar"
16647 $LCTL set_param jobid_var=$new_value ||
16648 error "'set_param a=b' did not accept a value containing '='"
16650 jobid_var_new=$($LCTL get_param -n jobid_var)
16651 [[ "$jobid_var_new" == "$new_value" ]] ||
16652 error "'set_param a=b' failed on a value containing '='"
16654 # Reset the jobid_var to test the other format
16655 $LCTL set_param jobid_var=$jobid_var_old
16656 jobid_var_new=$($LCTL get_param -n jobid_var)
16657 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16658 error "failed to reset jobid_var"
16660 $LCTL set_param jobid_var $new_value ||
16661 error "'set_param a b' did not accept a value containing '='"
16663 jobid_var_new=$($LCTL get_param -n jobid_var)
16664 [[ "$jobid_var_new" == "$new_value" ]] ||
16665 error "'set_param a b' failed on a value containing '='"
16667 $LCTL set_param jobid_var $jobid_var_old
16668 jobid_var_new=$($LCTL get_param -n jobid_var)
16669 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16670 error "failed to reset jobid_var"
16672 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
16675 local server_version=$(lustre_version_code $SINGLEMDS)
16676 [[ $server_version -ge $(version_code 2.7.66) ]] ||
16677 [[ $server_version -ge $(version_code 2.7.18.4) &&
16678 $server_version -lt $(version_code 2.7.50) ]] ||
16679 [[ $server_version -ge $(version_code 2.7.2) &&
16680 $server_version -lt $(version_code 2.7.11) ]] ||
16681 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
16683 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16684 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
16685 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
16686 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
16687 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
16688 echo "Touch failed - OK"
16690 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
16693 local file1=$DIR/$tfile.1
16694 local file2=$DIR/$tfile.2
16695 local tfile=$TMP/$tfile
16697 rm -f $file1 $file2 $tfile
16702 # 30 sec OBD_TIMEOUT in ll_getattr()
16703 # right before populating st_nlink
16704 $LCTL set_param fail_loc=0x80001409
16705 stat -c %h $file1 > $tfile &
16707 # create an alias, drop all locks and reclaim the dentry
16709 cancel_lru_locks mdc
16710 cancel_lru_locks osc
16711 sysctl -w vm.drop_caches=2
16715 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
16717 rm -f $tfile $file1 $file2
16719 run_test 403 "i_nlink should not drop to zero due to aliasing"
16721 test_404() { # LU-6601
16722 local server_version=$(lustre_version_code $SINGLEMDS)
16723 [[ $server_version -ge $(version_code 2.8.53) ]] ||
16724 { skip "Need server version newer than 2.8.52"; return 0; }
16726 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16727 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
16728 awk '/osp .*-osc-MDT/ { print $4}')
16731 for osp in $mosps; do
16732 echo "Deactivate: " $osp
16733 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
16734 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16735 awk -vp=$osp '$4 == p { print $2 }')
16736 [ $stat = IN ] || {
16737 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16738 error "deactivate error"
16740 echo "Activate: " $osp
16741 do_facet $SINGLEMDS $LCTL --device %$osp activate
16742 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16743 awk -vp=$osp '$4 == p { print $2 }')
16744 [ $stat = UP ] || {
16745 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16746 error "activate error"
16750 run_test 404 "validate manual {de}activated works properly for OSPs"
16753 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
16754 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
16755 skip "Layout swap lock is not supported" && return
16757 check_swap_layouts_support && return 0
16759 test_mkdir -p $DIR/$tdir
16760 swap_lock_test -d $DIR/$tdir ||
16761 error "One layout swap locked test failed"
16763 run_test 405 "Various layout swap lock tests"
16766 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16767 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16768 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
16769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16770 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
16771 skip "Need MDS version at least 2.8.50" && return
16773 local def_stripe_size=$($LFS getstripe -S $MOUNT)
16774 local test_pool=$TESTNAME
16776 if ! combined_mgs_mds ; then
16779 pool_add $test_pool || error "pool_add failed"
16780 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
16781 error "pool_add_targets failed"
16783 save_layout_restore_at_exit $MOUNT
16785 # parent set default stripe count only, child will stripe from both
16786 # parent and fs default
16787 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
16788 error "setstripe $MOUNT failed"
16789 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
16790 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
16791 for i in $(seq 10); do
16792 local f=$DIR/$tdir/$tfile.$i
16793 touch $f || error "touch failed"
16794 local count=$($LFS getstripe -c $f)
16795 [ $count -eq $OSTCOUNT ] ||
16796 error "$f stripe count $count != $OSTCOUNT"
16797 local offset=$($LFS getstripe -i $f)
16798 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
16799 local size=$($LFS getstripe -S $f)
16800 [ $size -eq $((def_stripe_size * 2)) ] ||
16801 error "$f stripe size $size != $((def_stripe_size * 2))"
16802 local pool=$($LFS getstripe -p $f)
16803 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
16806 # change fs default striping, delete parent default striping, now child
16807 # will stripe from new fs default striping only
16808 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
16809 error "change $MOUNT default stripe failed"
16810 $LFS setstripe -c 0 $DIR/$tdir ||
16811 error "delete $tdir default stripe failed"
16812 for i in $(seq 11 20); do
16813 local f=$DIR/$tdir/$tfile.$i
16814 touch $f || error "touch $f failed"
16815 local count=$($LFS getstripe -c $f)
16816 [ $count -eq 1 ] || error "$f stripe count $count != 1"
16817 local offset=$($LFS getstripe -i $f)
16818 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
16819 local size=$($LFS getstripe -S $f)
16820 [ $size -eq $def_stripe_size ] ||
16821 error "$f stripe size $size != $def_stripe_size"
16822 local pool=$($LFS getstripe -p $f)
16823 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
16826 unlinkmany $DIR/$tdir/$tfile. 1 20
16828 local f=$DIR/$tdir/$tfile
16829 pool_remove_all_targets $test_pool $f
16830 pool_remove $test_pool $f
16832 if ! combined_mgs_mds ; then
16836 run_test 406 "DNE support fs default striping"
16839 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16840 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16841 skip "Need MDS version at least 2.8.55" && return
16842 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16844 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
16845 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
16846 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
16847 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
16848 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
16850 #define OBD_FAIL_DT_TXN_STOP 0x2019
16851 for idx in $(seq $MDSCOUNT); do
16852 do_facet mds$idx "lctl set_param fail_loc=0x2019"
16854 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
16855 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
16856 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
16859 run_test 407 "transaction fail should cause operation fail"
16862 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
16864 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
16865 lctl set_param fail_loc=0x8000040a
16866 # let ll_prepare_partial_page() fail
16867 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
16871 # create at least 100 unused inodes so that
16872 # shrink_icache_memory(0) should not return 0
16873 touch $DIR/$tfile-{0..100}
16874 rm -f $DIR/$tfile-{0..100}
16877 echo 2 > /proc/sys/vm/drop_caches
16879 run_test 408 "drop_caches should not hang due to page leaks"
16883 [ $MDSCOUNT -lt 2 ] &&
16884 skip "We need at least 2 MDTs for this test" && return
16886 check_mount_and_prep
16888 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
16889 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
16890 touch $DIR/$tdir/guard || error "(2) Fail to create"
16892 local PREFIX=$(str_repeat 'A' 128)
16893 echo "Create 1K hard links start at $(date)"
16894 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16895 error "(3) Fail to hard link"
16897 echo "Links count should be right although linkEA overflow"
16898 stat $DIR/$tdir/guard || error "(4) Fail to stat"
16899 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
16900 [ $linkcount -eq 1001 ] ||
16901 error "(5) Unexpected hard links count: $linkcount"
16903 echo "List all links start at $(date)"
16904 ls -l $DIR/$tdir/foo > /dev/null ||
16905 error "(6) Fail to list $DIR/$tdir/foo"
16907 echo "Unlink hard links start at $(date)"
16908 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16909 error "(7) Fail to unlink"
16911 run_test 409 "Large amount of cross-MDTs hard links on the same file"
16915 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
16916 skip "Need client version at least 2.9.59" && return
16918 # Create a file, and stat it from the kernel
16919 local testfile=$DIR/$tfile
16922 local run_id=$RANDOM
16923 local my_ino=$(stat --format "%i" $testfile)
16925 # Try to insert the module. This will always fail as the
16926 # module is designed to not be inserted.
16927 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
16930 # Anything but success is a test failure
16932 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
16933 error "no inode match"
16935 run_test 410 "Test inode number returned from kernel thread"
16938 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16939 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16940 skip "Need server version at least 2.9.55" & exit 0
16941 start_full_debug_logging
16945 stop_full_debug_logging
16949 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16950 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16951 awk '/The barrier for/ { print $7 }')
16954 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
16959 barrier_expired() {
16962 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16963 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16964 awk '/will be expired/ { print $7 }')
16966 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
16975 echo "Start barrier_freeze at: $(date)"
16976 #define OBD_FAIL_BARRIER_DELAY 0x2202
16977 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16978 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
16981 local b_status=$(barrier_stat)
16982 echo "Got barrier status at: $(date)"
16983 [ "$b_status" = "'freezing_p1'" ] ||
16984 error "(1) unexpected barrier status $b_status"
16986 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16988 b_status=$(barrier_stat)
16989 [ "$b_status" = "'frozen'" ] ||
16990 error "(2) unexpected barrier status $b_status"
16992 local expired=$(barrier_expired)
16993 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
16994 sleep $((expired + 3))
16996 b_status=$(barrier_stat)
16997 [ "$b_status" = "'expired'" ] ||
16998 error "(3) unexpected barrier status $b_status"
17000 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
17001 error "(4) fail to freeze barrier"
17003 b_status=$(barrier_stat)
17004 [ "$b_status" = "'frozen'" ] ||
17005 error "(5) unexpected barrier status $b_status"
17007 echo "Start barrier_thaw at: $(date)"
17008 #define OBD_FAIL_BARRIER_DELAY 0x2202
17009 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17010 do_facet mgs $LCTL barrier_thaw $FSNAME &
17013 b_status=$(barrier_stat)
17014 echo "Got barrier status at: $(date)"
17015 [ "$b_status" = "'thawing'" ] ||
17016 error "(6) unexpected barrier status $b_status"
17018 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17020 b_status=$(barrier_stat)
17021 [ "$b_status" = "'thawed'" ] ||
17022 error "(7) unexpected barrier status $b_status"
17024 #define OBD_FAIL_BARRIER_FAILURE 0x2203
17025 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
17026 do_facet mgs $LCTL barrier_freeze $FSNAME
17028 b_status=$(barrier_stat)
17029 [ "$b_status" = "'failed'" ] ||
17030 error "(8) unexpected barrier status $b_status"
17032 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17033 do_facet mgs $LCTL barrier_thaw $FSNAME
17037 run_test 801a "write barrier user interfaces and stat machine"
17042 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17043 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
17044 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
17045 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
17046 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
17048 cancel_lru_locks mdc
17050 # 180 seconds should be long enough
17051 do_facet mgs $LCTL barrier_freeze $FSNAME 180
17053 local b_status=$(barrier_stat)
17054 [ "$b_status" = "'frozen'" ] ||
17055 error "(6) unexpected barrier status $b_status"
17057 mkdir $DIR/$tdir/d0/d10 &
17060 touch $DIR/$tdir/d1/f13 &
17063 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
17066 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
17069 rm -f $DIR/$tdir/d4/f12 &
17072 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
17074 # To guarantee taht the 'stat' is not blocked
17075 b_status=$(barrier_stat)
17076 [ "$b_status" = "'frozen'" ] ||
17077 error "(8) unexpected barrier status $b_status"
17079 # let above commands to run at background
17082 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
17083 ps -p $touch_pid || error "(10) touch should be blocked"
17084 ps -p $ln_pid || error "(11) link should be blocked"
17085 ps -p $mv_pid || error "(12) rename should be blocked"
17086 ps -p $rm_pid || error "(13) unlink should be blocked"
17088 b_status=$(barrier_stat)
17089 [ "$b_status" = "'frozen'" ] ||
17090 error "(14) unexpected barrier status $b_status"
17092 do_facet mgs $LCTL barrier_thaw $FSNAME
17093 b_status=$(barrier_stat)
17094 [ "$b_status" = "'thawed'" ] ||
17095 error "(15) unexpected barrier status $b_status"
17097 wait $mkdir_pid || error "(16) mkdir should succeed"
17098 wait $touch_pid || error "(17) touch should succeed"
17099 wait $ln_pid || error "(18) link should succeed"
17100 wait $mv_pid || error "(19) rename should succeed"
17101 wait $rm_pid || error "(20) unlink should succeed"
17105 run_test 801b "modification will be blocked by write barrier"
17108 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17112 stop mds2 || error "(1) Fail to stop mds2"
17114 do_facet mgs $LCTL barrier_freeze $FSNAME 30
17116 local b_status=$(barrier_stat)
17117 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
17118 do_facet mgs $LCTL barrier_thaw $FSNAME
17119 error "(2) unexpected barrier status $b_status"
17122 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17123 error "(3) Fail to rescan barrier bitmap"
17125 do_facet mgs $LCTL barrier_freeze $FSNAME 10
17127 b_status=$(barrier_stat)
17128 [ "$b_status" = "'frozen'" ] ||
17129 error "(4) unexpected barrier status $b_status"
17131 do_facet mgs $LCTL barrier_thaw $FSNAME
17132 b_status=$(barrier_stat)
17133 [ "$b_status" = "'thawed'" ] ||
17134 error "(5) unexpected barrier status $b_status"
17136 local devname=$(mdsdevname 2)
17138 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
17140 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17141 error "(7) Fail to rescan barrier bitmap"
17145 run_test 801c "rescan barrier bitmap"
17147 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
17148 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
17149 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
17155 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
17156 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
17157 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
17163 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17164 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17165 skip "Need server version at least 2.9.55" & exit 0
17167 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17169 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
17170 error "(2) Fail to copy"
17172 trap cleanup_802 EXIT
17174 # sync by force before remount as readonly
17175 sync; sync_all_data; sleep 3; sync_all_data
17179 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
17180 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
17181 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
17183 echo "Mount the server as read only"
17184 setupall server_only || error "(3) Fail to start servers"
17186 echo "Mount client without ro should fail"
17187 mount_client $MOUNT &&
17188 error "(4) Mount client without 'ro' should fail"
17190 echo "Mount client with ro should succeed"
17191 mount_client $MOUNT ro ||
17192 error "(5) Mount client with 'ro' should succeed"
17194 echo "Modify should be refused"
17195 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
17197 echo "Read should be allowed"
17198 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
17199 error "(7) Read should succeed under ro mode"
17203 run_test 802 "simulate readonly device"
17206 do_facet $SINGLEMDS zfs set quota=$old $fsset
17207 unlinkmany $DIR/$tdir/f- 1000000
17212 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
17213 [ "$(facet_fstype mds1)" != "zfs" ] &&
17214 skip "ZFS specific test" && return
17215 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
17216 skip "netfree not implemented before 0.7" && return
17217 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
17218 { skip "Need MDS version at least 2.10.57" && return 0; }
17225 local pref="osd-zfs.lustre-MDT0000."
17227 # limit available space on MDS dataset to meet nospace issue
17228 # quickly. then ZFS 0.7.2 can use reserved space if asked
17229 # properly (using netfree flag in osd_declare_destroy()
17230 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
17231 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
17233 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
17234 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
17235 let "usedkb=usedkb-freekb"
17236 let "freekb=freekb/2"
17237 if let "freekb > 5000"; then
17240 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
17241 trap cleanup_805 EXIT
17243 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
17244 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
17245 rm -rf $DIR/$tdir || error "not able to remove"
17246 do_facet $SINGLEMDS zfs set quota=$old $fsset
17249 run_test 805 "ZFS can remove from full fs"
17255 lctl set_param fail_loc=0x411
17256 dd if=/dev/urandom of=$DIR/$tfile bs=10240 count=2
17257 ORIG=$(md5sum $DIR/$tfile)
17258 lctl set_param ldlm.namespaces.*osc*.lru_size=clear
17259 CSUM=$(md5sum $DIR/$tfile)
17260 if [ "$ORIG" != "$CSUM" ]; then
17261 error "$ORIG != $CSUM"
17264 run_test 810 "partial page writes on ZFS (LU-11663)"
17267 # tests that do cleanup/setup should be run at the end
17271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17273 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
17274 $LCTL set_param fail_loc=0x903
17276 cancel_lru_locks MGC
17278 FAIL_ON_ERROR=true cleanup
17279 FAIL_ON_ERROR=true setup
17281 run_test 900 "umount should not race with any mgc requeue thread"
17284 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
17285 check_and_cleanup_lustre
17286 if [ "$I_MOUNTED" != "yes" ]; then
17287 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true