2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: LU-9693 LU-6493 LU-9693
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054
16 ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
18 # Check Grants after these tests
19 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
21 SRCDIR=$(cd $(dirname $0); echo $PWD)
22 export PATH=$PATH:/sbin
27 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
28 CREATETEST=${CREATETEST:-createtest}
30 LFIND=${LFIND:-"$LFS find"}
31 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
33 OPENFILE=${OPENFILE:-openfile}
34 OPENUNLINK=${OPENUNLINK:-openunlink}
35 export MULTIOP=${MULTIOP:-multiop}
36 READS=${READS:-"reads"}
37 MUNLINK=${MUNLINK:-munlink}
38 SOCKETSERVER=${SOCKETSERVER:-socketserver}
39 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
40 MEMHOG=${MEMHOG:-memhog}
41 DIRECTIO=${DIRECTIO:-directio}
42 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
57 . $LUSTRE/tests/test-framework.sh
59 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
63 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
65 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
66 # bug number for skipped test: LU-4536 LU-1957
67 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180"
69 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
75 if [ -r /etc/SuSE-release ]
77 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
78 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
80 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
87 # Check if we are running on Ubuntu or SLES so we can make decisions on
90 # bug number for skipped test: LU-4341
91 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
92 elif [ -r /etc/os-release ]; then
93 if grep -qi ubuntu /etc/os-release; then
94 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
99 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
100 # bug number for skipped test:
101 # LU-10334 LU-10335 LU-10335 LU-10335
102 ALWAYS_EXCEPT+=" 103a 130a 130b 130c"
103 # LU-10335 LU-10335 LU-10365 LU-10366
104 ALWAYS_EXCEPT+=" 130d 130e 400a 410"
113 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
114 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
123 check_swap_layouts_support()
125 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
126 { skip "Does not support layout lock."; return 0; }
130 check_and_setup_lustre
134 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
135 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
136 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
138 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
139 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
140 rm -rf $DIR/[Rdfs][0-9]*
142 # $RUNAS_ID may get set incorrectly somewhere else
143 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
145 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
149 if [ "${ONLY}" = "MOUNT" ] ; then
150 echo "Lustre is up, please go on"
154 echo "preparing for tests involving mounts"
155 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
157 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
158 echo # add a newline after mke2fs.
162 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
163 lctl set_param debug=-1 2> /dev/null || true
166 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
168 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
170 run_test 0a "touch; rm ====================="
173 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
174 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
176 run_test 0b "chmod 0755 $DIR ============================="
179 $LCTL get_param mdc.*.import | grep "state: FULL" ||
180 error "import not FULL"
181 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
184 run_test 0c "check import proc ============================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
189 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
190 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
193 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
195 run_test 1 "mkdir; remkdir; rmdir =============================="
198 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
199 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
200 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
202 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
204 run_test 2 "mkdir; touch; rmdir; check file ===================="
207 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
208 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
209 touch $DIR/$tdir/$tfile
210 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
212 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
214 run_test 3 "mkdir; touch; rmdir; check dir ====================="
216 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
220 test_mkdir $DIR/$tdir ||
221 error "Create remote directory failed"
223 touch $DIR/$tdir/$tfile ||
224 error "Create file under remote directory failed"
227 error "Expect error removing in-use dir $DIR/$tdir"
229 test -d $DIR/$tdir || error "Remote directory disappeared"
231 rm -rf $DIR/$tdir || error "remove remote dir error"
233 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
236 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
237 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
238 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
239 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
240 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
242 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
245 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
246 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
247 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
248 error "$tfile does not have perm 0666 or UID $UID"
249 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
250 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
251 error "$tfile should be 0666 and owned by UID $UID"
253 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
256 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
258 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
259 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
260 error "$tfile should be owned by UID $RUNAS_ID"
261 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
262 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
263 error "$tfile should be owned by UID $RUNAS_ID"
265 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
268 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
270 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
271 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
272 error "$tfile should be owned by GID $UID"
273 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
274 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
275 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
277 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
280 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
281 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
282 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
283 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
284 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
285 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
286 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
287 error "$tdir/d/subdir should be GID $RUNAS_GID"
288 if [[ $MDSCOUNT -gt 1 ]]; then
289 # check remote dir sgid inherite
290 $LFS mkdir -i 0 $DIR/$tdir.local ||
291 error "mkdir $tdir.local failed"
292 chmod g+s $DIR/$tdir.local ||
293 error "chmod $tdir.local failed"
294 chgrp $RUNAS_GID $DIR/$tdir.local ||
295 error "chgrp $tdir.local failed"
296 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
297 error "mkdir $tdir.remote failed"
298 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
299 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
300 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
301 error "$tdir.remote should be mode 02755"
304 run_test 6g "Is new dir in sgid dir inheriting group?"
306 test_6h() { # bug 7331
307 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
308 touch $DIR/$tfile || error "touch failed"
309 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
310 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
311 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
312 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
313 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
315 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
318 test_mkdir $DIR/$tdir
319 $MCREATE $DIR/$tdir/$tfile
320 chmod 0666 $DIR/$tdir/$tfile
321 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
322 error "$tdir/$tfile should be mode 0666"
324 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
327 if [ ! -d $DIR/$tdir ]; then
328 test_mkdir $DIR/$tdir
330 $MCREATE $DIR/$tdir/$tfile
331 echo -n foo > $DIR/$tdir/$tfile
332 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
333 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
335 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
338 test_mkdir $DIR/$tdir
339 touch $DIR/$tdir/$tfile
340 chmod 0666 $DIR/$tdir/$tfile
341 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
342 error "$tfile mode not 0666"
344 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
347 test_mkdir $DIR/$tdir
348 test_mkdir $DIR/$tdir/d2
349 test_mkdir $DIR/$tdir/d2/d3
350 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
352 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
355 test_mkdir $DIR/$tdir
356 test_mkdir $DIR/$tdir/d2
357 touch $DIR/$tdir/d2/$tfile
358 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
359 error "$tdir/d2/$tfile not a file"
361 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
364 test_mkdir $DIR/$tdir
365 test_mkdir $DIR/$tdir/d2
366 chmod 0666 $DIR/$tdir/d2
367 chmod 0705 $DIR/$tdir/d2
368 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
369 error "$tdir/d2 mode not 0705"
371 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
376 chmod 0666 $DIR/$tdir/$tfile
377 chmod 0654 $DIR/$tdir/$tfile
378 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
379 error "$tdir/d2 mode not 0654"
381 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
384 test_mkdir $DIR/$tdir
385 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
387 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
388 error "$tdir/$tfile size not 0 after truncate"
390 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
393 test_mkdir $DIR/$tdir
394 touch $DIR/$tdir/$tfile
396 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
398 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
401 test_mkdir $DIR/$tdir
402 touch $DIR/$tdir/$tfile
403 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
404 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
405 error "$tdir/${tfile_2} not a file after rename"
406 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
408 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
411 test_mkdir $DIR/$tdir
412 touch $DIR/$tdir/$tfile
413 rm -rf $DIR/$tdir/$tfile
414 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
416 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
419 test_mkdir -p $DIR/$tdir
420 touch $DIR/$tdir/$tfile
421 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
423 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
424 error "$tdir/l-exist not a symlink"
425 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
426 error "$tdir/l-exist not referencing a file"
427 rm -f $DIR/$tdir/l-exist
428 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
430 run_test 17a "symlinks: create, remove (real) =================="
433 test_mkdir -p $DIR/$tdir
434 ln -s no-such-file $DIR/$tdir/l-dangle
436 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
437 error "$tdir/l-dangle not referencing no-such-file"
438 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
439 error "$tdir/l-dangle not referencing non-existent file"
440 rm -f $DIR/$tdir/l-dangle
441 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
443 run_test 17b "symlinks: create, remove (dangling) =============="
445 test_17c() { # bug 3440 - don't save failed open RPC for replay
446 test_mkdir -p $DIR/$tdir
447 ln -s foo $DIR/$tdir/$tfile
448 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
450 run_test 17c "symlinks: open dangling (should return error) ===="
453 test_mkdir -p $DIR/$tdir
454 ln -s foo $DIR/$tdir/$tfile
455 touch $DIR/$tdir/$tfile || error "creating to new symlink"
457 run_test 17d "symlinks: create dangling ========================"
460 test_mkdir -p $DIR/$tdir
461 local foo=$DIR/$tdir/$tfile
462 ln -s $foo $foo || error "create symlink failed"
463 ls -l $foo || error "ls -l failed"
464 ls $foo && error "ls not failed" || true
466 run_test 17e "symlinks: create recursive symlink (should return error) ===="
469 test_mkdir -p $DIR/$tdir
470 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
471 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
472 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
473 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
474 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
475 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
478 run_test 17f "symlinks: long and very long symlink name ========================"
480 # str_repeat(S, N) generate a string that is string S repeated N times
485 while [ $((n -= 1)) -ge 0 ]; do
491 # Long symlinks and LU-2241
493 test_mkdir -p $DIR/$tdir
494 local TESTS="59 60 61 4094 4095"
496 # Fix for inode size boundary in 2.1.4
497 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
500 # Patch not applied to 2.2 or 2.3 branches
501 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
502 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
505 # skip long symlink name for rhel6.5.
506 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
507 grep -q '6.5' /etc/redhat-release &>/dev/null &&
508 TESTS="59 60 61 4062 4063"
511 local SYMNAME=$(str_repeat 'x' $i)
512 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
513 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
516 run_test 17g "symlinks: really long symlink name and inode boundaries"
518 test_17h() { #bug 17378
519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
522 test_mkdir -p $DIR/$tdir
523 if [[ $MDSCOUNT -gt 1 ]]; then
524 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
528 $SETSTRIPE -c -1 $DIR/$tdir
529 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
530 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
531 touch $DIR/$tdir/$tfile || true
533 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
535 test_17i() { #bug 20018
536 remote_mds_nodsh && skip "remote MDS with nodsh" && return
537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
538 test_mkdir -c1 $DIR/$tdir
539 local foo=$DIR/$tdir/$tfile
541 if [[ $MDSCOUNT -gt 1 ]]; then
542 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
546 ln -s $foo $foo || error "create symlink failed"
547 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
548 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
549 ls -l $foo && error "error not detected"
552 run_test 17i "don't panic on short symlink"
554 test_17k() { #bug 22301
555 [[ -z "$(which rsync 2>/dev/null)" ]] &&
556 skip "no rsync command" && return 0
557 rsync --help | grep -q xattr ||
558 skip_env "$(rsync --version | head -n1) does not support xattrs"
559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
560 test_mkdir -p $DIR/$tdir
561 test_mkdir -p $DIR/$tdir.new
562 touch $DIR/$tdir/$tfile
563 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
564 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
565 error "rsync failed with xattrs enabled"
567 run_test 17k "symlinks: rsync with xattrs enabled ========================="
569 test_17l() { # LU-279
570 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
571 skip "no getfattr command" && return 0
572 test_mkdir -p $DIR/$tdir
573 touch $DIR/$tdir/$tfile
574 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
575 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
576 # -h to not follow symlinks. -m '' to list all the xattrs.
577 # grep to remove first line: '# file: $path'.
578 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
580 lgetxattr_size_check $path $xattr ||
581 error "lgetxattr_size_check $path $xattr failed"
585 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
589 local short_sym="0123456789"
590 local WDIR=$DIR/${tdir}m
593 remote_mds_nodsh && skip "remote MDS with nodsh" && return
594 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
595 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
596 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
598 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
599 skip "ldiskfs only test" && return 0
601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
605 # create a long symlink file
606 for ((i = 0; i < 4; ++i)); do
607 long_sym=${long_sym}${long_sym}
610 echo "create 512 short and long symlink files under $WDIR"
611 for ((i = 0; i < 256; ++i)); do
612 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
613 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
619 wait_delete_completed
621 echo "recreate the 512 symlink files with a shorter string"
622 for ((i = 0; i < 512; ++i)); do
623 # rewrite the symlink file with a shorter string
624 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
625 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
628 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
629 local devname=$(mdsdevname $mds_index)
631 echo "stop and checking mds${mds_index}:"
632 # e2fsck should not return error
634 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
637 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
638 df $MOUNT > /dev/null 2>&1
640 error "e2fsck detected error for short/long symlink: rc=$rc"
642 run_test 17m "run e2fsck against MDT which contains short/long symlink"
644 check_fs_consistency_17n() {
648 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
649 # so it only check MDT1/MDT2 instead of all of MDTs.
650 for mdt_index in 1 2; do
651 local devname=$(mdsdevname $mdt_index)
652 # e2fsck should not return error
654 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
657 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
658 error "mount mds$mdt_index failed"
659 df $MOUNT > /dev/null 2>&1
667 remote_mds_nodsh && skip "remote MDS with nodsh" && return
668 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
669 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
670 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
672 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
673 skip "ldiskfs only test" && return 0
675 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
679 test_mkdir $DIR/$tdir
680 for ((i=0; i<10; i++)); do
681 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
682 error "create remote dir error $i"
683 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
684 error "create files under remote dir failed $i"
687 check_fs_consistency_17n ||
688 error "e2fsck report error after create files under remote dir"
690 for ((i = 0; i < 10; i++)); do
691 rm -rf $DIR/$tdir/remote_dir_${i} ||
692 error "destroy remote dir error $i"
695 check_fs_consistency_17n ||
696 error "e2fsck report error after unlink files under remote dir"
698 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
699 skip "lustre < 2.4.50 does not support migrate mv " && return
701 for ((i = 0; i < 10; i++)); do
702 mkdir -p $DIR/$tdir/remote_dir_${i}
703 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
704 error "create files under remote dir failed $i"
705 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
706 error "migrate remote dir error $i"
708 check_fs_consistency_17n || error "e2fsck report error after migration"
710 for ((i = 0; i < 10; i++)); do
711 rm -rf $DIR/$tdir/remote_dir_${i} ||
712 error "destroy remote dir error $i"
715 check_fs_consistency_17n || error "e2fsck report error after unlink"
717 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
720 remote_mds_nodsh && skip "remote MDS with nodsh" && return
721 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
722 skip "Need MDS version at least 2.3.64" && return
724 local WDIR=$DIR/${tdir}o
730 mdt_index=$($LFS getstripe -M $WDIR/$tfile)
731 mdt_index=$((mdt_index+1))
734 #fail mds will wait the failover finish then set
735 #following fail_loc to avoid interfer the recovery process.
738 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
739 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
740 ls -l $WDIR/$tfile && rc=1
741 do_facet mds${mdt_index} lctl set_param fail_loc=0
742 [[ $rc -ne 0 ]] && error "stat file should fail"
745 run_test 17o "stat file with incompat LMA feature"
748 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
749 ls $DIR || error "Failed to ls $DIR: $?"
751 run_test 18 "touch .../f ; ls ... =============================="
757 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
759 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
762 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
764 run_test 19b "ls -l .../f19 (should return error) =============="
767 [ $RUNAS_ID -eq $UID ] &&
768 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
769 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
771 run_test 19c "$RUNAS touch .../f19 (should return error) =="
774 cat $DIR/f19 && error || true
776 run_test 19d "cat .../f19 (should return error) =============="
785 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
787 run_test 20 "touch .../f ; ls -l ... ==========================="
790 test_mkdir -p $DIR/$tdir
791 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
792 ln -s dangle $DIR/$tdir/link
793 echo foo >> $DIR/$tdir/link
794 cat $DIR/$tdir/dangle
795 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
796 $CHECKSTAT -f -t file $DIR/$tdir/link ||
797 error "$tdir/link not linked to a file"
799 run_test 21 "write to dangling link ============================"
803 test_mkdir -p $DIR/$tdir
804 chown $RUNAS_ID:$RUNAS_GID $WDIR
805 (cd $WDIR || error "cd $WDIR failed";
806 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
808 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
809 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
810 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
812 run_test 22 "unpack tar archive as non-root user ==============="
816 test_mkdir -p $DIR/$tdir
817 local file=$DIR/$tdir/$tfile
819 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
820 openfile -f O_CREAT:O_EXCL $file &&
821 error "$file recreate succeeded" || true
823 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
825 test_23b() { # bug 18988
826 test_mkdir -p $DIR/$tdir
827 local file=$DIR/$tdir/$tfile
830 echo foo > $file || error "write filed"
831 echo bar >> $file || error "append filed"
832 $CHECKSTAT -s 8 $file || error "wrong size"
835 run_test 23b "O_APPEND check =========================="
837 # LU-11069 file offset is correct after appending writes
839 local file=$DIR/$tfile
842 echo CentaurHauls > $file
843 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
844 if ((offset != 26)); then
845 error "wrong offset, expected 26, got '$offset'"
848 run_test 23d "file offset is correct after appending writes"
852 echo '-- same directory rename'
853 test_mkdir $DIR/$tdir
854 touch $DIR/$tdir/$tfile.1
855 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
856 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
858 run_test 24a "rename file to non-existent target"
861 test_mkdir $DIR/$tdir
862 touch $DIR/$tdir/$tfile.{1,2}
863 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
864 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
865 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
867 run_test 24b "rename file to existing target"
870 test_mkdir $DIR/$tdir
871 test_mkdir $DIR/$tdir/d$testnum.1
872 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
873 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
874 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
876 run_test 24c "rename directory to non-existent target"
879 test_mkdir -c1 $DIR/$tdir
880 test_mkdir -c1 $DIR/$tdir/d$testnum.1
881 test_mkdir -c1 $DIR/$tdir/d$testnum.2
882 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
883 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
884 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
886 run_test 24d "rename directory to existing target"
889 echo '-- cross directory renames --'
893 mv $DIR/R5a/f $DIR/R5b/g
894 $CHECKSTAT -a $DIR/R5a/f || error
895 $CHECKSTAT -t file $DIR/R5b/g || error
897 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
902 touch $DIR/R6a/f $DIR/R6b/g
903 mv $DIR/R6a/f $DIR/R6b/g
904 $CHECKSTAT -a $DIR/R6a/f || error
905 $CHECKSTAT -t file $DIR/R6b/g || error
907 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
912 test_mkdir $DIR/R7a/d
913 mv $DIR/R7a/d $DIR/R7b/e
914 $CHECKSTAT -a $DIR/R7a/d || error
915 $CHECKSTAT -t dir $DIR/R7b/e || error
917 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
920 test_mkdir -c1 $DIR/R8a
921 test_mkdir -c1 $DIR/R8b
922 test_mkdir -c1 $DIR/R8a/d
923 test_mkdir -c1 $DIR/R8b/e
924 mrename $DIR/R8a/d $DIR/R8b/e
925 $CHECKSTAT -a $DIR/R8a/d || error
926 $CHECKSTAT -t dir $DIR/R8b/e || error
928 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
931 echo "-- rename error cases"
935 mrename $DIR/R9/f $DIR/R9/a
936 $CHECKSTAT -t file $DIR/R9/f || error
937 $CHECKSTAT -t dir $DIR/R9/a || error
938 $CHECKSTAT -a $DIR/R9/a/f || error
940 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
944 mrename $DIR/R10/f $DIR/R10/g
945 $CHECKSTAT -t dir $DIR/R10 || error
946 $CHECKSTAT -a $DIR/R10/f || error
947 $CHECKSTAT -a $DIR/R10/g || error
949 run_test 24j "source does not exist ============================"
953 test_mkdir $DIR/R11a/d
955 mv $DIR/R11a/f $DIR/R11a/d
956 $CHECKSTAT -a $DIR/R11a/f || error
957 $CHECKSTAT -t file $DIR/R11a/d/f || error
959 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
961 # bug 2429 - rename foo foo foo creates invalid file
964 $MULTIOP $f OcNs || error
966 run_test 24l "Renaming a file to itself ========================"
970 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
971 # on ext3 this does not remove either the source or target files
972 # though the "expected" operation would be to remove the source
973 $CHECKSTAT -t file ${f} || error "${f} missing"
974 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
976 run_test 24m "Renaming a file to a hard link to itself ========="
980 # this stats the old file after it was renamed, so it should fail
984 $CHECKSTAT ${f}.rename
987 run_test 24n "Statting the old file after renaming (Posix rename 2)"
990 test_mkdir -p $DIR/d24o
991 rename_many -s random -v -n 10 $DIR/d24o
993 run_test 24o "rename of files during htree split ==============="
998 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
999 mrename $DIR/R12a $DIR/R12b
1000 $CHECKSTAT -a $DIR/R12a || error
1001 $CHECKSTAT -t dir $DIR/R12b || error
1002 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1003 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1005 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1007 cleanup_multiop_pause() {
1009 kill -USR1 $MULTIPID
1013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1014 test_mkdir $DIR/R13a
1015 test_mkdir $DIR/R13b
1016 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1017 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1020 trap cleanup_multiop_pause EXIT
1021 mrename $DIR/R13a $DIR/R13b
1022 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1023 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1024 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1025 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1026 cleanup_multiop_pause
1027 wait $MULTIPID || error "multiop close failed"
1029 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1031 test_24r() { #bug 3789
1032 test_mkdir $DIR/R14a
1033 test_mkdir $DIR/R14a/b
1034 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1035 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1036 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1038 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1041 test_mkdir $DIR/R15a
1042 test_mkdir $DIR/R15a/b
1043 test_mkdir $DIR/R15a/b/c
1044 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1045 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1046 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1048 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1050 test_mkdir $DIR/R16a
1051 test_mkdir $DIR/R16a/b
1052 test_mkdir $DIR/R16a/b/c
1053 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1054 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1055 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1057 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1059 test_24u() { # bug12192
1060 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1061 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1063 run_test 24u "create stripe file"
1067 size=$(getconf PAGE_SIZE 2>/dev/null)
1068 echo -n ${size:-4096}
1071 simple_cleanup_common() {
1074 [ -z "$DIR" -o -z "$tdir" ] && return 0
1076 local start=$SECONDS
1079 wait_delete_completed
1080 echo "cleanup time $((SECONDS - start))"
1084 max_pages_per_rpc() {
1085 local mdtname="$(printf "MDT%04x" ${1:-0})"
1086 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1091 local nrfiles=${COUNT:-100000}
1092 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1093 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1095 local fname="$DIR/$tdir/$tfile"
1096 test_mkdir "$(dirname $fname)"
1097 # assume MDT0000 has the fewest inodes
1098 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1099 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1100 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1102 trap simple_cleanup_common EXIT
1104 createmany -m "$fname" $nrfiles
1106 cancel_lru_locks mdc
1107 lctl set_param mdc.*.stats clear
1109 # was previously test_24D: LU-6101
1110 # readdir() returns correct number of entries after cursor reload
1111 local num_ls=$(ls $DIR/$tdir | wc -l)
1112 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1113 local num_all=$(ls -a $DIR/$tdir | wc -l)
1114 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1115 $num_all -ne $((nrfiles + 2)) ]; then
1116 error "Expected $nrfiles files, got $num_ls " \
1117 "($num_uniq unique $num_all .&..)"
1119 # LU-5 large readdir
1120 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1121 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1122 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1123 # take into account of overhead in lu_dirpage header and end mark in
1124 # each page, plus one in rpc_num calculation.
1125 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1126 local page_entries=$((($(page_size) - 24) / dirent_size))
1127 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1128 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1129 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1130 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1131 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1132 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1133 error "large readdir doesn't take effect: " \
1134 "$mds_readpage should be about $rpc_max"
1136 simple_cleanup_common
1138 run_test 24v "list large directory (test hash collision, b=17560)"
1140 test_24w() { # bug21506
1142 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1143 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1144 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1145 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1146 [[ "$SZ1" -eq "$SZ2" ]] ||
1147 error "Error reading at the end of the file $tfile"
1149 run_test 24w "Reading a file larger than 4Gb"
1152 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1154 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1155 skip "Need MDS version at least 2.7.56" && return
1157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1159 local remote_dir=$DIR/$tdir/remote_dir
1161 test_mkdir -p $DIR/$tdir
1162 $LFS mkdir -i $MDTIDX $remote_dir ||
1163 error "create remote directory failed"
1165 test_mkdir -p $DIR/$tdir/src_dir
1166 touch $DIR/$tdir/src_file
1167 test_mkdir -p $remote_dir/tgt_dir
1168 touch $remote_dir/tgt_file
1170 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1171 error "rename dir cross MDT failed!"
1173 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1174 error "rename file cross MDT failed!"
1176 touch $DIR/$tdir/ln_file
1177 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1178 error "ln file cross MDT failed"
1180 rm -rf $DIR/$tdir || error "Can not delete directories"
1182 run_test 24x "cross MDT rename/link"
1185 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1188 local remote_dir=$DIR/$tdir/remote_dir
1190 test_mkdir -p $DIR/$tdir
1191 $LFS mkdir -i $MDTIDX $remote_dir ||
1192 error "create remote directory failed"
1194 test_mkdir -p $remote_dir/src_dir
1195 touch $remote_dir/src_file
1196 test_mkdir -p $remote_dir/tgt_dir
1197 touch $remote_dir/tgt_file
1199 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1200 error "rename subdir in the same remote dir failed!"
1202 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1203 error "rename files in the same remote dir failed!"
1205 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1206 error "link files in the same remote dir failed!"
1208 rm -rf $DIR/$tdir || error "Can not delete directories"
1210 run_test 24y "rename/link on the same dir should succeed"
1212 test_24A() { # LU-3182
1216 test_mkdir -p $DIR/$tdir
1217 trap simple_cleanup_common EXIT
1218 createmany -m $DIR/$tdir/$tfile $NFILES
1219 local t=$(ls $DIR/$tdir | wc -l)
1220 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1221 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1222 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1223 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1226 simple_cleanup_common || error "Can not delete directories"
1228 run_test 24A "readdir() returns correct number of entries."
1230 test_24B() { # LU-4805
1231 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1234 test_mkdir $DIR/$tdir
1235 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1236 error "create striped dir failed"
1238 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1239 [ $count -eq 2 ] || error "Expected 2, got $count"
1241 touch $DIR/$tdir/striped_dir/a
1243 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1244 [ $count -eq 3 ] || error "Expected 3, got $count"
1246 touch $DIR/$tdir/striped_dir/.f
1248 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1249 [ $count -eq 4 ] || error "Expected 4, got $count"
1251 rm -rf $DIR/$tdir || error "Can not delete directories"
1253 run_test 24B "readdir for striped dir return correct number of entries"
1256 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1262 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1263 error "create striped dir failed"
1265 cd $DIR/$tdir/d0/striped_dir
1267 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1268 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1269 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1271 [ "$d0_ino" = "$parent_ino" ] ||
1272 error ".. wrong, expect $d0_ino, get $parent_ino"
1274 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1275 error "mv striped dir failed"
1277 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1279 [ "$d1_ino" = "$parent_ino" ] ||
1280 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1282 run_test 24C "check .. in striped dir"
1285 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1289 mkdir $DIR/$tdir/src_dir
1290 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1291 error "create remote source failed"
1293 touch $DIR/$tdir/src_dir/src_child/a
1295 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1296 error "create remote target dir failed"
1298 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1299 error "create remote target child failed"
1301 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1302 error "rename dir cross MDT failed!"
1306 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1307 error "src_child still exists after rename"
1309 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1310 error "missing file(a) after rename"
1312 rm -rf $DIR/$tdir || error "Can not delete directories"
1314 run_test 24E "cross MDT rename/link"
1317 echo '== symlink sanity ============================================='
1321 touch $DIR/s25/foo || error
1323 run_test 25a "create file in symlinked directory ==============="
1326 [ ! -d $DIR/d25 ] && test_25a
1327 $CHECKSTAT -t file $DIR/s25/foo || error
1329 run_test 25b "lookup file in symlinked directory ==============="
1333 test_mkdir $DIR/d26/d26-2
1334 ln -s d26/d26-2 $DIR/s26
1335 touch $DIR/s26/foo || error
1337 run_test 26a "multiple component symlink ======================="
1340 test_mkdir -p $DIR/d26b/d26-2
1341 ln -s d26b/d26-2/foo $DIR/s26-2
1342 touch $DIR/s26-2 || error
1344 run_test 26b "multiple component symlink at end of lookup ======"
1347 test_mkdir $DIR/d26.2
1348 touch $DIR/d26.2/foo
1349 ln -s d26.2 $DIR/s26.2-1
1350 ln -s s26.2-1 $DIR/s26.2-2
1351 ln -s s26.2-2 $DIR/s26.2-3
1352 chmod 0666 $DIR/s26.2-3/foo
1354 run_test 26c "chain of symlinks ================================"
1356 # recursive symlinks (bug 439)
1358 ln -s d26-3/foo $DIR/d26-3
1360 run_test 26d "create multiple component recursive symlink ======"
1363 [ ! -h $DIR/d26-3 ] && test_26d
1366 run_test 26e "unlink multiple component recursive symlink ======"
1368 # recursive symlinks (bug 7022)
1370 test_mkdir -p $DIR/$tdir
1371 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1372 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1373 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1374 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1375 cd $tfile || error "cd $tfile failed"
1376 ln -s .. dotdot || error "ln dotdot failed"
1377 ln -s dotdot/lndir lndir || error "ln lndir failed"
1378 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1379 output=`ls $tfile/$tfile/lndir/bar1`
1380 [ "$output" = bar1 ] && error "unexpected output"
1381 rm -r $tfile || error "rm $tfile failed"
1382 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1384 run_test 26f "rm -r of a directory which has recursive symlink"
1387 test_mkdir -p $DIR/d27 || error "mkdir failed"
1388 $LFS getstripe $DIR/d27
1389 $LFS setstripe -c 1 $DIR/d27/f0 || error "setstripe failed"
1390 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1391 cp /etc/hosts $DIR/d27/f0 || error
1393 run_test 27a "one stripe file"
1396 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1397 test_mkdir -p $DIR/d27
1398 $LFS setstripe -c 2 $DIR/d27/f01 || error "setstripe failed"
1399 $LFS getstripe -c $DIR/d27/f01
1400 [ $($LFS getstripe -c $DIR/d27/f01) -eq 2 ] ||
1401 error "two-stripe file doesn't have two stripes"
1403 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1405 run_test 27b "create and write to two stripe file"
1408 test_mkdir -p $DIR/d27
1409 $LFS setstripe -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1410 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1411 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1413 run_test 27d "create file with default settings"
1416 # LU-5839 adds check for existed layout before setting it
1417 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1418 skip "Need MDS version at least 2.7.56" && return
1419 test_mkdir -p $DIR/d27
1420 $LFS setstripe -c 2 $DIR/d27/f12 || error "setstripe failed"
1421 $LFS setstripe -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1422 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1424 run_test 27e "setstripe existing file (should return error)"
1427 test_mkdir $DIR/$tdir
1428 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1429 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1430 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1431 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1432 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1433 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1435 run_test 27f "setstripe with bad stripe size (should return error)"
1438 test_mkdir -p $DIR/d27
1439 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1440 $LFS getstripe $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1441 error "$DIR/d27/fnone has object"
1443 run_test 27g "$LFS getstripe with no objects"
1446 test_mkdir $DIR/$tdir
1447 touch $DIR/$tdir/$tfile || error "touch failed"
1448 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1449 error "missing objects"
1451 run_test 27i "$LFS getstripe with some objects"
1454 test_mkdir -p $DIR/d27
1455 $LFS setstripe -i $OSTCOUNT $DIR/d27/f27j &&
1456 error "setstripe failed" || true
1458 run_test 27j "setstripe with bad stripe offset (should return error)"
1460 test_27k() { # bug 2844
1461 test_mkdir -p $DIR/d27
1463 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1464 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1465 $LFS setstripe -S 67108864 $FILE || error "setstripe failed"
1466 BLKSIZE=$(stat $FILE | awk '/IO Block:/ { print $7 }')
1467 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1468 dd if=/dev/zero of=$FILE bs=4k count=1
1469 BLKSIZE=$(stat $FILE | awk '/IO Block:/ { print $7 }')
1470 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1472 run_test 27k "limit i_blksize for broken user apps"
1475 test_mkdir -p $DIR/d27
1476 mcreate $DIR/f27l || error "creating file"
1477 $RUNAS $SETSTRIPE -c 1 $DIR/f27l &&
1478 error "setstripe should have failed" || true
1480 run_test 27l "check setstripe permissions (should return error)"
1483 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1485 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1487 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1488 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1491 trap simple_cleanup_common EXIT
1492 test_mkdir -p $DIR/$tdir
1493 $LFS setstripe -i 0 -c 1 $DIR/$tdir/f27m_1
1494 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1495 error "dd should fill OST0"
1497 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1499 [ $i -gt 256 ] && break
1502 touch $DIR/$tdir/f27m_$i
1503 [ $($LFS getstripe $DIR/$tdir/f27m_$i | grep -A 10 obdidx |
1504 awk '{print $1}' | grep -w "0") ] &&
1505 error "OST0 was full but new created file still use it"
1507 touch $DIR/$tdir/f27m_$i
1508 [ $($LFS getstripe $DIR/$tdir/f27m_$i | grep -A 10 obdidx |
1509 awk '{print $1}'| grep -w "0") ] &&
1510 error "OST0 was full but new created file still use it"
1511 simple_cleanup_common
1513 run_test 27m "create file while OST0 was full"
1516 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1517 head -n 1 | awk '{print $1 * 2}')
1521 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1522 # if the OST isn't full anymore.
1524 local OSTIDX=${1:-""}
1526 local list=$(comma_list $(osts_nodes))
1527 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1529 do_nodes $list lctl set_param fail_loc=0
1530 sync # initiate all OST_DESTROYs from MDS to OST
1534 exhaust_precreations() {
1537 local FAILIDX=${3:-$OSTIDX}
1538 local ofacet=ost$((OSTIDX + 1))
1540 test_mkdir -p -c1 $DIR/$tdir
1541 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1542 local mfacet=mds$((mdtidx + 1))
1543 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1545 local OST=$(ostname_from_index $OSTIDX)
1548 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1549 local last_id=$(do_facet $mfacet lctl get_param -n \
1550 osc.$mdtosc_proc1.prealloc_last_id)
1551 local next_id=$(do_facet $mfacet lctl get_param -n \
1552 osc.$mdtosc_proc1.prealloc_next_id)
1554 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1555 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1557 test_mkdir -p $DIR/$tdir/${OST}
1558 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1559 #define OBD_FAIL_OST_ENOSPC 0x215
1560 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1561 echo "Creating to objid $last_id on ost $OST..."
1562 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1563 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1564 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1568 exhaust_all_precreations() {
1570 for (( i=0; i < OSTCOUNT; i++ )) ; do
1571 exhaust_precreations $i $1 -1
1576 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1578 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1579 remote_ost_nodsh && skip "remote OST with nodsh" && return
1582 rm -f $DIR/$tdir/$tfile
1583 exhaust_precreations 0 0x80000215
1584 $LFS setstripe -c -1 $DIR/$tdir
1585 touch $DIR/$tdir/$tfile || error
1586 $LFS getstripe $DIR/$tdir/$tfile
1589 run_test 27n "create file with some full OSTs"
1592 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1594 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1595 remote_ost_nodsh && skip "remote OST with nodsh" && return
1598 rm -f $DIR/$tdir/$tfile
1599 exhaust_all_precreations 0x215
1601 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1606 run_test 27o "create file with all full OSTs (should error)"
1609 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1611 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1612 remote_ost_nodsh && skip "remote OST with nodsh" && return
1615 rm -f $DIR/$tdir/$tfile
1616 test_mkdir -p $DIR/$tdir
1618 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1619 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1620 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1622 exhaust_precreations 0 0x80000215
1623 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1624 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1625 $LFS getstripe $DIR/$tdir/$tfile
1629 run_test 27p "append to a truncated file with some full OSTs"
1632 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1633 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1634 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1635 remote_ost_nodsh && skip "remote OST with nodsh" && return
1638 rm -f $DIR/$tdir/$tfile
1640 test_mkdir -p $DIR/$tdir
1641 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1642 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1643 error "truncate $DIR/$tdir/$tfile failed"
1644 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1646 exhaust_all_precreations 0x215
1648 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1649 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1653 run_test 27q "append to truncated file with all OSTs full (should error)"
1656 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1658 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1659 remote_ost_nodsh && skip "remote OST with nodsh" && return
1662 rm -f $DIR/$tdir/$tfile
1663 exhaust_precreations 0 0x80000215
1665 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error
1669 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1671 test_27s() { # bug 10725
1672 test_mkdir -p $DIR/$tdir
1673 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1674 local stripe_count=0
1675 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1676 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1677 error "stripe width >= 2^32 succeeded" || true
1680 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1682 test_27t() { # bug 10864
1687 $WLFS getstripe $tfile
1690 run_test 27t "check that utils parse path correctly"
1692 test_27u() { # bug 4900
1693 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1694 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1696 local list=$(comma_list $(mdts_nodes))
1698 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1699 do_nodes $list $LCTL set_param fail_loc=0x139
1700 test_mkdir -p $DIR/$tdir
1701 trap simple_cleanup_common EXIT
1702 createmany -o $DIR/$tdir/t- 1000
1703 do_nodes $list $LCTL set_param fail_loc=0
1705 TLOG=$TMP/$tfile.getstripe
1706 $LFS getstripe $DIR/$tdir > $TLOG
1707 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1708 unlinkmany $DIR/$tdir/t- 1000
1710 [[ $OBJS -gt 0 ]] &&
1711 error "$OBJS objects created on OST-0. See $TLOG" || pass
1713 run_test 27u "skip object creation on OSC w/o objects"
1715 test_27v() { # bug 4900
1716 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1718 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1719 remote_ost_nodsh && skip "remote OST with nodsh" && return
1721 exhaust_all_precreations 0x215
1724 test_mkdir $DIR/$tdir
1725 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1727 touch $DIR/$tdir/$tfile
1728 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1730 for (( i=1; i < OSTCOUNT; i++ )); do
1731 do_facet ost$i lctl set_param fail_loc=0x705
1733 local START=`date +%s`
1734 createmany -o $DIR/$tdir/$tfile 32
1736 local FINISH=`date +%s`
1737 local TIMEOUT=`lctl get_param -n timeout`
1738 local PROCESS=$((FINISH - START))
1739 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1740 error "$FINISH - $START >= $TIMEOUT / 2"
1741 sleep $((TIMEOUT / 2 - PROCESS))
1744 run_test 27v "skip object creation on slow OST"
1746 test_27w() { # bug 10997
1747 test_mkdir $DIR/$tdir || error "mkdir failed"
1748 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1749 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1750 error "stripe size $size != 65536" || true
1751 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1752 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1754 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1757 [[ $OSTCOUNT -lt 2 ]] &&
1758 skip_env "skipping multiple stripe count/offset test" && return
1760 test_mkdir $DIR/$tdir || error "mkdir failed"
1761 for i in $(seq 1 $OSTCOUNT); do
1763 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1764 error "setstripe -c $i -i $offset failed"
1765 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1766 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1767 [ $count -ne $i ] && error "stripe count $count != $i" || true
1768 [ $index -ne $offset ] &&
1769 error "stripe offset $index != $offset" || true
1772 run_test 27wa "check $LFS setstripe -c -i options"
1775 remote_ost_nodsh && skip "remote OST with nodsh" && return
1776 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1778 OFFSET=$(($OSTCOUNT - 1))
1780 local OST=$(ostname_from_index $OSTIDX)
1782 test_mkdir -p $DIR/$tdir
1783 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1784 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1786 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1787 for i in $(seq 0 $OFFSET); do
1788 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1789 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1790 error "OST0 was degraded but new created file still use it"
1792 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1794 run_test 27x "create files while OST0 is degraded"
1797 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1798 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1799 remote_ost_nodsh && skip "remote OST with nodsh" && return
1800 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1802 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1803 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1804 osc.$mdtosc.prealloc_last_id)
1805 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1806 osc.$mdtosc.prealloc_next_id)
1807 local fcount=$((last_id - next_id))
1808 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1809 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1811 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1812 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1813 local OST_DEACTIVE_IDX=-1
1818 for OSC in $MDS_OSCS; do
1819 OST=$(osc_to_ost $OSC)
1820 OSTIDX=$(index_from_ostuuid $OST)
1821 if [ $OST_DEACTIVE_IDX == -1 ]; then
1822 OST_DEACTIVE_IDX=$OSTIDX
1824 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1825 echo $OSC "is Deactivated:"
1826 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1830 OSTIDX=$(index_from_ostuuid $OST)
1831 test_mkdir -p $DIR/$tdir
1832 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1834 for OSC in $MDS_OSCS; do
1835 OST=$(osc_to_ost $OSC)
1836 OSTIDX=$(index_from_ostuuid $OST)
1837 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1838 echo $OST "is degraded:"
1839 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1840 obdfilter.$OST.degraded=1
1845 createmany -o $DIR/$tdir/$tfile $fcount
1847 for OSC in $MDS_OSCS; do
1848 OST=$(osc_to_ost $OSC)
1849 OSTIDX=$(index_from_ostuuid $OST)
1850 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1851 echo $OST "is recovered from degraded:"
1852 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1853 obdfilter.$OST.degraded=0
1855 do_facet $SINGLEMDS lctl --device %$OSC activate
1859 # all osp devices get activated, hence -1 stripe count restored
1860 local stripe_count=0
1862 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1863 # devices get activated.
1865 $LFS setstripe -c -1 $DIR/$tfile
1866 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1868 [ $stripe_count -ne $OSTCOUNT ] &&
1869 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1872 run_test 27y "create files while OST0 is degraded and the rest inactive"
1878 lmm_count=$($GETSTRIPE -c $1)
1879 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1880 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1882 local old_ifs="$IFS"
1884 fid=($($LFS path2fid $1))
1887 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1888 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1890 # compare lmm_seq and lu_fid->f_seq
1891 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1892 # compare lmm_object_id and lu_fid->oid
1893 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1895 # check the trusted.fid attribute of the OST objects of the file
1896 local have_obdidx=false
1898 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1899 # skip lines up to and including "obdidx"
1900 [ -z "$obdidx" ] && break
1901 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1902 $have_obdidx || continue
1904 local ost=$((obdidx + 1))
1905 local dev=$(ostdevname $ost)
1908 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1910 seq=$(echo $seq | sed -e "s/^0x//g")
1911 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1912 oid_hex=$(echo $oid)
1914 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1916 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1920 # Don't unmount/remount the OSTs if we don't need to do that.
1921 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1922 # update too, until that use mount/ll_decode_filter_fid/mount.
1923 # Re-enable when debugfs will understand new filter_fid.
1925 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
1926 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1927 $dev 2>/dev/null" | grep "parent=")
1929 if [ -z "$ff" ]; then
1931 mount_fstype ost$ost
1932 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1933 $(facet_mntpt ost$ost)/$obj_file)
1934 unmount_fstype ost$ost
1935 start ost$ost $dev $OST_MOUNT_OPTS
1939 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1941 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1943 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1944 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1946 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
1947 # stripe_size=1048576 component_id=1 component_start=0 \
1948 # component_end=33554432
1949 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
1950 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
1951 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
1953 if grep -q 'stripe=' <<<$ff; then
1954 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
1956 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1957 # into f_ver in this case. See comment on ff_parent.
1958 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
1961 # compare lmm_seq and filter_fid->ff_parent.f_seq
1962 [ $ff_pseq = $lmm_seq ] ||
1963 error "FF parent SEQ $ff_pseq != $lmm_seq"
1964 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1965 [ $ff_poid = $lmm_oid ] ||
1966 error "FF parent OID $ff_poid != $lmm_oid"
1967 (($ff_pstripe == $stripe_nr)) ||
1968 error "FF stripe $ff_pstripe != $stripe_nr"
1970 stripe_nr=$((stripe_nr + 1))
1971 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
1973 if grep -q 'stripe_count=' <<<$ff; then
1974 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
1975 -e 's/ .*//' <<<$ff)
1976 [ $lmm_count = $ff_scnt ] ||
1977 error "FF stripe count $lmm_count != $ff_scnt"
1983 remote_ost_nodsh && skip "remote OST with nodsh" && return
1984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1985 test_mkdir -p $DIR/$tdir
1987 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1988 { error "setstripe -c -1 failed"; return 1; }
1989 # We need to send a write to every object to get parent FID info set.
1990 # This _should_ also work for setattr, but does not currently.
1991 # touch $DIR/$tdir/$tfile-1 ||
1992 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1993 { error "dd $tfile-1 failed"; return 2; }
1994 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1995 { error "setstripe -c -1 failed"; return 3; }
1996 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1997 { error "dd $tfile-2 failed"; return 4; }
1999 # make sure write RPCs have been sent to OSTs
2002 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2003 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2005 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2007 test_27A() { # b=19102
2008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2009 local restore_size=$($GETSTRIPE -S $MOUNT)
2010 local restore_count=$($GETSTRIPE -c $MOUNT)
2011 local restore_offset=$($GETSTRIPE -i $MOUNT)
2012 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
2013 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2014 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2015 local default_size=$($GETSTRIPE -S $MOUNT)
2016 local default_offset=$($GETSTRIPE -i $MOUNT)
2017 local dsize=$((1024 * 1024))
2018 [ $default_size -eq $dsize ] ||
2019 error "stripe size $default_size != $dsize"
2020 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
2021 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
2023 run_test 27A "check filesystem-wide default LOV EA values"
2025 test_27B() { # LU-2523
2026 test_mkdir -p $DIR/$tdir
2027 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2029 # open f1 with O_LOV_DELAY_CREATE
2031 # call setstripe ioctl on open file descriptor for f1
2033 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2037 # open f1 with O_LOV_DELAY_CREATE
2039 # call setstripe ioctl on open file descriptor for f1
2041 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2043 # Allow multiop to fail in imitation of NFS's busted semantics.
2046 run_test 27B "call setstripe on open unlinked file/rename victim"
2048 test_27C() { #LU-2871
2049 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2057 test_mkdir -p $DIR/$tdir
2059 for i in $(seq 0 $((OSTCOUNT - 1))); do
2060 # set stripe across all OSTs starting from OST$i
2061 $SETSTRIPE -i $i -c -1 $tfile$i
2062 # get striping information
2063 ost_idx=($($GETSTRIPE $tfile$i |
2064 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2068 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2069 error "${#ost_idx[@]} != $OSTCOUNT"
2071 for index in $(seq 0 $((OSTCOUNT - 1))); do
2073 for j in $(echo ${ost_idx[@]}); do
2074 if [ $index -eq $j ]; then
2080 error "Can not find $index in ${ost_idx[@]}"
2084 run_test 27C "check full striping across all OSTs"
2087 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2088 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2089 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2090 local POOL=${POOL:-testpool}
2092 local last_ost=$(($OSTCOUNT - 1))
2094 local ost_list=$(seq $first_ost $ost_step $last_ost)
2095 local ost_range="$first_ost $last_ost $ost_step"
2097 if ! combined_mgs_mds ; then
2101 test_mkdir -p $DIR/$tdir
2102 pool_add $POOL || error "pool_add failed"
2103 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2106 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2108 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2109 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2110 skip27D+=" -s 30,31"
2111 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2112 error "llapi_layout_test failed"
2114 destroy_test_pools || error "destroy test pools failed"
2116 if ! combined_mgs_mds ; then
2120 run_test 27D "validate llapi_layout API"
2122 # Verify that default_easize is increased from its initial value after
2123 # accessing a widely striped file.
2125 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2126 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2127 skip "client does not have LU-3338 fix" && return
2129 # 72 bytes is the minimum space required to store striping
2130 # information for a file striped across one OST:
2131 # (sizeof(struct lov_user_md_v3) +
2132 # sizeof(struct lov_user_ost_data_v1))
2134 $LCTL set_param -n llite.*.default_easize $min_easize ||
2135 error "lctl set_param failed"
2136 local easize=$($LCTL get_param -n llite.*.default_easize)
2138 [ $easize -eq $min_easize ] ||
2139 error "failed to set default_easize"
2141 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2142 error "setstripe failed"
2146 easize=$($LCTL get_param -n llite.*.default_easize)
2148 [ $easize -gt $min_easize ] ||
2149 error "default_easize not updated"
2151 run_test 27E "check that default extended attribute size properly increases"
2153 test_27F() { # LU-5346/LU-7975
2154 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2156 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2157 skip "Need MDS version at least 2.8.51" && return
2158 remote_ost_nodsh && skip "remote OST with nodsh" && return
2160 test_mkdir -p $DIR/$tdir
2162 $SETSTRIPE -c 2 $DIR/$tdir
2164 # stop all OSTs to reproduce situation for LU-7975 ticket
2165 for num in $(seq $OSTCOUNT); do
2169 # open/create f0 with O_LOV_DELAY_CREATE
2170 # truncate f0 to a non-0 size
2172 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2174 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2175 # open/write it again to force delayed layout creation
2176 cat /etc/hosts > $DIR/$tdir/f0 &
2180 for num in $(seq $OSTCOUNT); do
2181 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2182 error "ost$num failed to start"
2185 wait $catpid || error "cat failed"
2187 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2188 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2191 run_test 27F "Client resend delayed layout creation with non-zero size"
2193 test_27G() { #LU-10629
2194 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2195 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2196 local POOL=${POOL:-testpool}
2197 local ostrange="0 0 1"
2199 test_mkdir $DIR/$tdir
2200 pool_add $POOL || error "pool_add failed"
2201 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2202 $LFS setstripe -p $POOL $DIR/$tdir
2204 local pool=$($LFS getstripe -p $DIR/$tdir)
2206 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2208 $LFS setstripe -d $DIR/$tdir
2210 pool=$($LFS getstripe -p $DIR/$tdir)
2214 [ -z "$pool" ] || error "'$pool' is not empty"
2216 run_test 27G "Clear OST pool from stripe"
2218 # createtest also checks that device nodes are created and
2219 # then visible correctly (#2091)
2220 test_28() { # bug 2091
2222 $CREATETEST $DIR/d28/ct || error
2224 run_test 28 "create/mknod/mkdir with bad file types ============"
2227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2228 sync; sleep 1; sync # flush out any dirty pages from previous tests
2235 declare -i LOCKCOUNTORIG=0
2236 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2237 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2239 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2241 declare -i LOCKUNUSEDCOUNTORIG=0
2242 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2243 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2250 declare -i LOCKCOUNTCURRENT=0
2251 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2252 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2255 declare -i LOCKUNUSEDCOUNTCURRENT=0
2256 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2257 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2260 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2261 $LCTL set_param -n ldlm.dump_namespaces ""
2262 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2263 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2264 log "dumped log to $TMP/test_29.dk (bug 5793)"
2267 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2268 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2269 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2270 log "dumped log to $TMP/test_29.dk (bug 5793)"
2274 run_test 29 "IT_GETATTR regression ============================"
2276 test_30a() { # was test_30
2277 cp $(which ls) $DIR || cp /bin/ls $DIR
2281 run_test 30a "execute binary from Lustre (execve) =============="
2284 cp `which ls` $DIR || cp /bin/ls $DIR
2286 $RUNAS $DIR/ls / || error
2289 run_test 30b "execute binary from Lustre as non-root ==========="
2291 test_30c() { # b=22376
2292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2293 cp `which ls` $DIR || cp /bin/ls $DIR
2295 cancel_lru_locks mdc
2296 cancel_lru_locks osc
2297 $RUNAS $DIR/ls / || error
2300 run_test 30c "execute binary from Lustre without read perms ===="
2303 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2304 $CHECKSTAT -a $DIR/f31 || error
2306 run_test 31a "open-unlink file =================================="
2309 touch $DIR/f31 || error
2310 ln $DIR/f31 $DIR/f31b || error
2311 $MULTIOP $DIR/f31b Ouc || error
2312 $CHECKSTAT -t file $DIR/f31 || error
2314 run_test 31b "unlink file with multiple links while open ======="
2317 touch $DIR/f31 || error
2318 ln $DIR/f31 $DIR/f31c || error
2319 multiop_bg_pause $DIR/f31 O_uc || return 1
2321 $MULTIOP $DIR/f31c Ouc
2322 kill -USR1 $MULTIPID
2325 run_test 31c "open-unlink file with multiple links ============="
2328 opendirunlink $DIR/d31d $DIR/d31d || error
2329 $CHECKSTAT -a $DIR/d31d || error
2331 run_test 31d "remove of open directory ========================="
2333 test_31e() { # bug 2904
2334 openfilleddirunlink $DIR/d31e || error
2336 run_test 31e "remove of open non-empty directory ==============="
2338 test_31f() { # bug 4554
2339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2341 test_mkdir $DIR/d31f
2342 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2343 cp /etc/hosts $DIR/d31f
2345 $GETSTRIPE $DIR/d31f/hosts
2346 multiop_bg_pause $DIR/d31f D_c || return 1
2349 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2350 test_mkdir $DIR/d31f
2351 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2352 cp /etc/hosts $DIR/d31f
2354 $GETSTRIPE $DIR/d31f/hosts
2355 multiop_bg_pause $DIR/d31f D_c || return 1
2358 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2359 wait $MULTIPID || error "first opendir $MULTIPID failed"
2363 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2364 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2367 run_test 31f "remove of open directory with open-unlink file ==="
2370 echo "-- cross directory link --"
2371 test_mkdir -c1 $DIR/${tdir}ga
2372 test_mkdir -c1 $DIR/${tdir}gb
2373 touch $DIR/${tdir}ga/f
2374 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2375 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2376 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2377 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2378 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2380 run_test 31g "cross directory link==============="
2383 echo "-- cross directory link --"
2384 test_mkdir -c1 $DIR/${tdir}
2385 test_mkdir -c1 $DIR/${tdir}/dir
2386 touch $DIR/${tdir}/f
2387 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2388 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2389 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2390 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2391 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2393 run_test 31h "cross directory link under child==============="
2396 echo "-- cross directory link --"
2397 test_mkdir -c1 $DIR/$tdir
2398 test_mkdir -c1 $DIR/$tdir/dir
2399 touch $DIR/$tdir/dir/f
2400 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2401 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2402 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2403 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2404 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2406 run_test 31i "cross directory link under parent==============="
2409 test_mkdir -c1 -p $DIR/$tdir
2410 test_mkdir -c1 -p $DIR/$tdir/dir1
2411 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2412 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2413 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2414 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2417 run_test 31j "link for directory==============="
2420 test_mkdir -c1 -p $DIR/$tdir
2422 touch $DIR/$tdir/exist
2423 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2424 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2425 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2426 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2427 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2428 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2429 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2432 run_test 31k "link to file: the same, non-existing, dir==============="
2438 touch $DIR/d31m2/exist
2439 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2440 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2441 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2442 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2443 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2444 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2447 run_test 31m "link to file: the same, non-existing, dir==============="
2450 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2451 nlink=$(stat --format=%h $DIR/$tfile)
2452 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2454 local cmd="exec $fd<$DIR/$tfile"
2457 trap "eval $cmd" EXIT
2458 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2459 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2460 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2461 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2462 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2465 run_test 31n "check link count of unlinked file"
2468 local TEMPNAME=$(mktemp $1_XXXXXX)
2469 mlink $TEMPNAME $1 2> /dev/null &&
2470 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2474 test_31o() { # LU-2901
2475 test_mkdir -p $DIR/$tdir
2476 for LOOP in $(seq 100); do
2477 rm -f $DIR/$tdir/$tfile*
2478 for THREAD in $(seq 8); do
2479 link_one $DIR/$tdir/$tfile.$LOOP &
2482 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2483 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2484 error "$LINKS duplicate links to $tfile.$LOOP" &&
2488 run_test 31o "duplicate hard links with same filename"
2491 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2493 test_mkdir $DIR/$tdir
2494 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2495 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2497 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2498 error "open unlink test1 failed"
2499 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2500 error "open unlink test2 failed"
2502 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2503 error "test1 still exists"
2504 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2505 error "test2 still exists"
2507 run_test 31p "remove of open striped directory"
2509 cleanup_test32_mount() {
2512 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2513 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2514 losetup -d $loopdev || true
2520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2521 echo "== more mountpoints and symlinks ================="
2522 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2523 trap cleanup_test32_mount EXIT
2524 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2525 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2526 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2527 cleanup_test32_mount
2529 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2533 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2534 trap cleanup_test32_mount EXIT
2535 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2536 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2537 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2538 cleanup_test32_mount
2540 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2544 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2545 trap cleanup_test32_mount EXIT
2546 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2547 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2548 test_mkdir -p $DIR/$tdir/d2/test_dir
2549 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2550 cleanup_test32_mount
2552 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2556 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2557 trap cleanup_test32_mount EXIT
2558 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2559 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2560 test_mkdir -p $DIR/$tdir/d2/test_dir
2561 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2562 cleanup_test32_mount
2564 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2567 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2568 test_mkdir -p $DIR/d32e/tmp
2569 TMP_DIR=$DIR/d32e/tmp
2570 ln -s $DIR/d32e $TMP_DIR/symlink11
2571 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2572 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2573 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2575 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2578 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2579 test_mkdir -p $DIR/d32f/tmp
2580 TMP_DIR=$DIR/d32f/tmp
2581 ln -s $DIR/d32f $TMP_DIR/symlink11
2582 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2583 ls $DIR/d32f/tmp/symlink11 || error
2584 ls $DIR/d32f/symlink01 || error
2586 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2589 TMP_DIR=$DIR/$tdir/tmp
2590 test_mkdir -p $DIR/$tdir/tmp
2591 test_mkdir $DIR/${tdir}2
2592 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2593 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2594 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2595 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2596 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2597 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2599 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2602 rm -fr $DIR/$tdir $DIR/${tdir}2
2603 TMP_DIR=$DIR/$tdir/tmp
2604 test_mkdir -p $DIR/$tdir/tmp
2605 test_mkdir $DIR/${tdir}2
2606 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2607 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2608 ls $TMP_DIR/symlink12 || error
2609 ls $DIR/$tdir/symlink02 || error
2611 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2615 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2616 trap cleanup_test32_mount EXIT
2617 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2618 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2619 touch $DIR/$tdir/test_file
2620 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2621 cleanup_test32_mount
2623 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2627 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2628 trap cleanup_test32_mount EXIT
2629 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2630 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2631 touch $DIR/$tdir/test_file
2632 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2633 cleanup_test32_mount
2635 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2640 trap cleanup_test32_mount EXIT
2641 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2642 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2643 test_mkdir -p $DIR/$tdir/d2
2644 touch $DIR/$tdir/d2/test_file || error
2645 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2646 cleanup_test32_mount
2648 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2653 trap cleanup_test32_mount EXIT
2654 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2655 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2656 test_mkdir -p $DIR/$tdir/d2
2657 touch $DIR/$tdir/d2/test_file
2658 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2659 cleanup_test32_mount
2661 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2665 test_mkdir -p $DIR/d32m/tmp
2666 TMP_DIR=$DIR/d32m/tmp
2667 ln -s $DIR $TMP_DIR/symlink11
2668 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2669 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2670 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2672 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2676 test_mkdir -p $DIR/d32n/tmp
2677 TMP_DIR=$DIR/d32n/tmp
2678 ln -s $DIR $TMP_DIR/symlink11
2679 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2680 ls -l $DIR/d32n/tmp/symlink11 || error
2681 ls -l $DIR/d32n/symlink01 || error
2683 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2687 test_mkdir -p $DIR/d32o/tmp
2688 TMP_DIR=$DIR/d32o/tmp
2689 ln -s $DIR/$tfile $TMP_DIR/symlink12
2690 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2691 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2692 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2693 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2694 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2696 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2706 test_mkdir -p $DIR/d32p/tmp
2708 TMP_DIR=$DIR/d32p/tmp
2710 ln -s $DIR/$tfile $TMP_DIR/symlink12
2712 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2714 cat $DIR/d32p/tmp/symlink12 || error
2716 cat $DIR/d32p/symlink02 || error
2719 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2723 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2724 trap cleanup_test32_mount EXIT
2725 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2726 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2727 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2728 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2729 cleanup_test32_mount
2731 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2734 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2735 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2736 trap cleanup_test32_mount EXIT
2737 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2738 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2739 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2740 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2741 cleanup_test32_mount
2743 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2748 chmod 444 $DIR/$tfile
2749 chown $RUNAS_ID $DIR/$tfile
2751 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2754 run_test 33aa "write file with mode 444 (should return error) ===="
2758 test_mkdir -p $DIR/d33
2759 chown $RUNAS_ID $DIR/d33
2760 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2761 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2762 error "open RDWR" || true
2764 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2768 test_mkdir -p $DIR/d33
2769 chown $RUNAS_ID $DIR/d33
2770 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2772 run_test 33b "test open file with malformed flags (No panic)"
2775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2781 remote_ost_nodsh && skip "remote OST with nodsh" && return
2784 test_mkdir -p $DIR/d33
2785 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2788 for ostnum in $(seq $OSTCOUNT); do
2789 # test-framework's OST numbering is one-based, while Lustre's
2791 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2792 # Parsing llobdstat's output sucks; we could grep the /proc
2793 # path, but that's likely to not be as portable as using the
2794 # llobdstat utility. So we parse lctl output instead.
2795 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2796 obdfilter/$ostname/stats |
2797 awk '/^write_bytes/ {print $7}' )
2798 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2799 if (( ${write_bytes:-0} > 0 ))
2806 $all_zeros || return 0
2809 echo foo > $DIR/d33/bar
2813 # Total up write_bytes after writing. We'd better find non-zeros.
2814 for ostnum in $(seq $OSTCOUNT); do
2815 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2816 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2817 obdfilter/$ostname/stats |
2818 awk '/^write_bytes/ {print $7}' )
2819 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2820 if (( ${write_bytes:-0} > 0 ))
2829 for ostnum in $(seq $OSTCOUNT); do
2830 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2831 echo "Check that write_bytes is present in obdfilter/*/stats:"
2832 do_facet ost$ostnum lctl get_param -n \
2833 obdfilter/$ostname/stats
2835 error "OST not keeping write_bytes stats (b22312)"
2838 run_test 33c "test llobdstat and write_bytes"
2841 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2844 local remote_dir=$DIR/$tdir/remote_dir
2846 test_mkdir -p $DIR/$tdir
2847 $LFS mkdir -i $MDTIDX $remote_dir ||
2848 error "create remote directory failed"
2850 touch $remote_dir/$tfile
2851 chmod 444 $remote_dir/$tfile
2852 chown $RUNAS_ID $remote_dir/$tfile
2854 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2856 chown $RUNAS_ID $remote_dir
2857 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2858 error "create" || true
2859 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2860 error "open RDWR" || true
2861 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2863 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2866 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2870 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2871 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2872 mkdir $DIR/$tdir/local_dir
2874 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2875 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2876 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2878 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2879 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2881 rmdir $DIR/$tdir/* || error "rmdir failed"
2884 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2885 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2886 mkdir $DIR/$tdir/local_dir
2888 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2889 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2890 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2892 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2893 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2895 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2898 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2899 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2900 mkdir $DIR/$tdir/local_dir
2902 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2903 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2904 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2906 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2907 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2909 run_test 33e "mkdir and striped directory should have same mode"
2913 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2918 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2921 chmod go+rwx $DIR/$tdir
2922 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2923 trap cleanup_33f EXIT
2925 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2926 error "cannot create striped directory"
2928 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2929 error "cannot create files in striped directory"
2931 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2932 error "cannot remove files in striped directory"
2934 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2935 error "cannot remove striped directory"
2939 run_test 33f "nonroot user can create, access, and remove a striped directory"
2942 mkdir -p $DIR/$tdir/dir2
2944 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2946 [[ $err =~ "exists" ]] || error "Not exists error"
2948 run_test 33g "nonroot user create already existing root created file"
2950 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2953 $MCREATE $DIR/f34 || error
2954 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2955 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2956 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2957 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2959 run_test 34a "truncate file that has not been opened ==========="
2962 [ ! -f $DIR/f34 ] && test_34a
2963 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2964 $OPENFILE -f O_RDONLY $DIR/f34
2965 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2966 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2968 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2971 [ ! -f $DIR/f34 ] && test_34a
2972 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2973 $OPENFILE -f O_RDWR $DIR/f34
2974 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2975 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2977 run_test 34c "O_RDWR opening file-with-size works =============="
2980 [ ! -f $DIR/f34 ] && test_34a
2981 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2982 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2985 run_test 34d "write to sparse file ============================="
2989 $MCREATE $DIR/f34e || error
2990 $TRUNCATE $DIR/f34e 1000 || error
2991 $CHECKSTAT -s 1000 $DIR/f34e || error
2992 $OPENFILE -f O_RDWR $DIR/f34e
2993 $CHECKSTAT -s 1000 $DIR/f34e || error
2995 run_test 34e "create objects, some with size and some without =="
2997 test_34f() { # bug 6242, 6243
2998 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3001 $MCREATE $DIR/f34f || error
3002 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3003 dd if=$DIR/f34f of=$TMP/f34f
3004 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3005 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3006 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3007 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3008 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3010 run_test 34f "read from a file with no objects until EOF ======="
3013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3014 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
3015 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
3016 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
3017 cancel_lru_locks osc
3018 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
3019 error "wrong size after lock cancel"
3021 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
3022 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
3023 error "expanding truncate failed"
3024 cancel_lru_locks osc
3025 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
3026 error "wrong expanded size after lock cancel"
3028 run_test 34g "truncate long file ==============================="
3031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3035 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
3036 sync # Flush the cache so that multiop below does not block on cache
3037 # flush when getting the group lock
3038 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3041 # Since just timed wait is not good enough, let's do a sync write
3042 # that way we are sure enough time for a roundtrip + processing
3043 # passed + 2 seconds of extra margin.
3044 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
3048 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3049 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3053 local nsz=`stat -c %s $DIR/$tfile`
3054 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3056 run_test 34h "ftruncate file under grouplock should not block"
3059 cp /bin/sh $DIR/f35a
3061 chown $RUNAS_ID $DIR/f35a
3062 $RUNAS $DIR/f35a && error || true
3065 run_test 35a "exec file with mode 444 (should return and not leak) ====="
3069 utime $DIR/f36 || error
3071 run_test 36a "MDS utime check (mknod, utime) ==================="
3075 utime $DIR/f36 || error
3077 run_test 36b "OST utime check (open, utime) ===================="
3082 chown $RUNAS_ID $DIR/d36
3083 $RUNAS utime $DIR/d36/f36 || error
3085 run_test 36c "non-root MDS utime check (mknod, utime) =========="
3088 [ ! -d $DIR/d36 ] && test_36c
3089 echo "" > $DIR/d36/f36
3090 $RUNAS utime $DIR/d36/f36 || error
3092 run_test 36d "non-root OST utime check (open, utime) ==========="
3095 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3096 test_mkdir -p $DIR/$tdir
3097 touch $DIR/$tdir/$tfile
3098 $RUNAS utime $DIR/$tdir/$tfile && \
3099 error "utime worked, expected failure" || true
3101 run_test 36e "utime on non-owned file (should return error) ===="
3105 local LANG_SAVE=$LANG
3106 local LC_LANG_SAVE=$LC_LANG
3107 export LANG=C LC_LANG=C # for date language
3109 DATESTR="Dec 20 2000"
3110 test_mkdir -p $DIR/$tdir
3111 lctl set_param fail_loc=$fl
3113 cp /etc/hosts $DIR/$tdir/$tfile
3114 sync & # write RPC generated with "current" inode timestamp, but delayed
3116 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3117 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3118 cancel_lru_locks osc
3119 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3121 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3122 echo "BEFORE: $LS_BEFORE" && \
3123 echo "AFTER : $LS_AFTER" && \
3124 echo "WANT : $DATESTR" && \
3125 error "$DIR/$tdir/$tfile timestamps changed" || true
3127 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3132 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3133 subr_36fh "0x80000214"
3135 run_test 36f "utime on file racing with OST BRW write =========="
3138 remote_ost_nodsh && skip "remote OST with nodsh" && return
3139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3144 test_mkdir -p $DIR/$tdir
3145 fmd_max_age=$(do_facet ost1 \
3146 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3149 fmd_before=$(do_facet ost1 \
3150 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3151 touch $DIR/$tdir/$tfile
3152 sleep $((fmd_max_age + 12))
3153 fmd_after=$(do_facet ost1 \
3154 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3156 echo "fmd_before: $fmd_before"
3157 echo "fmd_after: $fmd_after"
3158 [[ $fmd_after -gt $fmd_before ]] &&
3159 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3160 error "fmd didn't expire after ping" || true
3162 run_test 36g "filter mod data cache expiry ====================="
3165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3166 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3167 subr_36fh "0x80000227"
3169 run_test 36h "utime on file racing with OST BRW write =========="
3172 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3174 test_mkdir $DIR/$tdir
3175 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3177 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3178 local new_mtime=$((mtime + 200))
3180 #change Modify time of striped dir
3181 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3182 error "change mtime failed"
3184 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3186 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3188 run_test 36i "change mtime on striped directory"
3190 # test_37 - duplicate with tests 32q 32r
3193 local file=$DIR/$tfile
3195 openfile -f O_DIRECTORY $file
3198 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3199 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3201 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3203 test_39a() { # was test_39
3205 touch $DIR/${tfile}2
3206 # ls -l $DIR/$tfile $DIR/${tfile}2
3207 # ls -lu $DIR/$tfile $DIR/${tfile}2
3208 # ls -lc $DIR/$tfile $DIR/${tfile}2
3210 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3211 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3213 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3215 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3217 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3218 error "O_TRUNC didn't change timestamps"
3221 run_test 39a "mtime changed on create ==========================="
3224 test_mkdir -p -c1 $DIR/$tdir
3225 cp -p /etc/passwd $DIR/$tdir/fopen
3226 cp -p /etc/passwd $DIR/$tdir/flink
3227 cp -p /etc/passwd $DIR/$tdir/funlink
3228 cp -p /etc/passwd $DIR/$tdir/frename
3229 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3232 echo "aaaaaa" >> $DIR/$tdir/fopen
3233 echo "aaaaaa" >> $DIR/$tdir/flink
3234 echo "aaaaaa" >> $DIR/$tdir/funlink
3235 echo "aaaaaa" >> $DIR/$tdir/frename
3237 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3238 local link_new=`stat -c %Y $DIR/$tdir/flink`
3239 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3240 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3242 cat $DIR/$tdir/fopen > /dev/null
3243 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3244 rm -f $DIR/$tdir/funlink2
3245 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3247 for (( i=0; i < 2; i++ )) ; do
3248 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3249 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3250 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3251 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3253 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3254 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3255 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3256 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3258 cancel_lru_locks osc
3259 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3262 run_test 39b "mtime change on open, link, unlink, rename ======"
3264 # this should be set to past
3265 TEST_39_MTIME=`date -d "1 year ago" +%s`
3271 local mtime0=`stat -c %Y $DIR1/$tfile`
3273 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3274 local mtime1=`stat -c %Y $DIR1/$tfile`
3275 [ "$mtime1" = $TEST_39_MTIME ] || \
3276 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3279 echo hello >> $DIR1/$tfile
3281 local mtime2=`stat -c %Y $DIR1/$tfile`
3282 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3283 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3285 mv $DIR1/$tfile $DIR1/$tfile-1
3287 for (( i=0; i < 2; i++ )) ; do
3288 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3289 [ "$mtime2" = "$mtime3" ] || \
3290 error "mtime ($mtime2) changed (to $mtime3) on rename"
3292 cancel_lru_locks osc
3293 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3296 run_test 39c "mtime change on rename ==========================="
3300 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3303 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3305 for (( i=0; i < 2; i++ )) ; do
3306 local mtime=`stat -c %Y $DIR1/$tfile`
3307 [ $mtime = $TEST_39_MTIME ] || \
3308 error "mtime($mtime) is not set to $TEST_39_MTIME"
3310 cancel_lru_locks osc
3311 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3314 run_test 39d "create, utime, stat =============================="
3318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3320 local mtime1=`stat -c %Y $DIR1/$tfile`
3322 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3324 for (( i=0; i < 2; i++ )) ; do
3325 local mtime2=`stat -c %Y $DIR1/$tfile`
3326 [ $mtime2 = $TEST_39_MTIME ] || \
3327 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3329 cancel_lru_locks osc
3330 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3333 run_test 39e "create, stat, utime, stat ========================"
3337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3339 mtime1=`stat -c %Y $DIR1/$tfile`
3342 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3344 for (( i=0; i < 2; i++ )) ; do
3345 local mtime2=`stat -c %Y $DIR1/$tfile`
3346 [ $mtime2 = $TEST_39_MTIME ] || \
3347 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3349 cancel_lru_locks osc
3350 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3353 run_test 39f "create, stat, sleep, utime, stat ================="
3357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3358 echo hello >> $DIR1/$tfile
3359 local mtime1=`stat -c %Y $DIR1/$tfile`
3362 chmod o+r $DIR1/$tfile
3364 for (( i=0; i < 2; i++ )) ; do
3365 local mtime2=`stat -c %Y $DIR1/$tfile`
3366 [ "$mtime1" = "$mtime2" ] || \
3367 error "lost mtime: $mtime2, should be $mtime1"
3369 cancel_lru_locks osc
3370 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3373 run_test 39g "write, chmod, stat ==============================="
3377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3382 echo hello >> $DIR1/$tfile
3383 local mtime1=`stat -c %Y $DIR1/$tfile`
3385 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3387 if [ "$d1" != "$d2" ]; then
3388 echo "write and touch not within one second"
3390 for (( i=0; i < 2; i++ )) ; do
3391 local mtime2=`stat -c %Y $DIR1/$tfile`
3392 [ "$mtime2" = $TEST_39_MTIME ] || \
3393 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3395 cancel_lru_locks osc
3396 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3400 run_test 39h "write, utime within one second, stat ============="
3403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3407 echo hello >> $DIR1/$tfile
3408 local mtime1=`stat -c %Y $DIR1/$tfile`
3410 mv $DIR1/$tfile $DIR1/$tfile-1
3412 for (( i=0; i < 2; i++ )) ; do
3413 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3415 [ "$mtime1" = "$mtime2" ] || \
3416 error "lost mtime: $mtime2, should be $mtime1"
3418 cancel_lru_locks osc
3419 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3422 run_test 39i "write, rename, stat =============================="
3425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3426 start_full_debug_logging
3430 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3431 lctl set_param fail_loc=0x80000412
3432 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3433 error "multiop failed"
3435 local mtime1=`stat -c %Y $DIR1/$tfile`
3437 mv $DIR1/$tfile $DIR1/$tfile-1
3439 kill -USR1 $multipid
3440 wait $multipid || error "multiop close failed"
3442 for (( i=0; i < 2; i++ )) ; do
3443 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3444 [ "$mtime1" = "$mtime2" ] ||
3445 error "mtime is lost on close: $mtime2, " \
3448 cancel_lru_locks osc
3449 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3451 lctl set_param fail_loc=0
3452 stop_full_debug_logging
3454 run_test 39j "write, rename, close, stat ======================="
3457 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3461 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3463 local mtime1=`stat -c %Y $DIR1/$tfile`
3465 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3467 kill -USR1 $multipid
3468 wait $multipid || error "multiop close failed"
3470 for (( i=0; i < 2; i++ )) ; do
3471 local mtime2=`stat -c %Y $DIR1/$tfile`
3473 [ "$mtime2" = $TEST_39_MTIME ] || \
3474 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3476 cancel_lru_locks osc
3477 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3480 run_test 39k "write, utime, close, stat ========================"
3482 # this should be set to future
3483 TEST_39_ATIME=`date -d "1 year" +%s`
3486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3488 local atime_diff=$(do_facet $SINGLEMDS \
3489 lctl get_param -n mdd.*MDT0000*.atime_diff)
3493 # test setting directory atime to future
3494 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3495 local atime=$(stat -c %X $DIR/$tdir)
3496 [ "$atime" = $TEST_39_ATIME ] ||
3497 error "atime is not set to future: $atime, $TEST_39_ATIME"
3499 # test setting directory atime from future to now
3500 local now=$(date +%s)
3501 touch -a -d @$now $DIR/$tdir
3503 atime=$(stat -c %X $DIR/$tdir)
3504 [ "$atime" -eq "$now" ] ||
3505 error "atime is not updated from future: $atime, $now"
3507 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3510 # test setting directory atime when now > dir atime + atime_diff
3511 local d1=$(date +%s)
3513 local d2=$(date +%s)
3514 cancel_lru_locks mdc
3515 atime=$(stat -c %X $DIR/$tdir)
3516 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3517 error "atime is not updated : $atime, should be $d2"
3519 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3522 # test not setting directory atime when now < dir atime + atime_diff
3524 cancel_lru_locks mdc
3525 atime=$(stat -c %X $DIR/$tdir)
3526 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3527 error "atime is updated to $atime, should remain $d1<atime<$d2"
3529 do_facet $SINGLEMDS \
3530 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3532 run_test 39l "directory atime update ==========================="
3535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3538 local far_past_mtime=$(date -d "May 29 1953" +%s)
3539 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3541 touch -m -d @$far_past_mtime $DIR1/$tfile
3542 touch -a -d @$far_past_atime $DIR1/$tfile
3544 for (( i=0; i < 2; i++ )) ; do
3545 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3546 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3547 error "atime or mtime set incorrectly"
3549 cancel_lru_locks osc
3550 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3553 run_test 39m "test atime and mtime before 1970"
3555 test_39n() { # LU-3832
3556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3557 local atime_diff=$(do_facet $SINGLEMDS \
3558 lctl get_param -n mdd.*MDT0000*.atime_diff)
3563 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3566 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3567 atime0=$(stat -c %X $DIR/$tfile)
3570 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3571 atime1=$(stat -c %X $DIR/$tfile)
3574 cancel_lru_locks mdc
3575 cancel_lru_locks osc
3576 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3577 atime2=$(stat -c %X $DIR/$tfile)
3579 do_facet $SINGLEMDS \
3580 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3582 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3583 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3585 run_test 39n "check that O_NOATIME is honored"
3588 TESTDIR=$DIR/$tdir/$tfile
3589 [ -e $TESTDIR ] && rm -rf $TESTDIR
3596 links2=$(stat -c %h .)
3597 [ $(($links1 + 2)) != $links2 ] &&
3598 error "wrong links count $(($links1 + 2)) != $links2"
3600 links3=$(stat -c %h .)
3601 [ $(($links1 + 1)) != $links3 ] &&
3602 error "wrong links count $links1 != $links3"
3605 run_test 39o "directory cached attributes updated after create ========"
3608 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3610 TESTDIR=$DIR/$tdir/$tfile
3611 [ -e $TESTDIR ] && rm -rf $TESTDIR
3612 test_mkdir -p $TESTDIR
3616 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3617 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3619 links2=$(stat -c %h .)
3620 [ $(($links1 + 2)) != $links2 ] &&
3621 error "wrong links count $(($links1 + 2)) != $links2"
3623 links3=$(stat -c %h .)
3624 [ $(($links1 + 1)) != $links3 ] &&
3625 error "wrong links count $links1 != $links3"
3628 run_test 39p "remote directory cached attributes updated after create ========"
3631 test_39q() { # LU-8041
3632 local testdir=$DIR/$tdir
3634 multiop_bg_pause $testdir D_c || error "multiop failed"
3636 cancel_lru_locks mdc
3637 kill -USR1 $multipid
3638 local atime=$(stat -c %X $testdir)
3639 [ "$atime" -ne 0 ] || error "atime is zero"
3641 run_test 39q "close won't zero out atime"
3644 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3645 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3646 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3647 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3648 error "$tfile is not 4096 bytes in size"
3650 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3654 small_write $DIR/f41 18
3656 run_test 41 "test small file write + fstat ====================="
3658 count_ost_writes() {
3659 lctl get_param -n osc.*.stats |
3660 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3661 END { printf("%0.0f", writes) }'
3668 BG_DIRTY_RATIO_SAVE=10
3669 MAX_BG_DIRTY_RATIO=25
3673 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3674 # dirty_ratio, dirty_background_ratio
3675 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3676 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3677 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3678 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3680 # if file not here, we are a 2.4 kernel
3681 kill -CONT `pidof kupdated`
3686 # setup the trap first, so someone cannot exit the test at the
3687 # exact wrong time and mess up a machine
3688 trap start_writeback EXIT
3689 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3690 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3691 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3692 sysctl -w vm.dirty_writeback_centisecs=0
3693 sysctl -w vm.dirty_writeback_centisecs=0
3694 # save and increase /proc/sys/vm/dirty_ratio
3695 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3696 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3697 # save and increase /proc/sys/vm/dirty_background_ratio
3698 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3699 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3701 # if file not here, we are a 2.4 kernel
3702 kill -STOP `pidof kupdated`
3706 # ensure that all stripes have some grant before we test client-side cache
3708 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3709 dd if=/dev/zero of=$i bs=4k count=1
3714 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3715 # file truncation, and file removal.
3717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3719 cancel_lru_locks osc
3721 sync; sleep 1; sync # just to be safe
3722 BEFOREWRITES=`count_ost_writes`
3723 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3724 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3725 AFTERWRITES=`count_ost_writes`
3726 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3727 error "$BEFOREWRITES < $AFTERWRITES"
3730 run_test 42a "ensure that we don't flush on close"
3733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3735 cancel_lru_locks osc
3738 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3739 BEFOREWRITES=$(count_ost_writes)
3740 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3741 AFTERWRITES=$(count_ost_writes)
3742 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3743 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3745 BEFOREWRITES=$(count_ost_writes)
3746 sync || error "sync: $?"
3747 AFTERWRITES=$(count_ost_writes)
3748 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3749 error "$BEFOREWRITES < $AFTERWRITES on sync"
3751 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3755 run_test 42b "test destroy of file with cached dirty data ======"
3757 # if these tests just want to test the effect of truncation,
3758 # they have to be very careful. consider:
3759 # - the first open gets a {0,EOF}PR lock
3760 # - the first write conflicts and gets a {0, count-1}PW
3761 # - the rest of the writes are under {count,EOF}PW
3762 # - the open for truncate tries to match a {0,EOF}PR
3763 # for the filesize and cancels the PWs.
3764 # any number of fixes (don't get {0,EOF} on open, match
3765 # composite locks, do smarter file size management) fix
3766 # this, but for now we want these tests to verify that
3767 # the cancellation with truncate intent works, so we
3768 # start the file with a full-file pw lock to match against
3769 # until the truncate.
3774 cancel_lru_locks osc
3776 # prime the file with 0,EOF PW to match
3780 # now the real test..
3781 dd if=/dev/zero of=$file bs=1024 count=100
3782 BEFOREWRITES=`count_ost_writes`
3783 $TRUNCATE $file $offset
3784 cancel_lru_locks osc
3785 AFTERWRITES=`count_ost_writes`
3790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3792 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3793 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3796 run_test 42c "test partial truncate of file with cached dirty data"
3799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3801 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3802 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3805 run_test 42d "test complete truncate of file with cached dirty data"
3807 test_42e() { # bug22074
3808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3809 local TDIR=$DIR/${tdir}e
3810 local pagesz=$(page_size)
3811 local pages=16 # hardcoded 16 pages, don't change it.
3812 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3813 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3817 test_mkdir -p $DIR/${tdir}e
3818 $SETSTRIPE -c 1 $TDIR
3819 createmany -o $TDIR/f $files
3821 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3823 # we assume that with $OSTCOUNT files, at least one of them will
3824 # be allocated on OST0.
3825 warmup_files=$((OSTCOUNT * max_dirty_mb))
3826 createmany -o $TDIR/w $warmup_files
3828 # write a large amount of data into one file and sync, to get good
3829 # avail_grant number from OST.
3830 for ((i=0; i<$warmup_files; i++)); do
3831 idx=$($GETSTRIPE -i $TDIR/w$i)
3832 [ $idx -ne 0 ] && continue
3833 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3836 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3838 $LCTL get_param $proc_osc0/cur_dirty_bytes
3839 $LCTL get_param $proc_osc0/cur_grant_bytes
3841 # create as much dirty pages as we can while not to trigger the actual
3842 # RPCs directly. but depends on the env, VFS may trigger flush during this
3843 # period, hopefully we are good.
3844 for ((i=0; i<$warmup_files; i++)); do
3845 idx=$($GETSTRIPE -i $TDIR/w$i)
3846 [ $idx -ne 0 ] && continue
3847 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3849 $LCTL get_param $proc_osc0/cur_dirty_bytes
3850 $LCTL get_param $proc_osc0/cur_grant_bytes
3852 # perform the real test
3853 $LCTL set_param $proc_osc0/rpc_stats 0
3854 for ((;i<$files; i++)); do
3855 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3856 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3859 $LCTL get_param $proc_osc0/rpc_stats
3862 local have_ppr=false
3863 $LCTL get_param $proc_osc0/rpc_stats |
3864 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3865 # skip lines until we are at the RPC histogram data
3866 [ "$PPR" == "pages" ] && have_ppr=true && continue
3867 $have_ppr || continue
3869 # we only want the percent stat for < 16 pages
3870 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3872 percent=$((percent + WPCT))
3873 if [[ $percent -gt 15 ]]; then
3874 error "less than 16-pages write RPCs" \
3881 run_test 42e "verify sub-RPC writes are not done synchronously"
3883 test_43A() { # was test_43
3884 test_mkdir -p $DIR/$tdir
3885 cp -p /bin/ls $DIR/$tdir/$tfile
3886 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3888 # give multiop a chance to open
3891 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3894 run_test 43A "execution of file opened for write should return -ETXTBSY"
3897 test_mkdir $DIR/$tdir
3898 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3899 cp -p multiop $DIR/$tdir/multiop
3900 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3901 error "multiop open $TMP/$tfile.junk failed"
3903 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3904 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3905 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3907 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3911 test_mkdir $DIR/$tdir
3912 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3913 cp -p multiop $DIR/$tdir/multiop
3914 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3915 error "multiop open $TMP/$tfile.junk failed"
3917 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3918 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3919 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3921 run_test 43b "truncate of file being executed should return -ETXTBSY"
3924 local testdir="$DIR/$tdir"
3927 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3928 ( cd $testdir && md5sum -c )
3930 run_test 43c "md5sum of copy into lustre"
3932 test_44A() { # was test_44
3933 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3934 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3935 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3937 run_test 44A "zero length read from a sparse stripe"
3940 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3942 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3943 [[ $nstripe -gt $OSTCOUNT ]] &&
3944 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3946 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3948 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3949 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3953 OFFSETS="0 $((stride/2)) $((stride-1))"
3954 for offset in $OFFSETS; do
3955 for i in $(seq 0 $((nstripe-1))); do
3956 local GLOBALOFFSETS=""
3958 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3959 local myfn=$DIR/d44a-$size
3960 echo "--------writing $myfn at $size"
3961 ll_sparseness_write $myfn $size ||
3962 error "ll_sparseness_write"
3963 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3964 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3965 error "ll_sparseness_verify $GLOBALOFFSETS"
3967 for j in $(seq 0 $((nstripe-1))); do
3969 size=$((((j + $nstripe )*$stride + $offset)))
3970 ll_sparseness_write $myfn $size ||
3971 error "ll_sparseness_write"
3972 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3974 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3975 error "ll_sparseness_verify $GLOBALOFFSETS"
3980 run_test 44a "test sparse pwrite ==============================="
3984 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3990 before=`dirty_osc_total`
3991 echo executing "\"$*\""
3993 after=`dirty_osc_total`
3994 echo before $before, after $after
3997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3999 # Obtain grants from OST if it supports it
4000 echo blah > ${f}_grant
4003 do_dirty_record "echo blah > $f"
4004 [[ $before -eq $after ]] && error "write wasn't cached"
4005 do_dirty_record "> $f"
4006 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4007 do_dirty_record "echo blah > $f"
4008 [[ $before -eq $after ]] && error "write wasn't cached"
4009 do_dirty_record "sync"
4010 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4011 do_dirty_record "echo blah > $f"
4012 [[ $before -eq $after ]] && error "write wasn't cached"
4013 do_dirty_record "cancel_lru_locks osc"
4014 [[ $before -gt $after ]] ||
4015 error "lock cancellation didn't lower dirty count"
4018 run_test 45 "osc io page accounting ============================"
4020 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4021 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4022 # objects offset and an assert hit when an rpc was built with 1023's mapped
4023 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4025 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4029 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4031 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
4032 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4036 run_test 46 "dirtying a previously written page ================"
4038 # test_47 is removed "Device nodes check" is moved to test_28
4040 test_48a() { # bug 2399
4041 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
4042 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
4043 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
4045 test_mkdir $DIR/$tdir
4047 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4048 test_mkdir $DIR/$tdir || error "recreate directory failed"
4049 touch foo || error "'touch foo' failed after recreating cwd"
4050 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
4051 touch .foo || error "'touch .foo' failed after recreating cwd"
4052 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
4053 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4054 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4055 cd . || error "'cd .' failed after recreating cwd"
4056 test_mkdir . && error "'mkdir .' worked after recreating cwd"
4057 rmdir . && error "'rmdir .' worked after recreating cwd"
4058 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4059 cd .. || error "'cd ..' failed after recreating cwd"
4061 run_test 48a "Access renamed working dir (should return errors)="
4063 test_48b() { # bug 2399
4065 test_mkdir $DIR/$tdir
4067 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4068 touch foo && error "'touch foo' worked after removing cwd"
4069 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4070 touch .foo && error "'touch .foo' worked after removing cwd"
4071 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4072 ls . > /dev/null && error "'ls .' worked after removing cwd"
4073 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4074 test_mkdir . && error "'mkdir .' worked after removing cwd"
4075 rmdir . && error "'rmdir .' worked after removing cwd"
4076 ln -s . foo && error "'ln -s .' worked after removing cwd"
4077 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4079 run_test 48b "Access removed working dir (should return errors)="
4081 test_48c() { # bug 2350
4082 #lctl set_param debug=-1
4085 test_mkdir -p $DIR/$tdir/dir
4087 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4088 $TRACE touch foo && error "touch foo worked after removing cwd"
4089 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4090 touch .foo && error "touch .foo worked after removing cwd"
4091 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
4092 $TRACE ls . && error "'ls .' worked after removing cwd"
4093 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4094 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
4095 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4096 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4097 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4099 run_test 48c "Access removed working subdir (should return errors)"
4101 test_48d() { # bug 2350
4102 #lctl set_param debug=-1
4105 test_mkdir -p $DIR/$tdir/dir
4107 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4108 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4109 $TRACE touch foo && error "'touch foo' worked after removing parent"
4110 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
4111 touch .foo && error "'touch .foo' worked after removing parent"
4112 test_mkdir .foo && error "mkdir .foo worked after removing parent"
4113 $TRACE ls . && error "'ls .' worked after removing parent"
4114 $TRACE ls .. && error "'ls ..' worked after removing parent"
4115 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
4116 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4117 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4120 run_test 48d "Access removed parent subdir (should return errors)"
4122 test_48e() { # bug 4134
4123 #lctl set_param debug=-1
4126 test_mkdir -p $DIR/$tdir/dir
4128 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4129 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4130 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4131 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4132 # On a buggy kernel addition of "touch foo" after cd .. will
4133 # produce kernel oops in lookup_hash_it
4134 touch ../foo && error "'cd ..' worked after recreate parent"
4136 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4138 run_test 48e "Access to recreated parent subdir (should return errors)"
4140 test_49() { # LU-1030
4141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4142 remote_ost_nodsh && skip "remote OST with nodsh" && return
4143 # get ost1 size - lustre-OST0000
4144 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4146 # write 800M at maximum
4147 [[ $ost1_size -lt 2 ]] && ost1_size=2
4148 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4150 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4151 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4154 # change max_pages_per_rpc while writing the file
4155 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4156 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4157 # loop until dd process exits
4158 while ps ax -opid | grep -wq $dd_pid; do
4159 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4160 sleep $((RANDOM % 5 + 1))
4162 # restore original max_pages_per_rpc
4163 $LCTL set_param $osc1_mppc=$orig_mppc
4164 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4166 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4170 test_mkdir $DIR/$tdir
4172 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4174 run_test 50 "special situations: /proc symlinks ==============="
4176 test_51a() { # was test_51
4177 # bug 1516 - create an empty entry right after ".." then split dir
4178 test_mkdir -c1 $DIR/$tdir
4179 touch $DIR/$tdir/foo
4180 $MCREATE $DIR/$tdir/bar
4182 createmany -m $DIR/$tdir/longfile 201
4184 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4185 $MCREATE $DIR/$tdir/longfile$FNUM
4190 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4192 run_test 51a "special situations: split htree with empty entry =="
4194 cleanup_print_lfs_df () {
4201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4202 local dir=$DIR/$tdir
4204 local nrdirs=$((65536 + 100))
4206 # cleanup the directory
4209 test_mkdir -p -c1 $dir
4213 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4214 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4215 [[ $numfree -lt $nrdirs ]] &&
4216 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4219 # need to check free space for the directories as well
4220 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4221 numfree=$(( blkfree / $(fs_inode_ksize) ))
4222 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4225 trap cleanup_print_lfs_df EXIT
4228 createmany -d $dir/d $nrdirs || {
4229 unlinkmany $dir/d $nrdirs
4230 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4234 nrdirs=$(ls -U $dir | wc -l)
4236 # unlink all but 100 subdirectories, then check it still works
4238 local delete=$((nrdirs - left))
4243 # for ldiskfs the nlink count should be 1, but this is OSD specific
4244 # and so this is listed for informational purposes only
4245 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4246 unlinkmany -d $dir/d $delete ||
4247 error "unlink of first $delete subdirs failed"
4249 echo "nlink between: $(stat -c %h $dir)"
4250 local found=$(ls -U $dir | wc -l)
4251 [ $found -ne $left ] &&
4252 error "can't find subdirs: found only $found, expected $left"
4254 unlinkmany -d $dir/d $delete $left ||
4255 error "unlink of second $left subdirs failed"
4256 # regardless of whether the backing filesystem tracks nlink accurately
4257 # or not, the nlink count shouldn't be more than "." and ".." here
4258 local after=$(stat -c %h $dir)
4259 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4260 echo "nlink after: $after"
4262 cleanup_print_lfs_df
4264 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4268 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4269 test_mkdir -p $DIR/$tdir
4270 createmany -o $DIR/$tdir/t- 1000
4271 $GETSTRIPE $DIR/$tdir > $TMP/$tfile
4272 for N in $(seq 0 $((OSTCOUNT - 1))); do
4273 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4274 END { printf("%0.0f", objs) }' $TMP/$tfile)
4275 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4276 '($1 == '$N') { objs += 1 } \
4277 END { printf("%0.0f", objs) }')
4278 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4280 unlinkmany $DIR/$tdir/t- 1000
4283 for N in $(seq 1 $((OSTCOUNT - 1))); do
4284 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4285 error "OST $N has less objects vs OST $NLAST" \
4286 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4287 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4288 error "OST $N has less objects vs OST $NLAST" \
4289 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4291 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4292 error "OST $N has less #0 objects vs OST $NLAST" \
4293 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4294 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4295 error "OST $N has less #0 objects vs OST $NLAST" \
4296 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4301 run_test 51d "check object distribution"
4304 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4305 skip "ldiskfs only test"
4309 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4310 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4312 touch $DIR/$tdir/d0/foo
4313 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4314 error "file exceed 65000 nlink limit!"
4315 unlinkmany $DIR/$tdir/d0/f- 65001
4318 run_test 51e "check file nlink limit"
4321 test_mkdir $DIR/$tdir
4324 local ulimit_old=$(ulimit -n)
4325 local spare=20 # number of spare fd's for scripts/libraries, etc.
4326 local mdt=$(lfs getstripe -M $DIR/$tdir)
4327 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4329 echo "MDT$mdt numfree=$numfree, max=$max"
4330 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4331 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4332 while ! ulimit -n $((numfree + spare)); do
4333 numfree=$((numfree * 3 / 4))
4335 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4337 echo "left ulimit at $ulimit_old"
4340 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4341 unlinkmany $DIR/$tdir/f $numfree
4342 error "create+open $numfree files in $DIR/$tdir failed"
4344 ulimit -n $ulimit_old
4346 # if createmany exits at 120s there will be fewer than $numfree files
4347 unlinkmany $DIR/$tdir/f $numfree || true
4349 run_test 51f "check many open files limit"
4352 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4353 test_mkdir -p $DIR/$tdir
4354 touch $DIR/$tdir/foo
4355 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4356 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4357 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4358 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4359 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4361 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4362 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4363 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4365 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4366 cp -r $DIR/$tdir $TMP/
4367 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4369 run_test 52a "append-only flag test (should return errors)"
4372 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4373 test_mkdir -p $DIR/$tdir
4374 touch $DIR/$tdir/foo
4375 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4376 cat test > $DIR/$tdir/foo && error "cat test worked"
4377 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4378 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4379 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4381 echo foo >> $DIR/$tdir/foo && error "echo worked"
4382 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4383 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4384 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4385 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4387 chattr -i $DIR/$tdir/foo || error "chattr failed"
4389 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4391 run_test 52b "immutable flag test (should return errors) ======="
4394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4395 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4396 remote_ost_nodsh && skip "remote OST with nodsh" && return
4409 local support_last_seq=true
4411 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4412 support_last_seq=false
4415 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4417 for value in $(do_facet $SINGLEMDS \
4418 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4419 param=$(echo ${value[0]} | cut -d "=" -f1)
4420 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4422 if $support_last_seq; then
4423 param_seq=$(echo $param |
4424 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4425 mds_last_seq=$(do_facet $SINGLEMDS \
4426 $LCTL get_param -n $param_seq)
4428 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4430 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4431 node=$(facet_active_host ost$((ostnum+1)))
4432 param="obdfilter.$ostname.last_id"
4433 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4434 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4435 ost_last_id=$ost_last
4437 if $support_last_seq; then
4438 ost_last_id=$(echo $ost_last |
4439 awk -F':' '{print $2}' |
4441 ost_last_seq=$(echo $ost_last |
4442 awk -F':' '{print $1}')
4443 [[ $ost_last_seq = $mds_last_seq ]] || continue
4446 if [[ $ost_last_id != $mds_last ]]; then
4447 error "$ost_last_id != $mds_last"
4454 $found || error "can not match last_seq/last_id for $mdtosc"
4457 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4460 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4462 $SOCKETSERVER $DIR/socket ||
4463 error "$SOCKETSERVER $DIR/socket failed: $?"
4464 $SOCKETCLIENT $DIR/socket ||
4465 error "$SOCKETCLIENT $DIR/socket failed: $?"
4466 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4468 run_test 54a "unix domain socket test =========================="
4474 dd if=/dev/zero of=$f bs=$(page_size) count=1
4476 run_test 54b "char device works in lustre ======================"
4479 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4480 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4481 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4483 for i in $(seq 3 7); do
4484 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4493 loopdev="$DIR/loop54c"
4496 $UMOUNT $DIR/$tdir || rc=$?
4497 losetup -d $loopdev || true
4498 losetup -d $LOOPDEV || true
4499 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4505 loopdev="$DIR/loop54c"
4508 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4509 trap cleanup_54c EXIT
4510 mknod $loopdev b 7 $LOOPNUM
4511 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4512 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4513 losetup $loopdev $DIR/$tfile ||
4514 error "can't set up $loopdev for $DIR/$tfile"
4515 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4516 test_mkdir -p $DIR/$tdir
4517 mount -t ext2 $loopdev $DIR/$tdir ||
4518 error "error mounting $loopdev on $DIR/$tdir"
4519 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4522 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4526 run_test 54c "block device works in lustre ====================="
4532 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4534 run_test 54d "fifo device works in lustre ======================"
4539 cp -aL /dev/console $f
4540 echo $string > $f || error "echo $string to $f failed"
4542 run_test 54e "console/tty device works in lustre ======================"
4544 #The test_55 used to be iopen test and it was removed by bz#24037.
4545 #run_test 55 "check iopen_connect_dentry() ======================"
4547 test_56a() { # was test_56
4550 test_mkdir -p $DIR/$tdir/dir
4552 NUMFILESx2=$(($NUMFILES * 2))
4553 for i in $(seq 1 $NUMFILES); do
4554 touch $DIR/$tdir/file$i
4555 touch $DIR/$tdir/dir/file$i
4558 # test lfs getstripe with --recursive
4559 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4560 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4561 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4562 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4563 [[ $FILENUM -eq $NUMFILES ]] ||
4564 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4565 echo "$GETSTRIPE --recursive passed."
4567 # test lfs getstripe with file instead of dir
4568 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4569 [[ $FILENUM -eq 1 ]] ||
4570 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4571 echo "$GETSTRIPE file1 passed."
4573 #test lfs getstripe with --verbose
4574 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4575 grep -c lmm_magic) -eq $NUMFILES ]] ||
4576 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4577 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4578 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4580 #test lfs getstripe with -v prints lmm_fid
4581 [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
4582 error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
4583 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
4584 error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
4585 echo "$GETSTRIPE --verbose passed."
4587 #check for FID information
4588 local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
4589 local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
4590 awk '/lmm_fid: / { print $2 }')
4591 local fid3=$($LFS path2fid $DIR/$tdir/file1)
4592 [ "$fid1" != "$fid2" ] &&
4593 error "getstripe --fid $fid1 != getstripe --verbose $fid2"
4594 [ "$fid1" != "$fid3" ] &&
4595 error "getstripe --fid $fid1 != lfs path2fid $fid3"
4596 echo "$GETSTRIPE --fid passed."
4598 #test lfs getstripe with --obd
4599 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4600 grep -q "unknown obduuid" ||
4601 error "$GETSTRIPE --obd wrong_uuid should return error message"
4603 [[ $OSTCOUNT -lt 2 ]] &&
4604 skip_env "skipping other $GETSTRIPE --obd test" && return
4607 OBDUUID=$(ostuuid_from_index $OSTIDX)
4608 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4609 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4610 [[ $FOUND -eq $FILENUM ]] ||
4611 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4612 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4613 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4614 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4615 error "$GETSTRIPE --obd: should not show file on other obd"
4616 echo "$GETSTRIPE --obd passed"
4618 run_test 56a "check $GETSTRIPE"
4621 test_mkdir $DIR/$tdir
4623 for i in $(seq 1 $NUMDIRS); do
4624 test_mkdir $DIR/$tdir/dir$i
4627 # test lfs getdirstripe default mode is non-recursion, which is
4628 # different from lfs getstripe
4629 dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
4630 [[ $dircnt -eq 1 ]] ||
4631 error "$LFS getdirstripe: found $dircnt, not 1"
4632 dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
4633 grep -c lmv_stripe_count)
4634 [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
4635 error "$LFS getdirstripe --recursive: found $dircnt, \
4636 not $((NUMDIRS + 1))"
4638 run_test 56b "check $LFS getdirstripe"
4642 local ost_name=$(ostname_from_index $ost_idx)
4644 local old_status=$(ost_dev_status $ost_idx)
4645 [[ -z "$old_status" ]] ||
4646 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4648 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4651 local new_status=$(ost_dev_status $ost_idx)
4652 [[ "$new_status" = "D" ]] ||
4653 error "OST $ost_name is in status of '$new_status', not 'D'"
4655 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4658 new_status=$(ost_dev_status $ost_idx)
4659 [[ -z "$new_status" ]] ||
4660 error "OST $ost_name is in status of '$new_status', not ''"
4662 run_test 56c "check 'lfs df' showing device status"
4667 local LOCAL_NUMFILES="$1"
4668 local LOCAL_NUMDIRS="$2"
4669 local MKDIR_PARAMS="$3"
4670 local DIR_STRIPE_PARAMS="$4"
4672 if [ ! -d "$TDIR" ] ; then
4673 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4674 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4675 for i in `seq 1 $LOCAL_NUMFILES` ; do
4678 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4679 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4680 for j in `seq 1 $LOCAL_NUMFILES` ; do
4681 touch $TDIR/dir$i/file$j
4687 setup_56_special() {
4691 if [ ! -e "$TDIR/loop1b" ] ; then
4692 for i in `seq 1 $LOCAL_NUMFILES` ; do
4693 mknod $TDIR/loop${i}b b 7 $i
4694 mknod $TDIR/null${i}c c 1 3
4695 ln -s $TDIR/file1 $TDIR/link${i}l
4697 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4698 mknod $TDIR/dir$i/loop${i}b b 7 $i
4699 mknod $TDIR/dir$i/null${i}c c 1 3
4700 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4709 setup_56 $NUMFILES $NUMDIRS
4711 EXPECTED=$(($NUMDIRS + 2))
4712 # test lfs find with -name
4713 for i in $(seq 1 $NUMFILES) ; do
4714 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4715 [ $NUMS -eq $EXPECTED ] ||
4716 error "lfs find -name \"*$i\" $TDIR wrong: "\
4717 "found $NUMS, expected $EXPECTED"
4720 run_test 56g "check lfs find -name ============================="
4726 setup_56 $NUMFILES $NUMDIRS
4728 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4729 # test lfs find with ! -name
4730 for i in $(seq 1 $NUMFILES) ; do
4731 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4732 [ $NUMS -eq $EXPECTED ] ||
4733 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4734 "found $NUMS, expected $EXPECTED"
4737 run_test 56h "check lfs find ! -name ============================="
4741 test_mkdir -p $DIR/$tdir
4742 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4743 CMD="$LFIND -ost $UUID $DIR/$tdir"
4745 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4747 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4751 setup_56_special $NUMFILES $NUMDIRS
4753 EXPECTED=$((NUMDIRS + 1))
4754 CMD="$LFIND -type d $TDIR"
4755 NUMS=$($CMD | wc -l)
4756 [ $NUMS -eq $EXPECTED ] ||
4757 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4759 run_test 56j "check lfs find -type d ============================="
4763 setup_56_special $NUMFILES $NUMDIRS
4765 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4766 CMD="$LFIND -type f $TDIR"
4767 NUMS=$($CMD | wc -l)
4768 [ $NUMS -eq $EXPECTED ] ||
4769 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4771 run_test 56k "check lfs find -type f ============================="
4775 setup_56_special $NUMFILES $NUMDIRS
4777 EXPECTED=$((NUMDIRS + NUMFILES))
4778 CMD="$LFIND -type b $TDIR"
4779 NUMS=$($CMD | wc -l)
4780 [ $NUMS -eq $EXPECTED ] ||
4781 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4783 run_test 56l "check lfs find -type b ============================="
4787 setup_56_special $NUMFILES $NUMDIRS
4789 EXPECTED=$((NUMDIRS + NUMFILES))
4790 CMD="$LFIND -type c $TDIR"
4791 NUMS=$($CMD | wc -l)
4792 [ $NUMS -eq $EXPECTED ] ||
4793 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4795 run_test 56m "check lfs find -type c ============================="
4799 setup_56_special $NUMFILES $NUMDIRS
4801 EXPECTED=$((NUMDIRS + NUMFILES))
4802 CMD="$LFIND -type l $TDIR"
4803 NUMS=$($CMD | wc -l)
4804 [ $NUMS -eq $EXPECTED ] ||
4805 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4807 run_test 56n "check lfs find -type l ============================="
4811 setup_56 $NUMFILES $NUMDIRS
4812 utime $TDIR/file1 > /dev/null || error "utime (1)"
4813 utime $TDIR/file2 > /dev/null || error "utime (2)"
4814 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4815 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4816 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4817 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4820 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4821 [ $NUMS -eq $EXPECTED ] || \
4822 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4825 CMD="$LFIND -mtime 0 $TDIR"
4826 NUMS=$($CMD | wc -l)
4827 [ $NUMS -eq $EXPECTED ] ||
4828 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4830 run_test 56o "check lfs find -mtime for old files =========================="
4833 [ $RUNAS_ID -eq $UID ] &&
4834 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4837 setup_56 $NUMFILES $NUMDIRS
4839 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4841 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4842 NUMS=$($CMD | wc -l)
4843 [ $NUMS -eq $EXPECTED ] || \
4844 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4846 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4847 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4848 NUMS=$($CMD | wc -l)
4849 [ $NUMS -eq $EXPECTED ] || \
4850 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4852 run_test 56p "check lfs find -uid and ! -uid ==============================="
4855 [ $RUNAS_ID -eq $UID ] &&
4856 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4859 setup_56 $NUMFILES $NUMDIRS
4861 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4864 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4865 NUMS=$($CMD | wc -l)
4866 [ $NUMS -eq $EXPECTED ] ||
4867 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4869 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4870 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4871 NUMS=$($CMD | wc -l)
4872 [ $NUMS -eq $EXPECTED ] ||
4873 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4875 run_test 56q "check lfs find -gid and ! -gid ==============================="
4879 setup_56 $NUMFILES $NUMDIRS
4882 CMD="$LFIND -size 0 -type f $TDIR"
4883 NUMS=$($CMD | wc -l)
4884 [ $NUMS -eq $EXPECTED ] ||
4885 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4887 CMD="$LFIND ! -size 0 -type f $TDIR"
4888 NUMS=$($CMD | wc -l)
4889 [ $NUMS -eq $EXPECTED ] ||
4890 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4891 echo "test" > $TDIR/$tfile
4892 echo "test2" > $TDIR/$tfile.2 && sync
4894 CMD="$LFIND -size 5 -type f $TDIR"
4895 NUMS=$($CMD | wc -l)
4896 [ $NUMS -eq $EXPECTED ] ||
4897 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4899 CMD="$LFIND -size +5 -type f $TDIR"
4900 NUMS=$($CMD | wc -l)
4901 [ $NUMS -eq $EXPECTED ] ||
4902 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4904 CMD="$LFIND -size +0 -type f $TDIR"
4905 NUMS=$($CMD | wc -l)
4906 [ $NUMS -eq $EXPECTED ] ||
4907 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4909 CMD="$LFIND ! -size -5 -type f $TDIR"
4910 NUMS=$($CMD | wc -l)
4911 [ $NUMS -eq $EXPECTED ] ||
4912 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4914 CMD="$LFIND -size -5 -type f $TDIR"
4915 NUMS=$($CMD | wc -l)
4916 [ $NUMS -eq $EXPECTED ] ||
4917 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4919 run_test 56r "check lfs find -size works =========================="
4921 test_56s() { # LU-611
4926 for i in $(seq 1 $NUMDIRS); do
4927 $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile
4930 CMD="$LFIND -c $OSTCOUNT $TDIR"
4931 NUMS=$($CMD | wc -l)
4932 [ $NUMS -eq $EXPECTED ] || {
4934 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4938 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4939 if [[ $OSTCOUNT -gt 1 ]]; then
4940 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4944 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4948 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4949 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4950 NUMS=$($CMD | wc -l)
4951 [ $NUMS -eq $EXPECTED ] || {
4953 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4956 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4957 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4958 NUMS=$($CMD | wc -l)
4959 [ $NUMS -eq $EXPECTED ] || {
4961 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4965 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4966 NUMS=$($CMD | wc -l)
4967 [ $NUMS -eq $EXPECTED ] || {
4969 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4972 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4973 NUMS=$($CMD | wc -l)
4974 [ $NUMS -eq $EXPECTED ] || {
4976 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4980 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4981 NUMS=$($CMD | wc -l)
4982 [ $NUMS -eq $EXPECTED ] || {
4984 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4987 run_test 56s "check lfs find -stripe-count works"
4989 test_56t() { # LU-611
4994 for i in $(seq 1 $NUMDIRS); do
4995 $SETSTRIPE -S 4M $TDIR/dir$i/$tfile
4998 CMD="$LFIND -S 4M $TDIR"
4999 NUMS=$($CMD | wc -l)
5000 [ $NUMS -eq $EXPECTED ] || {
5002 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5006 setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
5008 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
5010 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
5011 CMD="$LFIND -stripe-size 512k -type f $TDIR"
5012 NUMS=$($CMD | wc -l)
5013 [ $NUMS -eq $EXPECTED ] ||
5014 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5016 CMD="$LFIND -stripe-size +320k -type f $TDIR"
5017 NUMS=$($CMD | wc -l)
5018 [ $NUMS -eq $EXPECTED ] ||
5019 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5021 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
5022 CMD="$LFIND -stripe-size +200k -type f $TDIR"
5023 NUMS=$($CMD | wc -l)
5024 [ $NUMS -eq $EXPECTED ] ||
5025 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5027 CMD="$LFIND -stripe-size -640k -type f $TDIR"
5028 NUMS=$($CMD | wc -l)
5029 [ $NUMS -eq $EXPECTED ] ||
5030 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5033 CMD="$LFIND -stripe-size 256k -type f $TDIR"
5034 NUMS=$($CMD | wc -l)
5035 [ $NUMS -eq $EXPECTED ] ||
5036 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5038 CMD="$LFIND -stripe-size -320k -type f $TDIR"
5039 NUMS=$($CMD | wc -l)
5040 [ $NUMS -eq $EXPECTED ] ||
5041 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5044 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
5045 NUMS=$($CMD | wc -l)
5046 [ $NUMS -eq $EXPECTED ] ||
5047 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5049 run_test 56t "check lfs find -stripe-size works"
5051 test_56u() { # LU-611
5053 setup_56 $NUMFILES $NUMDIRS "-i 0"
5055 if [[ $OSTCOUNT -gt 1 ]]; then
5056 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
5062 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
5063 CMD="$LFIND -stripe-index 0 -type f $TDIR"
5064 NUMS=$($CMD | wc -l)
5065 [ $NUMS -eq $EXPECTED ] ||
5066 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5069 CMD="$LFIND -stripe-index 1 -type f $TDIR"
5070 NUMS=$($CMD | wc -l)
5071 [ $NUMS -eq $EXPECTED ] ||
5072 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5074 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
5075 NUMS=$($CMD | wc -l)
5076 [ $NUMS -eq $EXPECTED ] ||
5077 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5080 # This should produce an error and not return any files
5081 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
5082 NUMS=$($CMD 2>/dev/null | wc -l)
5083 [ $NUMS -eq $EXPECTED ] ||
5084 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5086 if [[ $OSTCOUNT -gt 1 ]]; then
5087 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
5088 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
5089 NUMS=$($CMD | wc -l)
5090 [ $NUMS -eq $EXPECTED ] ||
5091 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5094 run_test 56u "check lfs find -stripe-index works"
5101 setup_56 $NUMFILES $NUMDIRS
5103 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
5104 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
5106 for file in $($LFIND -mdt $UUID $TDIR); do
5107 file_mdt_idx=$($GETSTRIPE -M $file)
5108 [ $file_mdt_idx -eq $MDT_IDX ] ||
5109 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
5112 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5115 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5119 rm -rf $TDIR || error "remove $TDIR failed"
5120 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5123 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
5124 error "$GETSTRIPE -S -d $TDIR failed"
5125 stripe_size=${stripe_size%% *}
5127 local file_size=$((stripe_size * OSTCOUNT))
5128 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5129 local required_space=$((file_num * file_size))
5131 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5133 [[ $free_space -le $((required_space / 1024)) ]] &&
5134 skip_env "need $required_space bytes, have $free_space KB" &&
5138 local dd_count=$((file_size / dd_bs))
5140 # write data into the files
5144 for i in $(seq 1 $NUMFILES); do
5146 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5147 error "write data into $file failed"
5149 for i in $(seq 1 $NUMDIRS); do
5150 for j in $(seq 1 $NUMFILES); do
5151 file=$TDIR/dir$i/file$j
5152 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5153 error "write data into $file failed"
5157 # $LFS_MIGRATE will fail if hard link migration is unsupported
5158 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5159 createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 ||
5160 error "creating links to $TDIR/dir1/file1 failed"
5164 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5167 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
5169 eval $cmd || error "$cmd failed"
5171 check_stripe_count $TDIR/file1 $expected
5173 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5175 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5176 # OST 1 if it is on OST 0. This file is small enough to
5177 # be on only one stripe.
5178 file=$TDIR/migr_1_ost
5179 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5180 error "write data into $file failed"
5181 local obdidx=$($LFS getstripe -i $file)
5182 local oldmd5=$(md5sum $file)
5184 [[ $obdidx -eq 0 ]] && newobdidx=1
5185 cmd="$LFS migrate -i $newobdidx $file"
5187 eval $cmd || error "$cmd failed"
5188 local realobdix=$($LFS getstripe -i $file)
5189 local newmd5=$(md5sum $file)
5190 [[ $newobdidx -ne $realobdix ]] &&
5191 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
5192 [[ "$oldmd5" != "$newmd5" ]] &&
5193 error "md5sum differ: $oldmd5, $newmd5"
5197 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
5199 eval $cmd || error "$cmd failed"
5201 for j in $(seq 1 $NUMFILES); do
5202 check_stripe_count $TDIR/dir1/file$j $expected
5205 # lfs_migrate works with lfs find
5206 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
5207 $LFS_MIGRATE -y -c $expected"
5209 eval $cmd || error "$cmd failed"
5211 for i in $(seq 2 $NUMFILES); do
5212 check_stripe_count $TDIR/file$i $expected
5214 for i in $(seq 2 $NUMDIRS); do
5215 for j in $(seq 1 $NUMFILES); do
5216 check_stripe_count $TDIR/dir$i/file$j $expected
5220 run_test 56w "check lfs_migrate -c stripe_count works"
5223 check_swap_layouts_support && return 0
5224 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5226 local dir0=$DIR/$tdir
5227 local ref1=/etc/passwd
5228 local file1=$dir0/file1
5230 test_mkdir $dir0 || error "creating dir $dir0"
5231 $LFS setstripe -c 2 $file1
5233 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5234 stripe=$($LFS getstripe -c $file1)
5235 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5236 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5241 run_test 56x "lfs migration support"
5244 check_swap_layouts_support && return 0
5245 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5247 local dir0=$DIR/$tdir/$testnum
5248 test_mkdir -p $dir0 || error "creating dir $dir0"
5250 local ref1=/etc/passwd
5251 local file1=$dir0/file1
5253 $LFS setstripe -c 2 $file1
5255 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5256 local stripe=$($LFS getstripe -c $file1)
5257 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5258 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5263 run_test 56xa "lfs migration --block support"
5265 check_migrate_links() {
5267 local file1="$dir/file1"
5270 local total_count=$(($begin + $count - 1))
5271 local symlink_count=10
5274 if [ ! -f "$file1" ]; then
5275 echo -n "creating initial file..."
5276 $LFS setstripe -c 1 -S "512k" "$file1" ||
5277 error "cannot setstripe initial file"
5280 echo -n "creating symlinks..."
5281 for s in $(seq 1 $symlink_count); do
5282 ln -s "$file1" "$dir/slink$s" ||
5283 error "cannot create symlinks"
5287 echo -n "creating nonlinked files..."
5288 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5289 error "cannot create nonlinked files"
5294 if [ ! -f "$dir/file$total_count" ]; then
5295 echo -n "creating hard links $begin:$total_count..."
5296 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5297 /dev/null || error "cannot create hard links"
5301 echo -n "checking number of hard links listed in xattrs..."
5302 local fid=$($LFS getstripe -F "$file1")
5303 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5306 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5307 echo "hard link list has unexpected size, skipping test"
5310 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5311 error "link names should exceed xattrs size"
5314 echo -n "migrating files..."
5315 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5317 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5320 # make sure all links have been properly migrated
5321 echo -n "verifying files..."
5322 fid=$($LFS getstripe -F "$file1") ||
5323 error "cannot get fid for file $file1"
5324 for i in $(seq 2 $total_count); do
5325 local fid2=$($LFS getstripe -F $dir/file$i)
5326 [ "$fid2" == "$fid" ] ||
5327 error "migrated hard link has mismatched FID"
5330 # make sure hard links were properly detected, and migration was
5331 # performed only once for the entire link set; nonlinked files should
5333 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5334 local expected=$(($uniq_count + 1))
5335 [ "$actual" -eq "$expected" ] ||
5336 error "hard links individually migrated ($actual != $expected)"
5338 # make sure the correct number of hard links are present
5339 local hardlinks=$(stat -c '%h' "$file1")
5340 [ $hardlinks -eq $total_count ] ||
5341 error "num hard links $hardlinks != $total_count"
5348 local dir0="$DIR/$tdir"
5350 test_mkdir "$dir0" || error "cannot create dir $dir0"
5352 echo "testing lfs migrate mode when all links fit within xattrs"
5353 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 2 99
5355 echo "testing rsync mode when all links fit within xattrs"
5356 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 2 99
5358 echo "testing lfs migrate mode when all links do not fit within xattrs"
5359 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 101 100
5361 echo "testing rsync mode when all links do not fit within xattrs"
5362 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 101 100
5367 run_test 56xb "lfs migration hard link support"
5370 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5371 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5375 local dir0=$DIR/$tdir/$testnum
5376 test_mkdir -p $dir0 || error "creating dir $dir0"
5377 local f1=$dir0/file1
5378 local f2=$dir0/file2
5380 touch $f1 || error "creating std file $f1"
5381 $MULTIOP $f2 H2c || error "creating released file $f2"
5383 # a directory can be raid0, so ask only for files
5384 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5385 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5387 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5388 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5390 # only files can be released, so no need to force file search
5391 res=$($LFIND $dir0 -L released)
5392 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5394 res=$($LFIND $dir0 \! -L released)
5395 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5398 run_test 56y "lfs find -L raid0|released"
5400 test_56z() { # LU-4824
5401 # This checks to make sure 'lfs find' continues after errors
5402 # There are two classes of errors that should be caught:
5403 # - If multiple paths are provided, all should be searched even if one
5405 # - If errors are encountered during the search, it should not terminate
5408 test_mkdir $DIR/$tdir
5409 for i in d{0..9}; do
5410 test_mkdir $DIR/$tdir/$i
5412 touch $DIR/$tdir/d{0..9}/$tfile
5413 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5414 error "$LFS find did not return an error"
5415 # Make a directory unsearchable. This should NOT be the last entry in
5416 # directory order. Arbitrarily pick the 6th entry
5417 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5418 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5419 # The user should be able to see 10 directories and 9 files
5420 [ $count == 19 ] || error "$LFS find did not continue after error"
5422 run_test 56z "lfs find should continue after an error"
5424 test_56aa() { # LU-5937
5425 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5428 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5430 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5431 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5433 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5435 run_test 56aa "lfs find --size under striped dir"
5438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5439 # note test will not do anything if MDS is not local
5440 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5441 skip "ldiskfs only test"
5445 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5446 local MNTDEV="osd*.*MDT*.mntdev"
5447 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5448 [ -z "$DEV" ] && error "can't access $MNTDEV"
5449 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5450 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5451 error "can't access $DEV"
5452 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5453 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5457 run_test 57a "verify MDS filesystem created with large inodes =="
5460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5461 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5462 skip "ldiskfs only test"
5466 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5467 local dir=$DIR/$tdir
5471 local FILEN=$dir/f$FILECOUNT
5473 rm -rf $dir || error "removing $dir"
5474 test_mkdir -p -c1 $dir || error "creating $dir"
5475 local mdtidx=$($LFS getstripe -M $dir)
5476 local mdtname=MDT$(printf %04x $mdtidx)
5477 local facet=mds$((mdtidx + 1))
5479 echo "mcreating $FILECOUNT files"
5480 createmany -m $dir/f 1 $FILECOUNT || \
5481 error "creating files in $dir"
5483 # verify that files do not have EAs yet
5484 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5485 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5489 df $dir #make sure we get new statfs data
5490 local MDSFREE=$(do_facet $facet \
5491 lctl get_param -n osd*.*$mdtname.kbytesfree)
5492 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5493 echo "opening files to create objects/EAs"
5495 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5496 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5499 # verify that files have EAs now
5500 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5501 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5503 sleep 1 #make sure we get new statfs data
5505 local MDSFREE2=$(do_facet $facet \
5506 lctl get_param -n osd*.*$mdtname.kbytesfree)
5507 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5508 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5509 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5510 error "MDC before $MDCFREE != after $MDCFREE2"
5512 echo "MDC before $MDCFREE != after $MDCFREE2"
5513 echo "unable to confirm if MDS has large inodes"
5518 run_test 57b "default LOV EAs are stored inside large inodes ==="
5521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5522 [ -z "$(which wiretest 2>/dev/null)" ] &&
5523 skip_env "could not find wiretest" && return
5526 run_test 58 "verify cross-platform wire constants =============="
5529 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5530 echo "touch 130 files"
5531 createmany -o $DIR/f59- 130
5533 unlinkmany $DIR/f59- 130
5535 # wait for commitment of removal
5536 wait_delete_completed
5538 run_test 59 "verify cancellation of llog records async ========="
5540 TEST60_HEAD="test_60 run $RANDOM"
5542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5543 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5544 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5545 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5546 skip_env "missing subtest run-llog.sh" && return
5548 log "$TEST60_HEAD - from kernel mode"
5549 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5550 do_facet mgs sh run-llog.sh
5551 do_facet mgs $LCTL dk > $TMP/$tfile
5553 # LU-6388: test llog_reader
5554 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5555 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5556 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5557 skip_env "missing llog_reader" && return
5558 local fstype=$(facet_fstype mgs)
5559 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5560 skip_env "Only for ldiskfs or zfs type mgs" && return
5562 local mntpt=$(facet_mntpt mgs)
5563 local mgsdev=$(mgsdevname 1)
5575 #get fid and record list
5576 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5578 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5580 #remount mgs as ldiskfs or zfs type
5581 stop mgs || error "stop mgs failed"
5582 mount_fstype mgs || error "remount mgs failed"
5583 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5586 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5587 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5592 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5594 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5596 echo "obj_file is $obj_file"
5597 do_facet mgs $llog_reader $obj_file
5599 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5600 awk '{ print $3 }' | sed -e "s/^type=//g")
5601 if [ $rec_type != $rec ]; then
5602 echo "FAILED test_60a wrong record type $rec_type," \
5608 #check obj path if record type is LLOG_LOGID_MAGIC
5609 if [ "$rec" == "1064553b" ]; then
5610 path=$(do_facet mgs $llog_reader $obj_file |
5611 grep "path=" | awk '{ print $NF }' |
5612 sed -e "s/^path=//g")
5613 if [ $obj_file != $mntpt/$path ]; then
5614 echo "FAILED test_60a wrong obj path" \
5615 "$montpt/$path, should be $obj_file"
5622 #restart mgs before "error", otherwise it will block the next test
5623 stop mgs || error "stop mgs failed"
5624 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5625 $pass || error "test failed, see FAILED test_60a messages for specifics"
5627 run_test 60a "llog_test run from kernel module and test llog_reader"
5630 # test old logid format
5631 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5632 do_facet mgs $LCTL dl | grep MGS
5633 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5634 error "old llog_print failed"
5637 # test new logid format
5638 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5639 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5640 error "new llog_print failed"
5643 run_test 60aa "llog_print works with FIDs and simple names"
5645 test_60b() { # bug 6411
5646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5648 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5660 [[ $LLOG_COUNT -gt 100 ]] &&
5661 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5663 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5667 echo "create 5000 files"
5668 createmany -o $DIR/f60c- 5000
5669 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5670 lctl set_param fail_loc=0x80000137
5671 unlinkmany $DIR/f60c- 5000
5672 lctl set_param fail_loc=0
5674 run_test 60c "unlink file when mds full"
5677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5678 SAVEPRINTK=$(lctl get_param -n printk)
5680 # verify "lctl mark" is even working"
5681 MESSAGE="test message ID $RANDOM $$"
5682 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5683 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5685 lctl set_param printk=0 || error "set lnet.printk failed"
5686 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5687 MESSAGE="new test message ID $RANDOM $$"
5688 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5689 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5690 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5692 lctl set_param -n printk="$SAVEPRINTK"
5694 run_test 60d "test printk console message masking"
5697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5698 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5700 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5701 do_facet mds1 lctl set_param fail_loc=0x15b
5704 run_test 60e "no space while new llog is being created"
5707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5709 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5710 cancel_lru_locks osc
5711 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5714 run_test 61 "mmap() writes don't make sync hang ================"
5716 # bug 2330 - insufficient obd_match error checking causes LBUG
5718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5721 cancel_lru_locks osc
5722 lctl set_param fail_loc=0x405
5723 cat $f && error "cat succeeded, expect -EIO"
5724 lctl set_param fail_loc=0
5726 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5727 # match every page all of the time.
5728 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5730 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5731 # Though this test is irrelevant anymore, it helped to reveal some
5732 # other grant bugs (LU-4482), let's keep it.
5733 test_63a() { # was test_63
5734 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5735 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5736 for i in `seq 10` ; do
5737 dd if=/dev/zero of=$DIR/f63 bs=8k &
5743 rm -f $DIR/f63 || true
5745 run_test 63a "Verify oig_wait interruption does not crash ======="
5747 # bug 2248 - async write errors didn't return to application on sync
5748 # bug 3677 - async write errors left page locked
5750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5752 lctl set_param debug=-1
5754 # ensure we have a grant to do async writes
5755 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5758 sync # sync lest earlier test intercept the fail_loc
5760 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5761 lctl set_param fail_loc=0x80000406
5762 $MULTIOP $DIR/$tfile Owy && \
5763 error "sync didn't return ENOMEM"
5764 sync; sleep 2; sync # do a real sync this time to flush page
5765 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5766 error "locked page left in cache after async error" || true
5769 run_test 63b "async write errors should be returned to fsync ==="
5772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5774 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5776 run_test 64a "verify filter grant calculations (in kernel) ====="
5779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5780 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5782 run_test 64b "check out-of-space detection on client ==========="
5785 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5787 run_test 64c "verify grant shrink ========================------"
5789 # bug 1414 - set/get directories' stripe info
5791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5792 test_mkdir -p $DIR/$tdir
5794 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5796 run_test 65a "directory with no stripe info ===================="
5799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5800 test_mkdir -p $DIR/$tdir
5801 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5803 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5806 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5808 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5812 if [[ $OSTCOUNT -gt 1 ]]; then
5813 test_mkdir -p $DIR/$tdir
5814 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5816 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5817 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5819 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5822 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5826 test_mkdir -p $DIR/$tdir
5827 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5828 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5830 if [[ $STRIPECOUNT -le 0 ]]; then
5832 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5833 #LOV_MAX_STRIPE_COUNT is 2000
5834 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5836 sc=$(($STRIPECOUNT - 1))
5838 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5839 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5840 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5841 error "lverify failed"
5843 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5847 test_mkdir -p $DIR/$tdir
5849 $SETSTRIPE $DIR/$tdir || error "setstripe"
5850 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5851 error "no stripe info failed"
5853 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5855 run_test 65e "directory setstripe defaults ======================="
5858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5859 test_mkdir -p $DIR/${tdir}f
5860 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5862 run_test 65f "dir setstripe permission (should return error) ==="
5865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5866 test_mkdir -p $DIR/$tdir
5867 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5869 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5871 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5872 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5873 error "delete default stripe failed"
5875 run_test 65g "directory setstripe -d ==========================="
5878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5879 test_mkdir -p $DIR/$tdir
5880 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5882 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5884 test_mkdir -p $DIR/$tdir/dd1
5885 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5886 error "stripe info inherit failed"
5888 run_test 65h "directory stripe info inherit ===================="
5890 test_65i() { # bug6367
5891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5892 $SETSTRIPE -S 65536 -c -1 $MOUNT
5894 run_test 65i "set non-default striping on root directory (bug 6367)="
5896 test_65ia() { # bug12836
5897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5898 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5900 run_test 65ia "getstripe on -1 default directory striping"
5902 test_65ib() { # bug12836
5903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5904 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5906 run_test 65ib "getstripe -v on -1 default directory striping"
5908 test_65ic() { # bug12836
5909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5910 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5912 run_test 65ic "new find on -1 default directory striping"
5914 test_65j() { # bug6367
5915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5917 # if we aren't already remounting for each test, do so for this test
5918 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5919 cleanup || error "failed to unmount"
5922 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5924 run_test 65j "set default striping on root directory (bug 6367)="
5926 test_65k() { # bug11679
5927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5928 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5929 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5931 local disable_precreate=true
5932 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
5933 disable_precreate=false
5935 echo "Check OST status: "
5936 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
5937 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
5939 for OSC in $MDS_OSCS; do
5940 echo $OSC "is active"
5941 do_facet $SINGLEMDS lctl --device %$OSC activate
5944 for INACTIVE_OSC in $MDS_OSCS; do
5945 local ost=$(osc_to_ost $INACTIVE_OSC)
5946 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
5947 lov.*md*.target_obd |
5948 awk -F: /$ost/'{ print $1 }' | head -n 1)
5951 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
5952 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
5954 echo "Deactivate: " $INACTIVE_OSC
5955 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5957 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
5958 osp.$ost*MDT0000.create_count")
5959 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
5960 osp.$ost*MDT0000.max_create_count")
5961 $disable_precreate &&
5962 do_facet $SINGLEMDS "lctl set_param -n \
5963 osp.$ost*MDT0000.max_create_count=0"
5965 for idx in $(seq 0 $((OSTCOUNT - 1))); do
5966 [ -f $DIR/$tdir/$idx ] && continue
5967 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
5968 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
5969 error "setstripe $idx should succeed"
5970 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
5972 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
5975 do_facet $SINGLEMDS "lctl set_param -n \
5976 osp.$ost*MDT0000.max_create_count=$max_count"
5977 do_facet $SINGLEMDS "lctl set_param -n \
5978 osp.$ost*MDT0000.create_count=$count"
5979 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5980 echo $INACTIVE_OSC "is Activate"
5982 wait_osc_import_state mds ost$ostnum FULL
5985 run_test 65k "validate manual striping works properly with deactivated OSCs"
5987 test_65l() { # bug 12836
5988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5989 test_mkdir -p $DIR/$tdir/test_dir
5990 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5991 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5993 run_test 65l "lfs find on -1 stripe dir ========================"
5996 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
5999 run_test 65m "normal user can't set filesystem default stripe"
6001 # bug 2543 - update blocks count on client
6003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6005 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6006 sync; sync_all_data; sync; sync_all_data
6007 cancel_lru_locks osc
6008 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6009 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6011 run_test 66 "update inode blocks count on client ==============="
6014 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6018 swapon -s | awk '($1 == "'$1'") { print $4 }'
6021 # bug5265, obdfilter oa2dentry return -ENOENT
6022 # #define OBD_FAIL_SRV_ENOENT 0x217
6024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6025 remote_ost_nodsh && skip "remote OST with nodsh" && return
6028 $SETSTRIPE -c 1 -i 0 $f
6030 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6032 do_facet ost1 lctl set_param fail_loc=0x217
6033 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6034 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6036 do_facet ost1 lctl set_param fail_loc=0
6037 $DIRECTIO write $f 0 2 || error "write error"
6039 cancel_lru_locks osc
6040 $DIRECTIO read $f 0 1 || error "read error"
6042 do_facet ost1 lctl set_param fail_loc=0x217
6043 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6045 do_facet ost1 lctl set_param fail_loc=0
6048 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6051 test_mkdir -p $DIR/$tdir
6052 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6053 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6055 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6057 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6058 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6059 [ "$RUNAS_ID" = "$UID" ] &&
6060 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6062 # Check that testing environment is properly set up. Skip if not
6063 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
6064 skip_env "User $RUNAS_ID does not exist - skipping"
6068 chmod 777 $DIR/$tfile
6069 chmod ug+s $DIR/$tfile
6070 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6071 error "$RUNAS dd $DIR/$tfile failed"
6072 # See if we are still setuid/sgid
6073 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6074 error "S/gid is not dropped on write"
6075 # Now test that MDS is updated too
6076 cancel_lru_locks mdc
6077 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6078 error "S/gid is not dropped on MDS"
6081 run_test 72a "Test that remove suid works properly (bug5695) ===="
6083 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6086 [ "$RUNAS_ID" = "$UID" ] && \
6087 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6088 [ "$RUNAS_ID" -eq 0 ] && \
6089 skip_env "RUNAS_ID = 0 -- skipping" && return
6091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6092 # Check that testing environment is properly set up. Skip if not
6093 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
6094 skip_env "User $RUNAS_ID does not exist - skipping"
6097 touch $DIR/${tfile}-f{g,u}
6098 test_mkdir $DIR/${tfile}-dg
6099 test_mkdir $DIR/${tfile}-du
6100 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6101 chmod g+s $DIR/${tfile}-{f,d}g
6102 chmod u+s $DIR/${tfile}-{f,d}u
6103 for perm in 777 2777 4777; do
6104 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6105 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6106 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6107 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6111 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6113 # bug 3462 - multiple simultaneous MDC requests
6115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6116 test_mkdir $DIR/d73-1
6117 test_mkdir $DIR/d73-2
6118 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6121 lctl set_param fail_loc=0x80000129
6122 $MULTIOP $DIR/d73-1/f73-2 Oc &
6124 lctl set_param fail_loc=0
6126 $MULTIOP $DIR/d73-2/f73-3 Oc &
6130 wait $pid1 || return 1
6134 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6135 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6136 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6140 run_test 73 "multiple MDC requests (should not deadlock)"
6142 test_74a() { # bug 6149, 6184
6143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6144 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6146 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6147 # will spin in a tight reconnection loop
6149 $LCTL set_param fail_loc=0x8000030e
6150 # get any lock that won't be difficult - lookup works.
6152 $LCTL set_param fail_loc=0
6156 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6158 test_74b() { # bug 13310
6159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6160 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6162 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6163 # will spin in a tight reconnection loop
6164 $LCTL set_param fail_loc=0x8000030e
6165 # get a "difficult" lock
6167 $LCTL set_param fail_loc=0
6171 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6175 #define OBD_FAIL_LDLM_NEW_LOCK
6176 $LCTL set_param fail_loc=0x319
6177 touch $DIR/$tfile && error "touch successful"
6178 $LCTL set_param fail_loc=0
6181 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6184 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6187 test_76() { # Now for bug 20433, added originally in bug 1443
6188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6189 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6190 cancel_lru_locks osc
6191 BEFORE_INODES=$(num_inodes)
6192 echo "before inodes: $BEFORE_INODES"
6194 [ "$SLOW" = "no" ] && COUNT=100
6195 for i in $(seq $COUNT); do
6199 cancel_lru_locks osc
6200 AFTER_INODES=$(num_inodes)
6201 echo "after inodes: $AFTER_INODES"
6203 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6205 AFTER_INODES=$(num_inodes)
6207 echo "wait $wait seconds inodes: $AFTER_INODES"
6208 if [ $wait -gt 30 ]; then
6209 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6213 run_test 76 "confirm clients recycle inodes properly ===="
6219 # Note: in sptlrpc modes which enable its own bulk checksum, the
6220 # original crc32_le bulk checksum will be automatically disabled,
6221 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6222 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6223 # In this case set_checksums() will not be no-op, because sptlrpc
6224 # bulk checksum will be enabled all through the test.
6226 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6227 lctl set_param -n osc.*.checksums $1
6231 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6232 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6233 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6234 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6237 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6238 log "set checksum type to $1"
6241 F77_TMP=$TMP/f77-temp
6244 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6245 error "error writing to $F77_TMP"
6248 test_77a() { # bug 10889
6249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6250 $GSS && skip "could not run with gss" && return
6251 [ ! -f $F77_TMP ] && setup_f77
6253 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6257 run_test 77a "normal checksum read/write operation"
6259 test_77b() { # bug 10889
6260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6261 $GSS && skip "could not run with gss" && return
6262 [ ! -f $F77_TMP ] && setup_f77
6263 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6264 $LCTL set_param fail_loc=0x80000409
6267 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6268 error "dd error: $?"
6269 $LCTL set_param fail_loc=0
6271 for algo in $CKSUM_TYPES; do
6272 cancel_lru_locks osc
6273 set_checksum_type $algo
6274 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6275 $LCTL set_param fail_loc=0x80000408
6276 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6277 $LCTL set_param fail_loc=0
6280 set_checksum_type $ORIG_CSUM_TYPE
6283 run_test 77b "checksum error on client write, read"
6288 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6290 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6291 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6292 $check_ost && [ -n $ost_file_prefix ] &&
6293 do_facet ost1 rm -f ${ost_file_prefix}\*
6297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6298 $GSS && skip "could not run with gss" && return
6301 local osc_file_prefix
6303 local check_ost=false
6304 local ost_file_prefix
6310 # ensure corruption will occur on first OSS/OST
6311 $LFS setstripe -i 0 $DIR/$tfile
6313 [ ! -f $F77_TMP ] && setup_f77
6314 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6315 error "dd write error: $?"
6316 fid=$($LFS path2fid $DIR/$tfile)
6318 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6321 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6322 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6324 echo "OSS do not support bulk pages dump upon error"
6327 osc_file_prefix=$($LCTL get_param -n debug_path)
6328 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6330 trap cleanup_77c EXIT
6333 # enable bulk pages dump upon error on Client
6334 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6335 # enable bulk pages dump upon error on OSS
6337 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6339 # flush Client cache to allow next read to reach OSS
6340 cancel_lru_locks osc
6342 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6343 $LCTL set_param fail_loc=0x80000408
6344 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6345 $LCTL set_param fail_loc=0
6349 # check cksum dump on Client
6350 osc_file=$(ls ${osc_file_prefix}*)
6351 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6352 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6353 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6354 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6355 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6357 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6358 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6359 error "dump content does not match on Client"
6361 $check_ost || { skip "No need to check cksum dump on OSS"; return 0; }
6363 # check cksum dump on OSS
6364 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6365 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6366 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6367 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6368 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6369 error "dump content does not match on OSS"
6373 run_test 77c "checksum error on client read with debug"
6375 test_77d() { # bug 10889
6376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6377 $GSS && skip "could not run with gss" && return
6378 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6379 $LCTL set_param fail_loc=0x80000409
6381 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6382 error "direct write: rc=$?"
6383 $LCTL set_param fail_loc=0
6386 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6387 $LCTL set_param fail_loc=0x80000408
6389 cancel_lru_locks osc
6390 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6391 error "direct read: rc=$?"
6392 $LCTL set_param fail_loc=0
6395 run_test 77d "checksum error on OST direct write, read"
6397 test_77f() { # bug 10889
6398 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6399 $GSS && skip "could not run with gss" && return
6401 for algo in $CKSUM_TYPES; do
6402 cancel_lru_locks osc
6403 set_checksum_type $algo
6404 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6405 $LCTL set_param fail_loc=0x409
6406 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6407 error "direct write succeeded"
6408 $LCTL set_param fail_loc=0
6410 set_checksum_type $ORIG_CSUM_TYPE
6413 run_test 77f "repeat checksum error on write (expect error)"
6415 test_77g() { # bug 10889
6416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6417 $GSS && skip "could not run with gss" && return
6418 remote_ost_nodsh && skip "remote OST with nodsh" && return
6420 [ ! -f $F77_TMP ] && setup_f77
6422 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6423 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6424 do_facet ost1 lctl set_param fail_loc=0x8000021a
6426 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6427 error "write error: rc=$?"
6428 do_facet ost1 lctl set_param fail_loc=0
6431 cancel_lru_locks osc
6432 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6433 do_facet ost1 lctl set_param fail_loc=0x8000021b
6435 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6436 do_facet ost1 lctl set_param fail_loc=0
6439 run_test 77g "checksum error on OST write, read"
6441 test_77j() { # bug 13805
6442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6443 $GSS && skip "could not run with gss" && return
6444 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6445 lctl set_param fail_loc=0x40c
6446 remount_client $MOUNT
6447 lctl set_param fail_loc=0
6448 # wait async osc connect to finish and reflect updated state value
6450 for (( i=0; i < OSTCOUNT; i++ )) ; do
6451 wait_osc_import_state client ost$((i+1)) FULL
6454 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6455 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6456 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6457 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6459 remount_client $MOUNT
6461 run_test 77j "client only supporting ADLER32"
6463 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6472 test_78() { # bug 10901
6473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6474 remote_ost || { skip_env "local OST" && return; }
6477 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6478 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6479 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6480 echo "MemTotal: $MEMTOTAL"
6482 # reserve 256MB of memory for the kernel and other running processes,
6483 # and then take 1/2 of the remaining memory for the read/write buffers.
6484 if [ $MEMTOTAL -gt 512 ] ;then
6485 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6487 # for those poor memory-starved high-end clusters...
6488 MEMTOTAL=$((MEMTOTAL / 2))
6490 echo "Mem to use for directio: $MEMTOTAL"
6492 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6493 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6494 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6495 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6497 echo "Smallest OST: $SMALLESTOST"
6498 [[ $SMALLESTOST -lt 10240 ]] &&
6499 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6501 trap cleanup_test_78 EXIT
6503 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6504 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6506 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6507 echo "File size: $F78SIZE"
6508 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6509 for i in $(seq 1 $NSEQ); do
6510 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6511 echo directIO rdwr round $i of $NSEQ
6512 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6517 run_test 78 "handle large O_DIRECT writes correctly ============"
6519 test_79() { # bug 12743
6520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6521 wait_delete_completed
6523 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6524 BKFREE=$(calc_osc_kbytes kbytesfree)
6525 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6527 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6528 DFTOTAL=`echo $STRING | cut -d, -f1`
6529 DFUSED=`echo $STRING | cut -d, -f2`
6530 DFAVAIL=`echo $STRING | cut -d, -f3`
6531 DFFREE=$(($DFTOTAL - $DFUSED))
6533 ALLOWANCE=$((64 * $OSTCOUNT))
6535 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6536 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6537 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6539 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6540 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6541 error "df free($DFFREE) mismatch OST free($BKFREE)"
6543 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6544 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6545 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6548 run_test 79 "df report consistency check ======================="
6550 test_80() { # bug 10718
6551 remote_ost_nodsh && skip "remote OST with nodsh" && return
6552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6553 # relax strong synchronous semantics for slow backends like ZFS
6554 local soc="obdfilter.*.sync_on_lock_cancel"
6555 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6557 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6558 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6559 facet_active_host $host; done | sort -u)
6560 do_nodes $hosts lctl set_param $soc=never
6563 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6565 local BEFORE=`date +%s`
6566 cancel_lru_locks osc
6567 local AFTER=`date +%s`
6568 local DIFF=$((AFTER-BEFORE))
6569 if [ $DIFF -gt 1 ] ; then
6570 error "elapsed for 1M@1T = $DIFF"
6573 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6577 run_test 80 "Page eviction is equally fast at high offsets too ===="
6579 test_81a() { # LU-456
6580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6581 remote_ost_nodsh && skip "remote OST with nodsh" && return
6582 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6583 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6584 do_facet ost1 lctl set_param fail_loc=0x80000228
6586 # write should trigger a retry and success
6587 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6588 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6590 if [ $RC -ne 0 ] ; then
6591 error "write should success, but failed for $RC"
6594 run_test 81a "OST should retry write when get -ENOSPC ==============="
6596 test_81b() { # LU-456
6597 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6598 remote_ost_nodsh && skip "remote OST with nodsh" && return
6599 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6600 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6601 do_facet ost1 lctl set_param fail_loc=0x228
6603 # write should retry several times and return -ENOSPC finally
6604 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6605 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6608 if [ $RC -ne $ENOSPC ] ; then
6609 error "dd should fail for -ENOSPC, but succeed."
6612 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6614 test_82() { # LU-1031
6615 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6619 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6621 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6623 kill -USR1 $MULTIPID2
6625 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6626 error "First grouplock does not block second one"
6628 echo "Second grouplock blocks first one"
6630 kill -USR1 $MULTIPID1
6634 run_test 82 "Basic grouplock test ==============================="
6637 local sfile="/boot/System.map-$(uname -r)"
6638 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6639 $LCTL set_param fail_loc=0x140d
6640 cp $sfile $DIR/$tfile || error "write failed"
6641 diff -c $sfile $DIR/$tfile || error "files are different"
6642 $LCTL set_param fail_loc=0
6645 run_test 83 "Short write in ptask ==============================="
6648 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6650 test_mkdir -p $DIR/d99cvsroot
6651 chown $RUNAS_ID $DIR/d99cvsroot
6652 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6655 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6658 run_test 99a "cvs init ========================================="
6661 [ -z "$(which cvs 2>/dev/null)" ] &&
6662 skip_env "could not find cvs" && return
6663 [ ! -d $DIR/d99cvsroot ] && test_99a
6665 # some versions of cvs import exit(1) when asked to import links or
6666 # files they can't read. ignore those files.
6667 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6668 ! -perm /4 -printf '-I %f\n')
6669 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6670 d99reposname vtag rtag
6672 run_test 99b "cvs import ======================================="
6675 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6676 [ ! -d $DIR/d99cvsroot ] && test_99b
6678 test_mkdir -p $DIR/d99reposname
6679 chown $RUNAS_ID $DIR/d99reposname
6680 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6682 run_test 99c "cvs checkout ====================================="
6685 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6686 [ ! -d $DIR/d99cvsroot ] && test_99c
6687 cd $DIR/d99reposname
6689 $RUNAS cvs add -m 'addmsg' foo99
6691 run_test 99d "cvs add =========================================="
6694 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6695 [ ! -d $DIR/d99cvsroot ] && test_99c
6696 cd $DIR/d99reposname
6699 run_test 99e "cvs update ======================================="
6702 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6703 [ ! -d $DIR/d99cvsroot ] && test_99d
6704 cd $DIR/d99reposname
6705 $RUNAS cvs commit -m 'nomsg' foo99
6706 rm -fr $DIR/d99cvsroot
6708 run_test 99f "cvs commit ======================================="
6711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6712 [[ "$NETTYPE" =~ tcp ]] ||
6713 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
6716 remote_ost_nodsh && skip "remote OST with nodsh" && return
6717 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6719 { skip "useless for local single node setup" && return; }
6721 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6722 [ "$PROT" != "tcp" ] && continue
6723 RPORT=$(echo $REMOTE | cut -d: -f2)
6724 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6727 LPORT=`echo $LOCAL | cut -d: -f2`
6728 if [ $LPORT -ge 1024 ]; then
6729 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6731 error_exit "local: $LPORT > 1024, remote: $RPORT"
6734 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6736 run_test 100 "check local port using privileged port ==========="
6738 function get_named_value()
6747 echo $line | sed "s/^$tag[ ]*//"
6754 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6755 awk '/^max_cached_mb/ { print $2 }')
6758 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6763 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6764 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
6768 local cache_limit=32
6770 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6771 trap cleanup_101a EXIT
6772 $LCTL set_param -n llite.*.read_ahead_stats 0
6773 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6776 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6778 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6779 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6782 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6783 get_named_value 'read but discarded' | cut -d" " -f1); do
6784 discard=$(($discard + $s))
6788 if [[ $(($discard * 10)) -gt $nreads ]]; then
6789 $LCTL get_param osc.*-osc*.rpc_stats
6790 $LCTL get_param llite.*.read_ahead_stats
6791 error "too many ($discard) discarded pages"
6793 rm -f $DIR/$tfile || true
6795 run_test 101a "check read-ahead for random reads ================"
6798 test_mkdir -p $DIR/$tdir
6799 local STRIPE_SIZE=$1
6800 local FILE_LENGTH=$2
6803 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6805 local list=$(comma_list $(osts_nodes))
6806 set_osd_param $list '' read_cache_enable 0
6807 set_osd_param $list '' writethrough_cache_enable 0
6809 trap cleanup_test101bc EXIT
6810 # prepare the read-ahead file
6811 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6813 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6814 count=$FILE_SIZE_MB 2> /dev/null
6818 cleanup_test101bc() {
6823 local list=$(comma_list $(osts_nodes))
6824 set_osd_param $list '' read_cache_enable 1
6825 set_osd_param $list '' writethrough_cache_enable 1
6829 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6834 local STRIPE_SIZE=$2
6835 local FILE_LENGTH=$3
6836 local RA_INC=1048576
6837 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6838 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6839 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6840 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6841 get_named_value 'read but discarded' |
6842 cut -d" " -f1 | calc_total)
6843 if [[ $DISCARD -gt $discard_limit ]]; then
6844 $LCTL get_param llite.*.read_ahead_stats
6845 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6847 echo "Read-ahead success for size ${READ_SIZE}"
6852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6853 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6854 local STRIPE_SIZE=1048576
6855 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6856 if [ $SLOW == "yes" ]; then
6857 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6859 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6862 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6864 # prepare the read-ahead file
6865 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6866 cancel_lru_locks osc
6867 for BIDX in 2 4 8 16 32 64 128 256
6869 local BSIZE=$((BIDX*4096))
6870 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6871 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6872 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6873 $LCTL set_param -n llite.*.read_ahead_stats 0
6874 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6875 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6876 cancel_lru_locks osc
6877 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6882 run_test 101b "check stride-io mode read-ahead ================="
6885 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6886 local STRIPE_SIZE=1048576
6887 local FILE_LENGTH=$((STRIPE_SIZE*100))
6891 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6893 cancel_lru_locks osc
6894 $LCTL set_param osc.*.rpc_stats 0
6895 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6896 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6897 local stats=$($LCTL get_param -n $osc_rpc_stats)
6898 local lines=$(echo "$stats" | awk 'END {print NR;}')
6901 if [ $lines -le 20 ]; then
6904 for size in 1 2 4 8; do
6905 local rpc=$(echo "$stats" |
6906 awk '($1 == "'$size':") {print $2; exit; }')
6908 error "Small $((size*4))k read IO $rpc !"
6910 echo "$osc_rpc_stats check passed!"
6915 run_test 101c "check stripe_size aligned read-ahead ================="
6918 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6919 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6924 local file=$DIR/$tfile
6925 local sz_MB=${FILESIZE_101d:-500}
6926 local ra_MB=${READAHEAD_MB:-40}
6928 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6929 [ $free_MB -lt $sz_MB ] &&
6930 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6932 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6933 $SETSTRIPE -c -1 $file || error "setstripe failed"
6935 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6936 echo Cancel LRU locks on lustre client to flush the client cache
6937 cancel_lru_locks osc
6939 echo Disable read-ahead
6940 local old_READAHEAD=$(set_read_ahead 0)
6942 echo Reading the test file $file with read-ahead disabled
6943 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6945 echo Cancel LRU locks on lustre client to flush the client cache
6946 cancel_lru_locks osc
6947 echo Enable read-ahead with ${ra_MB}MB
6948 set_read_ahead $ra_MB
6950 echo Reading the test file $file with read-ahead enabled
6951 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6953 echo "read-ahead disabled time read $raOFF"
6954 echo "read-ahead enabled time read $raON"
6956 set_read_ahead $old_READAHEAD
6958 wait_delete_completed
6960 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6961 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6963 run_test 101d "file read with and without read-ahead enabled"
6966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6967 local file=$DIR/$tfile
6968 local size_KB=500 #KB
6972 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6973 local need_KB=$((count * size_KB))
6974 [[ $free_KB -le $need_KB ]] &&
6975 skip_env "Need free space $need_KB, have $free_KB" && return
6977 echo "Creating $count ${size_KB}K test files"
6978 for ((i = 0; i < $count; i++)); do
6979 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6982 echo "Cancel LRU locks on lustre client to flush the client cache"
6983 cancel_lru_locks osc
6985 echo "Reset readahead stats"
6986 $LCTL set_param -n llite.*.read_ahead_stats 0
6988 for ((i = 0; i < $count; i++)); do
6989 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6992 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6993 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6995 for ((i = 0; i < $count; i++)); do
6996 rm -rf $file.$i 2>/dev/null
6999 #10000 means 20% reads are missing in readahead
7000 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7002 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7005 which iozone || { skip "no iozone installed" && return; }
7007 local old_debug=$($LCTL get_param debug)
7008 old_debug=${old_debug#*=}
7009 $LCTL set_param debug="reada mmap"
7011 # create a test file
7012 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7014 echo Cancel LRU locks on lustre client to flush the client cache
7015 cancel_lru_locks osc
7017 echo Reset readahead stats
7018 $LCTL set_param -n llite.*.read_ahead_stats 0
7020 echo mmap read the file with small block size
7021 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7024 echo checking missing pages
7025 $LCTL get_param llite.*.read_ahead_stats
7026 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7027 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7029 $LCTL set_param debug="$old_debug"
7030 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7033 run_test 101f "check mmap read performance"
7035 test_101g_brw_size_test() {
7037 local pages=$((mb * 1048576 / $(page_size)))
7039 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7040 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7041 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7042 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7046 $LCTL set_param -n osc.*.rpc_stats=0
7048 # 10 RPCs should be enough for the test
7050 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
7051 { error "dd write ${mb} MB blocks failed"; return 3; }
7052 cancel_lru_locks osc
7053 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
7054 { error "dd write ${mb} MB blocks failed"; return 4; }
7056 # calculate number of full-sized read and write RPCs
7057 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7058 sed -n '/pages per rpc/,/^$/p' |
7059 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7060 END { print reads,writes }'))
7061 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7063 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7071 local osts=$(get_facets OST)
7072 local list=$(comma_list $(osts_nodes))
7073 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7074 local brw_size="obdfilter.*.brw_size"
7075 local ostver=$(lustre_version_code ost1)
7077 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7079 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7080 if [ $ostver -ge $(version_code 2.8.52) ] ||
7081 [ $ostver -ge $(version_code 2.7.17) -a \
7082 $ostver -lt $(version_code 2.7.50) ]; then
7083 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7084 if [[ $orig_mb -lt 16 ]]; then
7085 save_lustre_params $osts "$brw_size" > $p
7086 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7087 error "set 16MB RPC size failed"
7089 echo "remount client to enable new RPC size"
7090 remount_client $MOUNT || error "remount_client failed"
7093 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7094 # should be able to set brw_size=12, but no rpc_stats for that
7095 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7098 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7100 if [[ $orig_mb -lt 16 ]]; then
7101 restore_lustre_params < $p
7102 remount_client $MOUNT || error "remount_client restore failed"
7105 rm -f $p $DIR/$tfile
7107 run_test 101g "Big bulk(4/16 MiB) readahead"
7110 test_mkdir $DIR/$tdir
7111 chown $RUNAS_ID $DIR/$tdir
7114 STRIPE_COUNT=$OSTCOUNT
7115 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7117 trap cleanup_test102 EXIT
7119 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7121 for num in 1 2 3 4; do
7122 for count in $(seq 1 $STRIPE_COUNT); do
7123 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7124 local size=`expr $STRIPE_SIZE \* $num`
7125 local file=file"$num-$idx-$count"
7126 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7132 $1 tar cf $TMP/f102.tar $tdir --xattrs
7138 rm -rf $DIR/d0.sanity/d102
7142 local testfile=$DIR/$tfile
7146 [ "$UID" != 0 ] && skip_env "must run as root" && return
7147 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7148 skip_env "must have user_xattr" && return
7150 [ -z "$(which setfattr 2>/dev/null)" ] &&
7151 skip_env "could not find setfattr" && return
7153 echo "set/get xattr..."
7154 setfattr -n trusted.name1 -v value1 $testfile ||
7155 error "setfattr -n trusted.name1=value1 $testfile failed"
7156 getfattr -n trusted.name1 $testfile 2> /dev/null |
7157 grep "trusted.name1=.value1" ||
7158 error "$testfile missing trusted.name1=value1"
7160 setfattr -n user.author1 -v author1 $testfile ||
7161 error "setfattr -n user.author1=author1 $testfile failed"
7162 getfattr -n user.author1 $testfile 2> /dev/null |
7163 grep "user.author1=.author1" ||
7164 error "$testfile missing trusted.author1=author1"
7167 setfattr -n trusted.name2 -v value2 $testfile ||
7168 error "$testfile unable to set trusted.name2"
7169 setfattr -n trusted.name3 -v value3 $testfile ||
7170 error "$testfile unable to set trusted.name3"
7171 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7172 grep "trusted.name" | wc -l) -eq 3 ] ||
7173 error "$testfile missing 3 trusted.name xattrs"
7175 setfattr -n user.author2 -v author2 $testfile ||
7176 error "$testfile unable to set user.author2"
7177 setfattr -n user.author3 -v author3 $testfile ||
7178 error "$testfile unable to set user.author3"
7179 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7180 grep "user.author" | wc -l) -eq 3 ] ||
7181 error "$testfile missing 3 user.author xattrs"
7183 echo "remove xattr..."
7184 setfattr -x trusted.name1 $testfile ||
7185 error "$testfile error deleting trusted.name1"
7186 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7187 error "$testfile did not delete trusted.name1 xattr"
7189 setfattr -x user.author1 $testfile ||
7190 error "$testfile error deleting user.author1"
7191 echo "set lustre special xattr ..."
7192 $LFS setstripe -c1 $testfile
7193 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7194 awk -F "=" '/trusted.lov/ { print $2 }' )
7195 setfattr -n "trusted.lov" -v $lovea $testfile ||
7196 error "$testfile doesn't ignore setting trusted.lov again"
7197 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7198 error "$testfile allow setting invalid trusted.lov"
7201 run_test 102a "user xattr test =================================="
7204 [ -z "$(which setfattr 2>/dev/null)" ] &&
7205 skip_env "could not find setfattr" && return
7207 # b10930: get/set/list trusted.lov xattr
7208 echo "get/set/list trusted.lov xattr ..."
7209 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7210 local testfile=$DIR/$tfile
7211 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7212 error "setstripe failed"
7213 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7214 error "getstripe failed"
7215 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7216 error "can't get trusted.lov from $testfile"
7218 local testfile2=${testfile}2
7219 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7220 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7223 setfattr -n trusted.lov -v $value $testfile2
7224 local stripe_size=$($GETSTRIPE -S $testfile2)
7225 local stripe_count=$($GETSTRIPE -c $testfile2)
7226 [[ $stripe_size -eq 65536 ]] ||
7227 error "stripe size $stripe_size != 65536"
7228 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7229 error "stripe count $stripe_count != $STRIPECOUNT"
7232 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7235 [ -z "$(which setfattr 2>/dev/null)" ] &&
7236 skip_env "could not find setfattr" && return
7238 # b10930: get/set/list lustre.lov xattr
7239 echo "get/set/list lustre.lov xattr ..."
7240 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7241 test_mkdir $DIR/$tdir
7242 chown $RUNAS_ID $DIR/$tdir
7243 local testfile=$DIR/$tdir/$tfile
7244 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7245 error "setstripe failed"
7246 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7247 error "getstripe failed"
7248 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7249 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7251 local testfile2=${testfile}2
7252 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7253 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7255 $RUNAS $MCREATE $testfile2
7256 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7257 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7258 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7259 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7260 [ $stripe_count -eq $STRIPECOUNT ] ||
7261 error "stripe count $stripe_count != $STRIPECOUNT"
7263 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7265 compare_stripe_info1() {
7266 local stripe_index_all_zero=true
7268 for num in 1 2 3 4; do
7269 for count in $(seq 1 $STRIPE_COUNT); do
7270 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7271 local size=$((STRIPE_SIZE * num))
7272 local file=file"$num-$offset-$count"
7273 stripe_size=$($LFS getstripe -S $PWD/$file)
7274 [[ $stripe_size -ne $size ]] &&
7275 error "$file: size $stripe_size != $size"
7276 stripe_count=$($LFS getstripe -c $PWD/$file)
7277 # allow fewer stripes to be created, ORI-601
7278 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7279 error "$file: count $stripe_count != $count"
7280 stripe_index=$($LFS getstripe -i $PWD/$file)
7281 [[ $stripe_index -ne 0 ]] &&
7282 stripe_index_all_zero=false
7286 $stripe_index_all_zero &&
7287 error "all files are being extracted starting from OST index 0"
7291 have_xattrs_include() {
7292 tar --help | grep -q xattrs-include &&
7293 echo --xattrs-include="lustre.*"
7297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7298 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7299 local xinc=$(have_xattrs_include)
7301 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7303 compare_stripe_info1
7305 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
7308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7309 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7310 local xinc=$(have_xattrs_include)
7312 test_mkdir $DIR/$tdir.restore
7314 tar cf - --xattrs $tdir | tar xf - \
7315 -C $DIR/$tdir.restore --xattrs $xinc
7316 cd $DIR/$tdir.restore/$tdir
7317 compare_stripe_info1
7319 run_test 102f "tar copy files, not keep osts ==========="
7322 local xsize=${1:-1024} # in bytes
7323 local file=$DIR/$tfile
7325 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7326 skip "must have user_xattr" && return 0
7327 [ -z "$(which setfattr 2>/dev/null)" ] &&
7328 skip_env "could not find setfattr" && return 0
7329 [ -z "$(which getfattr 2>/dev/null)" ] &&
7330 skip_env "could not find getfattr" && return 0
7334 local value="$(generate_string $xsize)"
7336 local xbig=trusted.big
7337 log "save $xbig on $file"
7338 setfattr -n $xbig -v $value $file ||
7339 error "saving $xbig on $file failed"
7341 local orig=$(get_xattr_value $xbig $file)
7342 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7344 local xsml=trusted.sml
7345 log "save $xsml on $file"
7346 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7348 local new=$(get_xattr_value $xbig $file)
7349 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7351 log "grow $xsml on $file"
7352 setfattr -n $xsml -v "$value" $file ||
7353 error "growing $xsml on $file failed"
7355 new=$(get_xattr_value $xbig $file)
7356 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7357 log "$xbig still valid after growing $xsml"
7362 test_102h() { # bug 15777
7365 run_test 102h "grow xattr from inside inode to external block"
7368 large_xattr_enabled || { skip "ea_inode feature disabled" && return; }
7369 grow_xattr $(max_xattr_size)
7371 run_test 102ha "grow xattr from inside inode to external inode"
7373 test_102i() { # bug 17038
7374 [ -z "$(which getfattr 2>/dev/null)" ] &&
7375 skip "could not find getfattr" && return
7377 ln -s $DIR/$tfile $DIR/${tfile}link
7378 getfattr -n trusted.lov $DIR/$tfile ||
7379 error "lgetxattr on $DIR/$tfile failed"
7380 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7381 grep -i "no such attr" ||
7382 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7383 rm -f $DIR/$tfile $DIR/${tfile}link
7385 run_test 102i "lgetxattr test on symbolic link ============"
7388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7389 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7390 local xinc=$(have_xattrs_include)
7391 setup_test102 "$RUNAS"
7392 chown $RUNAS_ID $DIR/$tdir
7393 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7395 compare_stripe_info1 "$RUNAS"
7397 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7400 [ -z "$(which setfattr 2>/dev/null)" ] &&
7401 skip "could not find setfattr" && return
7403 # b22187 just check that does not crash for regular file.
7404 setfattr -n trusted.lov $DIR/$tfile
7405 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
7406 local test_kdir=$DIR/$tdir
7407 test_mkdir $test_kdir
7408 local default_size=`$GETSTRIPE -S $test_kdir`
7409 local default_count=`$GETSTRIPE -c $test_kdir`
7410 local default_offset=`$GETSTRIPE -i $test_kdir`
7411 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7412 error 'dir setstripe failed'
7413 setfattr -n trusted.lov $test_kdir
7414 local stripe_size=`$GETSTRIPE -S $test_kdir`
7415 local stripe_count=`$GETSTRIPE -c $test_kdir`
7416 local stripe_offset=`$GETSTRIPE -i $test_kdir`
7417 [ $stripe_size -eq $default_size ] ||
7418 error "stripe size $stripe_size != $default_size"
7419 [ $stripe_count -eq $default_count ] ||
7420 error "stripe count $stripe_count != $default_count"
7421 [ $stripe_offset -eq $default_offset ] ||
7422 error "stripe offset $stripe_offset != $default_offset"
7423 rm -rf $DIR/$tfile $test_kdir
7425 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7428 [ -z "$(which getfattr 2>/dev/null)" ] &&
7429 skip "could not find getfattr" && return
7431 # LU-532 trusted. xattr is invisible to non-root
7432 local testfile=$DIR/$tfile
7436 echo "listxattr as user..."
7437 chown $RUNAS_ID $testfile
7438 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7439 grep -q "trusted" &&
7440 error "$testfile trusted xattrs are user visible"
7444 run_test 102l "listxattr size test =================================="
7446 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7447 local path=$DIR/$tfile
7450 listxattr_size_check $path || error "listattr_size_check $path failed"
7452 run_test 102m "Ensure listxattr fails on small bufffer ========"
7456 getxattr() { # getxattr path name
7457 # Return the base64 encoding of the value of xattr name on path.
7461 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7463 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7465 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7467 getfattr --absolute-names --encoding=base64 --name=$name $path |
7468 awk -F= -v name=$name '$1 == name {
7469 print substr($0, index($0, "=") + 1);
7473 test_102n() { # LU-4101 mdt: protect internal xattrs
7474 [ -z "$(which setfattr 2>/dev/null)" ] &&
7475 skip "could not find setfattr" && return
7476 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7478 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7482 local file0=$DIR/$tfile.0
7483 local file1=$DIR/$tfile.1
7484 local xattr0=$TMP/$tfile.0
7485 local xattr1=$TMP/$tfile.1
7486 local namelist="lov lma lmv link fid version som hsm"
7490 rm -rf $file0 $file1 $xattr0 $xattr1
7493 # Get 'before' xattrs of $file1.
7494 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7496 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7497 namelist+=" lfsck_namespace"
7498 for name in $namelist; do
7499 # Try to copy xattr from $file0 to $file1.
7500 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7502 setfattr --name=trusted.$name --value="$value" $file1 ||
7503 error "setxattr 'trusted.$name' failed"
7505 # Try to set a garbage xattr.
7506 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7508 if [[ x$name == "xlov" ]]; then
7509 setfattr --name=trusted.lov --value="$value" $file1 &&
7510 error "setxattr invalid 'trusted.lov' success"
7512 setfattr --name=trusted.$name --value="$value" $file1 ||
7513 error "setxattr invalid 'trusted.$name' failed"
7516 # Try to remove the xattr from $file1. We don't care if this
7517 # appears to succeed or fail, we just don't want there to be
7518 # any changes or crashes.
7519 setfattr --remove=$trusted.$name $file1 2> /dev/null
7522 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7525 # Try to copy xattr from $file0 to $file1.
7526 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7528 setfattr --name=trusted.$name --value="$value" $file1 ||
7529 error "setxattr 'trusted.$name' failed"
7531 # Try to set a garbage xattr.
7532 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7534 setfattr --name=trusted.$name --value="$value" $file1 ||
7535 error "setxattr 'trusted.$name' failed"
7537 # Try to remove the xattr from $file1. We don't care if this
7538 # appears to succeed or fail, we just don't want there to be
7539 # any changes or crashes.
7540 setfattr --remove=$trusted.$name $file1 2> /dev/null
7543 # Get 'after' xattrs of file1.
7544 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7546 if ! diff $xattr0 $xattr1; then
7547 error "before and after xattrs of '$file1' differ"
7550 rm -rf $file0 $file1 $xattr0 $xattr1
7554 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7556 test_102p() { # LU-4703 setxattr did not check ownership
7557 local testfile=$DIR/$tfile
7559 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7560 skip "MDS needs to be at least 2.5.56" && return
7564 echo "setfacl as user..."
7565 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7566 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7568 echo "setfattr as user..."
7569 setfacl -m "u:$RUNAS_ID:---" $testfile
7570 $RUNAS setfattr -x system.posix_acl_access $testfile
7571 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7573 run_test 102p "check setxattr(2) correctly fails without permission"
7576 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7577 skip "MDS needs to be at least 2.6.92" && return
7578 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7580 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7583 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7584 skip "MDS needs to be at least 2.6.93" && return
7585 touch $DIR/$tfile || error "touch"
7586 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7587 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7588 rm $DIR/$tfile || error "rm"
7591 mkdir -p $DIR/$tdir || error "mkdir"
7592 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7593 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7594 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7595 error "$testfile error deleting user.author1"
7596 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7597 grep "user.$(basename $tdir)" &&
7598 error "$tdir did not delete user.$(basename $tdir)"
7599 rmdir $DIR/$tdir || error "rmdir"
7602 test_mkdir $DIR/$tdir || error "make striped dir"
7603 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7604 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7605 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7606 error "$testfile error deleting user.author1"
7607 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7608 grep "user.$(basename $tdir)" &&
7609 error "$tdir did not delete user.$(basename $tdir)"
7610 rmdir $DIR/$tdir || error "rm striped dir"
7612 run_test 102r "set EAs with empty values"
7615 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
7616 skip "MDS needs to be at least 2.11.52"
7618 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
7620 save_lustre_params client "llite.*.xattr_cache" > $save
7622 for cache in 0 1; do
7623 lctl set_param llite.*.xattr_cache=$cache
7626 touch $DIR/$tfile || error "touch"
7627 for prefix in lustre security system trusted user; do
7628 # Note getxattr() may fail with 'Operation not
7629 # supported' or 'No such attribute' depending
7630 # on prefix and cache.
7631 getfattr -n $prefix.n102s $DIR/$tfile &&
7632 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
7636 restore_lustre_params < $save
7638 run_test 102s "getting nonexistent xattrs should fail"
7642 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7647 [ "$UID" != 0 ] && skip_env "must run as root" && return
7648 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7649 skip "must have acl enabled" && return
7650 [ -z "$(which setfacl 2>/dev/null)" ] &&
7651 skip_env "could not find setfacl" && return
7652 $GSS && skip "could not run under gss" && return
7653 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7655 gpasswd -a daemon bin # LU-5641
7656 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7658 declare -a identity_old
7660 for num in $(seq $MDSCOUNT); do
7661 switch_identity $num true || identity_old[$num]=$?
7669 echo "performing cp ..."
7670 run_acl_subtest cp || error "run_acl_subtest cp failed"
7671 echo "performing getfacl-noacl..."
7672 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7673 echo "performing misc..."
7674 run_acl_subtest misc || error "misc test failed"
7675 echo "performing permissions..."
7676 run_acl_subtest permissions || error "permissions failed"
7677 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7678 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7679 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7680 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7682 echo "performing permissions xattr..."
7683 run_acl_subtest permissions_xattr ||
7684 error "permissions_xattr failed"
7686 echo "performing setfacl..."
7687 run_acl_subtest setfacl || error "setfacl test failed"
7689 # inheritance test got from HP
7690 echo "performing inheritance..."
7691 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7692 chmod +x make-tree || error "chmod +x failed"
7693 run_acl_subtest inheritance || error "inheritance test failed"
7696 echo "LU-974 ignore umask when acl is enabled..."
7697 run_acl_subtest 974 || error "LU-974 umask test failed"
7698 if [ $MDSCOUNT -ge 2 ]; then
7699 run_acl_subtest 974_remote ||
7700 error "LU-974 umask test failed under remote dir"
7703 echo "LU-2561 newly created file is same size as directory..."
7704 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7705 run_acl_subtest 2561 || error "LU-2561 test failed"
7707 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7710 run_acl_subtest 4924 || error "LU-4924 test failed"
7715 for num in $(seq $MDSCOUNT); do
7716 if [ "${identity_old[$num]}" = 1 ]; then
7717 switch_identity $num false || identity_old[$num]=$?
7721 run_test 103a "acl test ========================================="
7724 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7726 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7727 local mountopts=$MDS_MOUNT_OPTS
7729 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7733 stop $SINGLEMDS || error "failed to stop MDT."
7735 if [ -z "$MDS_MOUNT_OPTS" ]; then
7736 MDS_MOUNT_OPTS="-o noacl"
7738 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7740 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7741 error "failed to start MDT."
7742 MDS_MOUNT_OPTS=$mountopts
7746 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7750 stop $SINGLEMDS || error "failed to stop MDT."
7752 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7753 error "failed to start MDT."
7758 run_test 103b "MDS mount option 'noacl'"
7762 cp -rp $DIR/$tdir $DIR/$tdir.bak
7764 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7765 error "$DIR/$tdir shouldn't contain default ACL"
7766 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7767 error "$DIR/$tdir.bak shouldn't contain default ACL"
7770 run_test 103c "'cp -rp' won't set empty acl"
7773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7775 lfs df || error "lfs df failed"
7776 lfs df -ih || error "lfs df -ih failed"
7777 lfs df -h $DIR || error "lfs df -h $DIR failed"
7778 lfs df -i $DIR || error "lfs df -i $DIR failed"
7779 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7780 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7782 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7783 lctl --device %$OSC deactivate
7784 lfs df || error "lfs df with deactivated OSC failed"
7785 lctl --device %$OSC activate
7786 # wait the osc back to normal
7787 wait_osc_import_state client ost FULL
7789 lfs df || error "lfs df with reactivated OSC failed"
7792 run_test 104a "lfs df [-ih] [path] test ========================="
7795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7796 [ $RUNAS_ID -eq $UID ] &&
7797 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7799 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7800 grep "Permission denied" | wc -l)))
7801 if [ $denied_cnt -ne 0 ]; then
7802 error "lfs check servers test failed"
7805 run_test 104b "$RUNAS lfs check servers test ===================="
7808 # doesn't work on 2.4 kernels
7810 if $(flock_is_enabled); then
7811 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7813 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7817 run_test 105a "flock when mounted without -o flock test ========"
7821 if $(flock_is_enabled); then
7822 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7824 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7828 run_test 105b "fcntl when mounted without -o flock test ========"
7832 if $(flock_is_enabled); then
7833 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7835 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7839 run_test 105c "lockf when mounted without -o flock test ========"
7841 test_105d() { # bug 15924
7842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7843 test_mkdir -p $DIR/$tdir
7844 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7845 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7846 $LCTL set_param fail_loc=0x80000315
7847 flocks_test 2 $DIR/$tdir
7849 run_test 105d "flock race (should not freeze) ========"
7851 test_105e() { # bug 22660 && 22040
7852 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7854 flocks_test 3 $DIR/$tfile
7856 run_test 105e "Two conflicting flocks from same process ======="
7858 test_106() { #bug 10921
7859 test_mkdir -p $DIR/$tdir
7860 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7861 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7863 run_test 106 "attempt exec of dir followed by chown of that dir"
7866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7873 local save_pattern=$(sysctl -n kernel.core_pattern)
7874 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7875 sysctl -w kernel.core_pattern=$file
7876 sysctl -w kernel.core_uses_pid=0
7884 kill -s 11 $SLEEPPID
7886 if [ -e $file ]; then
7887 size=`stat -c%s $file`
7888 [ $size -eq 0 ] && error "Fail to create core file $file"
7890 error "Fail to create core file $file"
7893 sysctl -w kernel.core_pattern=$save_pattern
7894 sysctl -w kernel.core_uses_pid=$save_uses_pid
7897 run_test 107 "Coredump on SIG"
7900 test_mkdir -p $DIR/$tdir
7901 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7902 error "mkdir with 255 char failed"
7903 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7904 error "mkdir with 256 char should fail, but did not"
7905 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7906 error "create with 255 char failed"
7907 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7908 error "create with 256 char should fail, but did not"
7913 run_test 110 "filename length checking"
7916 # Purpose: To verify dynamic thread (OSS) creation.
7919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7920 remote_ost_nodsh && skip "remote OST with nodsh" && return
7922 # Lustre does not stop service threads once they are started.
7923 # Reset number of running threads to default.
7928 local save_params="$TMP/sanity-$TESTNAME.parameters"
7930 # Get ll_ost_io count before I/O
7931 OSTIO_pre=$(do_facet ost1 \
7932 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
7933 # Exit if lustre is not running (ll_ost_io not running).
7934 [ -z "$OSTIO_pre" ] && error "no OSS threads"
7936 echo "Starting with $OSTIO_pre threads"
7937 local thread_max=$((OSTIO_pre * 2))
7938 local rpc_in_flight=$((thread_max * 2))
7939 # Number of I/O Process proposed to be started.
7941 local facets=$(get_facets OST)
7943 save_lustre_params client \
7944 "osc.*OST*.max_rpcs_in_flight" > $save_params
7945 save_lustre_params $facets \
7946 "ost.OSS.ost_io.threads_max" >> $save_params
7948 # Set in_flight to $rpc_in_flight
7949 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
7950 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
7951 nfiles=${rpc_in_flight}
7952 # Set ost thread_max to $thread_max
7954 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
7956 # 5 Minutes should be sufficient for max number of OSS
7957 # threads(thread_max) to be created.
7961 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
7963 for i in $(seq $nfiles); do
7964 local file=$DIR/$tdir/${tfile}-$i
7965 $LFS setstripe -c -1 -i 0 $file
7966 ($WTL $file $timeout)&
7969 # I/O Started - Wait for thread_started to reach thread_max or report
7970 # error if thread_started is more than thread_max.
7971 echo "Waiting for thread_started to reach thread_max"
7972 local thread_started=0
7973 local end_time=$((SECONDS + timeout))
7975 while [ $SECONDS -le $end_time ] ; do
7977 # Get ost i/o thread_started count.
7978 thread_started=$(do_facet ost1 \
7980 ost.OSS.ost_io.threads_started | cut -d= -f2")
7981 # Break out if thread_started is equal/greater than thread_max
7982 if [[ $thread_started -ge $thread_max ]]; then
7983 echo ll_ost_io thread_started $thread_started, \
7984 equal/greater than thread_max $thread_max
7990 # Cleanup - We have the numbers, Kill i/o jobs if running.
7991 jobcount=($(jobs -p))
7992 for i in $(seq 0 $((${#jobcount[@]}-1)))
7994 kill -9 ${jobcount[$i]}
7995 if [ $? -ne 0 ] ; then
7997 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8001 # Cleanup files left by WTL binary.
8002 for i in $(seq $nfiles); do
8003 local file=$DIR/$tdir/${tfile}-$i
8005 if [ $? -ne 0 ] ; then
8006 echo "Warning: Failed to delete file $file"
8010 restore_lustre_params <$save_params
8011 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8013 # Error out if no new thread has started or Thread started is greater
8015 if [[ $thread_started -le $OSTIO_pre ||
8016 $thread_started -gt $thread_max ]]; then
8017 error "ll_ost_io: thread_started $thread_started" \
8018 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
8019 "No new thread started or thread started greater " \
8023 run_test 115 "verify dynamic thread creation===================="
8026 wait_delete_completed
8027 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8028 echo "OST kbytes available: ${AVAIL[@]}"
8033 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8034 #echo OST $i: ${AVAIL[i]}kb
8035 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8039 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8044 echo "Min free space: OST $MINI: $MINV"
8045 echo "Max free space: OST $MAXI: $MAXV"
8048 test_116a() { # was previously test_116()
8049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8050 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8052 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8054 echo -n "Free space priority "
8055 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
8060 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
8061 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
8063 trap simple_cleanup_common EXIT
8066 # Check if we need to generate uneven OSTs
8067 test_mkdir -p $DIR/$tdir/OST${MINI}
8068 local FILL=$((MINV / 4))
8069 local DIFF=$((MAXV - MINV))
8070 local DIFF2=$((DIFF * 100 / MINV))
8072 local threshold=$(do_facet $SINGLEMDS \
8073 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
8074 threshold=${threshold%%%}
8075 echo -n "Check for uneven OSTs: "
8076 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
8078 if [[ $DIFF2 -gt $threshold ]]; then
8080 echo "Don't need to fill OST$MINI"
8082 # generate uneven OSTs. Write 2% over the QOS threshold value
8084 DIFF=$((threshold - DIFF2 + 2))
8085 DIFF2=$((MINV * DIFF / 100))
8086 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
8087 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
8088 error "setstripe failed"
8089 DIFF=$((DIFF2 / 2048))
8091 while [ $i -lt $DIFF ]; do
8093 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8094 bs=2M count=1 2>/dev/null
8103 DIFF=$((MAXV - MINV))
8104 DIFF2=$((DIFF * 100 / MINV))
8105 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8106 if [ $DIFF2 -gt $threshold ]; then
8109 echo "failed - QOS mode won't be used"
8110 skip "QOS imbalance criteria not met"
8111 simple_cleanup_common
8120 # now fill using QOS
8121 $SETSTRIPE -c 1 $DIR/$tdir
8122 FILL=$((FILL / 200))
8123 if [ $FILL -gt 600 ]; then
8126 echo "writing $FILL files to QOS-assigned OSTs"
8128 while [ $i -lt $FILL ]; do
8130 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8134 echo "wrote $i 200k files"
8138 echo "Note: free space may not be updated, so measurements might be off"
8140 DIFF2=$((MAXV - MINV))
8141 echo "free space delta: orig $DIFF final $DIFF2"
8142 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8143 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8144 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8145 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8146 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8147 if [[ $DIFF -gt 0 ]]; then
8148 FILL=$((DIFF2 * 100 / DIFF - 100))
8149 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8152 # Figure out which files were written where
8153 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8154 awk '/'$MINI1': / {print $2; exit}')
8156 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8157 echo "$MINC files created on smaller OST $MINI1"
8158 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8159 awk '/'$MAXI1': / {print $2; exit}')
8161 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8162 echo "$MAXC files created on larger OST $MAXI1"
8163 if [[ $MINC -gt 0 ]]; then
8164 FILL=$((MAXC * 100 / MINC - 100))
8165 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8167 [[ $MAXC -gt $MINC ]] ||
8168 error_ignore LU-9 "stripe QOS didn't balance free space"
8169 simple_cleanup_common
8171 run_test 116a "stripe QOS: free space balance ==================="
8173 test_116b() { # LU-2093
8174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8175 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8177 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8178 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8179 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8180 [ -z "$old_rr" ] && skip "no QOS" && return 0
8181 do_facet $SINGLEMDS lctl set_param \
8182 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8184 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8185 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8186 do_facet $SINGLEMDS lctl set_param fail_loc=0
8188 do_facet $SINGLEMDS lctl set_param \
8189 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8191 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8193 test_117() # bug 10891
8195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8196 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8197 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8198 lctl set_param fail_loc=0x21e
8199 > $DIR/$tfile || error "truncate failed"
8200 lctl set_param fail_loc=0
8201 echo "Truncate succeeded."
8204 run_test 117 "verify osd extend =========="
8206 NO_SLOW_RESENDCOUNT=4
8207 export OLD_RESENDCOUNT=""
8208 set_resend_count () {
8209 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8210 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8211 lctl set_param -n $PROC_RESENDCOUNT $1
8212 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8215 # for reduce test_118* time (b=14842)
8216 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8218 # Reset async IO behavior after error case
8220 FILE=$DIR/reset_async
8222 # Ensure all OSCs are cleared
8223 $SETSTRIPE -c -1 $FILE
8224 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8229 test_118a() #bug 11710
8231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8234 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8235 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8236 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8238 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8239 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8244 run_test 118a "verify O_SYNC works =========="
8248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8249 remote_ost_nodsh && skip "remote OST with nodsh" && return
8253 #define OBD_FAIL_SRV_ENOENT 0x217
8254 set_nodes_failloc "$(osts_nodes)" 0x217
8255 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8257 set_nodes_failloc "$(osts_nodes)" 0
8258 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8259 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8262 if [[ $RC -eq 0 ]]; then
8263 error "Must return error due to dropped pages, rc=$RC"
8267 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8268 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8272 echo "Dirty pages not leaked on ENOENT"
8274 # Due to the above error the OSC will issue all RPCs syncronously
8275 # until a subsequent RPC completes successfully without error.
8276 $MULTIOP $DIR/$tfile Ow4096yc
8281 run_test 118b "Reclaim dirty pages on fatal error =========="
8285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8287 # for 118c, restore the original resend count, LU-1940
8288 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8289 set_resend_count $OLD_RESENDCOUNT
8290 remote_ost_nodsh && skip "remote OST with nodsh" && return
8294 #define OBD_FAIL_OST_EROFS 0x216
8295 set_nodes_failloc "$(osts_nodes)" 0x216
8297 # multiop should block due to fsync until pages are written
8298 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8302 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8303 error "Multiop failed to block on fsync, pid=$MULTIPID"
8306 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8308 if [[ $WRITEBACK -eq 0 ]]; then
8309 error "No page in writeback, writeback=$WRITEBACK"
8312 set_nodes_failloc "$(osts_nodes)" 0
8315 if [[ $RC -ne 0 ]]; then
8316 error "Multiop fsync failed, rc=$RC"
8319 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8320 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8322 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8323 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8327 echo "Dirty pages flushed via fsync on EROFS"
8330 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8332 # continue to use small resend count to reduce test_118* time (b=14842)
8333 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8338 remote_ost_nodsh && skip "remote OST with nodsh" && return
8342 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8343 set_nodes_failloc "$(osts_nodes)" 0x214
8344 # multiop should block due to fsync until pages are written
8345 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8349 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8350 error "Multiop failed to block on fsync, pid=$MULTIPID"
8353 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8355 if [[ $WRITEBACK -eq 0 ]]; then
8356 error "No page in writeback, writeback=$WRITEBACK"
8359 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8360 set_nodes_failloc "$(osts_nodes)" 0
8362 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8363 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8365 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8366 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8370 echo "Dirty pages gaurenteed flushed via fsync"
8373 run_test 118d "Fsync validation inject a delay of the bulk =========="
8376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8379 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8380 lctl set_param fail_loc=0x8000040a
8382 # Should simulate EINVAL error which is fatal
8383 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8385 if [[ $RC -eq 0 ]]; then
8386 error "Must return error due to dropped pages, rc=$RC"
8389 lctl set_param fail_loc=0x0
8391 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8392 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8393 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8395 if [[ $LOCKED -ne 0 ]]; then
8396 error "Locked pages remain in cache, locked=$LOCKED"
8399 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8400 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8404 echo "No pages locked after fsync"
8409 run_test 118f "Simulate unrecoverable OSC side error =========="
8412 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8415 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8416 lctl set_param fail_loc=0x406
8418 # simulate local -ENOMEM
8419 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8422 lctl set_param fail_loc=0
8423 if [[ $RC -eq 0 ]]; then
8424 error "Must return error due to dropped pages, rc=$RC"
8427 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8428 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8429 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8431 if [[ $LOCKED -ne 0 ]]; then
8432 error "Locked pages remain in cache, locked=$LOCKED"
8435 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8436 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8440 echo "No pages locked after fsync"
8445 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8449 remote_ost_nodsh && skip "remote OST with nodsh" && return
8453 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8454 set_nodes_failloc "$(osts_nodes)" 0x20e
8455 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8456 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8459 set_nodes_failloc "$(osts_nodes)" 0
8460 if [[ $RC -eq 0 ]]; then
8461 error "Must return error due to dropped pages, rc=$RC"
8464 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8465 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8466 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8468 if [[ $LOCKED -ne 0 ]]; then
8469 error "Locked pages remain in cache, locked=$LOCKED"
8472 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8473 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8477 echo "No pages locked after fsync"
8481 run_test 118h "Verify timeout in handling recoverables errors =========="
8483 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8487 remote_ost_nodsh && skip "remote OST with nodsh" && return
8491 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8492 set_nodes_failloc "$(osts_nodes)" 0x20e
8494 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8495 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8498 set_nodes_failloc "$(osts_nodes)" 0
8502 if [[ $RC -ne 0 ]]; then
8503 error "got error, but should be not, rc=$RC"
8506 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8507 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8508 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8509 if [[ $LOCKED -ne 0 ]]; then
8510 error "Locked pages remain in cache, locked=$LOCKED"
8513 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8514 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8518 echo "No pages locked after fsync"
8522 run_test 118i "Fix error before timeout in recoverable error =========="
8524 [ "$SLOW" = "no" ] && set_resend_count 4
8527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8528 remote_ost_nodsh && skip "remote OST with nodsh" && return
8532 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8533 set_nodes_failloc "$(osts_nodes)" 0x220
8535 # return -EIO from OST
8536 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8538 set_nodes_failloc "$(osts_nodes)" 0x0
8539 if [[ $RC -eq 0 ]]; then
8540 error "Must return error due to dropped pages, rc=$RC"
8543 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8544 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8545 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8546 if [[ $LOCKED -ne 0 ]]; then
8547 error "Locked pages remain in cache, locked=$LOCKED"
8550 # in recoverable error on OST we want resend and stay until it finished
8551 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8552 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8556 echo "No pages locked after fsync"
8560 run_test 118j "Simulate unrecoverable OST side error =========="
8564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8565 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8567 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8568 set_nodes_failloc "$(osts_nodes)" 0x20e
8569 test_mkdir -p $DIR/$tdir
8571 for ((i=0;i<10;i++)); do
8572 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8573 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8580 set_nodes_failloc "$(osts_nodes)" 0
8583 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8589 test_mkdir -p $DIR/$tdir
8590 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8593 run_test 118l "fsync dir ========="
8595 test_118m() # LU-3066
8597 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8598 test_mkdir -p $DIR/$tdir
8599 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8602 run_test 118m "fdatasync dir ========="
8604 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8606 test_119a() # bug 11737
8608 BSIZE=$((512 * 1024))
8609 directio write $DIR/$tfile 0 1 $BSIZE
8610 # We ask to read two blocks, which is more than a file size.
8611 # directio will indicate an error when requested and actual
8612 # sizes aren't equeal (a normal situation in this case) and
8613 # print actual read amount.
8614 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8615 if [ "$NOB" != "$BSIZE" ]; then
8616 error "read $NOB bytes instead of $BSIZE"
8620 run_test 119a "Short directIO read must return actual read amount"
8622 test_119b() # bug 11737
8624 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8626 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8627 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8629 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8630 error "direct read failed"
8633 run_test 119b "Sparse directIO read must return actual read amount"
8635 test_119c() # bug 13099
8638 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8639 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8642 run_test 119c "Testing for direct read hitting hole"
8644 test_119d() # bug 15950
8646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8647 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8648 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8650 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8651 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8652 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8653 lctl set_param fail_loc=0x40d
8654 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8657 cat $DIR/$tfile > /dev/null &
8658 lctl set_param fail_loc=0
8661 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8663 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8664 error "the read rpcs have not completed in 2s"
8666 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8668 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8672 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8673 test_mkdir -p $DIR/$tdir
8674 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8675 skip "no early lock cancel on server" && return 0
8677 lru_resize_disable mdc
8678 lru_resize_disable osc
8679 cancel_lru_locks mdc
8680 # asynchronous object destroy at MDT could cause bl ast to client
8681 cancel_lru_locks osc
8683 stat $DIR/$tdir > /dev/null
8684 can1=$(do_facet $SINGLEMDS \
8685 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8686 awk '/ldlm_cancel/ {print $2}')
8687 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8688 awk '/ldlm_bl_callback/ {print $2}')
8689 test_mkdir -c1 $DIR/$tdir/d1
8690 can2=$(do_facet $SINGLEMDS \
8691 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8692 awk '/ldlm_cancel/ {print $2}')
8693 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8694 awk '/ldlm_bl_callback/ {print $2}')
8695 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8696 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8697 lru_resize_enable mdc
8698 lru_resize_enable osc
8700 run_test 120a "Early Lock Cancel: mkdir test"
8703 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8704 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8705 test_mkdir $DIR/$tdir
8706 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8707 skip "no early lock cancel on server" && return 0
8708 lru_resize_disable mdc
8709 lru_resize_disable osc
8710 cancel_lru_locks mdc
8711 stat $DIR/$tdir > /dev/null
8712 can1=$(do_facet $SINGLEMDS \
8713 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8714 awk '/ldlm_cancel/ {print $2}')
8715 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8716 awk '/ldlm_bl_callback/ {print $2}')
8718 can2=$(do_facet $SINGLEMDS \
8719 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8720 awk '/ldlm_cancel/ {print $2}')
8721 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8722 awk '/ldlm_bl_callback/ {print $2}')
8723 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8724 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8725 lru_resize_enable mdc
8726 lru_resize_enable osc
8728 run_test 120b "Early Lock Cancel: create test"
8731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8732 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8733 test_mkdir -c1 $DIR/$tdir
8734 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8735 skip "no early lock cancel on server" && return 0
8736 lru_resize_disable mdc
8737 lru_resize_disable osc
8738 test_mkdir -p -c1 $DIR/$tdir/d1
8739 test_mkdir -p -c1 $DIR/$tdir/d2
8740 touch $DIR/$tdir/d1/f1
8741 cancel_lru_locks mdc
8742 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8743 can1=$(do_facet $SINGLEMDS \
8744 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8745 awk '/ldlm_cancel/ {print $2}')
8746 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8747 awk '/ldlm_bl_callback/ {print $2}')
8748 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8749 can2=$(do_facet $SINGLEMDS \
8750 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8751 awk '/ldlm_cancel/ {print $2}')
8752 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8753 awk '/ldlm_bl_callback/ {print $2}')
8754 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8755 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8756 lru_resize_enable mdc
8757 lru_resize_enable osc
8759 run_test 120c "Early Lock Cancel: link test"
8762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8763 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8764 test_mkdir -p -c1 $DIR/$tdir
8765 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8766 skip "no early lock cancel on server" && return 0
8767 lru_resize_disable mdc
8768 lru_resize_disable osc
8770 cancel_lru_locks mdc
8771 stat $DIR/$tdir > /dev/null
8772 can1=$(do_facet $SINGLEMDS \
8773 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8774 awk '/ldlm_cancel/ {print $2}')
8775 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8776 awk '/ldlm_bl_callback/ {print $2}')
8777 chmod a+x $DIR/$tdir
8778 can2=$(do_facet $SINGLEMDS \
8779 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8780 awk '/ldlm_cancel/ {print $2}')
8781 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8782 awk '/ldlm_bl_callback/ {print $2}')
8783 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8784 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8785 lru_resize_enable mdc
8786 lru_resize_enable osc
8788 run_test 120d "Early Lock Cancel: setattr test"
8791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8792 ! $($LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_can) &&
8793 skip "no early lock cancel on server" && return 0
8794 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8795 local dlmtrace_set=false
8797 test_mkdir -p -c1 $DIR/$tdir
8798 lru_resize_disable mdc
8799 lru_resize_disable osc
8800 ! $LCTL get_param debug | grep -q dlmtrace &&
8801 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8802 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8803 cancel_lru_locks mdc
8804 cancel_lru_locks osc
8805 dd if=$DIR/$tdir/f1 of=/dev/null
8806 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8807 # XXX client can not do early lock cancel of OST lock
8808 # during unlink (LU-4206), so cancel osc lock now.
8810 cancel_lru_locks osc
8811 can1=$(do_facet $SINGLEMDS \
8812 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8813 awk '/ldlm_cancel/ {print $2}')
8814 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8815 awk '/ldlm_bl_callback/ {print $2}')
8816 unlink $DIR/$tdir/f1
8818 can2=$(do_facet $SINGLEMDS \
8819 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8820 awk '/ldlm_cancel/ {print $2}')
8821 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8822 awk '/ldlm_bl_callback/ {print $2}')
8823 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8824 $LCTL dk $TMP/cancel.debug.txt
8825 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8826 $LCTL dk $TMP/blocking.debug.txt
8827 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8828 lru_resize_enable mdc
8829 lru_resize_enable osc
8831 run_test 120e "Early Lock Cancel: unlink test"
8834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8835 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8836 skip "no early lock cancel on server" && return 0
8837 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8838 test_mkdir -p -c1 $DIR/$tdir
8839 lru_resize_disable mdc
8840 lru_resize_disable osc
8841 test_mkdir -p -c1 $DIR/$tdir/d1
8842 test_mkdir -p -c1 $DIR/$tdir/d2
8843 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8844 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8845 cancel_lru_locks mdc
8846 cancel_lru_locks osc
8847 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8848 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8849 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8850 # XXX client can not do early lock cancel of OST lock
8851 # during rename (LU-4206), so cancel osc lock now.
8853 cancel_lru_locks osc
8854 can1=$(do_facet $SINGLEMDS \
8855 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8856 awk '/ldlm_cancel/ {print $2}')
8857 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8858 awk '/ldlm_bl_callback/ {print $2}')
8859 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8861 can2=$(do_facet $SINGLEMDS \
8862 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8863 awk '/ldlm_cancel/ {print $2}')
8864 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8865 awk '/ldlm_bl_callback/ {print $2}')
8866 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8867 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8868 lru_resize_enable mdc
8869 lru_resize_enable osc
8871 run_test 120f "Early Lock Cancel: rename test"
8874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8875 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8876 skip "no early lock cancel on server" && return 0
8877 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8878 lru_resize_disable mdc
8879 lru_resize_disable osc
8881 echo create $count files
8882 test_mkdir -p $DIR/$tdir
8883 cancel_lru_locks mdc
8884 cancel_lru_locks osc
8887 can0=$(do_facet $SINGLEMDS \
8888 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8889 awk '/ldlm_cancel/ {print $2}')
8890 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8891 awk '/ldlm_bl_callback/ {print $2}')
8892 createmany -o $DIR/$tdir/f $count
8894 can1=$(do_facet $SINGLEMDS \
8895 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8896 awk '/ldlm_cancel/ {print $2}')
8897 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8898 awk '/ldlm_bl_callback/ {print $2}')
8900 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8901 echo rm $count files
8904 can2=$(do_facet $SINGLEMDS \
8905 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8906 awk '/ldlm_cancel/ {print $2}')
8907 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8908 awk '/ldlm_bl_callback/ {print $2}')
8910 echo total: $count removes in $((t2-t1))
8911 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8913 # wait for commitment of removal
8914 lru_resize_enable mdc
8915 lru_resize_enable osc
8917 run_test 120g "Early Lock Cancel: performance test"
8919 test_121() { #bug #10589
8920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8922 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8923 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8924 lctl set_param fail_loc=0x310
8925 cancel_lru_locks osc > /dev/null
8926 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8927 lctl set_param fail_loc=0
8928 [[ $reads -eq $writes ]] ||
8929 error "read $reads blocks, must be $writes blocks"
8931 run_test 121 "read cancel race ========="
8933 test_123a() { # was test 123, statahead(bug 11401)
8934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8936 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8937 log "testing on UP system. Performance may be not as good as expected."
8942 test_mkdir -p $DIR/$tdir
8943 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8944 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8946 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8947 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8949 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8950 lctl set_param -n llite.*.statahead_max 0
8951 lctl get_param llite.*.statahead_max
8952 cancel_lru_locks mdc
8953 cancel_lru_locks osc
8955 time ls -l $DIR/$tdir | wc -l
8957 delta=$((etime - stime))
8958 log "ls $i files without statahead: $delta sec"
8959 lctl set_param llite.*.statahead_max=$max
8961 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8962 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8963 cancel_lru_locks mdc
8964 cancel_lru_locks osc
8966 time ls -l $DIR/$tdir | wc -l
8968 delta_sa=$((etime - stime))
8969 log "ls $i files with statahead: $delta_sa sec"
8970 lctl get_param -n llite.*.statahead_stats
8971 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8973 [[ $swrong -lt $ewrong ]] &&
8974 log "statahead was stopped, maybe too many locks held!"
8975 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8977 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8978 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8979 lctl set_param -n llite.*.statahead_max 0
8980 lctl get_param llite.*.statahead_max
8981 cancel_lru_locks mdc
8982 cancel_lru_locks osc
8984 time ls -l $DIR/$tdir | wc -l
8986 delta=$((etime - stime))
8987 log "ls $i files again without statahead: $delta sec"
8988 lctl set_param llite.*.statahead_max=$max
8989 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8990 if [ $SLOWOK -eq 0 ]; then
8991 error "ls $i files is slower with statahead!"
8993 log "ls $i files is slower with statahead!"
8999 [ $delta -gt 20 ] && break
9000 [ $delta -gt 8 ] && MULT=$((50 / delta))
9001 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
9009 delta=$((etime - stime))
9010 log "rm -r $DIR/$tdir/: $delta seconds"
9012 lctl get_param -n llite.*.statahead_stats
9014 run_test 123a "verify statahead work"
9016 test_123b () { # statahead(bug 15027)
9017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9018 test_mkdir -p $DIR/$tdir
9019 createmany -o $DIR/$tdir/$tfile-%d 1000
9021 cancel_lru_locks mdc
9022 cancel_lru_locks osc
9024 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
9025 lctl set_param fail_loc=0x80000803
9026 ls -lR $DIR/$tdir > /dev/null
9028 lctl set_param fail_loc=0x0
9029 lctl get_param -n llite.*.statahead_stats
9034 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
9037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9038 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9039 skip "no lru resize on server" && return 0
9041 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9043 log "create $NR files at $DIR/$tdir"
9044 createmany -o $DIR/$tdir/f $NR ||
9045 error "failed to create $NR files in $DIR/$tdir"
9047 cancel_lru_locks mdc
9048 ls -l $DIR/$tdir > /dev/null
9052 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
9053 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
9054 LRU_SIZE=$($LCTL get_param -n $PARAM)
9055 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
9056 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
9058 log "NS=$(basename $NSDIR)"
9063 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9064 skip "Not enough cached locks created!"
9071 # We know that lru resize allows one client to hold $LIMIT locks
9072 # for 10h. After that locks begin to be killed by client.
9074 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9076 if [ $LIMIT -lt $LRU_SIZE ]; then
9077 skip "Limit is too small $LIMIT"
9081 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9082 # killing locks. Some time was spent for creating locks. This means
9083 # that up to the moment of sleep finish we must have killed some of
9084 # them (10-100 locks). This depends on how fast ther were created.
9085 # Many of them were touched in almost the same moment and thus will
9086 # be killed in groups.
9087 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9089 # Use $LRU_SIZE_B here to take into account real number of locks
9090 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9091 local LRU_SIZE_B=$LRU_SIZE
9093 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9094 log "OLD_LVF=$OLD_LVF"
9095 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9097 # Let's make sure that we really have some margin. Client checks
9098 # cached locks every 10 sec.
9100 log "Sleep ${SLEEP} sec"
9102 while ((SEC<$SLEEP)); do
9106 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9110 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9111 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9113 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9114 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9115 unlinkmany $DIR/$tdir/f $NR
9119 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9120 log "unlink $NR files at $DIR/$tdir"
9121 unlinkmany $DIR/$tdir/f $NR
9123 run_test 124a "lru resize ======================================="
9125 get_max_pool_limit()
9127 local limit=$($LCTL get_param \
9128 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9131 if [[ $l -gt $max ]]; then
9139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9140 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9141 skip "no lru resize on server" && return 0
9143 LIMIT=$(get_max_pool_limit)
9145 NR=$(($(default_lru_size)*20))
9146 if [[ $NR -gt $LIMIT ]]; then
9147 log "Limit lock number by $LIMIT locks"
9151 IFree=$(mdsrate_inodes_available)
9152 if [ $IFree -lt $NR ]; then
9153 log "Limit lock number by $IFree inodes"
9157 lru_resize_disable mdc
9158 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
9159 error "failed to create $DIR/$tdir/disable_lru_resize"
9161 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9162 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9163 cancel_lru_locks mdc
9166 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9169 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9172 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9176 nolruresize_delta=$((etime-stime))
9177 log "ls -la time: $nolruresize_delta seconds"
9178 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9179 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9181 lru_resize_enable mdc
9182 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
9183 error "failed to create $DIR/$tdir/enable_lru_resize"
9185 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9186 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9187 cancel_lru_locks mdc
9190 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9193 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9196 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9200 lruresize_delta=$((etime-stime))
9201 log "ls -la time: $lruresize_delta seconds"
9202 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9204 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9205 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9206 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9207 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9209 log "lru resize performs the same with no lru resize"
9211 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9213 run_test 124b "lru resize (performance test) ======================="
9216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9217 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9218 skip "no lru resize on server" && return 0
9220 # cache ununsed locks on client
9222 cancel_lru_locks mdc
9223 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9224 createmany -o $DIR/$tdir/f $nr ||
9225 error "failed to create $nr files in $DIR/$tdir"
9226 ls -l $DIR/$tdir > /dev/null
9228 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9229 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9230 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9231 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9232 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9234 # set lru_max_age to 1 sec
9235 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9236 echo "sleep $((recalc_p * 2)) seconds..."
9237 sleep $((recalc_p * 2))
9239 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9240 # restore lru_max_age
9241 $LCTL set_param -n $nsdir.lru_max_age $max_age
9242 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9243 unlinkmany $DIR/$tdir/f $nr
9245 run_test 124c "LRUR cancel very aged locks"
9247 test_125() { # 13358
9248 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9249 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
9250 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9251 test_mkdir -p $DIR/d125 || error "mkdir failed"
9252 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
9253 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
9254 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
9256 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9258 test_126() { # bug 12829/13455
9259 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9260 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
9261 $GSS && skip "must run as gss disabled" && return
9263 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9264 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9266 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9268 run_test 126 "check that the fsgid provided by the client is taken into account"
9270 test_127a() { # bug 15521
9271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9272 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9273 $LCTL set_param osc.*.stats=0
9274 FSIZE=$((2048 * 1024))
9275 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9276 cancel_lru_locks osc
9277 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9279 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9280 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9281 echo "got $COUNT $NAME"
9282 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9283 eval $NAME=$COUNT || error "Wrong proc format"
9286 read_bytes|write_bytes)
9287 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9288 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9289 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9290 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9291 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9292 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9293 error "sumsquare is too small: $SUMSQ"
9294 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9295 error "sumsquare is too big: $SUMSQ"
9299 done < $DIR/${tfile}.tmp
9301 #check that we actually got some stats
9302 [ "$read_bytes" ] || error "Missing read_bytes stats"
9303 [ "$write_bytes" ] || error "Missing write_bytes stats"
9304 [ "$read_bytes" != 0 ] || error "no read done"
9305 [ "$write_bytes" != 0 ] || error "no write done"
9307 run_test 127a "verify the client stats are sane"
9309 test_127b() { # bug LU-333
9310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9311 $LCTL set_param llite.*.stats=0
9312 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9313 # perform 2 reads and writes so MAX is different from SUM.
9314 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9315 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9316 cancel_lru_locks osc
9317 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9318 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9320 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9321 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9322 echo "got $COUNT $NAME"
9323 eval $NAME=$COUNT || error "Wrong proc format"
9327 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9328 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9329 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9330 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9333 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9334 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9335 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9336 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9340 done < $TMP/${tfile}.tmp
9342 #check that we actually got some stats
9343 [ "$read_bytes" ] || error "Missing read_bytes stats"
9344 [ "$write_bytes" ] || error "Missing write_bytes stats"
9345 [ "$read_bytes" != 0 ] || error "no read done"
9346 [ "$write_bytes" != 0 ] || error "no write done"
9348 rm -f $TMP/${tfile}.tmp
9350 run_test 127b "verify the llite client stats are sane"
9352 test_128() { # bug 15212
9354 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9359 result=$(grep error $TMP/$tfile.log)
9360 rm -f $DIR/$tfile $TMP/$tfile.log
9362 error "consecutive find's under interactive lfs failed"
9364 run_test 128 "interactive lfs for 2 consecutive find's"
9371 local ldproc=/proc/fs/ldiskfs
9372 local facets=$(get_facets MDS)
9374 for facet in ${facets//,/ }; do
9375 canondev=$(ldiskfs_canon \
9376 *.$(convert_facet2label $facet).mntdev $facet)
9377 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9378 ldproc=/sys/fs/ldiskfs
9379 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9380 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9385 local facets=$(get_facets MDS)
9386 for facet in ${facets//,/ }; do
9387 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9393 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9394 { skip "Need MDS version with at least 2.5.56"; return 0; }
9396 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9397 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9398 skip "ldiskfs only test"
9401 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9404 local has_warning=false
9409 # block size of mds1
9410 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9411 set_dir_limits $maxsize $maxsize
9412 local dirsize=$(stat -c%s "$DIR/$tdir")
9414 while [[ $dirsize -le $maxsize ]]; do
9415 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9417 if ! $has_warning; then
9418 check_mds_dmesg '"is approaching"' && has_warning=true
9421 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9422 # EFBIG for previous versions included in ldiskfs series
9423 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9425 echo "return code $rc received as expected"
9427 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9428 error_exit "create failed w/o dir size limit"
9430 check_mds_dmesg '"has reached"' ||
9431 error_exit "reached message should be output"
9433 [ $has_warning = "false" ] &&
9434 error_exit "warning message should be output"
9436 dirsize=$(stat -c%s "$DIR/$tdir")
9438 [[ $dirsize -ge $maxsize ]] && return 0
9439 error_exit "current dir size $dirsize, " \
9440 "previous limit $maxsize"
9441 elif [ $rc -ne 0 ]; then
9443 error_exit "return $rc received instead of expected " \
9444 "$EFBIG or $ENOSPC, files in dir $dirsize"
9446 nfiles=$((nfiles + 1))
9447 dirsize=$(stat -c%s "$DIR/$tdir")
9451 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9453 run_test 129 "test directory size limit ========================"
9462 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9463 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9466 trap cleanup_130 EXIT RETURN
9468 local fm_file=$DIR/$tfile
9469 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9470 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9471 error "dd failed for $fm_file"
9473 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9474 filefrag -ves $fm_file
9476 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9477 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9478 [ $RC != 0 ] && error "filefrag $fm_file failed"
9480 filefrag_op=$(filefrag -ve $fm_file |
9481 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9482 lun=$($GETSTRIPE -i $fm_file)
9484 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9487 for line in $filefrag_op
9489 frag_lun=`echo $line | cut -d: -f5`
9490 ext_len=`echo $line | cut -d: -f4`
9491 if (( $frag_lun != $lun )); then
9493 error "FIEMAP on 1-stripe file($fm_file) failed"
9496 (( tot_len += ext_len ))
9499 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9501 error "FIEMAP on 1-stripe file($fm_file) failed;"
9507 echo "FIEMAP on single striped file succeeded"
9509 run_test 130a "FIEMAP (1-stripe file)"
9512 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9514 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9515 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9518 trap cleanup_130 EXIT RETURN
9520 local fm_file=$DIR/$tfile
9521 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9522 error "setstripe on $fm_file"
9523 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9524 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9526 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9527 error "dd failed on $fm_file"
9529 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9530 filefrag_op=$(filefrag -ve $fm_file |
9531 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9533 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9534 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9539 for line in $filefrag_op
9541 frag_lun=$(echo $line | cut -d: -f5 |
9542 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9543 ext_len=$(echo $line | cut -d: -f4)
9544 if (( $frag_lun != $last_lun )); then
9545 if (( tot_len != 1024 )); then
9547 error "FIEMAP on $fm_file failed; returned " \
9548 "len $tot_len for OST $last_lun instead of 1024"
9555 (( tot_len += ext_len ))
9558 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9560 error "FIEMAP on $fm_file failed; returned wrong number of " \
9561 "luns or wrong len for OST $last_lun"
9567 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9569 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9572 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9574 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9575 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9578 trap cleanup_130 EXIT RETURN
9580 local fm_file=$DIR/$tfile
9581 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9582 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9583 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9585 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9586 error "dd failed on $fm_file"
9588 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9589 filefrag_op=$(filefrag -ve $fm_file |
9590 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9592 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9593 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9598 for line in $filefrag_op
9600 frag_lun=$(echo $line | cut -d: -f5 |
9601 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9602 ext_len=$(echo $line | cut -d: -f4)
9603 if (( $frag_lun != $last_lun )); then
9604 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9605 if (( logical != 512 )); then
9607 error "FIEMAP on $fm_file failed; returned " \
9608 "logical start for lun $logical instead of 512"
9611 if (( tot_len != 512 )); then
9613 error "FIEMAP on $fm_file failed; returned " \
9614 "len $tot_len for OST $last_lun instead of 1024"
9621 (( tot_len += ext_len ))
9624 if (( num_luns != 2 || tot_len != 512 )); then
9626 error "FIEMAP on $fm_file failed; returned wrong number of " \
9627 "luns or wrong len for OST $last_lun"
9633 echo "FIEMAP on 2-stripe file with hole succeeded"
9635 run_test 130c "FIEMAP (2-stripe file with hole)"
9638 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9640 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9641 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9644 trap cleanup_130 EXIT RETURN
9646 local fm_file=$DIR/$tfile
9647 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9648 error "setstripe on $fm_file"
9649 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9650 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9652 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
9653 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
9654 error "dd failed on $fm_file"
9656 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9657 filefrag_op=$(filefrag -ve $fm_file |
9658 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9660 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9661 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9666 for line in $filefrag_op
9668 frag_lun=$(echo $line | cut -d: -f5 |
9669 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9670 ext_len=$(echo $line | cut -d: -f4)
9671 if (( $frag_lun != $last_lun )); then
9672 if (( tot_len != 1024 )); then
9674 error "FIEMAP on $fm_file failed; returned " \
9675 "len $tot_len for OST $last_lun instead of 1024"
9682 (( tot_len += ext_len ))
9685 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
9687 error "FIEMAP on $fm_file failed; returned wrong number of " \
9688 "luns or wrong len for OST $last_lun"
9694 echo "FIEMAP on N-stripe file succeeded"
9696 run_test 130d "FIEMAP (N-stripe file)"
9699 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9701 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9702 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9704 trap cleanup_130 EXIT RETURN
9706 local fm_file=$DIR/$tfile
9707 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9708 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9709 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9712 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9713 for ((i = 0; i < $NUM_BLKS; i++))
9715 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9718 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9719 filefrag_op=$(filefrag -ve $fm_file |
9720 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9722 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9723 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9728 for line in $filefrag_op
9730 frag_lun=$(echo $line | cut -d: -f5 |
9731 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9732 ext_len=$(echo $line | cut -d: -f4)
9733 if (( $frag_lun != $last_lun )); then
9734 if (( tot_len != $EXPECTED_LEN )); then
9736 error "FIEMAP on $fm_file failed; returned " \
9737 "len $tot_len for OST $last_lun instead " \
9745 (( tot_len += ext_len ))
9748 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9750 error "FIEMAP on $fm_file failed; returned wrong number " \
9751 "of luns or wrong len for OST $last_lun"
9757 echo "FIEMAP with continuation calls succeeded"
9759 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9761 # Test for writev/readv
9763 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
9764 error "writev test failed"
9765 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
9766 error "readv failed"
9769 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9772 local fsize=$((524288 + 1048576 + 1572864))
9773 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
9774 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9775 error "append writev test failed"
9777 ((fsize += 1572864 + 1048576))
9778 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
9779 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9780 error "append writev test failed"
9783 run_test 131b "test append writev"
9786 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9789 run_test 131c "test read/write on file w/o objects"
9792 rwv -f $DIR/$tfile -w -n 1 1572864
9793 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9794 if [ "$NOB" != 1572864 ]; then
9795 error "Short read filed: read $NOB bytes instead of 1572864"
9799 run_test 131d "test short read"
9802 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9803 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9804 error "read hitting hole failed"
9807 run_test 131e "test read hitting hole"
9816 mds*) res=$(do_facet $facet \
9817 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9819 ost*) res=$(do_facet $facet \
9820 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9822 *) error "Wrong facet '$facet'" ;;
9825 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9826 # if the argument $3 is zero, it means any stat increment is ok.
9827 if [[ $want -gt 0 ]]; then
9828 local count=$(echo $res | awk '{ print $2 }')
9829 [[ $count -ne $want ]] &&
9830 error "The $op counter on $facet is $count, not $want"
9835 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9836 remote_ost_nodsh && skip "remote OST with nodsh" && return
9837 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9839 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9840 { skip "MDS doesn't support rename stats"; return; }
9841 local testdir=$DIR/${tdir}/stats_testdir
9842 mkdir -p $DIR/${tdir}
9845 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9846 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9848 # verify mdt stats first.
9849 mkdir ${testdir} || error "mkdir failed"
9850 check_stats $SINGLEMDS "mkdir" 1
9851 touch ${testdir}/${tfile} || error "touch failed"
9852 check_stats $SINGLEMDS "open" 1
9853 check_stats $SINGLEMDS "close" 1
9854 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
9855 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
9856 check_stats $SINGLEMDS "mknod" 2
9858 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
9859 check_stats $SINGLEMDS "unlink" 1
9860 rm -f ${testdir}/${tfile} || error "file remove failed"
9861 check_stats $SINGLEMDS "unlink" 2
9863 # remove working dir and check mdt stats again.
9864 rmdir ${testdir} || error "rmdir failed"
9865 check_stats $SINGLEMDS "rmdir" 1
9867 local testdir1=$DIR/${tdir}/stats_testdir1
9869 mkdir -p ${testdir1}
9870 touch ${testdir1}/test1
9871 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9872 check_stats $SINGLEMDS "crossdir_rename" 1
9874 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9875 check_stats $SINGLEMDS "samedir_rename" 1
9879 run_test 133a "Verifying MDT stats ========================================"
9882 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9883 remote_ost_nodsh && skip "remote OST with nodsh" && return
9884 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9885 local testdir=$DIR/${tdir}/stats_testdir
9886 mkdir -p ${testdir} || error "mkdir failed"
9887 touch ${testdir}/${tfile} || error "touch failed"
9888 cancel_lru_locks mdc
9891 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9892 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9894 # extra mdt stats verification.
9895 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9896 check_stats $SINGLEMDS "setattr" 1
9897 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9898 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9900 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9901 check_stats $SINGLEMDS "getattr" 1
9903 $LFS df || error "lfs failed"
9904 check_stats $SINGLEMDS "statfs" 1
9908 run_test 133b "Verifying extra MDT stats =================================="
9911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9912 remote_ost_nodsh && skip "remote OST with nodsh" && return
9913 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9914 local testdir=$DIR/${tdir}/stats_testdir
9915 test_mkdir -p ${testdir} || error "mkdir failed"
9917 # verify obdfilter stats.
9918 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9920 cancel_lru_locks osc
9921 wait_delete_completed
9924 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9925 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9927 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9929 cancel_lru_locks osc
9930 check_stats ost1 "write" 1
9932 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9933 check_stats ost1 "read" 1
9935 > ${testdir}/${tfile} || error "truncate failed"
9936 check_stats ost1 "punch" 1
9938 rm -f ${testdir}/${tfile} || error "file remove failed"
9939 wait_delete_completed
9940 check_stats ost1 "destroy" 1
9944 run_test 133c "Verifying OST stats ========================================"
9951 while [ $value -ge 2 ]; do
9956 if [ $orig -gt $order ]; then
9964 local size=('K' 'M' 'G' 'T');
9966 local size_string=$value
9968 while [ $value -ge 1024 ]; do
9969 if [ $i -gt 3 ]; then
9970 #T is the biggest unit we get here, if that is bigger,
9972 size_string=${value}T
9975 value=$((value >> 10))
9976 if [ $value -lt 1024 ]; then
9977 size_string=${value}${size[$i]}
9988 local context=${2:-.}
9989 local sample=$(do_facet $SINGLEMDS $LCTL \
9990 get_param mdt.$FSNAME-MDT0000.rename_stats |
9992 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9998 remote_ost_nodsh && skip "remote OST with nodsh" && return
9999 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10000 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10001 { skip "MDS doesn't support rename stats"; return; }
10003 local testdir1=$DIR/${tdir}/stats_testdir1
10004 local testdir2=$DIR/${tdir}/stats_testdir2
10005 mkdir -p $DIR/${tdir}
10007 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10009 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
10010 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
10012 createmany -o $testdir1/test 512 || error "createmany failed"
10014 # check samedir rename size
10015 mv ${testdir1}/test0 ${testdir1}/test_0
10017 local testdir1_size=$(ls -l $DIR/${tdir} |
10018 awk '/stats_testdir1/ {print $5}')
10019 local testdir2_size=$(ls -l $DIR/${tdir} |
10020 awk '/stats_testdir2/ {print $5}')
10022 testdir1_size=$(order_2 $testdir1_size)
10023 testdir2_size=$(order_2 $testdir2_size)
10025 testdir1_size=$(size_in_KMGT $testdir1_size)
10026 testdir2_size=$(size_in_KMGT $testdir2_size)
10028 echo "source rename dir size: ${testdir1_size}"
10029 echo "target rename dir size: ${testdir2_size}"
10031 local cmd="do_facet $SINGLEMDS $LCTL "
10032 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
10034 eval $cmd || error "$cmd failed"
10035 local samedir=$($cmd | grep 'same_dir')
10036 local same_sample=$(get_rename_size $testdir1_size)
10037 [ -z "$samedir" ] && error "samedir_rename_size count error"
10038 [[ $same_sample -eq 1 ]] ||
10039 error "samedir_rename_size error $same_sample"
10040 echo "Check same dir rename stats success"
10042 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10044 # check crossdir rename size
10045 mv ${testdir1}/test_0 ${testdir2}/test_0
10047 testdir1_size=$(ls -l $DIR/${tdir} |
10048 awk '/stats_testdir1/ {print $5}')
10049 testdir2_size=$(ls -l $DIR/${tdir} |
10050 awk '/stats_testdir2/ {print $5}')
10052 testdir1_size=$(order_2 $testdir1_size)
10053 testdir2_size=$(order_2 $testdir2_size)
10055 testdir1_size=$(size_in_KMGT $testdir1_size)
10056 testdir2_size=$(size_in_KMGT $testdir2_size)
10058 echo "source rename dir size: ${testdir1_size}"
10059 echo "target rename dir size: ${testdir2_size}"
10061 eval $cmd || error "$cmd failed"
10062 local crossdir=$($cmd | grep 'crossdir')
10063 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10064 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10065 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10066 [[ $src_sample -eq 1 ]] ||
10067 error "crossdir_rename_size error $src_sample"
10068 [[ $tgt_sample -eq 1 ]] ||
10069 error "crossdir_rename_size error $tgt_sample"
10070 echo "Check cross dir rename stats success"
10071 rm -rf $DIR/${tdir}
10073 run_test 133d "Verifying rename_stats ========================================"
10076 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10077 remote_ost_nodsh && skip "remote OST with nodsh" && return
10078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10079 local testdir=$DIR/${tdir}/stats_testdir
10080 local ctr f0 f1 bs=32768 count=42 sum
10082 mkdir -p ${testdir} || error "mkdir failed"
10084 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10086 for ctr in {write,read}_bytes; do
10088 cancel_lru_locks osc
10090 do_facet ost1 $LCTL set_param -n \
10091 "obdfilter.*.exports.clear=clear"
10093 if [ $ctr = write_bytes ]; then
10095 f1=${testdir}/${tfile}
10097 f0=${testdir}/${tfile}
10101 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10104 cancel_lru_locks osc
10106 sum=$(do_facet ost1 $LCTL get_param \
10107 "obdfilter.*.exports.*.stats" |
10108 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10109 $1 == ctr { sum += $7 }
10110 END { printf("%0.0f", sum) }')
10112 if ((sum != bs * count)); then
10113 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10117 rm -rf $DIR/${tdir}
10119 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10121 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10124 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10125 remote_ost_nodsh && skip "remote OST with nodsh" && return
10126 # First without trusting modes.
10127 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10128 echo "proc_dirs='$proc_dirs'"
10129 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10130 find $proc_dirs -exec cat '{}' \; &> /dev/null
10132 # Second verifying readability.
10133 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10135 # eventually, this can also be replaced with "lctl get_param -R",
10136 # but not until that option is always available on the server
10138 for facet in mds1 ost1; do
10139 local facet_proc_dirs=$(do_facet $facet \
10140 \\\ls -d $proc_regexp 2>/dev/null)
10141 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10142 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10143 do_facet $facet find $facet_proc_dirs \
10144 ! -name req_history \
10145 -exec cat '{}' \\\; &> /dev/null
10147 do_facet $facet find $facet_proc_dirs \
10148 ! -name req_history \
10150 -exec cat '{}' \\\; &> /dev/null ||
10151 error "proc file read failed"
10154 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
10157 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10158 remote_ost_nodsh && skip "remote OST with nodsh" && return
10159 # Second verifying writability.
10160 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10161 echo "proc_dirs='$proc_dirs'"
10162 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10165 -not -name force_lbug \
10166 -not -name changelog_mask \
10167 -exec badarea_io '{}' \; &> /dev/null ||
10168 error "find $proc_dirs failed"
10171 for facet in mds1 ost1; do
10172 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10173 skip "Too old lustre on $facet" && continue
10174 local facet_proc_dirs=$(do_facet $facet \
10175 \\\ls -d $proc_regexp 2> /dev/null)
10176 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10177 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10178 do_facet $facet find $facet_proc_dirs \
10180 -not -name force_lbug \
10181 -not -name changelog_mask \
10182 -exec badarea_io '{}' \\\; &> /dev/null ||
10183 error "$facet find $facet_proc_dirs failed"
10186 # remount the FS in case writes/reads /proc break the FS
10187 cleanup || error "failed to unmount"
10188 setup || error "failed to setup"
10191 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
10194 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10195 remote_ost_nodsh && skip "remote OST with nodsh" && return
10196 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10197 skip "Need MDS version at least 2.9.54" && return
10200 for facet in client mds1 ost1; do
10201 local facet_proc_dirs=$(do_facet $facet \
10202 \\\ls -d $proc_regexp 2> /dev/null)
10203 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10204 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10205 # Get the list of files that are missing the terminating newline
10206 local missing=($(do_facet $facet \
10207 find ${facet_proc_dirs} -type f \| \
10208 while read F\; do \
10209 awk -v FS='\v' -v RS='\v\v' \
10210 "'END { if(NR>0 && \
10211 \\\$NF !~ /.*\\\n\$/) \
10212 print FILENAME}'" \
10215 [ ${#missing[*]} -eq 0 ] ||
10216 error "files do not end with newline: ${missing[*]}"
10219 run_test 133h "Proc files should end with newlines"
10222 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10223 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10224 skip "Need MDS version at least 2.7.54" && return
10226 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10227 cancel_lru_locks mdc
10229 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10230 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10231 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10234 createmany -o $DIR/$tdir/f $nr ||
10235 error "failed to create $nr files in $DIR/$tdir"
10236 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10238 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10239 do_facet mds1 $LCTL set_param fail_loc=0x327
10240 do_facet mds1 $LCTL set_param fail_val=500
10243 echo "sleep 10 seconds ..."
10245 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10247 do_facet mds1 $LCTL set_param fail_loc=0
10248 do_facet mds1 $LCTL set_param fail_val=0
10249 [ $lck_cnt -lt $unused ] ||
10250 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10253 unlinkmany $DIR/$tdir/f $nr
10255 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10258 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10259 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10260 skip "Need MDS version at least 2.7.54" && return
10262 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10263 cancel_lru_locks mdc
10265 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10266 ldlm.lock_reclaim_threshold_mb)
10267 # disable reclaim temporarily
10268 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10270 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10271 do_facet mds1 $LCTL set_param fail_loc=0x328
10272 do_facet mds1 $LCTL set_param fail_val=500
10274 $LCTL set_param debug=+trace
10277 createmany -o $DIR/$tdir/f $nr &
10278 local create_pid=$!
10280 echo "Sleep $TIMEOUT seconds ..."
10282 if ! ps -p $create_pid > /dev/null 2>&1; then
10283 do_facet mds1 $LCTL set_param fail_loc=0
10284 do_facet mds1 $LCTL set_param fail_val=0
10285 do_facet mds1 $LCTL set_param \
10286 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10287 error "createmany finished incorrectly!"
10289 do_facet mds1 $LCTL set_param fail_loc=0
10290 do_facet mds1 $LCTL set_param fail_val=0
10291 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10292 wait $create_pid || return 1
10294 unlinkmany $DIR/$tdir/f $nr
10296 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10298 test_140() { #bug-17379
10299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10300 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
10301 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10302 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10304 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10305 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10307 while i=`expr $i + 1`; do
10308 test_mkdir -p $i || error "Creating dir $i"
10309 cd $i || error "Changing to $i"
10310 ln -s ../stat stat || error "Creating stat symlink"
10311 # Read the symlink until ELOOP present,
10312 # not LBUGing the system is considered success,
10313 # we didn't overrun the stack.
10314 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10315 [ $ret -ne 0 ] && {
10316 if [ $ret -eq 40 ]; then
10319 error "Open stat symlink"
10325 echo "The symlink depth = $i"
10326 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10327 error "Invalid symlink depth"
10329 # Test recursive symlink
10330 ln -s symlink_self symlink_self
10331 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10332 echo "open symlink_self returns $ret"
10333 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10335 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10339 local TF="$TMP/$tfile"
10341 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10343 cancel_lru_locks osc
10344 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10345 remount_client $MOUNT
10347 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10350 $TRUNCATE $DIR/$tfile 6000
10351 cancel_lru_locks osc
10352 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10355 echo "12345" >>$DIR/$tfile
10356 cancel_lru_locks osc
10357 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10360 echo "12345" >>$DIR/$tfile
10361 cancel_lru_locks osc
10362 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10367 run_test 150 "truncate/append tests"
10369 #LU-2902 roc_hit was not able to read all values from lproc
10370 function roc_hit_init() {
10371 local list=$(comma_list $(osts_nodes))
10372 local dir=$DIR/$tdir-check
10373 local file=$dir/file
10379 #use setstripe to do a write to every ost
10380 for i in $(seq 0 $((OSTCOUNT-1))); do
10381 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10382 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10383 idx=$(printf %04x $i)
10384 BEFORE=$(get_osd_param $list *OST*$idx stats |
10385 awk '$1 == "cache_access" {sum += $7}
10386 END { printf("%0.0f", sum) }')
10388 cancel_lru_locks osc
10389 cat $file >/dev/null
10391 AFTER=$(get_osd_param $list *OST*$idx stats |
10392 awk '$1 == "cache_access" {sum += $7}
10393 END { printf("%0.0f", sum) }')
10395 echo BEFORE:$BEFORE AFTER:$AFTER
10396 if ! let "AFTER - BEFORE == 4"; then
10398 error "roc_hit is not safe to use"
10406 function roc_hit() {
10407 local list=$(comma_list $(osts_nodes))
10408 echo $(get_osd_param $list '' stats |
10409 awk '$1 == "cache_hit" {sum += $7}
10410 END { printf("%0.0f", sum) }')
10413 function set_cache() {
10416 if [ "$2" == "off" ]; then
10419 local list=$(comma_list $(osts_nodes))
10420 set_osd_param $list '' $1_cache_enable $on
10422 cancel_lru_locks osc
10426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10427 remote_ost_nodsh && skip "remote OST with nodsh" && return
10430 local list=$(comma_list $(osts_nodes))
10432 # check whether obdfilter is cache capable at all
10433 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10434 echo "not cache-capable obdfilter"
10438 # check cache is enabled on all obdfilters
10439 if get_osd_param $list '' read_cache_enable | grep 0; then
10440 echo "oss cache is disabled"
10444 set_osd_param $list '' writethrough_cache_enable 1
10446 # check write cache is enabled on all obdfilters
10447 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10448 echo "oss write cache is NOT enabled"
10454 #define OBD_FAIL_OBD_NO_LRU 0x609
10455 do_nodes $list $LCTL set_param fail_loc=0x609
10457 # pages should be in the case right after write
10458 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10461 local BEFORE=$(roc_hit)
10462 cancel_lru_locks osc
10463 cat $DIR/$tfile >/dev/null
10464 local AFTER=$(roc_hit)
10466 do_nodes $list $LCTL set_param fail_loc=0
10468 if ! let "AFTER - BEFORE == CPAGES"; then
10469 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10472 # the following read invalidates the cache
10473 cancel_lru_locks osc
10474 set_osd_param $list '' read_cache_enable 0
10475 cat $DIR/$tfile >/dev/null
10477 # now data shouldn't be found in the cache
10479 cancel_lru_locks osc
10480 cat $DIR/$tfile >/dev/null
10482 if let "AFTER - BEFORE != 0"; then
10483 error "IN CACHE: before: $BEFORE, after: $AFTER"
10486 set_osd_param $list '' read_cache_enable 1
10489 run_test 151 "test cache on oss and controls ==============================="
10492 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10493 local TF="$TMP/$tfile"
10495 # simulate ENOMEM during write
10496 #define OBD_FAIL_OST_NOMEM 0x226
10497 lctl set_param fail_loc=0x80000226
10498 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10500 sync || error "sync failed"
10501 lctl set_param fail_loc=0
10503 # discard client's cache
10504 cancel_lru_locks osc
10506 # simulate ENOMEM during read
10507 lctl set_param fail_loc=0x80000226
10508 cmp $TF $DIR/$tfile || error "cmp failed"
10509 lctl set_param fail_loc=0
10513 run_test 152 "test read/write with enomem ============================"
10516 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10518 run_test 153 "test if fdatasync does not crash ======================="
10520 dot_lustre_fid_permission_check() {
10522 local ffid=$MOUNT/.lustre/fid/$fid
10525 echo "stat fid $fid"
10526 stat $ffid > /dev/null || error "stat $ffid failed."
10527 echo "touch fid $fid"
10528 touch $ffid || error "touch $ffid failed."
10529 echo "write to fid $fid"
10530 cat /etc/hosts > $ffid || error "write $ffid failed."
10531 echo "read fid $fid"
10532 diff /etc/hosts $ffid || error "read $ffid failed."
10533 echo "append write to fid $fid"
10534 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10535 echo "rename fid $fid"
10536 mv $ffid $test_dir/$tfile.1 &&
10537 error "rename $ffid to $tfile.1 should fail."
10538 touch $test_dir/$tfile.1
10539 mv $test_dir/$tfile.1 $ffid &&
10540 error "rename $tfile.1 to $ffid should fail."
10541 rm -f $test_dir/$tfile.1
10542 echo "truncate fid $fid"
10543 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10544 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10545 echo "link fid $fid"
10546 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10548 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10549 echo "setfacl fid $fid"
10550 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10551 echo "getfacl fid $fid"
10552 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10554 echo "unlink fid $fid"
10555 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10556 echo "mknod fid $fid"
10557 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10559 fid=[0xf00000400:0x1:0x0]
10560 ffid=$MOUNT/.lustre/fid/$fid
10562 echo "stat non-exist fid $fid"
10563 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10564 echo "write to non-exist fid $fid"
10565 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10566 echo "link new fid $fid"
10567 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10569 mkdir -p $test_dir/$tdir
10570 touch $test_dir/$tdir/$tfile
10571 fid=$($LFS path2fid $test_dir/$tdir)
10574 error "error: could not get fid for $test_dir/$dir/$tfile."
10576 ffid=$MOUNT/.lustre/fid/$fid
10579 ls $ffid > /dev/null || error "ls $ffid failed."
10580 echo "touch $fid/$tfile.1"
10581 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10583 echo "touch $MOUNT/.lustre/fid/$tfile"
10584 touch $MOUNT/.lustre/fid/$tfile && \
10585 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10587 echo "setxattr to $MOUNT/.lustre/fid"
10588 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10590 echo "listxattr for $MOUNT/.lustre/fid"
10591 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10593 echo "delxattr from $MOUNT/.lustre/fid"
10594 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10596 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10597 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10598 error "touch invalid fid should fail."
10600 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10601 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10602 error "touch non-normal fid should fail."
10604 echo "rename $tdir to $MOUNT/.lustre/fid"
10605 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10606 error "rename to $MOUNT/.lustre/fid should fail."
10608 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10610 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10611 local new_obf_mode=777
10613 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10614 chmod $new_obf_mode $DIR/.lustre/fid ||
10615 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10617 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10618 [ $obf_mode -eq $new_obf_mode ] ||
10619 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10621 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10622 chmod $old_obf_mode $DIR/.lustre/fid ||
10623 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10626 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10627 fid=$($LFS path2fid $test_dir/$tfile-2)
10629 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10631 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10632 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10633 error "create lov data thru .lustre failed"
10635 echo "cp /etc/passwd $test_dir/$tfile-2"
10636 cp /etc/passwd $test_dir/$tfile-2 ||
10637 error "copy to $test_dir/$tfile-2 failed."
10638 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10639 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10640 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10642 rm -rf $test_dir/tfile.lnk
10643 rm -rf $test_dir/$tfile-2
10647 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10648 skip "Need MDS version at least 2.4.1" && return
10650 local tf=$DIR/$tfile
10653 local fid=$($LFS path2fid $tf)
10654 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10656 # check that we get the same pathname back
10657 local found=$($LFS fid2path $MOUNT "$fid")
10658 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10659 [ "$found" == "$tf" ] ||
10660 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10662 run_test 154A "lfs path2fid and fid2path basic checks"
10665 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10666 skip "Need MDS version at least 2.4.1" && return
10668 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10669 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10670 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10671 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10673 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10674 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10676 # check that we get the same pathname
10677 echo "PFID: $PFID, name: $name"
10678 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10679 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10680 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10681 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10683 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10685 run_test 154B "verify the ll_decode_linkea tool"
10688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10689 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10690 { skip "Need MDS version at least 2.2.51"; return 0; }
10691 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10692 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10694 cp /etc/hosts $DIR/$tfile
10696 fid=$($LFS path2fid $DIR/$tfile)
10698 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10700 dot_lustre_fid_permission_check "$fid" $DIR ||
10701 error "dot lustre permission check $fid failed"
10703 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10705 touch $MOUNT/.lustre/file &&
10706 error "creation is not allowed under .lustre"
10708 mkdir $MOUNT/.lustre/dir &&
10709 error "mkdir is not allowed under .lustre"
10713 run_test 154a "Open-by-FID"
10716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10717 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10718 { skip "Need MDS version at least 2.2.51"; return 0; }
10719 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10721 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10723 local remote_dir=$DIR/$tdir/remote_dir
10727 mkdir -p $DIR/$tdir
10728 $LFS mkdir -i $MDTIDX $remote_dir ||
10729 error "create remote directory failed"
10731 cp /etc/hosts $remote_dir/$tfile
10733 fid=$($LFS path2fid $remote_dir/$tfile)
10735 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10737 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10738 error "dot lustre permission check $fid failed"
10741 run_test 154b "Open-by-FID for remote directory"
10744 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10745 skip "Need MDS version at least 2.4.1" && return
10747 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10748 local FID1=$($LFS path2fid $DIR/$tfile.1)
10749 local FID2=$($LFS path2fid $DIR/$tfile.2)
10750 local FID3=$($LFS path2fid $DIR/$tfile.3)
10753 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10754 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10755 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10757 [ "$FID" = "${!want}" ] ||
10758 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10762 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10764 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10765 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10769 run_test 154c "lfs path2fid and fid2path multiple arguments"
10772 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10773 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10774 skip "Need MDS version at least 2.5.53" && return
10776 if remote_mds; then
10777 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10781 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10788 local fid=$($LFS path2fid $DIR/$tfile)
10791 cmd="exec $fd<$DIR/$tfile"
10793 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10794 echo "$fid_list" | grep "$fid"
10797 cmd="exec $fd>/dev/null"
10799 if [ $rc -ne 0 ]; then
10800 error "FID $fid not found in open files list $fid_list"
10803 run_test 154d "Verify open file fid"
10807 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10808 skip "Need MDS version at least 2.6.50" && return
10810 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10811 error ".lustre returned by readdir"
10814 run_test 154e ".lustre is not returned by readdir"
10817 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10818 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10819 test_mkdir -p -c1 $DIR/$tdir/d
10820 # test dirs inherit from its stripe
10821 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10822 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10823 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10824 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10827 # get fid of parents
10828 local FID0=$($LFS path2fid $DIR/$tdir/d)
10829 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10830 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10831 local FID3=$($LFS path2fid $DIR)
10833 # check that path2fid --parents returns expected <parent_fid>/name
10834 # 1) test for a directory (single parent)
10835 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10836 [ "$parent" == "$FID0/foo1" ] ||
10837 error "expected parent: $FID0/foo1, got: $parent"
10839 # 2) test for a file with nlink > 1 (multiple parents)
10840 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10841 echo "$parent" | grep -F "$FID1/$tfile" ||
10842 error "$FID1/$tfile not returned in parent list"
10843 echo "$parent" | grep -F "$FID2/link" ||
10844 error "$FID2/link not returned in parent list"
10846 # 3) get parent by fid
10847 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10848 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10849 echo "$parent" | grep -F "$FID1/$tfile" ||
10850 error "$FID1/$tfile not returned in parent list (by fid)"
10851 echo "$parent" | grep -F "$FID2/link" ||
10852 error "$FID2/link not returned in parent list (by fid)"
10854 # 4) test for entry in root directory
10855 parent=$($LFS path2fid --parents $DIR/f)
10856 echo "$parent" | grep -F "$FID3/f" ||
10857 error "$FID3/f not returned in parent list"
10859 # 5) test it on root directory
10860 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10861 error "$MOUNT should not have parents"
10863 # enable xattr caching and check that linkea is correctly updated
10864 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10865 save_lustre_params client "llite.*.xattr_cache" > $save
10866 lctl set_param llite.*.xattr_cache 1
10868 # 6.1) linkea update on rename
10869 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10871 # get parents by fid
10872 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10873 # foo1 should no longer be returned in parent list
10874 echo "$parent" | grep -F "$FID1" &&
10875 error "$FID1 should no longer be in parent list"
10876 # the new path should appear
10877 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10878 error "$FID2/$tfile.moved is not in parent list"
10880 # 6.2) linkea update on unlink
10881 rm -f $DIR/$tdir/d/foo2/link
10882 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10883 # foo2/link should no longer be returned in parent list
10884 echo "$parent" | grep -F "$FID2/link" &&
10885 error "$FID2/link should no longer be in parent list"
10889 restore_lustre_params < $save
10892 run_test 154f "get parent fids by reading link ea"
10896 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
10897 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
10898 { skip "Need MDS version at least 2.6.92"; return 0; }
10899 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10901 mkdir -p $DIR/$tdir
10902 llapi_fid_test -d $DIR/$tdir
10904 run_test 154g "various llapi FID tests"
10906 test_155_small_load() {
10907 local temp=$TMP/$tfile
10908 local file=$DIR/$tfile
10910 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10911 error "dd of=$temp bs=6096 count=1 failed"
10913 cancel_lru_locks osc
10914 cmp $temp $file || error "$temp $file differ"
10916 $TRUNCATE $temp 6000
10917 $TRUNCATE $file 6000
10918 cmp $temp $file || error "$temp $file differ (truncate1)"
10920 echo "12345" >>$temp
10921 echo "12345" >>$file
10922 cmp $temp $file || error "$temp $file differ (append1)"
10924 echo "12345" >>$temp
10925 echo "12345" >>$file
10926 cmp $temp $file || error "$temp $file differ (append2)"
10932 test_155_big_load() {
10933 remote_ost_nodsh && skip "remote OST with nodsh" && return
10934 local temp=$TMP/$tfile
10935 local file=$DIR/$tfile
10938 local cache_size=$(do_facet ost$((MAXI+1)) \
10939 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10940 local large_file_size=$((cache_size * 2))
10942 echo "OSS cache size: $cache_size KB"
10943 echo "Large file size: $large_file_size KB"
10945 [ $MAXV -le $large_file_size ] && \
10946 skip_env "max available OST size needs > $large_file_size KB" && \
10949 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10951 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10952 error "dd of=$temp bs=$large_file_size count=1k failed"
10955 cancel_lru_locks osc
10956 cmp $temp $file || error "$temp $file differ"
10962 save_writethrough() {
10963 local facets=$(get_facets OST)
10965 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
10966 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
10970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10971 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10972 save_writethrough $p
10975 set_cache writethrough on
10976 test_155_small_load
10977 restore_lustre_params < $p
10980 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10984 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10985 save_writethrough $p
10988 set_cache writethrough off
10989 test_155_small_load
10990 restore_lustre_params < $p
10993 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10997 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10998 save_writethrough $p
11001 set_cache writethrough on
11002 test_155_small_load
11003 restore_lustre_params < $p
11006 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
11009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11010 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11011 save_writethrough $p
11014 set_cache writethrough off
11015 test_155_small_load
11016 restore_lustre_params < $p
11019 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
11022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11023 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11024 save_writethrough $p
11027 set_cache writethrough on
11029 restore_lustre_params < $p
11032 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11036 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11037 save_writethrough $p
11040 set_cache writethrough off
11042 restore_lustre_params < $p
11045 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11049 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11050 save_writethrough $p
11053 set_cache writethrough on
11055 restore_lustre_params < $p
11058 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11062 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11063 save_writethrough $p
11066 set_cache writethrough off
11068 restore_lustre_params < $p
11071 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11074 remote_ost_nodsh && skip "remote OST with nodsh" && return
11075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11079 local file="$DIR/$tfile"
11080 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11082 [ "$(facet_fstype ost1)" = "zfs" -a \
11083 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11084 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
11087 save_writethrough $p
11090 log "Turn on read and write cache"
11092 set_cache writethrough on
11094 log "Write data and read it back."
11095 log "Read should be satisfied from the cache."
11096 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11098 cancel_lru_locks osc
11099 cat $file >/dev/null
11101 if ! let "AFTER - BEFORE == CPAGES"; then
11102 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11104 log "cache hits:: before: $BEFORE, after: $AFTER"
11107 log "Read again; it should be satisfied from the cache."
11109 cancel_lru_locks osc
11110 cat $file >/dev/null
11112 if ! let "AFTER - BEFORE == CPAGES"; then
11113 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11115 log "cache hits:: before: $BEFORE, after: $AFTER"
11118 log "Turn off the read cache and turn on the write cache"
11120 set_cache writethrough on
11122 log "Read again; it should be satisfied from the cache."
11124 cancel_lru_locks osc
11125 cat $file >/dev/null
11127 if ! let "AFTER - BEFORE == CPAGES"; then
11128 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11130 log "cache hits:: before: $BEFORE, after: $AFTER"
11133 log "Read again; it should not be satisfied from the cache."
11135 cancel_lru_locks osc
11136 cat $file >/dev/null
11138 if ! let "AFTER - BEFORE == 0"; then
11139 error "IN CACHE: before: $BEFORE, after: $AFTER"
11141 log "cache hits:: before: $BEFORE, after: $AFTER"
11144 log "Write data and read it back."
11145 log "Read should be satisfied from the cache."
11146 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11148 cancel_lru_locks osc
11149 cat $file >/dev/null
11151 if ! let "AFTER - BEFORE == CPAGES"; then
11152 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11154 log "cache hits:: before: $BEFORE, after: $AFTER"
11157 log "Read again; it should not be satisfied from the cache."
11159 cancel_lru_locks osc
11160 cat $file >/dev/null
11162 if ! let "AFTER - BEFORE == 0"; then
11163 error "IN CACHE: before: $BEFORE, after: $AFTER"
11165 log "cache hits:: before: $BEFORE, after: $AFTER"
11168 log "Turn off read and write cache"
11170 set_cache writethrough off
11172 log "Write data and read it back"
11173 log "It should not be satisfied from the cache."
11175 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11176 cancel_lru_locks osc
11178 cat $file >/dev/null
11180 if ! let "AFTER - BEFORE == 0"; then
11181 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11183 log "cache hits:: before: $BEFORE, after: $AFTER"
11186 log "Turn on the read cache and turn off the write cache"
11188 set_cache writethrough off
11190 log "Write data and read it back"
11191 log "It should not be satisfied from the cache."
11193 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11195 cancel_lru_locks osc
11196 cat $file >/dev/null
11198 if ! let "AFTER - BEFORE == 0"; then
11199 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11201 log "cache hits:: before: $BEFORE, after: $AFTER"
11204 log "Read again; it should be satisfied from the cache."
11206 cancel_lru_locks osc
11207 cat $file >/dev/null
11209 if ! let "AFTER - BEFORE == CPAGES"; then
11210 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11212 log "cache hits:: before: $BEFORE, after: $AFTER"
11216 restore_lustre_params < $p
11219 run_test 156 "Verification of tunables"
11222 cleanup_changelog () {
11224 echo "Deregistering changelog client $CL_USER"
11225 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11229 if [[ $MDSCOUNT -gt 1 ]]; then
11230 error_ignore bz17935 $*
11238 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11240 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11242 if [ $MASK -eq 1 ]; then
11243 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11245 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11249 changelog_extract_field() {
11253 local identifier=$4
11255 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11256 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11262 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11263 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11264 { skip "Need MDS version at least 2.2.0"; return; }
11266 local CL_USERS="mdd.$MDT0.changelog_users"
11267 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11268 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11269 changelog_register -n)
11270 echo "Registered as changelog user $CL_USER"
11271 trap cleanup_changelog EXIT
11272 $GET_CL_USERS | grep -q $CL_USER ||
11273 error "User $CL_USER not found in changelog_users"
11276 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11277 touch $DIR/$tdir/pics/2008/zachy/timestamp
11278 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11279 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11280 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11281 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11282 rm $DIR/$tdir/pics/desktop.jpg
11284 $LFS changelog $MDT0 | tail -5
11286 echo "verifying changelog mask"
11287 changelog_chmask "MKDIR"
11288 changelog_chmask "CLOSE"
11290 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11291 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11293 changelog_chmask "MKDIR"
11294 changelog_chmask "CLOSE"
11296 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11297 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11299 $LFS changelog $MDT0
11300 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11301 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11302 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11303 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11306 echo "verifying target fid"
11307 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11308 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11309 [ "$fidc" == "$fidf" ] ||
11310 err17935 "fid in changelog $fidc != file fid $fidf"
11311 echo "verifying parent fid"
11312 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11313 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11314 [ "$fidc" == "$fidf" ] ||
11315 err17935 "pfid in changelog $fidc != dir fid $fidf"
11317 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11318 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11319 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11320 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11321 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11322 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11324 MIN_REC=$($GET_CL_USERS |
11325 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11326 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11327 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11328 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11329 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11331 # LU-3446 changelog index reset on MDT restart
11332 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11333 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11334 $LFS changelog_clear $MDT0 $CL_USER 0
11335 stop $SINGLEMDS || error "Fail to stop MDT."
11336 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11337 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11338 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11339 [ $CUR_REC1 == $CUR_REC2 ] ||
11340 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11342 echo "verifying user deregister"
11344 $GET_CL_USERS | grep -q $CL_USER &&
11345 error "User $CL_USER still in changelog_users"
11347 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11348 if [ $CL_USER -eq 0 ]; then
11349 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11350 touch $DIR/$tdir/chloe
11351 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11352 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11353 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11355 echo "$CL_USER other changelog users; can't verify off"
11358 run_test 160a "changelog sanity"
11360 test_160b() { # LU-3587
11361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11362 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11363 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11364 { skip "Need MDS version at least 2.2.0"; return; }
11366 local CL_USERS="mdd.$MDT0.changelog_users"
11367 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11368 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11369 changelog_register -n)
11370 echo "Registered as changelog user $CL_USER"
11371 trap cleanup_changelog EXIT
11372 $GET_CL_USERS | grep -q $CL_USER ||
11373 error "User $CL_USER not found in changelog_users"
11375 local LONGNAME1=$(str_repeat a 255)
11376 local LONGNAME2=$(str_repeat b 255)
11379 echo "creating very long named file"
11380 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11381 echo "moving very long named file"
11382 mv $LONGNAME1 $LONGNAME2
11384 $LFS changelog $MDT0 | grep RENME
11388 run_test 160b "Verify that very long rename doesn't crash in changelog"
11391 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11394 local server_version=$(lustre_version_code $SINGLEMDS)
11396 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11397 [[ $server_version -gt $(version_code 2.5.1) &&
11398 $server_version -lt $(version_code 2.5.50) ]] ||
11399 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11402 # Registration step
11403 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11404 changelog_register -n)
11405 trap cleanup_changelog EXIT
11408 mkdir -p $DIR/$tdir
11409 $MCREATE $DIR/$tdir/foo_160c
11410 changelog_chmask "TRUNC"
11411 $TRUNCATE $DIR/$tdir/foo_160c 200
11412 changelog_chmask "TRUNC"
11413 $TRUNCATE $DIR/$tdir/foo_160c 199
11414 $LFS changelog $MDT0
11415 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11416 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11417 $LFS changelog_clear $MDT0 $CL_USER 0
11419 # Deregistration step
11422 run_test 160c "verify that changelog log catch the truncate event"
11425 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11426 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11428 local server_version=$(lustre_version_code mds1)
11429 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11431 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11432 { skip "Need MDS version at least 2.7.60+"; return; }
11433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11435 # Registration step
11436 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11437 changelog_register -n)
11439 trap cleanup_changelog EXIT
11440 mkdir -p $DIR/$tdir/migrate_dir
11441 $LFS changelog_clear $MDT0 $CL_USER 0
11443 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11444 $LFS changelog $MDT0
11445 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11446 $LFS changelog_clear $MDT0 $CL_USER 0
11447 [ $MIGRATES -eq 1 ] ||
11448 error "MIGRATE changelog mask count $MIGRATES != 1"
11450 # Deregistration step
11453 run_test 160d "verify that changelog log catch the migrate event"
11456 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11459 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11460 changelog_register -n)
11461 echo "Registered as changelog user $CL_USER"
11462 trap cleanup_changelog EXIT
11464 # Delete a future user (expect fail)
11465 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11468 if [ $rc -eq 0 ]; then
11469 error "Deleted non-existant user cl77"
11470 elif [ $rc -ne 2 ]; then
11471 error "changelog_deregister failed with $rc, " \
11472 "expected 2 (ENOENT)"
11475 # Clear to a bad index (1 billion should be safe)
11476 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11479 if [ $rc -eq 0 ]; then
11480 error "Successfully cleared to invalid CL index"
11481 elif [ $rc -ne 22 ]; then
11482 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11485 run_test 160e "changelog negative testing"
11488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11489 test_mkdir -p -c1 $DIR/$tdir
11490 cp /etc/hosts $DIR/$tdir/$tfile
11491 test_mkdir -c1 $DIR/$tdir/foo1
11492 test_mkdir -c1 $DIR/$tdir/foo2
11493 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11494 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11495 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11496 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11497 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11498 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11499 $LFS fid2path $DIR $FID
11500 err17935 "bad link ea"
11503 rm $DIR/$tdir/foo2/zachary
11505 rm $DIR/$tdir/foo2/thor
11507 rm $DIR/$tdir/$tfile
11509 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11510 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11512 $LFS fid2path $DIR $FID
11513 err17935 "bad link rename"
11515 rm $DIR/$tdir/foo2/maggie
11518 local longname=filename_avg_len_is_thirty_two_
11519 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11520 error "failed to hardlink many files"
11521 links=$($LFS fid2path $DIR $FID | wc -l)
11522 echo -n "${links}/1000 links in link EA"
11523 [[ $links -gt 60 ]] ||
11524 err17935 "expected at least 60 links in link EA"
11525 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11526 error "failed to unlink many hardlinks"
11528 run_test 161a "link ea sanity"
11531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11532 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11534 local remote_dir=$DIR/$tdir/remote_dir
11536 mkdir -p $DIR/$tdir
11537 $LFS mkdir -i $MDTIDX $remote_dir ||
11538 error "create remote directory failed"
11540 cp /etc/hosts $remote_dir/$tfile
11541 mkdir -p $remote_dir/foo1
11542 mkdir -p $remote_dir/foo2
11543 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11544 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11545 ln $remote_dir/$tfile $remote_dir/foo1/luna
11546 ln $remote_dir/$tfile $remote_dir/foo2/thor
11548 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11550 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11551 $LFS fid2path $DIR $FID
11552 err17935 "bad link ea"
11555 rm $remote_dir/foo2/zachary
11557 rm $remote_dir/foo2/thor
11559 rm $remote_dir/$tfile
11561 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11562 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11563 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11564 $LFS fid2path $DIR $FID
11565 err17935 "bad link rename"
11567 rm $remote_dir/foo2/maggie
11570 local longname=filename_avg_len_is_thirty_two_
11571 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11572 error "failed to hardlink many files"
11573 links=$($LFS fid2path $DIR $FID | wc -l)
11574 echo -n "${links}/1000 links in link EA"
11575 [[ ${links} -gt 60 ]] ||
11576 err17935 "expected at least 60 links in link EA"
11577 unlinkmany $remote_dir/foo2/$longname 1000 ||
11578 error "failed to unlink many hardlinks"
11580 run_test 161b "link ea sanity under remote directory"
11583 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11585 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11586 skip "Need MDS version at least 2.1.5" && return
11588 # define CLF_RENAME_LAST 0x0001
11589 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11590 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11591 changelog_register -n)
11593 trap cleanup_changelog EXIT
11595 mkdir -p $DIR/$tdir
11596 touch $DIR/$tdir/foo_161c
11597 touch $DIR/$tdir/bar_161c
11598 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11599 $LFS changelog $MDT0 | grep RENME
11600 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11602 $LFS changelog_clear $MDT0 $CL_USER 0
11603 if [ x$flags != "x0x1" ]; then
11604 error "flag $flags is not 0x1"
11606 echo "rename overwrite a target having nlink = 1," \
11607 "changelog record has flags of $flags"
11609 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11610 touch $DIR/$tdir/foo_161c
11611 touch $DIR/$tdir/bar_161c
11612 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11613 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11614 $LFS changelog $MDT0 | grep RENME
11615 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11616 $LFS changelog_clear $MDT0 $CL_USER 0
11617 if [ x$flags != "x0x0" ]; then
11618 error "flag $flags is not 0x0"
11620 echo "rename overwrite a target having nlink > 1," \
11621 "changelog record has flags of $flags"
11623 # rename doesn't overwrite a target (changelog flag 0x0)
11624 touch $DIR/$tdir/foo_161c
11625 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11626 $LFS changelog $MDT0 | grep RENME
11627 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11628 $LFS changelog_clear $MDT0 $CL_USER 0
11629 if [ x$flags != "x0x0" ]; then
11630 error "flag $flags is not 0x0"
11632 echo "rename doesn't overwrite a target," \
11633 "changelog record has flags of $flags"
11635 # define CLF_UNLINK_LAST 0x0001
11636 # unlink a file having nlink = 1 (changelog flag 0x1)
11637 rm -f $DIR/$tdir/foo2_161c
11638 $LFS changelog $MDT0 | grep UNLNK
11639 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11640 $LFS changelog_clear $MDT0 $CL_USER 0
11641 if [ x$flags != "x0x1" ]; then
11642 error "flag $flags is not 0x1"
11644 echo "unlink a file having nlink = 1," \
11645 "changelog record has flags of $flags"
11647 # unlink a file having nlink > 1 (changelog flag 0x0)
11648 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11649 rm -f $DIR/$tdir/foobar_161c
11650 $LFS changelog $MDT0 | grep UNLNK
11651 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11652 $LFS changelog_clear $MDT0 $CL_USER 0
11653 if [ x$flags != "x0x0" ]; then
11654 error "flag $flags is not 0x0"
11656 echo "unlink a file having nlink > 1," \
11657 "changelog record has flags of $flags"
11660 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11667 # cleanup previous run
11668 rm -rf $DIR/$tdir/$tfile
11670 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11671 changelog_register -n)
11672 [[ $? -eq 0 ]] || error "changelog_register failed"
11674 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11675 # interfer with $MOUNT/.lustre/fid/ access
11677 [[ $? -eq 0 ]] || error "mkdir failed"
11679 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11680 $LCTL set_param fail_loc=0x8000140c
11682 $LCTL set_param fail_val=5
11685 echo foofoo > $DIR/$tdir/$tfile &
11688 # wait for create to be delayed
11692 [[ $? -eq 0 ]] || error "create should be blocked"
11694 local tempfile=$(mktemp)
11695 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11696 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11697 # some delay may occur during ChangeLog publishing and file read just
11698 # above, that could allow file write to happen finally
11699 [[ -s $tempfile ]] && echo "file should be empty"
11701 $LCTL set_param fail_loc=0
11704 [[ $? -eq 0 ]] || error "create failed"
11706 $LFS changelog_clear $MDT0 $user 0
11707 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11709 run_test 161d "create with concurrent .lustre/fid access"
11716 local path=$(${LFS} fid2path $*)
11717 # Remove the '//' indicating a remote directory
11718 path=$(echo $path | sed 's#//#/#g')
11721 if [ $RC -ne 0 ]; then
11722 err17935 "path looked up of $expected failed. Error $RC"
11724 elif [ "${path}" != "${expected}" ]; then
11725 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11728 echo "fid $fid resolves to path $path (expected $expected)"
11731 test_162a() { # was test_162
11732 # Make changes to filesystem
11733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11734 test_mkdir -p -c1 $DIR/$tdir/d2
11735 touch $DIR/$tdir/d2/$tfile
11736 touch $DIR/$tdir/d2/x1
11737 touch $DIR/$tdir/d2/x2
11738 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11739 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11741 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11742 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11743 error "check path $tdir/d2/$tfile failed"
11746 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11747 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11748 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11749 error "check path $tdir/d2/p/q/r/slink failed"
11751 # softlink to wrong file
11752 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11753 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11754 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11755 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11758 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11759 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11760 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11761 # fid2path dir/fsname should both work
11762 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11763 error "check path $tdir/d2/a/b/c/new_file failed"
11764 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11765 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11767 # hardlink count: check that there are 2 links
11768 # Doesnt work with CMD yet: 17935
11769 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11770 err17935 "expected 2 links"
11772 # hardlink indexing: remove the first link
11773 rm $DIR/$tdir/d2/p/q/r/hlink
11774 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11775 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11779 run_test 162a "path lookup sanity"
11782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11783 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11786 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11787 error "create striped dir failed"
11789 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11790 tail -n 1 | awk '{print $2}')
11791 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11793 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11794 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11797 for ((i=0;i<5;i++)); do
11798 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11799 error "get fid for f$i failed"
11800 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11801 error "check path $tdir/striped_dir/f$i failed"
11803 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11804 error "get fid for d$i failed"
11805 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11806 error "check path $tdir/striped_dir/d$i failed"
11811 run_test 162b "striped directory path lookup sanity"
11813 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11815 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11816 skip "Need MDS version at least 2.7.51" && return
11817 test_mkdir $DIR/$tdir.local
11818 test_mkdir $DIR/$tdir.remote
11819 local lpath=$tdir.local
11820 local rpath=$tdir.remote
11822 for ((i = 0; i <= 101; i++)); do
11825 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11826 error "get fid for local directory $DIR/$lpath failed"
11827 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11828 error "check path for local directory $DIR/$lpath failed"
11831 test_mkdir $DIR/$rpath
11832 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11833 error "get fid for remote directory $DIR/$rpath failed"
11834 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11835 error "check path for remote directory $DIR/$rpath failed"
11840 run_test 162c "fid2path works with paths 100 or more directories deep"
11843 # do directio so as not to populate the page cache
11844 log "creating a 10 Mb file"
11845 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11846 log "starting reads"
11847 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11848 log "truncating the file"
11849 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11851 kill %+ || true # reads might have finished
11852 echo "wait until dd is finished"
11854 log "removing the temporary file"
11855 rm -rf $DIR/$tfile || error "tmp file removal failed"
11857 run_test 169 "parallel read and truncate should not deadlock"
11860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11861 $LCTL clear # bug 18514
11862 $LCTL debug_daemon start $TMP/${tfile}_log_good
11864 $LCTL debug_daemon stop
11865 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11866 error "sed failed to read log_good"
11868 $LCTL debug_daemon start $TMP/${tfile}_log_good
11870 $LCTL debug_daemon stop
11872 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11873 error "lctl df log_bad failed"
11875 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11876 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11878 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11879 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11881 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11882 error "bad_line good_line1 good_line2 are empty"
11884 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11885 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11886 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11888 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11889 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11890 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11892 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11893 error "bad_line_new good_line_new are empty"
11895 local expected_good=$((good_line1 + good_line2*2))
11897 rm -f $TMP/${tfile}*
11898 # LU-231, short malformed line may not be counted into bad lines
11899 if [ $bad_line -ne $bad_line_new ] &&
11900 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11901 error "expected $bad_line bad lines, but got $bad_line_new"
11905 if [ $expected_good -ne $good_line_new ]; then
11906 error "expected $expected_good good lines, but got $good_line_new"
11911 run_test 170 "test lctl df to handle corrupted log ====================="
11913 test_171() { # bug20592
11914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11915 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11916 $LCTL set_param fail_loc=0x50e
11917 $LCTL set_param fail_val=3000
11918 multiop_bg_pause $DIR/$tfile O_s || true
11920 kill -USR1 $MULTIPID
11924 if dmesg | grep "recursive fault"; then
11925 error "caught a recursive fault"
11927 $LCTL set_param fail_loc=0
11930 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11932 # it would be good to share it with obdfilter-survey/iokit-libecho code
11933 setup_obdecho_osc () {
11936 local obdfilter_name=$2
11937 echo "Creating new osc for $obdfilter_name on $ost_nid"
11938 # make sure we can find loopback nid
11939 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11941 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11942 ${obdfilter_name}_osc_UUID || rc=2; }
11943 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11944 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11948 cleanup_obdecho_osc () {
11949 local obdfilter_name=$1
11950 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11951 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11958 local pages=${3:-64}
11963 local obd_size=$(get_obd_size $node $OBD)
11964 local page_size=$(get_page_size $node)
11965 if [[ -n "$obd_size" ]]; then
11966 local new_count=$((obd_size / (pages * page_size / 1024)))
11967 [[ $new_count -ge $count ]] || count=$new_count
11970 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11971 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11973 if [ $rc -eq 0 ]; then
11974 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11975 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11977 echo "New object id is $id"
11978 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11980 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11981 "test_brw $count w v $pages $id" || rc=4; }
11982 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11984 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11985 "cleanup" || rc=5; }
11986 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11987 "detach" || rc=6; }
11988 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11994 remote_ost_nodsh && skip "remote OST with nodsh" && return
11996 local rmmod_local=0
11998 if ! module_loaded obdecho; then
11999 load_module obdecho/obdecho
12003 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
12004 local host=$(lctl get_param -n osc.$osc.import |
12005 awk '/current_connection:/ {print $2}' )
12006 local target=$(lctl get_param -n osc.$osc.import |
12007 awk '/target:/ {print $2}' )
12008 target=${target%_UUID}
12010 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
12011 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
12012 [[ -n $target ]] && cleanup_obdecho_osc $target
12013 [ $rmmod_local -eq 1 ] && rmmod obdecho
12016 run_test 180a "test obdecho on osc"
12019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12020 remote_ost_nodsh && skip "remote OST with nodsh" && return
12022 local rmmod_remote=0
12024 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12025 rmmod_remote=true || error "failed to load module obdecho"
12026 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
12027 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12028 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12031 run_test 180b "test obdecho directly on obdfilter"
12033 test_180c() { # LU-2598
12034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12035 remote_ost_nodsh && skip "remote OST with nodsh" && return
12036 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12037 skip "Need MDS version at least 2.4.0" && return
12040 local rmmod_remote=false
12041 local pages=16384 # 64MB bulk I/O RPC size
12044 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12045 rmmod_remote=true || error "failed to load module obdecho"
12047 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
12049 if [ -n "$target" ]; then
12050 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12052 echo "there is no obdfilter target on ost1"
12055 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12058 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12060 test_181() { # bug 22177
12061 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12062 # create enough files to index the directory
12063 createmany -o $DIR/$tdir/foobar 4000
12064 # print attributes for debug purpose
12067 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12069 # remove the files & current working dir
12070 unlinkmany $DIR/$tdir/foobar 4000
12072 kill -USR1 $MULTIPID
12074 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12077 run_test 181 "Test open-unlinked dir ========================"
12083 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12085 $LCTL set_param mdc.*.rpc_stats=clear
12087 for (( i = 0; i < $tcount; i++ )) ; do
12088 mkdir $DIR/$tdir/$i
12091 for (( i = 0; i < $tcount; i++ )) ; do
12092 createmany -o $DIR/$tdir/$i/f- $fcount &
12096 for (( i = 0; i < $tcount; i++ )) ; do
12097 unlinkmany $DIR/$tdir/$i/f- $fcount &
12101 $LCTL get_param mdc.*.rpc_stats
12105 run_test 182 "Test parallel modify metadata operations ================"
12107 test_183() { # LU-2275
12108 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12109 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12110 skip "Need MDS version at least 2.3.56" && return
12112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12113 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12114 echo aaa > $DIR/$tdir/$tfile
12116 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12117 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12119 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12120 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12122 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12124 # Flush negative dentry cache
12125 touch $DIR/$tdir/$tfile
12127 # We are not checking for any leaked references here, they'll
12128 # become evident next time we do cleanup with module unload.
12131 run_test 183 "No crash or request leak in case of strange dispositions ========"
12133 # test suite 184 is for LU-2016, LU-2017
12135 check_swap_layouts_support && return 0
12137 dir0=$DIR/$tdir/$testnum
12138 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
12143 $SETSTRIPE -c1 $file1
12145 $SETSTRIPE -c2 $file2
12147 gen1=$($GETSTRIPE -g $file1)
12148 gen2=$($GETSTRIPE -g $file2)
12150 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12151 gen=$($GETSTRIPE -g $file1)
12152 [[ $gen1 != $gen ]] ||
12153 "Layout generation on $file1 does not change"
12154 gen=$($GETSTRIPE -g $file2)
12155 [[ $gen2 != $gen ]] ||
12156 "Layout generation on $file2 does not change"
12158 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12159 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12161 run_test 184a "Basic layout swap"
12164 check_swap_layouts_support && return 0
12166 dir0=$DIR/$tdir/$testnum
12167 mkdir -p $dir0 || error "creating dir $dir0"
12174 $SETSTRIPE -c1 $file1
12175 $SETSTRIPE -c2 $file2
12176 $SETSTRIPE -c1 $file3
12177 chown $RUNAS_ID $file3
12178 gen1=$($GETSTRIPE -g $file1)
12179 gen2=$($GETSTRIPE -g $file2)
12181 $LFS swap_layouts $dir1 $dir2 &&
12182 error "swap of directories layouts should fail"
12183 $LFS swap_layouts $dir1 $file1 &&
12184 error "swap of directory and file layouts should fail"
12185 $RUNAS $LFS swap_layouts $file1 $file2 &&
12186 error "swap of file we cannot write should fail"
12187 $LFS swap_layouts $file1 $file3 &&
12188 error "swap of file with different owner should fail"
12189 /bin/true # to clear error code
12191 run_test 184b "Forbidden layout swap (will generate errors)"
12194 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12195 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12196 check_swap_layouts_support && return 0
12198 local dir0=$DIR/$tdir/$testnum
12199 mkdir -p $dir0 || error "creating dir $dir0"
12201 local ref1=$dir0/ref1
12202 local ref2=$dir0/ref2
12203 local file1=$dir0/file1
12204 local file2=$dir0/file2
12205 # create a file large enough for the concurrent test
12206 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12207 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12208 echo "ref file size: ref1($(stat -c %s $ref1))," \
12209 "ref2($(stat -c %s $ref2))"
12212 dd if=$ref1 of=$file1 bs=16k &
12215 # Make sure dd starts to copy file
12216 while [ ! -f $file1 ]; do sleep 0.1; done
12218 $LFS swap_layouts $file1 $file2
12221 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12222 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12224 # how many bytes copied before swapping layout
12225 local copied=$(stat -c %s $file2)
12226 local remaining=$(stat -c %s $ref1)
12227 remaining=$((remaining - copied))
12228 echo "Copied $copied bytes before swapping layout..."
12230 cmp -n $copied $file1 $ref2 | grep differ &&
12231 error "Content mismatch [0, $copied) of ref2 and file1"
12232 cmp -n $copied $file2 $ref1 ||
12233 error "Content mismatch [0, $copied) of ref1 and file2"
12234 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12235 error "Content mismatch [$copied, EOF) of ref1 and file1"
12238 rm -f $ref1 $ref2 $file1 $file2
12240 run_test 184c "Concurrent write and layout swap"
12243 check_swap_layouts_support && return 0
12244 [ -z "$(which getfattr 2>/dev/null)" ] &&
12245 skip "no getfattr command" && return 0
12247 local file1=$DIR/$tdir/$tfile-1
12248 local file2=$DIR/$tdir/$tfile-2
12249 local file3=$DIR/$tdir/$tfile-3
12253 mkdir -p $DIR/$tdir
12254 touch $file1 || error "create $file1 failed"
12255 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12256 error "create $file2 failed"
12257 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12258 error "create $file3 failed"
12259 lovea1=$(get_layout_param $file1)
12261 $LFS swap_layouts $file2 $file3 ||
12262 error "swap $file2 $file3 layouts failed"
12263 $LFS swap_layouts $file1 $file2 ||
12264 error "swap $file1 $file2 layouts failed"
12266 lovea2=$(get_layout_param $file2)
12269 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12271 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12272 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12274 run_test 184d "allow stripeless layouts swap"
12277 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12278 { skip "Need MDS version at least 2.6.94"; return 0; }
12279 check_swap_layouts_support && return 0
12280 [ -z "$(which getfattr 2>/dev/null)" ] &&
12281 skip "no getfattr command" && return 0
12283 local file1=$DIR/$tdir/$tfile-1
12284 local file2=$DIR/$tdir/$tfile-2
12285 local file3=$DIR/$tdir/$tfile-3
12288 mkdir -p $DIR/$tdir
12289 touch $file1 || error "create $file1 failed"
12290 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12291 error "create $file2 failed"
12292 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12293 error "create $file3 failed"
12295 $LFS swap_layouts $file1 $file2 ||
12296 error "swap $file1 $file2 layouts failed"
12298 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12299 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12301 echo 123 > $file1 || error "Should be able to write into $file1"
12303 $LFS swap_layouts $file1 $file3 ||
12304 error "swap $file1 $file3 layouts failed"
12306 echo 123 > $file1 || error "Should be able to write into $file1"
12308 rm -rf $file1 $file2 $file3
12310 run_test 184e "Recreate layout after stripeless layout swaps"
12312 test_185() { # LU-2441
12313 # LU-3553 - no volatile file support in old servers
12314 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12315 { skip "Need MDS version at least 2.3.60"; return 0; }
12317 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12318 touch $DIR/$tdir/spoo
12319 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12320 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12321 error "cannot create/write a volatile file"
12322 [ "$FILESET" == "" ] &&
12323 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12324 error "FID is still valid after close"
12326 multiop_bg_pause $DIR/$tdir vVw4096_c
12333 # assume that the next FID for this client is sequential, since stdout
12334 # is unfortunately eaten by multiop_bg_pause
12335 local n=$((${fidv[1]} + 1))
12336 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12337 if [ "$FILESET" == "" ]; then
12338 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12339 error "FID is missing before close"
12341 kill -USR1 $multi_pid
12342 # 1 second delay, so if mtime change we will see it
12344 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12345 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12347 run_test 185 "Volatile file support"
12350 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12351 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12352 skip "Need MDS version at least 2.3.0" && return
12354 local dir0=$DIR/$tdir/$testnum
12355 mkdir -p $dir0 || error "creating dir $dir0"
12357 local file=$dir0/file1
12358 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12359 local dv1=$($LFS data_version $file)
12360 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12361 local dv2=$($LFS data_version $file)
12362 [[ $dv1 != $dv2 ]] ||
12363 error "data version did not change on write $dv1 == $dv2"
12368 run_test 187a "Test data version change"
12371 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12372 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12373 skip "Need MDS version at least 2.3.0" && return
12375 local dir0=$DIR/$tdir/$testnum
12376 mkdir -p $dir0 || error "creating dir $dir0"
12378 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12379 [[ ${DV[0]} != ${DV[1]} ]] ||
12380 error "data version did not change on write"\
12381 " ${DV[0]} == ${DV[1]}"
12386 run_test 187b "Test data version change on volatile file"
12389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12390 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12391 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12393 local POOL=${POOL:-cea1}
12394 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12395 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12398 local last_ost=$(($OSTCOUNT - 1))
12400 local ost_list=$(seq $first_ost $ost_step $last_ost)
12401 local ost_range="$first_ost $last_ost $ost_step"
12402 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12403 local file_dir=$POOL_ROOT/file_tst
12404 local subdir=$test_path/subdir
12407 if ! combined_mgs_mds ; then
12412 # former test_200a test_200b
12413 pool_add $POOL || { rc=$? ; break; }
12414 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12415 # former test_200c test_200d
12416 mkdir -p $test_path
12417 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12418 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12420 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12421 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12422 || { rc=$? ; break; }
12423 # former test_200e test_200f
12424 local files=$((OSTCOUNT*3))
12425 pool_alloc_files $POOL $test_path $files "$ost_list" \
12426 || { rc=$? ; break; }
12427 pool_create_files $POOL $file_dir $files "$ost_list" \
12428 || { rc=$? ; break; }
12429 # former test_200g test_200h
12430 pool_lfs_df $POOL || { rc=$? ; break; }
12431 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12433 # former test_201a test_201b test_201c
12434 pool_remove_first_target $POOL || { rc=$? ; break; }
12436 local f=$test_path/$tfile
12437 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12438 pool_remove $POOL $f || { rc=$? ; break; }
12444 if ! combined_mgs_mds ; then
12449 run_test 200 "OST pools"
12451 # usage: default_attr <count | size | offset>
12453 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12456 # usage: check_default_stripe_attr
12457 check_default_stripe_attr() {
12458 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12461 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12463 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12467 error "unknown getstripe attr '$1'"
12470 [ $ACTUAL != $EXPECTED ] &&
12471 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12475 test_mkdir -p $DIR/$tdir
12476 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12478 check_default_stripe_attr --stripe-count
12479 check_default_stripe_attr --stripe-size
12480 check_default_stripe_attr --stripe-index
12484 run_test 204a "Print default stripe attributes ================="
12487 test_mkdir -p $DIR/$tdir
12488 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12490 check_default_stripe_attr --stripe-size
12491 check_default_stripe_attr --stripe-index
12495 run_test 204b "Print default stripe size and offset ==========="
12498 test_mkdir -p $DIR/$tdir
12499 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12501 check_default_stripe_attr --stripe-count
12502 check_default_stripe_attr --stripe-index
12506 run_test 204c "Print default stripe count and offset ==========="
12509 test_mkdir -p $DIR/$tdir
12510 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12512 check_default_stripe_attr --stripe-count
12513 check_default_stripe_attr --stripe-size
12517 run_test 204d "Print default stripe count and size ============="
12520 test_mkdir -p $DIR/$tdir
12521 $SETSTRIPE -d $DIR/$tdir
12523 check_default_stripe_attr --stripe-count --raw
12524 check_default_stripe_attr --stripe-size --raw
12525 check_default_stripe_attr --stripe-index --raw
12529 run_test 204e "Print raw stripe attributes ================="
12532 test_mkdir -p $DIR/$tdir
12533 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12535 check_default_stripe_attr --stripe-size --raw
12536 check_default_stripe_attr --stripe-index --raw
12540 run_test 204f "Print raw stripe size and offset ==========="
12543 test_mkdir -p $DIR/$tdir
12544 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12546 check_default_stripe_attr --stripe-count --raw
12547 check_default_stripe_attr --stripe-index --raw
12551 run_test 204g "Print raw stripe count and offset ==========="
12554 test_mkdir -p $DIR/$tdir
12555 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12557 check_default_stripe_attr --stripe-count --raw
12558 check_default_stripe_attr --stripe-size --raw
12562 run_test 204h "Print raw stripe count and size ============="
12564 # Figure out which job scheduler is being used, if any,
12565 # or use a fake one
12566 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12567 JOBENV=SLURM_JOB_ID
12568 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12570 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12572 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12573 JOBENV=LOADL_STEP_ID
12574 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12577 $LCTL list_param jobid_name > /dev/null 2>&1
12578 if [ $? -eq 0 ]; then
12585 verify_jobstats() {
12590 # we don't really need to clear the stats for this test to work, since each
12591 # command has a unique jobid, but it makes debugging easier if needed.
12592 # for facet in $facets; do
12593 # local dev=$(convert_facet2label $facet)
12594 # # clear old jobstats
12595 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12598 # use a new JobID for each test, or we might see an old one
12599 [ "$JOBENV" = "FAKE_JOBID" ] &&
12600 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12604 [ "$JOBENV" = "nodelocal" ] && {
12605 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12606 $LCTL set_param jobid_name=$FAKE_JOBID
12610 log "Test: ${cmd[*]}"
12611 log "Using JobID environment variable $JOBENV=$JOBVAL"
12613 if [ $JOBENV = "FAKE_JOBID" ]; then
12614 FAKE_JOBID=$JOBVAL ${cmd[*]}
12619 # all files are created on OST0000
12620 for facet in $facets; do
12621 local stats="*.$(convert_facet2label $facet).job_stats"
12622 if [ $(do_facet $facet lctl get_param $stats |
12623 grep -c $JOBVAL) -ne 1 ]; then
12624 do_facet $facet lctl get_param $stats
12625 error "No jobstats for $JOBVAL found on $facet::$stats"
12632 NEW_JOBENV=${1:-$OLD_JOBENV}
12633 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12634 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12639 do_facet $SINGLEMDS \
12640 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12641 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12645 test_205() { # Job stats
12646 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12647 { skip "Need MDS version with at least 2.7.1"; return 0; }
12649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12650 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12651 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12652 remote_ost_nodsh && skip "remote OST with nodsh" && return
12654 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12655 skip "Server doesn't support jobstats" && return 0
12656 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12658 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12659 if [ $OLD_JOBENV != $JOBENV ]; then
12660 jobstats_set $JOBENV
12661 trap cleanup_205 EXIT
12664 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12665 echo "Registered as changelog user $CL_USER"
12667 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12668 lctl get_param -n mdt.*.job_cleanup_interval)
12669 local interval_new=5
12670 do_facet $SINGLEMDS \
12671 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12672 local start=$SECONDS
12676 cmd="mkdir $DIR/$tdir"
12677 verify_jobstats "$cmd" "$SINGLEMDS"
12679 cmd="rmdir $DIR/$tdir"
12680 verify_jobstats "$cmd" "$SINGLEMDS"
12681 # mkdir on secondary MDT
12682 if [ $MDSCOUNT -gt 1 ]; then
12683 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12684 verify_jobstats "$cmd" "mds2"
12687 cmd="mknod $DIR/$tfile c 1 3"
12688 verify_jobstats "$cmd" "$SINGLEMDS"
12690 cmd="rm -f $DIR/$tfile"
12691 verify_jobstats "$cmd" "$SINGLEMDS"
12692 # create all files on OST0000 so verify_jobstats can find OST stats
12694 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12695 verify_jobstats "$cmd" "$SINGLEMDS"
12697 cmd="touch $DIR/$tfile"
12698 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12700 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12701 verify_jobstats "$cmd" "ost1"
12703 cancel_lru_locks osc
12704 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12705 verify_jobstats "$cmd" "ost1"
12707 cmd="$TRUNCATE $DIR/$tfile 0"
12708 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12710 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12711 verify_jobstats "$cmd" "$SINGLEMDS"
12712 # jobstats expiry - sleep until old stats should be expired
12713 local left=$((interval_new + 5 - (SECONDS - start)))
12714 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12715 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12717 cmd="mkdir $DIR/$tdir.expire"
12718 verify_jobstats "$cmd" "$SINGLEMDS"
12719 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12720 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12722 # Ensure that jobid are present in changelog (if supported by MDS)
12723 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12725 $LFS changelog $MDT0 | tail -9
12726 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12727 [ $jobids -eq 9 ] ||
12728 error "Wrong changelog jobid count $jobids != 9"
12732 jobstats_set $JOBENV
12734 $LFS changelog $MDT0 | tail -1
12735 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12736 [ $jobids -eq 0 ] ||
12737 error "Unexpected jobids when jobid_var=$JOBENV"
12742 run_test 205 "Verify job stats"
12744 # LU-1480, LU-1773 and LU-1657
12746 mkdir -p $DIR/$tdir
12747 $SETSTRIPE -c -1 $DIR/$tdir
12748 #define OBD_FAIL_LOV_INIT 0x1403
12749 $LCTL set_param fail_loc=0xa0001403
12750 $LCTL set_param fail_val=1
12751 touch $DIR/$tdir/$tfile || true
12753 run_test 206 "fail lov_init_raid0() doesn't lbug"
12756 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12757 local fsz=`stat -c %s $DIR/$tfile`
12758 cancel_lru_locks mdc
12760 # do not return layout in getattr intent
12761 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12762 $LCTL set_param fail_loc=0x170
12763 local sz=`stat -c %s $DIR/$tfile`
12765 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12769 run_test 207a "can refresh layout at glimpse"
12772 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12773 local cksum=`md5sum $DIR/$tfile`
12774 local fsz=`stat -c %s $DIR/$tfile`
12775 cancel_lru_locks mdc
12776 cancel_lru_locks osc
12778 # do not return layout in getattr intent
12779 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12780 $LCTL set_param fail_loc=0x171
12782 # it will refresh layout after the file is opened but before read issues
12783 echo checksum is "$cksum"
12784 echo "$cksum" |md5sum -c --quiet || error "file differs"
12788 run_test 207b "can refresh layout at open"
12791 # FIXME: in this test suite, only RD lease is used. This is okay
12792 # for now as only exclusive open is supported. After generic lease
12793 # is done, this test suite should be revised. - Jinshan
12795 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12796 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12797 { skip "Need MDS version at least 2.4.52"; return 0; }
12799 echo "==== test 1: verify get lease work"
12800 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12802 echo "==== test 2: verify lease can be broken by upcoming open"
12803 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12807 $MULTIOP $DIR/$tfile oO_RDONLY:c
12808 kill -USR1 $PID && wait $PID || error "break lease error"
12810 echo "==== test 3: verify lease can't be granted if an open already exists"
12811 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12815 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12816 kill -USR1 $PID && wait $PID || error "open file error"
12818 echo "==== test 4: lease can sustain over recovery"
12819 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12825 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12827 echo "==== test 5: lease broken can't be regained by replay"
12828 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12832 # open file to break lease and then recovery
12833 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12836 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12840 run_test 208 "Exclusive open"
12843 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12844 skip_env "must have disp_stripe" && return
12847 sync; sleep 5; sync;
12849 echo 3 > /proc/sys/vm/drop_caches
12850 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12852 # open/close 500 times
12853 for i in $(seq 500); do
12857 echo 3 > /proc/sys/vm/drop_caches
12858 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12860 echo "before: $req_before, after: $req_after"
12861 [ $((req_after - req_before)) -ge 300 ] &&
12862 error "open/close requests are not freed"
12865 run_test 209 "read-only open/close requests should be freed promptly"
12869 size=$((size % 8192 + 1))
12870 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12871 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12872 rm -f $DIR/f212 $DIR/f212.xyz
12874 run_test 212 "Sendfile test ============================================"
12877 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12878 cancel_lru_locks osc
12879 lctl set_param fail_loc=0x8000040f
12880 # generate a read lock
12881 cat $DIR/$tfile > /dev/null
12882 # write to the file, it will try to cancel the above read lock.
12883 cat /etc/hosts >> $DIR/$tfile
12885 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12887 test_214() { # for bug 20133
12888 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12889 for (( i=0; i < 340; i++ )) ; do
12890 touch $DIR/$tdir/d214c/a$i
12893 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12894 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12895 ls $DIR/d214c || error "ls $DIR/d214c failed"
12896 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12897 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12899 run_test 214 "hash-indexed directory test - bug 20133"
12901 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12902 create_lnet_proc_files() {
12903 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
12904 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
12906 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12907 rm -f "$TMP/lnet_$1.sys_tmp"
12910 # counterpart of create_lnet_proc_files
12911 remove_lnet_proc_files() {
12912 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12915 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12916 # 3rd arg as regexp for body
12917 check_lnet_proc_stats() {
12918 local l=$(cat "$TMP/lnet_$1" |wc -l)
12919 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12921 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12924 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12925 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12926 # optional and can be regexp for 2nd line (lnet.routes case)
12927 check_lnet_proc_entry() {
12928 local blp=2 # blp stands for 'position of 1st line of body'
12929 [ -z "$5" ] || blp=3 # lnet.routes case
12931 local l=$(cat "$TMP/lnet_$1" |wc -l)
12932 # subtracting one from $blp because the body can be empty
12933 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12935 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12936 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12938 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12939 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12941 # bail out if any unexpected line happened
12942 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12943 [ "$?" != 0 ] || error "$2 misformatted"
12946 test_215() { # for bugs 18102, 21079, 21517
12947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12948 local N='(0|[1-9][0-9]*)' # non-negative numeric
12949 local P='[1-9][0-9]*' # positive numeric
12950 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12951 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12952 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12953 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12955 local L1 # regexp for 1st line
12956 local L2 # regexp for 2nd line (optional)
12957 local BR # regexp for the rest (body)
12959 # lnet.stats should look as 11 space-separated non-negative numerics
12960 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12961 create_lnet_proc_files "stats"
12962 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12963 remove_lnet_proc_files "stats"
12965 # lnet.routes should look like this:
12966 # Routing disabled/enabled
12967 # net hops priority state router
12968 # where net is a string like tcp0, hops > 0, priority >= 0,
12969 # state is up/down,
12970 # router is a string like 192.168.1.1@tcp2
12971 L1="^Routing (disabled|enabled)$"
12972 L2="^net +hops +priority +state +router$"
12973 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12974 create_lnet_proc_files "routes"
12975 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12976 remove_lnet_proc_files "routes"
12978 # lnet.routers should look like this:
12979 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12980 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12981 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12982 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12983 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12984 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12985 create_lnet_proc_files "routers"
12986 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12987 remove_lnet_proc_files "routers"
12989 # lnet.peers should look like this:
12990 # nid refs state last max rtr min tx min queue
12991 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12992 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12993 # numeric (0 or >0 or <0), queue >= 0.
12994 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12995 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12996 create_lnet_proc_files "peers"
12997 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12998 remove_lnet_proc_files "peers"
13000 # lnet.buffers should look like this:
13001 # pages count credits min
13002 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
13003 L1="^pages +count +credits +min$"
13004 BR="^ +$N +$N +$I +$I$"
13005 create_lnet_proc_files "buffers"
13006 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
13007 remove_lnet_proc_files "buffers"
13009 # lnet.nis should look like this:
13010 # nid status alive refs peer rtr max tx min
13011 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
13012 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
13013 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
13014 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
13015 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
13016 create_lnet_proc_files "nis"
13017 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
13018 remove_lnet_proc_files "nis"
13020 # can we successfully write to lnet.stats?
13021 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
13022 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
13024 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
13026 test_216() { # bug 20317
13027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13028 remote_ost_nodsh && skip "remote OST with nodsh" && return
13031 local facets=$(get_facets OST)
13032 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13034 save_lustre_params client "osc.*.contention_seconds" > $p
13035 save_lustre_params $facets \
13036 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13037 save_lustre_params $facets \
13038 "ldlm.namespaces.filter-*.contended_locks" >> $p
13039 save_lustre_params $facets \
13040 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13041 clear_stats osc.*.osc_stats
13043 # agressive lockless i/o settings
13044 do_nodes $(comma_list $(osts_nodes)) \
13045 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13046 ldlm.namespaces.filter-*.contended_locks=0 \
13047 ldlm.namespaces.filter-*.contention_seconds=60"
13048 lctl set_param -n osc.*.contention_seconds=60
13050 $DIRECTIO write $DIR/$tfile 0 10 4096
13051 $CHECKSTAT -s 40960 $DIR/$tfile
13053 # disable lockless i/o
13054 do_nodes $(comma_list $(osts_nodes)) \
13055 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13056 ldlm.namespaces.filter-*.contended_locks=32 \
13057 ldlm.namespaces.filter-*.contention_seconds=0"
13058 lctl set_param -n osc.*.contention_seconds=0
13059 clear_stats osc.*.osc_stats
13061 dd if=/dev/zero of=$DIR/$tfile count=0
13062 $CHECKSTAT -s 0 $DIR/$tfile
13064 restore_lustre_params <$p
13068 run_test 216 "check lockless direct write updates file size and kms correctly"
13070 test_217() { # bug 22430
13071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13075 for node in $(nodes_list); do
13076 nid=$(host_nids_address $node $NETTYPE)
13077 if [[ $nid = *-* ]] ; then
13078 echo "lctl ping $(h2nettype $nid)"
13079 lctl ping $(h2nettype $nid)
13081 echo "skipping $node (no hyphen detected)"
13085 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13088 # do directio so as not to populate the page cache
13089 log "creating a 10 Mb file"
13090 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13091 log "starting reads"
13092 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13093 log "truncating the file"
13094 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13096 kill %+ || true # reads might have finished
13097 echo "wait until dd is finished"
13099 log "removing the temporary file"
13100 rm -rf $DIR/$tfile || error "tmp file removal failed"
13102 run_test 218 "parallel read and truncate should not deadlock ======================="
13105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13106 # write one partial page
13107 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13108 # set no grant so vvp_io_commit_write will do sync write
13109 $LCTL set_param fail_loc=0x411
13110 # write a full page at the end of file
13111 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13113 $LCTL set_param fail_loc=0
13114 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13115 $LCTL set_param fail_loc=0x411
13116 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13119 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13120 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13122 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13124 test_220() { #LU-325
13125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13126 remote_ost_nodsh && skip "remote OST with nodsh" && return
13127 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13128 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13131 # create on MDT0000 so the last_id and next_id are correct
13133 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13137 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13138 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13139 osc.$mdtosc_proc1.prealloc_last_id)
13140 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13141 osc.$mdtosc_proc1.prealloc_next_id)
13145 if ! combined_mgs_mds ; then
13149 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13150 #define OBD_FAIL_OST_ENOINO 0x229
13151 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13152 create_pool $FSNAME.$TESTNAME || return 1
13153 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13155 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13157 MDSOBJS=$((last_id - next_id))
13158 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13160 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13161 echo "OST still has $count kbytes free"
13163 echo "create $MDSOBJS files @next_id..."
13164 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13166 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13167 osc.$mdtosc_proc1.prealloc_last_id)
13168 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13169 osc.$mdtosc_proc1.prealloc_next_id)
13171 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13176 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13177 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13179 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
13180 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
13181 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
13182 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
13183 echo "unlink $MDSOBJS files @$next_id..."
13184 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
13186 if ! combined_mgs_mds ; then
13190 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13194 dd if=`which date` of=$MOUNT/date oflag=sync
13195 chmod +x $MOUNT/date
13197 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13198 $LCTL set_param fail_loc=0x80001401
13200 $MOUNT/date > /dev/null
13203 run_test 221 "make sure fault and truncate race to not cause OOM"
13206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13208 test_mkdir -p $DIR/$tdir
13209 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13210 createmany -o $DIR/$tdir/$tfile 10
13211 cancel_lru_locks mdc
13212 cancel_lru_locks osc
13213 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13214 $LCTL set_param fail_loc=0x31a
13215 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13216 $LCTL set_param fail_loc=0
13219 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
13222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13224 test_mkdir -p $DIR/$tdir
13225 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13226 createmany -o $DIR/$tdir/$tfile 10
13227 cancel_lru_locks mdc
13228 cancel_lru_locks osc
13229 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13230 $LCTL set_param fail_loc=0x31a
13231 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13232 $LCTL set_param fail_loc=0
13234 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
13237 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13239 test_mkdir -p $DIR/$tdir
13240 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13241 createmany -o $DIR/$tdir/$tfile 10
13242 cancel_lru_locks mdc
13243 cancel_lru_locks osc
13244 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13245 $LCTL set_param fail_loc=0x31b
13246 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13247 $LCTL set_param fail_loc=0
13250 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13252 test_224a() { # LU-1039, MRP-303
13253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13254 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13255 $LCTL set_param fail_loc=0x508
13256 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13257 $LCTL set_param fail_loc=0
13260 run_test 224a "Don't panic on bulk IO failure"
13262 test_224b() { # LU-1039, MRP-303
13263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13264 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13265 cancel_lru_locks osc
13266 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13267 $LCTL set_param fail_loc=0x515
13268 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13269 $LCTL set_param fail_loc=0
13272 run_test 224b "Don't panic on bulk IO failure"
13274 test_224c() { # LU-6441
13275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13276 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13278 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13279 save_writethrough $p
13280 set_cache writethrough on
13282 local pages_per_rpc=$($LCTL get_param \
13283 osc.*.max_pages_per_rpc)
13284 local at_max=$($LCTL get_param -n at_max)
13285 local timeout=$($LCTL get_param -n timeout)
13286 local test_at="$LCTL get_param -n at_max"
13287 local param_at="$FSNAME.sys.at_max"
13288 local test_timeout="$LCTL get_param -n timeout"
13289 local param_timeout="$FSNAME.sys.timeout"
13291 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13293 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13294 error "conf_param at_max=0 failed"
13295 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13296 error "conf_param timeout=5 failed"
13298 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13299 do_facet ost1 $LCTL set_param fail_loc=0x520
13300 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13301 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13303 do_facet ost1 $LCTL set_param fail_loc=0
13305 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13306 error "conf_param at_max=$at_max failed"
13307 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13308 $timeout || error "conf_param timeout=$timeout failed"
13310 $LCTL set_param -n $pages_per_rpc
13311 restore_lustre_params < $p
13314 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13316 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13319 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13320 if [ -z ${MDSSURVEY} ]; then
13321 skip_env "mds-survey not found" && return
13324 [ $MDSCOUNT -ge 2 ] &&
13325 skip "skipping now for more than one MDT" && return
13327 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13328 { skip "Need MDS version at least 2.2.51"; return; }
13330 local mds=$(facet_host $SINGLEMDS)
13331 local target=$(do_nodes $mds 'lctl dl' | \
13332 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13334 local cmd1="file_count=1000 thrhi=4"
13335 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13336 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13337 local cmd="$cmd1 $cmd2 $cmd3"
13339 rm -f ${TMP}/mds_survey*
13341 eval $cmd || error "mds-survey with zero-stripe failed"
13342 cat ${TMP}/mds_survey*
13343 rm -f ${TMP}/mds_survey*
13345 run_test 225a "Metadata survey sanity with zero-stripe"
13348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13349 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13350 if [ -z ${MDSSURVEY} ]; then
13351 skip_env "mds-survey not found" && return
13353 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13354 { skip "Need MDS version at least 2.2.51"; return; }
13356 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13357 skip_env "Need to mount OST to test" && return
13360 local mds=$(facet_host $SINGLEMDS)
13361 local target=$(do_nodes $mds 'lctl dl' | \
13362 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13364 local cmd1="file_count=1000 thrhi=4"
13365 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13366 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13367 local cmd="$cmd1 $cmd2 $cmd3"
13369 rm -f ${TMP}/mds_survey*
13371 eval $cmd || error "mds-survey with stripe_count failed"
13372 cat ${TMP}/mds_survey*
13373 rm -f ${TMP}/mds_survey*
13375 run_test 225b "Metadata survey sanity with stripe_count = 1"
13377 mcreate_path2fid () {
13383 local path=$DIR/$tdir/$name
13388 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13389 error "cannot create $desc"
13391 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13393 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13395 fid_path=$($LFS fid2path $MOUNT $fid)
13397 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13399 [ "$path" == "$fid_path" ] ||
13400 error "fid2path returned $fid_path, expected $path"
13402 echo "pass with $path and $fid"
13407 mkdir -p $DIR/$tdir
13409 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13410 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13411 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13412 mcreate_path2fid 0040666 0 0 dir "directory"
13413 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13414 mcreate_path2fid 0100666 0 0 file "regular file"
13415 mcreate_path2fid 0120666 0 0 link "symbolic link"
13416 mcreate_path2fid 0140666 0 0 sock "socket"
13418 run_test 226a "call path2fid and fid2path on files of all type"
13421 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13425 mkdir -p $DIR/$tdir
13426 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13427 error "create remote directory failed"
13428 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13429 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13430 "character special file (null)"
13431 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13432 "character special file (no device)"
13433 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13434 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13435 "block special file (loop)"
13436 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13437 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13438 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13440 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13442 # LU-1299 Executing or running ldd on a truncated executable does not
13443 # cause an out-of-memory condition.
13445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13446 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13447 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13448 chmod +x $MOUNT/date
13450 $MOUNT/date > /dev/null
13451 ldd $MOUNT/date > /dev/null
13454 run_test 227 "running truncated executable does not cause OOM"
13456 # LU-1512 try to reuse idle OI blocks
13458 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13459 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13460 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13461 skip "ldiskfs only test" && return
13463 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13464 local myDIR=$DIR/$tdir
13467 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13468 $LCTL set_param fail_loc=0x80001002
13469 createmany -o $myDIR/t- 10000
13470 $LCTL set_param fail_loc=0
13471 # The guard is current the largest FID holder
13473 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13475 local IDX=$(($SEQ % 64))
13477 do_facet $SINGLEMDS sync
13478 # Make sure journal flushed.
13480 local blk1=$(do_facet $SINGLEMDS \
13481 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13482 grep Blockcount | awk '{print $4}')
13484 # Remove old files, some OI blocks will become idle.
13485 unlinkmany $myDIR/t- 10000
13486 # Create new files, idle OI blocks should be reused.
13487 createmany -o $myDIR/t- 2000
13488 do_facet $SINGLEMDS sync
13489 # Make sure journal flushed.
13491 local blk2=$(do_facet $SINGLEMDS \
13492 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13493 grep Blockcount | awk '{print $4}')
13495 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13497 run_test 228a "try to reuse idle OI blocks"
13500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13501 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13502 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13503 skip "ldiskfs only test" && return
13505 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13506 local myDIR=$DIR/$tdir
13509 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13510 $LCTL set_param fail_loc=0x80001002
13511 createmany -o $myDIR/t- 10000
13512 $LCTL set_param fail_loc=0
13513 # The guard is current the largest FID holder
13515 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13517 local IDX=$(($SEQ % 64))
13519 do_facet $SINGLEMDS sync
13520 # Make sure journal flushed.
13522 local blk1=$(do_facet $SINGLEMDS \
13523 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13524 grep Blockcount | awk '{print $4}')
13526 # Remove old files, some OI blocks will become idle.
13527 unlinkmany $myDIR/t- 10000
13530 stop $SINGLEMDS || error "Fail to stop MDT."
13532 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13534 df $MOUNT || error "Fail to df."
13535 # Create new files, idle OI blocks should be reused.
13536 createmany -o $myDIR/t- 2000
13537 do_facet $SINGLEMDS sync
13538 # Make sure journal flushed.
13540 local blk2=$(do_facet $SINGLEMDS \
13541 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13542 grep Blockcount | awk '{print $4}')
13544 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13546 run_test 228b "idle OI blocks can be reused after MDT restart"
13550 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13551 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13552 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13553 skip "ldiskfs only test" && return
13555 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13556 local myDIR=$DIR/$tdir
13559 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13560 $LCTL set_param fail_loc=0x80001002
13561 # 20000 files can guarantee there are index nodes in the OI file
13562 createmany -o $myDIR/t- 20000
13563 $LCTL set_param fail_loc=0
13564 # The guard is current the largest FID holder
13566 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13568 local IDX=$(($SEQ % 64))
13570 do_facet $SINGLEMDS sync
13571 # Make sure journal flushed.
13573 local blk1=$(do_facet $SINGLEMDS \
13574 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13575 grep Blockcount | awk '{print $4}')
13577 # Remove old files, some OI blocks will become idle.
13578 unlinkmany $myDIR/t- 20000
13580 # The OI file should become empty now
13582 # Create new files, idle OI blocks should be reused.
13583 createmany -o $myDIR/t- 2000
13584 do_facet $SINGLEMDS sync
13585 # Make sure journal flushed.
13587 local blk2=$(do_facet $SINGLEMDS \
13588 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13589 grep Blockcount | awk '{print $4}')
13591 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13593 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13595 test_229() { # LU-2482, LU-3448
13596 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13597 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13600 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13604 # Create a file with a released layout and stripe count 2.
13605 $MULTIOP $DIR/$tfile H2c ||
13606 error "failed to create file with released layout"
13608 $GETSTRIPE -v $DIR/$tfile
13610 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13611 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
13613 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13614 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13615 stat $DIR/$tfile || error "failed to stat released file"
13617 chown $RUNAS_ID $DIR/$tfile ||
13618 error "chown $RUNAS_ID $DIR/$tfile failed"
13620 chgrp $RUNAS_ID $DIR/$tfile ||
13621 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13623 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13624 rm $DIR/$tfile || error "failed to remove released file"
13626 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13630 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13633 test_mkdir $DIR/$tdir
13634 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13635 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13636 [ $mdt_idx -ne 0 ] &&
13637 error "create local directory on wrong MDT $mdt_idx"
13639 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13640 error "create remote directory failed"
13641 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13642 [ $mdt_idx -ne $MDTIDX ] &&
13643 error "create remote directory on wrong MDT $mdt_idx"
13645 createmany -o $DIR/$tdir/test_230/t- 10 ||
13646 error "create files on remote directory failed"
13647 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13648 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13649 rm -r $DIR/$tdir || error "unlink remote directory failed"
13651 run_test 230a "Create remote directory and files under the remote directory"
13654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13655 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13662 local migrate_dir=$DIR/$tdir/migrate_dir
13663 local other_dir=$DIR/$tdir/other_dir
13665 test_mkdir $DIR/$tdir
13666 test_mkdir -i0 -c1 $migrate_dir
13667 test_mkdir -i0 -c1 $other_dir
13668 for ((i=0; i<10; i++)); do
13669 mkdir -p $migrate_dir/dir_${i}
13670 createmany -o $migrate_dir/dir_${i}/f 10 ||
13671 error "create files under remote dir failed $i"
13674 cp /etc/passwd $migrate_dir/$tfile
13675 cp /etc/passwd $other_dir/$tfile
13676 chattr +SAD $migrate_dir
13677 chattr +SAD $migrate_dir/$tfile
13679 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13680 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13681 local old_dir_mode=$(stat -c%f $migrate_dir)
13682 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13684 mkdir -p $migrate_dir/dir_default_stripe2
13685 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13686 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13688 mkdir -p $other_dir
13689 ln $migrate_dir/$tfile $other_dir/luna
13690 ln $migrate_dir/$tfile $migrate_dir/sofia
13691 ln $other_dir/$tfile $migrate_dir/david
13692 ln -s $migrate_dir/$tfile $other_dir/zachary
13693 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13694 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13696 $LFS migrate -m $MDTIDX $migrate_dir ||
13697 error "fails on migrating remote dir to MDT1"
13699 echo "migratate to MDT1, then checking.."
13700 for ((i = 0; i < 10; i++)); do
13701 for file in $(find $migrate_dir/dir_${i}); do
13702 mdt_index=$($LFS getstripe -M $file)
13703 [ $mdt_index == $MDTIDX ] ||
13704 error "$file is not on MDT${MDTIDX}"
13708 # the multiple link file should still in MDT0
13709 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13710 [ $mdt_index == 0 ] ||
13711 error "$file is not on MDT${MDTIDX}"
13713 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13714 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13715 error " expect $old_dir_flag get $new_dir_flag"
13717 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13718 [ "$old_file_flag" = "$new_file_flag" ] ||
13719 error " expect $old_file_flag get $new_file_flag"
13721 local new_dir_mode=$(stat -c%f $migrate_dir)
13722 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13723 error "expect mode $old_dir_mode get $new_dir_mode"
13725 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13726 [ "$old_file_mode" = "$new_file_mode" ] ||
13727 error "expect mode $old_file_mode get $new_file_mode"
13729 diff /etc/passwd $migrate_dir/$tfile ||
13730 error "$tfile different after migration"
13732 diff /etc/passwd $other_dir/luna ||
13733 error "luna different after migration"
13735 diff /etc/passwd $migrate_dir/sofia ||
13736 error "sofia different after migration"
13738 diff /etc/passwd $migrate_dir/david ||
13739 error "david different after migration"
13741 diff /etc/passwd $other_dir/zachary ||
13742 error "zachary different after migration"
13744 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13745 error "${tfile}_ln different after migration"
13747 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13748 error "${tfile}_ln_other different after migration"
13750 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13751 [ $stripe_count = 2 ] ||
13752 error "dir strpe_count $d != 2 after migration."
13754 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13755 [ $stripe_count = 2 ] ||
13756 error "file strpe_count $d != 2 after migration."
13758 #migrate back to MDT0
13761 $LFS migrate -m $MDTIDX $migrate_dir ||
13762 error "fails on migrating remote dir to MDT0"
13764 echo "migrate back to MDT0, checking.."
13765 for file in $(find $migrate_dir); do
13766 mdt_index=$($LFS getstripe -M $file)
13767 [ $mdt_index == $MDTIDX ] ||
13768 error "$file is not on MDT${MDTIDX}"
13771 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13772 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13773 error " expect $old_dir_flag get $new_dir_flag"
13775 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13776 [ "$old_file_flag" = "$new_file_flag" ] ||
13777 error " expect $old_file_flag get $new_file_flag"
13779 local new_dir_mode=$(stat -c%f $migrate_dir)
13780 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13781 error "expect mode $old_dir_mode get $new_dir_mode"
13783 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13784 [ "$old_file_mode" = "$new_file_mode" ] ||
13785 error "expect mode $old_file_mode get $new_file_mode"
13787 diff /etc/passwd ${migrate_dir}/$tfile ||
13788 error "$tfile different after migration"
13790 diff /etc/passwd ${other_dir}/luna ||
13791 error "luna different after migration"
13793 diff /etc/passwd ${migrate_dir}/sofia ||
13794 error "sofia different after migration"
13796 diff /etc/passwd ${other_dir}/zachary ||
13797 error "zachary different after migration"
13799 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13800 error "${tfile}_ln different after migration"
13802 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13803 error "${tfile}_ln_other different after migration"
13805 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13806 [ $stripe_count = 2 ] ||
13807 error "dir strpe_count $d != 2 after migration."
13809 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13810 [ $stripe_count = 2 ] ||
13811 error "file strpe_count $d != 2 after migration."
13813 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13815 run_test 230b "migrate directory"
13818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13819 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13820 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13824 local migrate_dir=$DIR/$tdir/migrate_dir
13826 #If migrating directory fails in the middle, all entries of
13827 #the directory is still accessiable.
13828 test_mkdir $DIR/$tdir
13829 test_mkdir -i0 -c1 $migrate_dir
13831 createmany -o $migrate_dir/f 10 ||
13832 error "create files under ${migrate_dir} failed"
13834 #failed after migrating 5 entries
13835 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13836 do_facet mds1 lctl set_param fail_loc=0x20001801
13837 do_facet mds1 lctl set_param fail_val=5
13838 local t=$(ls $migrate_dir | wc -l)
13839 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13840 error "migrate should fail after 5 entries"
13842 mkdir $migrate_dir/dir &&
13843 error "mkdir succeeds under migrating directory"
13844 touch $migrate_dir/file &&
13845 error "touch file succeeds under migrating directory"
13847 local u=$(ls $migrate_dir | wc -l)
13848 [ "$u" == "$t" ] || error "$u != $t during migration"
13850 for file in $(find $migrate_dir); do
13851 stat $file || error "stat $file failed"
13854 do_facet mds1 lctl set_param fail_loc=0
13855 do_facet mds1 lctl set_param fail_val=0
13857 $LFS migrate -m $MDTIDX $migrate_dir ||
13858 error "migrate open files should failed with open files"
13860 echo "Finish migration, then checking.."
13861 for file in $(find $migrate_dir); do
13862 mdt_index=$($LFS getstripe -M $file)
13863 [ $mdt_index == $MDTIDX ] ||
13864 error "$file is not on MDT${MDTIDX}"
13867 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13869 run_test 230c "check directory accessiblity if migration is failed"
13872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13873 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13876 local migrate_dir=$DIR/$tdir/migrate_dir
13880 test_mkdir $DIR/$tdir
13881 test_mkdir -i0 -c1 $migrate_dir
13883 for ((i=0; i<100; i++)); do
13884 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13885 createmany -o $migrate_dir/dir_${i}/f 100 ||
13886 error "create files under remote dir failed $i"
13889 $LFS migrate -m $MDTIDX $migrate_dir ||
13890 error "migrate remote dir error"
13892 echo "Finish migration, then checking.."
13893 for file in $(find $migrate_dir); do
13894 mdt_index=$($LFS getstripe -M $file)
13895 [ $mdt_index == $MDTIDX ] ||
13896 error "$file is not on MDT${MDTIDX}"
13899 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13901 run_test 230d "check migrate big directory"
13904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13905 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13911 mkdir -p $DIR/$tdir
13912 mkdir $DIR/$tdir/migrate_dir
13913 mkdir $DIR/$tdir/other_dir
13914 touch $DIR/$tdir/migrate_dir/a
13915 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13916 ls $DIR/$tdir/other_dir
13918 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13919 error "migrate dir fails"
13921 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13922 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13924 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13925 [ $mdt_index == 0 ] || error "a is not on MDT0"
13927 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13928 error "migrate dir fails"
13930 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13931 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13933 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13934 [ $mdt_index == 1 ] || error "a is not on MDT1"
13936 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13937 [ $mdt_index == 1 ] || error "b is not on MDT1"
13939 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13940 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13942 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13944 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13946 run_test 230e "migrate mulitple local link files"
13949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13950 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13954 mkdir -p $DIR/$tdir
13955 mkdir $DIR/$tdir/migrate_dir
13956 $LFS mkdir -i1 $DIR/$tdir/other_dir
13957 touch $DIR/$tdir/migrate_dir/a
13958 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13959 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13960 ls $DIR/$tdir/other_dir
13962 # a should be migrated to MDT1, since no other links on MDT0
13963 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13964 error "#1 migrate dir fails"
13965 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13966 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13967 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13968 [ $mdt_index == 1 ] || error "a is not on MDT1"
13970 # a should stay on MDT1, because it is a mulitple link file
13971 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13972 error "#2 migrate dir fails"
13973 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13974 [ $mdt_index == 1 ] || error "a is not on MDT1"
13976 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13977 error "#3 migrate dir fails"
13979 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13980 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13981 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13983 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13984 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13986 # a should be migrated to MDT0, since no other links on MDT1
13987 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13988 error "#4 migrate dir fails"
13989 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13990 [ $mdt_index == 0 ] || error "a is not on MDT0"
13992 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13994 run_test 230f "migrate mulitple remote link files"
13997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13998 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14000 mkdir -p $DIR/$tdir/migrate_dir
14002 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
14003 error "migrating dir to non-exist MDT succeeds"
14006 run_test 230g "migrate dir to non-exist MDT"
14009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14010 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14011 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
14012 skip "Need MDS version at least 2.7.64" && return
14015 mkdir -p $DIR/$tdir/migrate_dir
14017 $LFS migrate -m1 $DIR &&
14018 error "migrating mountpoint1 should fail"
14020 $LFS migrate -m1 $DIR/$tdir/.. &&
14021 error "migrating mountpoint2 should fail"
14023 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
14024 error "migrating $tdir fail"
14026 mdt_index=$($LFS getstripe -M $DIR/$tdir)
14027 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14029 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14030 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14033 run_test 230h "migrate .. and root"
14036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14037 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14039 mkdir -p $DIR/$tdir/migrate_dir
14041 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
14042 error "migration fails with a tailing slash"
14044 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14045 error "migration fails with two tailing slashes"
14047 run_test 230i "lfs migrate -m tolerates trailing slashes"
14051 # For simplicity this test assumes that max_pages_per_rpc
14052 # is the same across all OSCs
14053 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14054 local bulk_size=$((max_pages * 4096))
14055 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14058 mkdir -p $DIR/$tdir
14059 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14060 error "failed to set stripe with -S ${brw_size}M option"
14062 # clear the OSC stats
14063 $LCTL set_param osc.*.stats=0 &>/dev/null
14066 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14067 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14068 oflag=direct &>/dev/null || error "dd failed"
14070 sync; sleep 1; sync # just to be safe
14071 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14072 if [ x$nrpcs != "x1" ]; then
14073 $LCTL get_param osc.*.stats
14074 error "found $nrpcs ost_write RPCs, not 1 as expected"
14078 # Drop the OSC cache, otherwise we will read from it
14079 cancel_lru_locks osc
14081 # clear the OSC stats
14082 $LCTL set_param osc.*.stats=0 &>/dev/null
14084 # Client reads $bulk_size.
14085 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14086 iflag=direct &>/dev/null || error "dd failed"
14088 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14089 if [ x$nrpcs != "x1" ]; then
14090 $LCTL get_param osc.*.stats
14091 error "found $nrpcs ost_read RPCs, not 1 as expected"
14094 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14097 mkdir -p $DIR/$tdir
14099 for i in {0..1023}; do
14100 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14101 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14102 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14106 run_test 231b "must not assert on fully utilized OST request buffer"
14109 mkdir -p $DIR/$tdir
14110 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14111 $LCTL set_param fail_loc=0x31c
14113 # ignore dd failure
14114 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
14116 $LCTL set_param fail_loc=0
14117 umount_client $MOUNT || error "umount failed"
14118 mount_client $MOUNT || error "mount failed"
14120 run_test 232 "failed lock should not block umount"
14123 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14124 { skip "Need MDS version at least 2.3.64"; return; }
14125 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14127 local fid=$($LFS path2fid $MOUNT)
14128 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14129 error "cannot access $MOUNT using its FID '$fid'"
14131 run_test 233a "checking that OBF of the FS root succeeds"
14134 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14135 { skip "Need MDS version at least 2.5.90"; return; }
14136 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14138 local fid=$($LFS path2fid $MOUNT/.lustre)
14139 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14140 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14142 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14143 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14144 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14146 run_test 233b "checking that OBF of the FS .lustre succeeds"
14149 local p="$TMP/sanityN-$TESTNAME.parameters"
14150 save_lustre_params client "llite.*.xattr_cache" > $p
14151 lctl set_param llite.*.xattr_cache 1 ||
14152 { skip "xattr cache is not supported"; return 0; }
14154 mkdir -p $DIR/$tdir || error "mkdir failed"
14155 touch $DIR/$tdir/$tfile || error "touch failed"
14156 # OBD_FAIL_LLITE_XATTR_ENOMEM
14157 $LCTL set_param fail_loc=0x1405
14158 # output of the form: attr 2 4 44 3 fc13 x86_64
14159 V=($(IFS=".-" rpm -q attr))
14160 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
14161 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
14162 # attr pre-2.4.44-7 had a bug with rc
14163 # LU-3703 - SLES 11 and FC13 clients have older attr
14164 getfattr -n user.attr $DIR/$tdir/$tfile &&
14165 error "getfattr should have failed with ENOMEM"
14167 skip "LU-3703: attr version $(getfattr --version) too old"
14169 $LCTL set_param fail_loc=0x0
14172 restore_lustre_params < $p
14175 run_test 234 "xattr cache should not crash on ENOMEM"
14178 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14179 skip "Need MDS version at least 2.4.52" && return
14180 flock_deadlock $DIR/$tfile
14185 124) error "process hangs on a deadlock"
14187 *) error "error executing flock_deadlock $DIR/$tfile"
14191 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14195 check_swap_layouts_support && return 0
14196 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
14198 local ref1=/etc/passwd
14199 local ref2=/etc/group
14200 local file1=$DIR/$tdir/f1
14201 local file2=$DIR/$tdir/f2
14203 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14204 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14205 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14206 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14207 local fd=$(free_fd)
14208 local cmd="exec $fd<>$file2"
14211 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14212 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14215 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14220 run_test 236 "Layout swap on open unlinked file"
14222 # test to verify file handle related system calls
14223 # (name_to_handle_at/open_by_handle_at)
14224 # The new system calls are supported in glibc >= 2.14.
14227 echo "Test file_handle syscalls" > $DIR/$tfile ||
14228 error "write failed"
14229 check_fhandle_syscalls $DIR/$tfile ||
14230 error "check_fhandle_syscalls failed"
14232 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14234 # LU-4659 linkea consistency
14236 local server_version=$(lustre_version_code $SINGLEMDS)
14238 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14239 [[ $server_version -gt $(version_code 2.5.1) &&
14240 $server_version -lt $(version_code 2.5.50) ]] ||
14241 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14244 ln $DIR/$tfile $DIR/$tfile.lnk
14245 touch $DIR/$tfile.new
14246 mv $DIR/$tfile.new $DIR/$tfile
14247 local fid1=$($LFS path2fid $DIR/$tfile)
14248 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14249 local path1=$($LFS fid2path $FSNAME "$fid1")
14250 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14251 local path2=$($LFS fid2path $FSNAME "$fid2")
14252 [ $tfile.lnk == $path2 ] ||
14253 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14256 run_test 238 "Verify linkea consistency"
14259 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14260 skip "Need MDS version at least 2.5.60" && return
14261 local list=$(comma_list $(mdts_nodes))
14263 mkdir -p $DIR/$tdir
14264 createmany -o $DIR/$tdir/f- 5000
14265 unlinkmany $DIR/$tdir/f- 5000
14266 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.1) ] &&
14267 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14268 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14269 osp.*MDT*.sync_in_flight" | calc_sum)
14270 [ "$changes" -eq 0 ] || error "$changes not synced"
14272 run_test 239 "osp_sync test"
14274 test_239a() { #LU-5297
14275 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14277 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14278 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14279 chgrp $RUNAS_GID $DIR/$tfile
14280 wait_delete_completed
14282 run_test 239a "process invalid osp sync record correctly"
14284 test_239b() { #LU-5297
14285 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14287 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14288 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14289 chgrp $RUNAS_GID $DIR/$tfile1
14290 wait_delete_completed
14291 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14293 chgrp $RUNAS_GID $DIR/$tfile2
14294 wait_delete_completed
14296 run_test 239b "process osp sync record with ENOMEM error correctly"
14299 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14300 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14302 mkdir -p $DIR/$tdir
14304 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14305 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14306 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14307 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14309 umount_client $MOUNT || error "umount failed"
14310 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14311 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14312 mount_client $MOUNT || error "failed to mount client"
14314 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14315 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14317 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14320 for LOOP in $(seq $1); do
14321 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14322 cancel_lru_locks osc || true
14327 for LOOP in $(seq $1); do
14328 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14329 iflag=direct 2>/dev/null
14333 test_241a() { # was test_241
14334 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14336 cancel_lru_locks osc
14337 test_241_bio 1000 &
14342 run_test 241a "bio vs dio"
14345 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14347 test_241_dio 1000 &
14352 run_test 241b "dio vs dio"
14355 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14356 mkdir -p $DIR/$tdir
14357 touch $DIR/$tdir/$tfile
14359 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14360 do_facet mds1 lctl set_param fail_loc=0x105
14361 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14363 do_facet mds1 lctl set_param fail_loc=0
14364 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14366 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14370 test_mkdir -p $DIR/$tdir
14371 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14373 run_test 243 "various group lock tests"
14377 test_mkdir -p $DIR/$tdir
14378 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14379 sendfile_grouplock $DIR/$tdir/$tfile || \
14380 error "sendfile+grouplock failed"
14383 run_test 244 "sendfile with group lock tests"
14386 local flagname="multi_mod_rpcs"
14387 local connect_data_name="max_mod_rpcs"
14390 # check if multiple modify RPCs flag is set
14391 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14392 grep "connect_flags:")
14395 echo "$out" | grep -qw $flagname
14396 if [ $? -ne 0 ]; then
14397 echo "connect flag $flagname is not set"
14401 # check if multiple modify RPCs data is set
14402 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14405 echo "$out" | grep -qw $connect_data_name ||
14406 error "import should have connect data $connect_data_name"
14408 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14410 test_246() { # LU-7371
14411 remote_ost_nodsh && skip "remote OST with nodsh" && return
14412 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14413 skip "Need OST version >= 2.7.62" && return 0
14414 do_facet ost1 $LCTL set_param fail_val=4095
14415 #define OBD_FAIL_OST_READ_SIZE 0x234
14416 do_facet ost1 $LCTL set_param fail_loc=0x234
14417 $LFS setstripe $DIR/$tfile -i 0 -c 1
14418 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14419 cancel_lru_locks $FSNAME-OST0000
14420 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14422 run_test 246 "Read file of size 4095 should return right length"
14425 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14427 { skip "Fileset feature is not supported"; return; }
14429 local submount=${MOUNT}_$tdir
14432 mkdir -p $submount || error "mkdir $submount failed"
14433 FILESET="$FILESET/$tdir" mount_client $submount ||
14434 error "mount $submount failed"
14435 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14436 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14437 error "read $MOUNT/$tdir/$tfile failed"
14438 umount_client $submount || error "umount $submount failed"
14441 run_test 247a "mount subdir as fileset"
14444 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14445 { skip "Fileset feature is not supported"; return; }
14447 local submount=${MOUNT}_$tdir
14449 rm -rf $MOUNT/$tdir
14450 mkdir -p $submount || error "mkdir $submount failed"
14452 FILESET="$FILESET/$tdir" mount_client $submount &&
14453 error "mount $submount should fail"
14456 run_test 247b "mount subdir that dose not exist"
14459 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14460 { skip "Fileset feature is not supported"; return; }
14462 local submount=${MOUNT}_$tdir
14464 mkdir -p $MOUNT/$tdir/dir1
14465 mkdir -p $submount || error "mkdir $submount failed"
14466 FILESET="$FILESET/$tdir" mount_client $submount ||
14467 error "mount $submount failed"
14468 local fid=$($LFS path2fid $MOUNT/)
14469 $LFS fid2path $submount $fid && error "fid2path should fail"
14470 umount_client $submount || error "umount $submount failed"
14473 run_test 247c "running fid2path outside root"
14476 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14477 { skip "Fileset feature is not supported"; return; }
14479 local submount=${MOUNT}_$tdir
14481 mkdir -p $MOUNT/$tdir/dir1
14482 mkdir -p $submount || error "mkdir $submount failed"
14483 FILESET="$FILESET/$tdir" mount_client $submount ||
14484 error "mount $submount failed"
14485 local fid=$($LFS path2fid $submount/dir1)
14486 $LFS fid2path $submount $fid || error "fid2path should succeed"
14487 umount_client $submount || error "umount $submount failed"
14490 run_test 247d "running fid2path inside root"
14494 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14496 { skip "Fileset feature is not supported"; return; }
14498 local submount=${MOUNT}_$tdir
14501 mkdir -p $submount || error "mkdir $submount failed"
14502 FILESET="$FILESET/.." mount_client $submount &&
14503 error "mount $submount should fail"
14506 run_test 247e "mount .. as fileset"
14509 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14510 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14512 # create a large file for fast read verification
14513 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14515 # make sure the file is created correctly
14516 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14517 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14519 echo "Test 1: verify that fast read is 4 times faster on cache read"
14521 # small read with fast read enabled
14522 $LCTL set_param -n llite.*.fast_read=1
14523 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14524 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14525 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14526 # small read with fast read disabled
14527 $LCTL set_param -n llite.*.fast_read=0
14528 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14529 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14530 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14532 # verify that fast read is 4 times faster for cache read
14533 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14534 error_not_in_vm "fast read was not 4 times faster: " \
14535 "$t_fast vs $t_slow"
14537 echo "Test 2: verify the performance between big and small read"
14538 $LCTL set_param -n llite.*.fast_read=1
14540 # 1k non-cache read
14541 cancel_lru_locks osc
14542 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14543 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14544 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14546 # 1M non-cache read
14547 cancel_lru_locks osc
14548 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14549 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14550 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14552 # verify that big IO is not 4 times faster than small IO
14553 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14554 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14556 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14559 run_test 248 "fast read verification"
14561 test_249() { # LU-7890
14563 $SETSTRIPE -c 1 $DIR/$tfile
14565 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14566 skip "Need at least version 2.8.54"
14568 # Offset 2T == 4k * 512M
14569 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14570 error "dd to 2T offset failed"
14572 run_test 249 "Write above 2T file size"
14575 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14576 && skip "no 16TB file size limit on ZFS" && return
14578 $SETSTRIPE -c 1 $DIR/$tfile
14579 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14580 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14581 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14582 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14583 conv=notrunc,fsync && error "append succeeded"
14586 run_test 250 "Write above 16T limit"
14589 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14591 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14592 #Skip once - writing the first stripe will succeed
14593 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14594 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14595 error "short write happened"
14597 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14598 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14599 error "short read happened"
14603 run_test 251 "Handling short read and write correctly"
14613 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14614 remote_ost_nodsh && skip "remote OST with nodsh" && return
14615 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14616 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14617 skip "ldiskfs only test"
14621 # check lr_reader on OST0000
14623 dev=$(facet_device $tgt)
14624 out=$(do_facet $tgt $LR_READER $dev)
14625 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14627 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14628 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14629 error "Invalid uuid returned by $LR_READER on target $tgt"
14630 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14632 # check lr_reader -c on MDT0000
14634 dev=$(facet_device $tgt)
14635 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14636 echo "$LR_READER does not support additional options"
14639 out=$(do_facet $tgt $LR_READER -c $dev)
14640 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14642 num=$(echo "$out" | grep -c "mdtlov")
14643 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14644 error "Invalid number of mdtlov clients returned by $LR_READER"
14645 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14647 # check lr_reader -cr on MDT0000
14648 out=$(do_facet $tgt $LR_READER -cr $dev)
14649 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14651 echo "$out" | grep -q "^reply_data:$" ||
14652 error "$LR_READER should have returned 'reply_data' section"
14653 num=$(echo "$out" | grep -c "client_generation")
14654 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14656 run_test 252 "check lr_reader tool"
14658 test_253_fill_ost() {
14659 local size_mb #how many MB should we write to pass watermark
14660 local lwm=$3 #low watermark
14661 local free_10mb #10% of free space
14663 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14664 size_mb=$((free_kb / 1024 - lwm))
14665 free_10mb=$((free_kb / 10240))
14666 #If 10% of free space cross low watermark use it
14667 if (( free_10mb > size_mb )); then
14670 #At least we need to store 1.1 of difference between
14671 #free space and low watermark
14672 size_mb=$((size_mb + size_mb / 10))
14674 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14675 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14676 oflag=append conv=notrunc
14681 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14682 echo "OST still has $((free_kb / 1024)) mbytes free"
14689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14690 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14691 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14693 local ost_name=$($LFS osts |
14694 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14696 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14697 do_facet $SINGLEMDS $LCTL get_param -n \
14698 osp.$mdtosc_proc1.reserved_mb_high ||
14699 { skip "remote MDS does not support reserved_mb_high" &&
14704 wait_delete_completed
14707 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14708 osp.$mdtosc_proc1.reserved_mb_high)
14709 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14710 osp.$mdtosc_proc1.reserved_mb_low)
14711 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14713 if ! combined_mgs_mds ; then
14716 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14717 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14718 error "Adding $ost_name to pool failed"
14720 # Wait for client to see a OST at pool
14721 wait_update $HOSTNAME "$LCTL get_param -n
14722 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14723 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14724 error "Client can not see the pool"
14725 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14726 error "Setstripe failed"
14728 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14729 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14730 echo "OST still has $((blocks/1024)) mbytes free"
14732 local new_lwm=$((blocks/1024-10))
14733 do_facet $SINGLEMDS $LCTL set_param \
14734 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14735 do_facet $SINGLEMDS $LCTL set_param \
14736 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14738 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14740 #First enospc could execute orphan deletion so repeat.
14741 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14743 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14744 osp.$mdtosc_proc1.prealloc_status)
14745 echo "prealloc_status $oa_status"
14747 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14748 error "File creation should fail"
14749 #object allocation was stopped, but we still able to append files
14750 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14751 error "Append failed"
14752 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14754 wait_delete_completed
14758 for i in $(seq 10 12); do
14759 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14760 error "File creation failed after rm";
14763 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14764 osp.$mdtosc_proc1.prealloc_status)
14765 echo "prealloc_status $oa_status"
14767 if (( oa_status != 0 )); then
14768 error "Object allocation still disable after rm"
14770 do_facet $SINGLEMDS $LCTL set_param \
14771 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14772 do_facet $SINGLEMDS $LCTL set_param \
14773 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14776 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14777 error "Remove $ost_name from pool failed"
14778 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14779 error "Pool destroy fialed"
14781 if ! combined_mgs_mds ; then
14785 run_test 253 "Check object allocation limit"
14790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14791 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14792 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14793 { skip "MDS does not support changelog_size" && return; }
14795 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14796 echo "Registered as changelog user $cl_user"
14798 $LFS changelog_clear $MDT0 $cl_user 0
14800 local size1=$(do_facet mds1 \
14801 $LCTL get_param -n mdd.$MDT0.changelog_size)
14802 echo "Changelog size $size1"
14805 $LFS mkdir -i 0 $DIR/$tdir
14807 mkdir -p $DIR/$tdir/pics/2008/zachy
14808 touch $DIR/$tdir/pics/2008/zachy/timestamp
14809 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
14810 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14811 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14812 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14813 rm $DIR/$tdir/pics/desktop.jpg
14815 local size2=$(do_facet mds1 \
14816 $LCTL get_param -n mdd.$MDT0.changelog_size)
14817 echo "Changelog size after work $size2"
14819 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14821 if (( size2 <= size1 )); then
14822 error "Changelog size after work should be greater than original"
14826 run_test 254 "Check changelog size"
14833 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
14834 awk -F: '{print $2}' | grep $type > /dev/null
14835 if [ $? -ne 0 ]; then
14845 lfs ladvise -a willread $file > /dev/null 2>&1
14846 if [ $? -eq 0 ]; then
14850 lfs ladvise -a willread $file 2>&1 |
14851 grep "Inappropriate ioctl for device" > /dev/null
14852 if [ $? -eq 0 ]; then
14859 bc <<<"scale=2; ($1 - $2) * 100 / $2"
14862 # run a random read IO workload
14863 # usage: random_read_iops <filename> <filesize> <iosize>
14864 random_read_iops() {
14867 local iosize=${3:-4096}
14869 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
14870 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
14873 drop_file_oss_cache() {
14877 $LFS ladvise -a dontneed $file 2>/dev/null ||
14878 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
14881 ladvise_willread_performance()
14884 local average_origin=0
14885 local average_cache=0
14886 local average_ladvise=0
14888 for ((i = 1; i <= $repeat; i++)); do
14889 echo "Iter $i/$repeat: reading without willread hint"
14890 cancel_lru_locks osc
14891 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14892 local speed_origin=$(random_read_iops $DIR/$tfile $size)
14893 echo "Iter $i/$repeat: uncached speed: $speed_origin"
14894 average_origin=$(bc <<<"$average_origin + $speed_origin")
14896 cancel_lru_locks osc
14897 local speed_cache=$(random_read_iops $DIR/$tfile $size)
14898 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
14899 average_cache=$(bc <<<"$average_cache + $speed_cache")
14901 cancel_lru_locks osc
14902 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14903 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
14904 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
14905 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
14906 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
14908 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
14909 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
14910 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
14912 speedup_cache=$(percent $average_cache $average_origin)
14913 speedup_ladvise=$(percent $average_ladvise $average_origin)
14915 echo "Average uncached read: $average_origin"
14916 echo "Average speedup with OSS cached read: " \
14917 "$average_cache = +$speedup_cache%"
14918 echo "Average speedup with ladvise willread: " \
14919 "$average_ladvise = +$speedup_ladvise%"
14921 local lowest_speedup=20
14922 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
14923 echo "Speedup with OSS cached read less than $lowest_speedup%, " \
14924 "got $average_cache%. Skipping ladvise willread check."
14928 # the test won't work on ZFS until it supports 'ladvise dontneed', but
14929 # it is still good to run until then to exercise 'ladvise willread'
14930 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14931 [ "$(facet_fstype ost1)" = "zfs" ] &&
14932 echo "osd-zfs does not support dontneed or drop_caches" &&
14935 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
14936 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
14937 error_not_in_vm "Speedup with willread is less than " \
14938 "$lowest_speedup%, got $average_ladvise%"
14942 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14943 skip "lustre < 2.8.54 does not support ladvise " && return
14944 remote_ost_nodsh && skip "remote OST with nodsh" && return
14946 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
14948 ladvise_no_type willread $DIR/$tfile &&
14949 skip "willread ladvise is not supported" && return
14951 ladvise_no_ioctl $DIR/$tfile &&
14952 skip "ladvise ioctl is not supported" && return
14955 local size=$((size_mb * 1048576))
14956 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14957 error "dd to $DIR/$tfile failed"
14959 lfs ladvise -a willread $DIR/$tfile ||
14960 error "Ladvise failed with no range argument"
14962 lfs ladvise -a willread -s 0 $DIR/$tfile ||
14963 error "Ladvise failed with no -l or -e argument"
14965 lfs ladvise -a willread -e 1 $DIR/$tfile ||
14966 error "Ladvise failed with only -e argument"
14968 lfs ladvise -a willread -l 1 $DIR/$tfile ||
14969 error "Ladvise failed with only -l argument"
14971 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
14972 error "End offset should not be smaller than start offset"
14974 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
14975 error "End offset should not be equal to start offset"
14977 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
14978 error "Ladvise failed with overflowing -s argument"
14980 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
14981 error "Ladvise failed with overflowing -e argument"
14983 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
14984 error "Ladvise failed with overflowing -l argument"
14986 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
14987 error "Ladvise succeeded with conflicting -l and -e arguments"
14989 echo "Synchronous ladvise should wait"
14991 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
14992 do_nodes $(comma_list $(osts_nodes)) \
14993 $LCTL set_param fail_val=$delay fail_loc=0x237
14995 local start_ts=$SECONDS
14996 lfs ladvise -a willread $DIR/$tfile ||
14997 error "Ladvise failed with no range argument"
14998 local end_ts=$SECONDS
14999 local inteval_ts=$((end_ts - start_ts))
15001 if [ $inteval_ts -lt $(($delay - 1)) ]; then
15002 error "Synchronous advice didn't wait reply"
15005 echo "Asynchronous ladvise shouldn't wait"
15006 local start_ts=$SECONDS
15007 lfs ladvise -a willread -b $DIR/$tfile ||
15008 error "Ladvise failed with no range argument"
15009 local end_ts=$SECONDS
15010 local inteval_ts=$((end_ts - start_ts))
15012 if [ $inteval_ts -gt $(($delay / 2)) ]; then
15013 error "Asynchronous advice blocked"
15016 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
15017 ladvise_willread_performance
15019 run_test 255a "check 'lfs ladvise -a willread'"
15025 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
15029 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15030 skip "lustre < 2.8.54 does not support ladvise " && return
15031 remote_ost_nodsh && skip "remote OST with nodsh" && return
15033 lfs setstripe -c 1 -i 0 $DIR/$tfile
15035 ladvise_no_type dontneed $DIR/$tfile &&
15036 skip "dontneed ladvise is not supported" && return
15038 ladvise_no_ioctl $DIR/$tfile &&
15039 skip "ladvise ioctl is not supported" && return
15041 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15042 skip "lustre < 2.8.54 does not support ladvise" && return
15044 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15045 [ "$(facet_fstype ost1)" = "zfs" ] &&
15046 skip "zfs-osd does not support 'ladvise dontneed'" && return
15049 local size=$((size_mb * 1048576))
15050 # In order to prevent disturbance of other processes, only check 3/4
15051 # of the memory usage
15052 local kibibytes=$((size_mb * 1024 * 3 / 4))
15054 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15055 error "dd to $DIR/$tfile failed"
15057 local total=$(facet_meminfo ost1 MemTotal)
15058 echo "Total memory: $total KiB"
15060 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15061 local before_read=$(facet_meminfo ost1 Cached)
15062 echo "Cache used before read: $before_read KiB"
15064 lfs ladvise -a willread $DIR/$tfile ||
15065 error "Ladvise willread failed"
15066 local after_read=$(facet_meminfo ost1 Cached)
15067 echo "Cache used after read: $after_read KiB"
15069 lfs ladvise -a dontneed $DIR/$tfile ||
15070 error "Ladvise dontneed again failed"
15071 local no_read=$(facet_meminfo ost1 Cached)
15072 echo "Cache used after dontneed ladvise: $no_read KiB"
15074 if [ $total -lt $((before_read + kibibytes)) ]; then
15075 echo "Memory is too small, abort checking"
15079 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15080 error "Ladvise willread should use more memory" \
15081 "than $kibibytes KiB"
15084 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15085 error "Ladvise dontneed should release more memory" \
15086 "than $kibibytes KiB"
15089 run_test 255b "check 'lfs ladvise -a dontneed'"
15096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15097 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15098 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
15099 skip "ldiskfs only test" && return
15101 mdt_dev=$(mdsdevname 1)
15103 cl_user=$(do_facet mds1 \
15104 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
15105 if [[ -n $cl_user ]]; then
15106 skip "active changelog user"
15110 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15111 echo "Registered as changelog user $cl_user"
15114 mkdir -p $DIR/$tdir
15116 $LFS changelog_clear $MDT0 $cl_user 0
15119 touch $DIR/$tdir/{1..10}
15122 stop mds1 || error "Fail to stop MDT."
15125 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
15127 #after mount new plainllog is used
15128 touch $DIR/$tdir/{11..19}
15129 local TEMP256FILE=$(mktemp TEMP256XXXXXX)
15130 cat_sl=$(do_facet mds1 \
15131 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15132 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15135 if (( cat_sl != 2 )); then
15136 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15137 error "Changelog catalog has wrong number of slots $cat_sl"
15140 $LFS changelog_clear $MDT0 $cl_user 0
15142 TEMP256FILE=$(mktemp TEMP256XXXXXX)
15143 cat_sl=$(do_facet mds1 \
15144 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15145 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15148 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15150 if (( cat_sl == 2 )); then
15151 error "Empty plain llog was not deleted from changelog catalog"
15153 if (( cat_sl != 1 )); then
15154 error "Active plain llog shouldn\`t be deleted from catalog"
15157 run_test 256 "Check llog delete for empty and not full state"
15160 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15161 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15162 skip "Need MDS version at least 2.8.55" && return
15164 test_mkdir -p $DIR/$tdir
15166 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15167 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15170 #define OBD_FAIL_MDS_XATTR_REP 0x161
15171 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15172 local facet=mds$((mdtidx + 1))
15173 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15174 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15176 stop $facet || error "stop MDS failed"
15177 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15178 error "start MDS fail"
15180 run_test 257 "xattr locks are not lost"
15182 # Verify we take the i_mutex when security requires it
15184 #define OBD_FAIL_IMUTEX_SEC 0x141c
15185 $LCTL set_param fail_loc=0x141c
15187 chmod u+s $DIR/$tfile
15188 chmod a+rwx $DIR/$tfile
15189 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15191 if [ $RC -ne 0 ]; then
15192 error "error, failed to take i_mutex, rc=$?"
15198 # Verify we do NOT take the i_mutex in the normal case
15200 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15201 $LCTL set_param fail_loc=0x141d
15204 chmod a+rw $DIR/$tfile
15205 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15207 if [ $RC -ne 0 ]; then
15208 error "error, took i_mutex unnecessarily, rc=$?"
15213 run_test 258b "verify i_mutex security behavior"
15216 #define OBD_FAIL_MDC_CLOSE 0x806
15217 $LCTL set_param fail_loc=0x80000806
15221 run_test 260 "Check mdc_close fail"
15224 remote_ost_nodsh && skip "remote OST with nodsh" && return
15225 [ $(lustre_version_code ost1) -lt $(version_code 2.10.1) ] &&
15226 skip "Need OST version >= 2.10.1" && return 0
15228 local file=$DIR/$tfile
15231 oss=$(comma_list $(osts_nodes))
15233 dd if=/dev/urandom of=$file bs=1M count=2 ||
15234 error "failed to create a file"
15235 cancel_lru_locks osc
15238 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
15239 error "failed to read a file"
15241 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
15242 $LCTL set_param fail_loc=0x8000031f
15244 cancel_lru_locks osc &
15247 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
15248 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
15249 #IO takes another lock, but matches the PENDING one
15250 #and places it to the IO RPC
15251 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
15252 error "failed to read a file with PENDING lock"
15254 run_test 275 "Read on a canceled duplicate lock"
15257 remote_ost_nodsh && skip "remote OST with nodsh" && return
15260 do_facet ost1 "(while true; do \
15261 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
15262 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
15265 for LOOP in $(seq 20); do
15267 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
15270 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
15271 rm $TMP/sanity_276_pid"
15273 run_test 276 "Race between mount and obd_statfs"
15275 cleanup_test_300() {
15279 test_striped_dir() {
15284 mkdir -p $DIR/$tdir
15286 SAVE_UMASK=$(umask)
15287 trap cleanup_test_300 RETURN EXIT
15289 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
15290 $DIR/$tdir/striped_dir ||
15291 error "set striped dir error"
15293 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
15294 [ "$mode" = "755" ] || error "expect 755 got $mode"
15296 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
15297 error "getdirstripe failed"
15298 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
15299 if [ "$stripe_count" != "2" ]; then
15300 error "1:stripe_count is $stripe_count, expect 2"
15302 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
15303 if [ "$stripe_count" != "2" ]; then
15304 error "2:stripe_count is $stripe_count, expect 2"
15307 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
15308 if [ "$stripe_index" != "$mdt_index" ]; then
15309 error "stripe_index is $stripe_index, expect $mdt_index"
15312 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15313 error "nlink error after create striped dir"
15315 mkdir $DIR/$tdir/striped_dir/a
15316 mkdir $DIR/$tdir/striped_dir/b
15318 stat $DIR/$tdir/striped_dir/a ||
15319 error "create dir under striped dir failed"
15320 stat $DIR/$tdir/striped_dir/b ||
15321 error "create dir under striped dir failed"
15323 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
15324 error "nlink error after mkdir"
15326 rmdir $DIR/$tdir/striped_dir/a
15327 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
15328 error "nlink error after rmdir"
15330 rmdir $DIR/$tdir/striped_dir/b
15331 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15332 error "nlink error after rmdir"
15334 chattr +i $DIR/$tdir/striped_dir
15335 createmany -o $DIR/$tdir/striped_dir/f 10 &&
15336 error "immutable flags not working under striped dir!"
15337 chattr -i $DIR/$tdir/striped_dir
15339 rmdir $DIR/$tdir/striped_dir ||
15340 error "rmdir striped dir error"
15348 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15349 skip "skipped for lustre < 2.7.0" && return
15350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15351 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15353 test_striped_dir 0 || error "failed on striped dir on MDT0"
15354 test_striped_dir 1 || error "failed on striped dir on MDT0"
15356 run_test 300a "basic striped dir sanity test"
15359 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15360 skip "skipped for lustre < 2.7.0" && return
15361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15362 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15368 test_mkdir $DIR/$tdir || error "mkdir fail"
15369 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15370 error "set striped dir error"
15371 for ((i=0; i<10; i++)); do
15372 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
15374 touch $DIR/$tdir/striped_dir/file_$i ||
15375 error "touch error $i"
15376 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
15377 [ $mtime1 -eq $mtime2 ] &&
15378 error "mtime not change after create"
15380 rm -f $DIR/$tdir/striped_dir/file_$i ||
15381 error "unlink error $i"
15382 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
15383 [ $mtime2 -eq $mtime3 ] &&
15384 error "mtime did not change after unlink"
15388 run_test 300b "check ctime/mtime for striped dir"
15391 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15392 skip "skipped for lustre < 2.7.0" && return
15393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15394 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15397 mkdir -p $DIR/$tdir
15398 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
15399 error "set striped dir error"
15401 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
15402 error "chown striped dir failed"
15404 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
15405 error "create 5k files failed"
15407 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
15409 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
15413 run_test 300c "chown && check ls under striped directory"
15416 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15417 skip "skipped for lustre < 2.7.0" && return
15418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15419 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15423 mkdir -p $DIR/$tdir
15424 $SETSTRIPE -c 2 $DIR/$tdir
15426 #local striped directory
15427 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15428 error "set striped dir error"
15429 createmany -o $DIR/$tdir/striped_dir/f 10 ||
15430 error "create 10 files failed"
15432 #remote striped directory
15433 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
15434 error "set striped dir error"
15435 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
15436 error "create 10 files failed"
15438 for file in $(find $DIR/$tdir); do
15439 stripe_count=$($GETSTRIPE -c $file)
15440 [ $stripe_count -eq 2 ] ||
15441 error "wrong stripe $stripe_count for $file"
15446 run_test 300d "check default stripe under striped directory"
15449 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15450 skip "Need MDS version at least 2.7.55" && return
15451 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15452 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15456 mkdir -p $DIR/$tdir
15458 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15459 error "set striped dir error"
15461 touch $DIR/$tdir/striped_dir/a
15462 touch $DIR/$tdir/striped_dir/b
15463 touch $DIR/$tdir/striped_dir/c
15465 mkdir $DIR/$tdir/striped_dir/dir_a
15466 mkdir $DIR/$tdir/striped_dir/dir_b
15467 mkdir $DIR/$tdir/striped_dir/dir_c
15469 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
15470 error "set striped adir under striped dir error"
15472 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
15473 error "set striped bdir under striped dir error"
15475 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
15476 error "set striped cdir under striped dir error"
15478 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
15479 error "rename dir under striped dir fails"
15481 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
15482 error "rename dir under different stripes fails"
15484 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
15485 error "rename file under striped dir should succeed"
15487 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
15488 error "rename dir under striped dir should succeed"
15492 run_test 300e "check rename under striped directory"
15495 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15496 skip "Need MDS version at least 2.7.55" && return
15497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15498 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15503 mkdir -p $DIR/$tdir
15505 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15506 error "set striped dir error"
15508 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
15509 error "set striped dir error"
15511 touch $DIR/$tdir/striped_dir/a
15512 mkdir $DIR/$tdir/striped_dir/dir_a
15513 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
15514 error "create striped dir under striped dir fails"
15516 touch $DIR/$tdir/striped_dir1/b
15517 mkdir $DIR/$tdir/striped_dir1/dir_b
15518 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
15519 error "create striped dir under striped dir fails"
15521 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
15522 error "rename dir under different striped dir should fail"
15524 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
15525 error "rename striped dir under diff striped dir should fail"
15527 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
15528 error "rename file under diff striped dirs fails"
15532 run_test 300f "check rename cross striped directory"
15534 test_300_check_default_striped_dir()
15537 local default_count=$2
15538 local default_index=$3
15541 local dir_stripe_index
15544 echo "checking $dirname $default_count $default_index"
15545 $LFS setdirstripe -D -c $default_count -i $default_index \
15546 -t all_char $DIR/$tdir/$dirname ||
15547 error "set default stripe on striped dir error"
15548 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
15549 [ $stripe_count -eq $default_count ] ||
15550 error "expect $default_count get $stripe_count for $dirname"
15552 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
15553 [ $stripe_index -eq $default_index ] ||
15554 error "expect $default_index get $stripe_index for $dirname"
15556 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
15557 error "create dirs failed"
15559 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
15560 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
15561 for dir in $(find $DIR/$tdir/$dirname/*); do
15562 stripe_count=$($LFS getdirstripe -c $dir)
15563 [ $stripe_count -eq $default_count ] ||
15564 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
15565 error "stripe count $default_count != $stripe_count for $dir"
15567 stripe_index=$($LFS getdirstripe -i $dir)
15568 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
15569 error "$stripe_index != $default_index for $dir"
15571 #check default stripe
15572 stripe_count=$($LFS getdirstripe -D -c $dir)
15573 [ $stripe_count -eq $default_count ] ||
15574 error "default count $default_count != $stripe_count for $dir"
15576 stripe_index=$($LFS getdirstripe -D -i $dir)
15577 [ $stripe_index -eq $default_index ] ||
15578 error "default index $default_index != $stripe_index for $dir"
15580 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
15584 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15585 skip "Need MDS version at least 2.7.55" && return
15586 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15592 mkdir $DIR/$tdir/normal_dir
15594 #Checking when client cache stripe index
15595 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
15596 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
15597 error "create striped_dir failed"
15599 mkdir $DIR/$tdir/striped_dir/dir1 ||
15600 error "create dir1 fails"
15601 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
15602 [ $stripe_index -eq 1 ] ||
15603 error "dir1 expect 1 got $stripe_index"
15605 $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
15606 error "create dir2 fails"
15607 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
15608 [ $stripe_index -eq 2 ] ||
15609 error "dir2 expect 2 got $stripe_index"
15611 #check default stripe count/stripe index
15612 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
15613 test_300_check_default_striped_dir normal_dir 1 0
15614 test_300_check_default_striped_dir normal_dir 2 1
15615 test_300_check_default_striped_dir normal_dir 2 -1
15617 #delete default stripe information
15618 echo "delete default stripeEA"
15619 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
15620 error "set default stripe on striped dir error"
15622 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
15623 for dir in $(find $DIR/$tdir/normal_dir/*); do
15624 stripe_count=$($LFS getdirstripe -c $dir)
15625 [ $stripe_count -eq 0 ] ||
15626 error "expect 1 get $stripe_count for $dir"
15627 stripe_index=$($LFS getdirstripe -i $dir)
15628 [ $stripe_index -eq 0 ] ||
15629 error "expect 0 get $stripe_index for $dir"
15632 run_test 300g "check default striped directory for normal directory"
15635 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15636 skip "Need MDS version at least 2.7.55" && return
15637 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15642 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
15643 $DIR/$tdir/striped_dir ||
15644 error "set striped dir error"
15646 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
15647 test_300_check_default_striped_dir striped_dir 1 0
15648 test_300_check_default_striped_dir striped_dir 2 1
15649 test_300_check_default_striped_dir striped_dir 2 -1
15651 #delete default stripe information
15652 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
15653 error "set default stripe on striped dir error"
15655 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
15656 for dir in $(find $DIR/$tdir/striped_dir/*); do
15657 stripe_count=$($LFS getdirstripe -c $dir)
15658 [ $stripe_count -eq 0 ] ||
15659 error "expect 1 get $stripe_count for $dir"
15662 run_test 300h "check default striped directory for striped directory"
15665 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15666 skip "Need MDS version at least 2.7.55" && return
15667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15668 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15674 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15675 error "set striped dir error"
15677 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15678 error "create files under striped dir failed"
15680 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
15681 error "set striped hashdir error"
15683 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
15684 error "create dir0 under hash dir failed"
15685 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
15686 error "create dir1 under hash dir failed"
15688 # unfortunately, we need to umount to clear dir layout cache for now
15689 # once we fully implement dir layout, we can drop this
15690 umount_client $MOUNT || error "umount failed"
15691 mount_client $MOUNT || error "mount failed"
15693 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
15694 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
15695 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
15697 #set the stripe to be unknown hash type
15698 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
15699 $LCTL set_param fail_loc=0x1901
15700 for ((i = 0; i < 10; i++)); do
15701 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
15702 error "stat f-$i failed"
15703 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
15706 touch $DIR/$tdir/striped_dir/f0 &&
15707 error "create under striped dir with unknown hash should fail"
15709 $LCTL set_param fail_loc=0
15711 umount_client $MOUNT || error "umount failed"
15712 mount_client $MOUNT || error "mount failed"
15716 run_test 300i "client handle unknown hash type striped directory"
15719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15720 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15721 skip "Need MDS version at least 2.7.55" && return
15722 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15728 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
15729 $LCTL set_param fail_loc=0x1702
15730 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15731 error "set striped dir error"
15733 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15734 error "create files under striped dir failed"
15736 $LCTL set_param fail_loc=0
15738 rm -rf $DIR/$tdir || error "unlink striped dir fails"
15742 run_test 300j "test large update record"
15745 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15746 skip "Need MDS version at least 2.7.55" && return
15747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15748 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15754 #define OBD_FAIL_LARGE_STRIPE 0x1703
15755 $LCTL set_param fail_loc=0x1703
15756 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
15757 error "set striped dir error"
15758 $LCTL set_param fail_loc=0
15760 $LFS getdirstripe $DIR/$tdir/striped_dir ||
15761 error "getstripeddir fails"
15762 rm -rf $DIR/$tdir/striped_dir ||
15763 error "unlink striped dir fails"
15767 run_test 300k "test large striped directory"
15770 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15771 skip "Need MDS version at least 2.7.55" && return
15772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15773 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15776 test_mkdir -p $DIR/$tdir/striped_dir
15777 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
15778 error "chown $RUNAS_ID failed"
15779 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
15780 error "set default striped dir failed"
15782 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
15783 $LCTL set_param fail_loc=0x80000158
15784 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
15786 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
15787 [ $stripe_index -eq 1 ] ||
15788 error "expect 1 get $stripe_index for $dir"
15790 run_test 300l "non-root user to create dir under striped dir with stale layout"
15793 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15794 skip "Need MDS version at least 2.7.55" && return
15795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15796 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
15798 mkdir -p $DIR/$tdir/striped_dir
15799 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
15800 error "set default stripes dir error"
15802 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
15804 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
15805 [ $stripe_count -eq 0 ] ||
15806 error "expect 0 get $stripe_count for a"
15808 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
15809 error "set default stripes dir error"
15811 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
15813 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
15814 [ $stripe_count -eq 0 ] ||
15815 error "expect 0 get $stripe_count for b"
15817 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
15818 error "set default stripes dir error"
15820 mkdir $DIR/$tdir/striped_dir/c &&
15821 error "default stripe_index is invalid, mkdir c should fails"
15823 rm -rf $DIR/$tdir || error "rmdir fails"
15825 run_test 300m "setstriped directory on single MDT FS"
15828 local list=$(comma_list $(mdts_nodes))
15831 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15835 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15836 skip "Need MDS version at least 2.7.55" && return
15837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15838 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15839 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15842 local list=$(comma_list $(mdts_nodes))
15844 trap cleanup_300n RETURN EXIT
15845 mkdir -p $DIR/$tdir
15846 chmod 777 $DIR/$tdir
15847 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
15848 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15849 error "create striped dir succeeds with gid=0"
15851 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15852 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
15853 error "create striped dir fails with gid=-1"
15855 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15856 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
15857 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15858 error "set default striped dir succeeds with gid=0"
15861 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15862 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
15863 error "set default striped dir fails with gid=-1"
15866 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15867 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
15868 error "create test_dir fails"
15869 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
15870 error "create test_dir1 fails"
15871 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
15872 error "create test_dir2 fails"
15875 run_test 300n "non-root user to create dir under striped dir with default EA"
15878 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15879 skip "Need MDS version at least 2.7.55" && return
15880 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15881 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15885 mkdir -p $DIR/$tdir
15887 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
15888 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
15889 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
15890 skip "not enough free inodes $numfree1 $numfree2"
15894 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
15895 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
15896 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
15897 skip "not enough free space $numfree1 $numfree2"
15901 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
15902 error "setdirstripe fails"
15904 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
15905 error "create dirs fails"
15907 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
15908 ls $DIR/$tdir/striped_dir > /dev/null ||
15909 error "ls striped dir fails"
15910 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
15911 error "unlink big striped dir fails"
15913 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
15916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15918 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15920 mkdir -p $DIR/$tdir
15922 #define OBD_FAIL_OUT_ENOSPC 0x1704
15923 do_facet mds2 lctl set_param fail_loc=0x80001704
15924 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
15925 error "create striped directory should fail"
15927 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
15929 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
15932 run_test 300p "create striped directory without space"
15935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15936 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15938 local fd=$(free_fd)
15939 local cmd="exec $fd<$tdir"
15941 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
15944 trap "eval $cmd" EXIT
15945 cd $tdir || error "cd $tdir fails"
15946 rmdir ../$tdir || error "rmdir $tdir fails"
15947 mkdir local_dir && error "create dir succeeds"
15948 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
15952 run_test 300q "create remote directory under orphan directory"
15954 prepare_remote_file() {
15955 mkdir $DIR/$tdir/src_dir ||
15956 error "create remote source failed"
15958 cp /etc/hosts $DIR/$tdir/src_dir/a || error
15959 touch $DIR/$tdir/src_dir/a
15961 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
15962 error "create remote target dir failed"
15964 touch $DIR/$tdir/tgt_dir/b
15966 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
15967 error "rename dir cross MDT failed!"
15969 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
15970 error "src_child still exists after rename"
15972 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
15973 error "missing file(a) after rename"
15975 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
15976 error "diff after rename"
15980 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15982 local remote_file=$DIR/$tdir/tgt_dir/b
15984 mkdir -p $DIR/$tdir
15986 prepare_remote_file || error "prepare remote file failed"
15989 $OPENUNLINK $remote_file $remote_file || error
15990 $CHECKSTAT -a $remote_file || error
15992 run_test 310a "open unlink remote file"
15995 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15997 local remote_file=$DIR/$tdir/tgt_dir/b
15999 mkdir -p $DIR/$tdir
16001 prepare_remote_file || error "prepare remote file failed"
16003 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16004 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
16005 $CHECKSTAT -t file $remote_file || error "check file failed"
16007 run_test 310b "unlink remote file with multiple links while open"
16010 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
16011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16012 local remote_file=$DIR/$tdir/tgt_dir/b
16014 mkdir -p $DIR/$tdir
16016 prepare_remote_file || error "prepare remote file failed"
16018 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16019 multiop_bg_pause $remote_file O_uc ||
16020 error "mulitop failed for remote file"
16022 $MULTIOP $DIR/$tfile Ouc
16023 kill -USR1 $MULTIPID
16026 run_test 310c "open-unlink remote file with multiple links"
16030 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16031 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
16032 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
16033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16034 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16036 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16038 mkdir -p $DIR/$tdir
16039 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
16040 createmany -o $DIR/$tdir/$tfile. 1000
16042 # statfs data is not real time, let's just calculate it
16043 old_iused=$((old_iused + 1000))
16045 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
16046 osp.*OST0000*MDT0000.create_count")
16047 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
16048 osp.*OST0000*MDT0000.max_create_count")
16049 for idx in $(seq $MDSCOUNT); do
16050 do_facet mds$idx "lctl set_param -n \
16051 osp.*OST0000*MDT000?.max_create_count=0"
16054 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
16055 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
16056 [ $index -ne 0 ] || error "$tfile stripe index is 0"
16058 unlinkmany $DIR/$tdir/$tfile. 1000
16060 for idx in $(seq $MDSCOUNT); do
16061 do_facet mds$idx "lctl set_param -n \
16062 osp.*OST0000*MDT000?.max_create_count=$max_count"
16063 do_facet mds$idx "lctl set_param -n \
16064 osp.*OST0000*MDT000?.create_count=$count"
16068 for i in $(seq 120); do
16069 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16070 # system may be too busy to destroy all objs in time, use
16071 # a somewhat small value to not fail autotest
16072 [ $((old_iused - new_iused)) -gt 400 ] && break
16076 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
16077 [ $((old_iused - new_iused)) -gt 400 ] ||
16078 error "objs not destroyed after unlink"
16080 run_test 311 "disable OSP precreate, and unlink should destroy objs"
16087 local vdevdir=$(dirname $(facet_vdevice $ost))
16088 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
16089 local zfs_zapid=$(do_facet $ost $cmd |
16090 grep -w "/O/0/d$((objid%32))" -C 5 |
16091 awk '/Object/{getline; print $1}')
16092 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
16093 awk "/$objid = /"'{printf $3}')
16098 zfs_object_blksz() {
16102 local vdevdir=$(dirname $(facet_vdevice $ost))
16103 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
16104 local blksz=$(do_facet $ost $cmd $objid |
16105 awk '/dblk/{getline; printf $4}')
16107 case "${blksz: -1}" in
16108 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
16109 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
16116 test_312() { # LU-4856
16117 remote_ost_nodsh && skip "remote OST with nodsh" && return
16119 [ $(facet_fstype ost1) = "zfs" ] ||
16120 { skip "the test only applies to zfs" && return; }
16122 local max_blksz=$(do_facet ost1 \
16123 $ZFS get -p recordsize $(facet_device ost1) |
16124 awk '!/VALUE/{print $3}')
16125 local min_blksz=$(getconf PAGE_SIZE)
16127 # to make life a little bit easier
16128 $LFS mkdir -c 1 -i 0 $DIR/$tdir
16129 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16131 local tf=$DIR/$tdir/$tfile
16133 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16135 # Get ZFS object id
16136 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16138 # block size change by sequential over write
16140 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
16141 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
16143 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16144 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
16148 # block size change by sequential append write
16149 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
16150 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16151 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16153 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
16154 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
16155 oflag=sync conv=notrunc
16157 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16158 [ $blksz -eq $((2 * count * min_blksz)) ] ||
16159 error "blksz error, actual $blksz, " \
16160 "expected: 2 * $count * $min_blksz"
16166 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16167 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16169 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
16170 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16171 [ $blksz -eq $min_blksz ] ||
16172 error "blksz error: $blksz, expected: $min_blksz"
16174 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
16175 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16176 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
16178 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
16179 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16180 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
16182 run_test 312 "make sure ZFS adjusts its block size by write pattern"
16185 remote_ost_nodsh && skip "remote OST with nodsh" && return
16187 local file=$DIR/$tfile
16189 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
16191 # define OBD_FAIL_TGT_RCVD_EIO 0x720
16192 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16193 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
16194 error "write should failed"
16195 do_facet ost1 "$LCTL set_param fail_loc=0"
16198 run_test 313 "io should fail after last_rcvd update fail"
16201 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16203 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
16204 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16206 wait_delete_completed
16207 do_facet ost1 "$LCTL set_param fail_loc=0"
16209 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
16211 test_315() { # LU-618
16212 local file=$DIR/$tfile
16215 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
16216 $MULTIOP $file oO_RDONLY:r4096000_c &
16221 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
16224 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
16227 run_test 315 "read should be accounted"
16230 local read_write=$1
16231 if [ "$read_write" = "write" ]; then
16232 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
16233 elif [ "$read_write" = "read" ]; then
16234 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
16236 error "argument error"
16239 # turn off debug for performance testing
16240 local saved_debug=$($LCTL get_param -n debug)
16241 $LCTL set_param debug=0
16243 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
16245 # get ost1 size - lustre-OST0000
16246 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
16247 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
16248 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
16250 if [ "$read_write" = "read" ]; then
16251 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
16254 local start_time=$(date +%s.%N)
16255 $dd_cmd bs=1M count=$blocks oflag=sync ||
16256 error "real dd $read_write error"
16257 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
16259 if [ "$read_write" = "write" ]; then
16263 # define OBD_FAIL_OST_FAKE_RW 0x238
16264 do_facet ost1 $LCTL set_param fail_loc=0x238
16266 local start_time=$(date +%s.%N)
16267 $dd_cmd bs=1M count=$blocks oflag=sync ||
16268 error "fake dd $read_write error"
16269 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
16271 if [ "$read_write" = "write" ]; then
16273 cancel_lru_locks osc
16274 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
16275 error "$tfile size not $blocks MB"
16277 do_facet ost1 $LCTL set_param fail_loc=0
16279 echo "fake $read_write $duration_fake vs. normal $read_write" \
16280 "$duration in seconds"
16281 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
16282 error_not_in_vm "fake write is slower"
16284 $LCTL set_param -n debug="$saved_debug"
16287 test_399a() { # LU-7655 for OST fake write
16288 remote_ost_nodsh && skip "remote OST with nodsh" && return
16292 run_test 399a "fake write should not be slower than normal write"
16294 test_399b() { # LU-8726 for OST fake read
16295 remote_ost_nodsh && skip "remote OST with nodsh" && return
16297 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
16298 skip "ldiskfs only test" && return 0
16302 run_test 399b "fake read should not be slower than normal read"
16304 test_400a() { # LU-1606, was conf-sanity test_74
16305 local extra_flags=''
16306 local out=$TMP/$tfile
16307 local prefix=/usr/include/lustre
16310 if ! which $CC > /dev/null 2>&1; then
16311 skip_env "$CC is not installed"
16315 if ! [[ -d $prefix ]]; then
16316 # Assume we're running in tree and fixup the include path.
16317 extra_flags+=" -I$LUSTRE/../libcfs/include"
16318 extra_flags+=" -I$LUSTRE/include"
16319 extra_flags+=" -L$LUSTRE/utils"
16322 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
16323 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
16324 error "client api broken"
16328 run_test 400a "Lustre client api program can compile and link"
16330 test_400b() { # LU-1606, LU-5011
16332 local out=$TMP/$tfile
16333 local prefix=/usr/include/lustre
16335 # We use a hard coded prefix so that this test will not fail
16336 # when run in tree. There are headers in lustre/include/lustre/
16337 # that are not packaged (like lustre_idl.h) and have more
16338 # complicated include dependencies (like config.h and lnet/types.h).
16339 # Since this test about correct packaging we just skip them when
16340 # they don't exist (see below) rather than try to fixup cppflags.
16342 if ! which $CC > /dev/null 2>&1; then
16343 skip_env "$CC is not installed"
16347 for header in $prefix/*.h; do
16348 if ! [[ -f "$header" ]]; then
16352 if [[ "$(basename $header)" == liblustreapi.h ]]; then
16353 continue # liblustreapi.h is deprecated.
16356 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
16357 error "cannot compile '$header'"
16361 run_test 400b "packaged headers can be compiled"
16363 test_401a() { #LU-7437
16364 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
16365 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
16367 #count the number of parameters by "list_param -R"
16368 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
16369 #count the number of parameters by listing proc files
16370 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
16371 echo "proc_dirs='$proc_dirs'"
16372 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
16373 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
16376 [ $params -eq $procs ] ||
16377 error "found $params parameters vs. $procs proc files"
16379 # test the list_param -D option only returns directories
16380 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
16381 #count the number of parameters by listing proc directories
16382 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
16385 [ $params -eq $procs ] ||
16386 error "found $params parameters vs. $procs proc files"
16388 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
16391 local save=$($LCTL get_param -n jobid_var)
16394 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
16395 error "no error returned when setting bad parameters"
16397 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
16398 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
16400 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
16401 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
16402 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
16404 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
16407 local jobid_var_old=$($LCTL get_param -n jobid_var)
16408 local jobid_var_new
16410 $LCTL set_param jobid_var= &&
16411 error "no error returned for 'set_param a='"
16413 jobid_var_new=$($LCTL get_param -n jobid_var)
16414 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16415 error "jobid_var was changed by setting without value"
16417 $LCTL set_param jobid_var &&
16418 error "no error returned for 'set_param a'"
16420 jobid_var_new=$($LCTL get_param -n jobid_var)
16421 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16422 error "jobid_var was changed by setting without value"
16424 run_test 401c "Verify 'lctl set_param' without value fails in either format."
16427 local jobid_var_old=$($LCTL get_param -n jobid_var)
16428 local jobid_var_new
16429 local new_value="foo=bar"
16431 $LCTL set_param jobid_var=$new_value ||
16432 error "'set_param a=b' did not accept a value containing '='"
16434 jobid_var_new=$($LCTL get_param -n jobid_var)
16435 [[ "$jobid_var_new" == "$new_value" ]] ||
16436 error "'set_param a=b' failed on a value containing '='"
16438 # Reset the jobid_var to test the other format
16439 $LCTL set_param jobid_var=$jobid_var_old
16440 jobid_var_new=$($LCTL get_param -n jobid_var)
16441 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16442 error "failed to reset jobid_var"
16444 $LCTL set_param jobid_var $new_value ||
16445 error "'set_param a b' did not accept a value containing '='"
16447 jobid_var_new=$($LCTL get_param -n jobid_var)
16448 [[ "$jobid_var_new" == "$new_value" ]] ||
16449 error "'set_param a b' failed on a value containing '='"
16451 $LCTL set_param jobid_var $jobid_var_old
16452 jobid_var_new=$($LCTL get_param -n jobid_var)
16453 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16454 error "failed to reset jobid_var"
16456 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
16459 local server_version=$(lustre_version_code $SINGLEMDS)
16460 [[ $server_version -ge $(version_code 2.7.66) ]] ||
16461 [[ $server_version -ge $(version_code 2.7.18.4) &&
16462 $server_version -lt $(version_code 2.7.50) ]] ||
16463 [[ $server_version -ge $(version_code 2.7.2) &&
16464 $server_version -lt $(version_code 2.7.11) ]] ||
16465 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
16467 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16468 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
16469 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
16470 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
16471 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
16472 echo "Touch failed - OK"
16474 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
16477 local file1=$DIR/$tfile.1
16478 local file2=$DIR/$tfile.2
16479 local tfile=$TMP/$tfile
16481 rm -f $file1 $file2 $tfile
16486 # 30 sec OBD_TIMEOUT in ll_getattr()
16487 # right before populating st_nlink
16488 $LCTL set_param fail_loc=0x80001409
16489 stat -c %h $file1 > $tfile &
16491 # create an alias, drop all locks and reclaim the dentry
16493 cancel_lru_locks mdc
16494 cancel_lru_locks osc
16495 sysctl -w vm.drop_caches=2
16499 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
16501 rm -f $tfile $file1 $file2
16503 run_test 403 "i_nlink should not drop to zero due to aliasing"
16505 test_404() { # LU-6601
16506 local server_version=$(lustre_version_code $SINGLEMDS)
16507 [[ $server_version -ge $(version_code 2.8.53) ]] ||
16508 { skip "Need server version newer than 2.8.52"; return 0; }
16510 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16511 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
16512 awk '/osp .*-osc-MDT/ { print $4}')
16515 for osp in $mosps; do
16516 echo "Deactivate: " $osp
16517 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
16518 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16519 awk -vp=$osp '$4 == p { print $2 }')
16520 [ $stat = IN ] || {
16521 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16522 error "deactivate error"
16524 echo "Activate: " $osp
16525 do_facet $SINGLEMDS $LCTL --device %$osp activate
16526 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16527 awk -vp=$osp '$4 == p { print $2 }')
16528 [ $stat = UP ] || {
16529 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16530 error "activate error"
16534 run_test 404 "validate manual {de}activated works properly for OSPs"
16537 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
16538 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
16539 skip "Layout swap lock is not supported" && return
16541 check_swap_layouts_support && return 0
16543 test_mkdir -p $DIR/$tdir
16544 swap_lock_test -d $DIR/$tdir ||
16545 error "One layout swap locked test failed"
16547 run_test 405 "Various layout swap lock tests"
16550 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16551 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16552 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
16553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16554 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
16555 skip "Need MDS version at least 2.8.50" && return
16557 local def_stripe_count=$($GETSTRIPE -c $MOUNT)
16558 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
16559 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
16560 local def_pool=$($GETSTRIPE -p $MOUNT)
16561 local test_pool=$TESTNAME
16563 if ! combined_mgs_mds ; then
16566 pool_add $test_pool || error "pool_add failed"
16567 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
16568 error "pool_add_targets failed"
16570 # parent set default stripe count only, child will stripe from both
16571 # parent and fs default
16572 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
16573 error "setstripe $MOUNT failed"
16574 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
16575 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
16576 for i in $(seq 10); do
16577 local f=$DIR/$tdir/$tfile.$i
16578 touch $f || error "touch failed"
16579 local count=$($GETSTRIPE -c $f)
16580 [ $count -eq $OSTCOUNT ] ||
16581 error "$f stripe count $count != $OSTCOUNT"
16582 local offset=$($GETSTRIPE -i $f)
16583 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
16584 local size=$($GETSTRIPE -S $f)
16585 [ $size -eq $((def_stripe_size * 2)) ] ||
16586 error "$f stripe size $size != $((def_stripe_size * 2))"
16587 local pool=$($GETSTRIPE -p $f)
16588 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
16591 # change fs default striping, delete parent default striping, now child
16592 # will stripe from new fs default striping only
16593 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
16594 error "change $MOUNT default stripe failed"
16595 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
16596 for i in $(seq 11 20); do
16597 local f=$DIR/$tdir/$tfile.$i
16598 touch $f || error "touch $f failed"
16599 local count=$($GETSTRIPE -c $f)
16600 [ $count -eq 1 ] || error "$f stripe count $count != 1"
16601 local offset=$($GETSTRIPE -i $f)
16602 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
16603 local size=$($GETSTRIPE -S $f)
16604 [ $size -eq $def_stripe_size ] ||
16605 error "$f stripe size $size != $def_stripe_size"
16606 local pool=$($GETSTRIPE -p $f)
16607 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
16611 unlinkmany $DIR/$tdir/$tfile. 1 20
16613 # restore FS default striping
16614 if [ -z $def_pool ]; then
16615 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16616 -i $def_stripe_offset $MOUNT ||
16617 error "restore default striping failed"
16619 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16620 -i $def_stripe_offset -p $def_pool $MOUNT ||
16621 error "restore default striping with $def_pool failed"
16624 local f=$DIR/$tdir/$tfile
16625 pool_remove_all_targets $test_pool $f
16626 pool_remove $test_pool $f
16628 if ! combined_mgs_mds ; then
16632 run_test 406 "DNE support fs default striping"
16635 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16636 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16637 skip "Need MDS version at least 2.8.55" && return
16638 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16640 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
16641 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
16642 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
16643 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
16644 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
16646 #define OBD_FAIL_DT_TXN_STOP 0x2019
16647 for idx in $(seq $MDSCOUNT); do
16648 do_facet mds$idx "lctl set_param fail_loc=0x2019"
16650 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
16651 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
16652 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
16655 run_test 407 "transaction fail should cause operation fail"
16658 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
16660 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
16661 lctl set_param fail_loc=0x8000040a
16662 # let ll_prepare_partial_page() fail
16663 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
16667 # create at least 100 unused inodes so that
16668 # shrink_icache_memory(0) should not return 0
16669 touch $DIR/$tfile-{0..100}
16670 rm -f $DIR/$tfile-{0..100}
16673 echo 2 > /proc/sys/vm/drop_caches
16675 run_test 408 "drop_caches should not hang due to page leaks"
16679 [ $MDSCOUNT -lt 2 ] &&
16680 skip "We need at least 2 MDTs for this test" && return
16682 check_mount_and_prep
16684 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
16685 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
16686 touch $DIR/$tdir/guard || error "(2) Fail to create"
16688 local PREFIX=$(str_repeat 'A' 128)
16689 echo "Create 1K hard links start at $(date)"
16690 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16691 error "(3) Fail to hard link"
16693 echo "Links count should be right although linkEA overflow"
16694 stat $DIR/$tdir/guard || error "(4) Fail to stat"
16695 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
16696 [ $linkcount -eq 1001 ] ||
16697 error "(5) Unexpected hard links count: $linkcount"
16699 echo "List all links start at $(date)"
16700 ls -l $DIR/$tdir/foo > /dev/null ||
16701 error "(6) Fail to list $DIR/$tdir/foo"
16703 echo "Unlink hard links start at $(date)"
16704 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16705 error "(7) Fail to unlink"
16707 run_test 409 "Large amount of cross-MDTs hard links on the same file"
16711 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
16712 skip "Need client version at least 2.9.59" && return
16714 # Create a file, and stat it from the kernel
16715 local testfile=$DIR/$tfile
16718 local run_id=$RANDOM
16719 local my_ino=$(stat --format "%i" $testfile)
16721 # Try to insert the module. This will always fail as the
16722 # module is designed to not be inserted.
16723 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
16726 # Anything but success is a test failure
16728 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
16729 error "no inode match"
16731 run_test 410 "Test inode number returned from kernel thread"
16734 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16735 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16736 skip "Need server version at least 2.9.55" & exit 0
16737 start_full_debug_logging
16741 stop_full_debug_logging
16745 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16746 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16747 awk '/The barrier for/ { print $7 }')
16750 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
16755 barrier_expired() {
16758 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16759 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16760 awk '/will be expired/ { print $7 }')
16762 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
16771 echo "Start barrier_freeze at: $(date)"
16772 #define OBD_FAIL_BARRIER_DELAY 0x2202
16773 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16774 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
16777 local b_status=$(barrier_stat)
16778 echo "Got barrier status at: $(date)"
16779 [ "$b_status" = "'freezing_p1'" ] ||
16780 error "(1) unexpected barrier status $b_status"
16782 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16784 b_status=$(barrier_stat)
16785 [ "$b_status" = "'frozen'" ] ||
16786 error "(2) unexpected barrier status $b_status"
16788 local expired=$(barrier_expired)
16789 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
16790 sleep $((expired + 3))
16792 b_status=$(barrier_stat)
16793 [ "$b_status" = "'expired'" ] ||
16794 error "(3) unexpected barrier status $b_status"
16796 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
16797 error "(4) fail to freeze barrier"
16799 b_status=$(barrier_stat)
16800 [ "$b_status" = "'frozen'" ] ||
16801 error "(5) unexpected barrier status $b_status"
16803 echo "Start barrier_thaw at: $(date)"
16804 #define OBD_FAIL_BARRIER_DELAY 0x2202
16805 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16806 do_facet mgs $LCTL barrier_thaw $FSNAME &
16809 b_status=$(barrier_stat)
16810 echo "Got barrier status at: $(date)"
16811 [ "$b_status" = "'thawing'" ] ||
16812 error "(6) unexpected barrier status $b_status"
16814 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16816 b_status=$(barrier_stat)
16817 [ "$b_status" = "'thawed'" ] ||
16818 error "(7) unexpected barrier status $b_status"
16820 #define OBD_FAIL_BARRIER_FAILURE 0x2203
16821 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
16822 do_facet mgs $LCTL barrier_freeze $FSNAME
16824 b_status=$(barrier_stat)
16825 [ "$b_status" = "'failed'" ] ||
16826 error "(8) unexpected barrier status $b_status"
16828 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16829 do_facet mgs $LCTL barrier_thaw $FSNAME
16833 run_test 801a "write barrier user interfaces and stat machine"
16838 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16839 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
16840 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
16841 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
16842 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
16844 cancel_lru_locks mdc
16846 # 180 seconds should be long enough
16847 do_facet mgs $LCTL barrier_freeze $FSNAME 180
16849 local b_status=$(barrier_stat)
16850 [ "$b_status" = "'frozen'" ] ||
16851 error "(6) unexpected barrier status $b_status"
16853 mkdir $DIR/$tdir/d0/d10 &
16856 touch $DIR/$tdir/d1/f13 &
16859 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
16862 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
16865 rm -f $DIR/$tdir/d4/f12 &
16868 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
16870 # To guarantee taht the 'stat' is not blocked
16871 b_status=$(barrier_stat)
16872 [ "$b_status" = "'frozen'" ] ||
16873 error "(8) unexpected barrier status $b_status"
16875 # let above commands to run at background
16878 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
16879 ps -p $touch_pid || error "(10) touch should be blocked"
16880 ps -p $ln_pid || error "(11) link should be blocked"
16881 ps -p $mv_pid || error "(12) rename should be blocked"
16882 ps -p $rm_pid || error "(13) unlink should be blocked"
16884 b_status=$(barrier_stat)
16885 [ "$b_status" = "'frozen'" ] ||
16886 error "(14) unexpected barrier status $b_status"
16888 do_facet mgs $LCTL barrier_thaw $FSNAME
16889 b_status=$(barrier_stat)
16890 [ "$b_status" = "'thawed'" ] ||
16891 error "(15) unexpected barrier status $b_status"
16893 wait $mkdir_pid || error "(16) mkdir should succeed"
16894 wait $touch_pid || error "(17) touch should succeed"
16895 wait $ln_pid || error "(18) link should succeed"
16896 wait $mv_pid || error "(19) rename should succeed"
16897 wait $rm_pid || error "(20) unlink should succeed"
16901 run_test 801b "modification will be blocked by write barrier"
16904 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
16908 stop mds2 || error "(1) Fail to stop mds2"
16910 do_facet mgs $LCTL barrier_freeze $FSNAME 30
16912 local b_status=$(barrier_stat)
16913 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
16914 do_facet mgs $LCTL barrier_thaw $FSNAME
16915 error "(2) unexpected barrier status $b_status"
16918 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16919 error "(3) Fail to rescan barrier bitmap"
16921 do_facet mgs $LCTL barrier_freeze $FSNAME 10
16923 b_status=$(barrier_stat)
16924 [ "$b_status" = "'frozen'" ] ||
16925 error "(4) unexpected barrier status $b_status"
16927 do_facet mgs $LCTL barrier_thaw $FSNAME
16928 b_status=$(barrier_stat)
16929 [ "$b_status" = "'thawed'" ] ||
16930 error "(5) unexpected barrier status $b_status"
16932 local devname=$(mdsdevname 2)
16934 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
16936 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16937 error "(7) Fail to rescan barrier bitmap"
16941 run_test 801c "rescan barrier bitmap"
16943 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
16944 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
16945 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
16951 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
16952 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
16953 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
16959 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16960 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16961 skip "Need server version at least 2.9.55" & exit 0
16963 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16965 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
16966 error "(2) Fail to copy"
16968 trap cleanup_802 EXIT
16970 # sync by force before remount as readonly
16971 sync; sync_all_data; sleep 3; sync_all_data
16975 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
16976 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
16977 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
16979 echo "Mount the server as read only"
16980 setupall server_only || error "(3) Fail to start servers"
16982 echo "Mount client without ro should fail"
16983 mount_client $MOUNT &&
16984 error "(4) Mount client without 'ro' should fail"
16986 echo "Mount client with ro should succeed"
16987 mount_client $MOUNT ro ||
16988 error "(5) Mount client with 'ro' should succeed"
16990 echo "Modify should be refused"
16991 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
16993 echo "Read should be allowed"
16994 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
16995 error "(7) Read should succeed under ro mode"
16999 run_test 802 "simulate readonly device"
17002 do_facet $SINGLEMDS zfs set quota=$old $fsset
17003 unlinkmany $DIR/$tdir/f- 1000000
17008 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
17009 [ "$(facet_fstype mds1)" != "zfs" ] &&
17010 skip "ZFS specific test" && return
17011 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
17012 skip "netfree not implemented before 0.7" && return
17013 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
17014 { skip "Need MDS version at least 2.10.57" && return 0; }
17021 local pref="osd-zfs.lustre-MDT0000."
17023 # limit available space on MDS dataset to meet nospace issue
17024 # quickly. then ZFS 0.7.2 can use reserved space if asked
17025 # properly (using netfree flag in osd_declare_destroy()
17026 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
17027 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
17029 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
17030 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
17031 let "usedkb=usedkb-freekb"
17032 let "freekb=freekb/2"
17033 if let "freekb > 5000"; then
17036 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
17037 trap cleanup_805 EXIT
17039 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
17040 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
17041 rm -rf $DIR/$tdir || error "not able to remove"
17042 do_facet $SINGLEMDS zfs set quota=$old $fsset
17045 run_test 805 "ZFS can remove from full fs"
17051 lctl set_param fail_loc=0x411
17052 dd if=/dev/urandom of=$DIR/$tfile bs=10240 count=2
17053 ORIG=$(md5sum $DIR/$tfile)
17054 lctl set_param ldlm.namespaces.*osc*.lru_size=clear
17055 CSUM=$(md5sum $DIR/$tfile)
17056 if [ "$ORIG" != "$CSUM" ]; then
17057 error "$ORIG != $CSUM"
17060 run_test 810 "partial page writes on ZFS (LU-11663)"
17063 # tests that do cleanup/setup should be run at the end
17067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17069 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
17070 $LCTL set_param fail_loc=0x903
17072 cancel_lru_locks MGC
17074 FAIL_ON_ERROR=true cleanup
17075 FAIL_ON_ERROR=true setup
17077 run_test 900 "umount should not race with any mgc requeue thread"
17080 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
17081 check_and_cleanup_lustre
17082 if [ "$I_MOUNTED" != "yes" ]; then
17083 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true