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 # createtest also checks that device nodes are created and
2194 # then visible correctly (#2091)
2195 test_28() { # bug 2091
2197 $CREATETEST $DIR/d28/ct || error
2199 run_test 28 "create/mknod/mkdir with bad file types ============"
2202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2203 sync; sleep 1; sync # flush out any dirty pages from previous tests
2210 declare -i LOCKCOUNTORIG=0
2211 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2212 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2214 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2216 declare -i LOCKUNUSEDCOUNTORIG=0
2217 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2218 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2225 declare -i LOCKCOUNTCURRENT=0
2226 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2227 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2230 declare -i LOCKUNUSEDCOUNTCURRENT=0
2231 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2232 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2235 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2236 $LCTL set_param -n ldlm.dump_namespaces ""
2237 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2238 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2239 log "dumped log to $TMP/test_29.dk (bug 5793)"
2242 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2243 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2244 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2245 log "dumped log to $TMP/test_29.dk (bug 5793)"
2249 run_test 29 "IT_GETATTR regression ============================"
2251 test_30a() { # was test_30
2252 cp $(which ls) $DIR || cp /bin/ls $DIR
2256 run_test 30a "execute binary from Lustre (execve) =============="
2259 cp `which ls` $DIR || cp /bin/ls $DIR
2261 $RUNAS $DIR/ls / || error
2264 run_test 30b "execute binary from Lustre as non-root ==========="
2266 test_30c() { # b=22376
2267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2268 cp `which ls` $DIR || cp /bin/ls $DIR
2270 cancel_lru_locks mdc
2271 cancel_lru_locks osc
2272 $RUNAS $DIR/ls / || error
2275 run_test 30c "execute binary from Lustre without read perms ===="
2278 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2279 $CHECKSTAT -a $DIR/f31 || error
2281 run_test 31a "open-unlink file =================================="
2284 touch $DIR/f31 || error
2285 ln $DIR/f31 $DIR/f31b || error
2286 $MULTIOP $DIR/f31b Ouc || error
2287 $CHECKSTAT -t file $DIR/f31 || error
2289 run_test 31b "unlink file with multiple links while open ======="
2292 touch $DIR/f31 || error
2293 ln $DIR/f31 $DIR/f31c || error
2294 multiop_bg_pause $DIR/f31 O_uc || return 1
2296 $MULTIOP $DIR/f31c Ouc
2297 kill -USR1 $MULTIPID
2300 run_test 31c "open-unlink file with multiple links ============="
2303 opendirunlink $DIR/d31d $DIR/d31d || error
2304 $CHECKSTAT -a $DIR/d31d || error
2306 run_test 31d "remove of open directory ========================="
2308 test_31e() { # bug 2904
2309 openfilleddirunlink $DIR/d31e || error
2311 run_test 31e "remove of open non-empty directory ==============="
2313 test_31f() { # bug 4554
2314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2316 test_mkdir $DIR/d31f
2317 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2318 cp /etc/hosts $DIR/d31f
2320 $GETSTRIPE $DIR/d31f/hosts
2321 multiop_bg_pause $DIR/d31f D_c || return 1
2324 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2325 test_mkdir $DIR/d31f
2326 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2327 cp /etc/hosts $DIR/d31f
2329 $GETSTRIPE $DIR/d31f/hosts
2330 multiop_bg_pause $DIR/d31f D_c || return 1
2333 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2334 wait $MULTIPID || error "first opendir $MULTIPID failed"
2338 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2339 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2342 run_test 31f "remove of open directory with open-unlink file ==="
2345 echo "-- cross directory link --"
2346 test_mkdir -c1 $DIR/${tdir}ga
2347 test_mkdir -c1 $DIR/${tdir}gb
2348 touch $DIR/${tdir}ga/f
2349 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2350 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2351 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2352 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2353 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2355 run_test 31g "cross directory link==============="
2358 echo "-- cross directory link --"
2359 test_mkdir -c1 $DIR/${tdir}
2360 test_mkdir -c1 $DIR/${tdir}/dir
2361 touch $DIR/${tdir}/f
2362 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2363 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2364 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2365 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2366 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2368 run_test 31h "cross directory link under child==============="
2371 echo "-- cross directory link --"
2372 test_mkdir -c1 $DIR/$tdir
2373 test_mkdir -c1 $DIR/$tdir/dir
2374 touch $DIR/$tdir/dir/f
2375 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2376 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2377 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2378 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2379 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2381 run_test 31i "cross directory link under parent==============="
2384 test_mkdir -c1 -p $DIR/$tdir
2385 test_mkdir -c1 -p $DIR/$tdir/dir1
2386 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2387 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2388 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2389 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2392 run_test 31j "link for directory==============="
2395 test_mkdir -c1 -p $DIR/$tdir
2397 touch $DIR/$tdir/exist
2398 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2399 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2400 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2401 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2402 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2403 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2404 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2407 run_test 31k "link to file: the same, non-existing, dir==============="
2413 touch $DIR/d31m2/exist
2414 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2415 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2416 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2417 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2418 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2419 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2422 run_test 31m "link to file: the same, non-existing, dir==============="
2425 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2426 nlink=$(stat --format=%h $DIR/$tfile)
2427 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2429 local cmd="exec $fd<$DIR/$tfile"
2432 trap "eval $cmd" EXIT
2433 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2434 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2435 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2436 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2437 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2440 run_test 31n "check link count of unlinked file"
2443 local TEMPNAME=$(mktemp $1_XXXXXX)
2444 mlink $TEMPNAME $1 2> /dev/null &&
2445 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2449 test_31o() { # LU-2901
2450 test_mkdir -p $DIR/$tdir
2451 for LOOP in $(seq 100); do
2452 rm -f $DIR/$tdir/$tfile*
2453 for THREAD in $(seq 8); do
2454 link_one $DIR/$tdir/$tfile.$LOOP &
2457 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2458 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2459 error "$LINKS duplicate links to $tfile.$LOOP" &&
2463 run_test 31o "duplicate hard links with same filename"
2466 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2468 test_mkdir $DIR/$tdir
2469 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2470 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2472 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2473 error "open unlink test1 failed"
2474 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2475 error "open unlink test2 failed"
2477 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2478 error "test1 still exists"
2479 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2480 error "test2 still exists"
2482 run_test 31p "remove of open striped directory"
2484 cleanup_test32_mount() {
2487 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2488 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2489 losetup -d $loopdev || true
2495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2496 echo "== more mountpoints and symlinks ================="
2497 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2498 trap cleanup_test32_mount EXIT
2499 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2500 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2501 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2502 cleanup_test32_mount
2504 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2508 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2509 trap cleanup_test32_mount EXIT
2510 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2511 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2512 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2513 cleanup_test32_mount
2515 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2519 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2520 trap cleanup_test32_mount EXIT
2521 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2522 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2523 test_mkdir -p $DIR/$tdir/d2/test_dir
2524 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2525 cleanup_test32_mount
2527 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2531 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2532 trap cleanup_test32_mount EXIT
2533 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2534 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2535 test_mkdir -p $DIR/$tdir/d2/test_dir
2536 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2537 cleanup_test32_mount
2539 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2542 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2543 test_mkdir -p $DIR/d32e/tmp
2544 TMP_DIR=$DIR/d32e/tmp
2545 ln -s $DIR/d32e $TMP_DIR/symlink11
2546 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2547 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2548 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2550 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2553 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2554 test_mkdir -p $DIR/d32f/tmp
2555 TMP_DIR=$DIR/d32f/tmp
2556 ln -s $DIR/d32f $TMP_DIR/symlink11
2557 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2558 ls $DIR/d32f/tmp/symlink11 || error
2559 ls $DIR/d32f/symlink01 || error
2561 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2564 TMP_DIR=$DIR/$tdir/tmp
2565 test_mkdir -p $DIR/$tdir/tmp
2566 test_mkdir $DIR/${tdir}2
2567 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2568 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2569 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2570 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2571 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2572 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2574 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2577 rm -fr $DIR/$tdir $DIR/${tdir}2
2578 TMP_DIR=$DIR/$tdir/tmp
2579 test_mkdir -p $DIR/$tdir/tmp
2580 test_mkdir $DIR/${tdir}2
2581 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2582 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2583 ls $TMP_DIR/symlink12 || error
2584 ls $DIR/$tdir/symlink02 || error
2586 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2590 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2591 trap cleanup_test32_mount EXIT
2592 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2593 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2594 touch $DIR/$tdir/test_file
2595 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2596 cleanup_test32_mount
2598 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2602 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2603 trap cleanup_test32_mount EXIT
2604 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2605 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2606 touch $DIR/$tdir/test_file
2607 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2608 cleanup_test32_mount
2610 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2615 trap cleanup_test32_mount EXIT
2616 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2617 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2618 test_mkdir -p $DIR/$tdir/d2
2619 touch $DIR/$tdir/d2/test_file || error
2620 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2621 cleanup_test32_mount
2623 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
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 test_mkdir -p $DIR/$tdir/d2
2632 touch $DIR/$tdir/d2/test_file
2633 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2634 cleanup_test32_mount
2636 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2640 test_mkdir -p $DIR/d32m/tmp
2641 TMP_DIR=$DIR/d32m/tmp
2642 ln -s $DIR $TMP_DIR/symlink11
2643 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2644 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2645 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2647 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2651 test_mkdir -p $DIR/d32n/tmp
2652 TMP_DIR=$DIR/d32n/tmp
2653 ln -s $DIR $TMP_DIR/symlink11
2654 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2655 ls -l $DIR/d32n/tmp/symlink11 || error
2656 ls -l $DIR/d32n/symlink01 || error
2658 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2662 test_mkdir -p $DIR/d32o/tmp
2663 TMP_DIR=$DIR/d32o/tmp
2664 ln -s $DIR/$tfile $TMP_DIR/symlink12
2665 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2666 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2667 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2668 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2669 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2671 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2681 test_mkdir -p $DIR/d32p/tmp
2683 TMP_DIR=$DIR/d32p/tmp
2685 ln -s $DIR/$tfile $TMP_DIR/symlink12
2687 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2689 cat $DIR/d32p/tmp/symlink12 || error
2691 cat $DIR/d32p/symlink02 || error
2694 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2698 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2699 trap cleanup_test32_mount EXIT
2700 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2701 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2702 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2703 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2704 cleanup_test32_mount
2706 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2710 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2711 trap cleanup_test32_mount EXIT
2712 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2713 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2714 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2715 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2716 cleanup_test32_mount
2718 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2723 chmod 444 $DIR/$tfile
2724 chown $RUNAS_ID $DIR/$tfile
2726 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2729 run_test 33aa "write file with mode 444 (should return error) ===="
2733 test_mkdir -p $DIR/d33
2734 chown $RUNAS_ID $DIR/d33
2735 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2736 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2737 error "open RDWR" || true
2739 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2743 test_mkdir -p $DIR/d33
2744 chown $RUNAS_ID $DIR/d33
2745 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2747 run_test 33b "test open file with malformed flags (No panic)"
2750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2756 remote_ost_nodsh && skip "remote OST with nodsh" && return
2759 test_mkdir -p $DIR/d33
2760 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2763 for ostnum in $(seq $OSTCOUNT); do
2764 # test-framework's OST numbering is one-based, while Lustre's
2766 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2767 # Parsing llobdstat's output sucks; we could grep the /proc
2768 # path, but that's likely to not be as portable as using the
2769 # llobdstat utility. So we parse lctl output instead.
2770 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2771 obdfilter/$ostname/stats |
2772 awk '/^write_bytes/ {print $7}' )
2773 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2774 if (( ${write_bytes:-0} > 0 ))
2781 $all_zeros || return 0
2784 echo foo > $DIR/d33/bar
2788 # Total up write_bytes after writing. We'd better find non-zeros.
2789 for ostnum in $(seq $OSTCOUNT); do
2790 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2791 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2792 obdfilter/$ostname/stats |
2793 awk '/^write_bytes/ {print $7}' )
2794 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2795 if (( ${write_bytes:-0} > 0 ))
2804 for ostnum in $(seq $OSTCOUNT); do
2805 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2806 echo "Check that write_bytes is present in obdfilter/*/stats:"
2807 do_facet ost$ostnum lctl get_param -n \
2808 obdfilter/$ostname/stats
2810 error "OST not keeping write_bytes stats (b22312)"
2813 run_test 33c "test llobdstat and write_bytes"
2816 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2819 local remote_dir=$DIR/$tdir/remote_dir
2821 test_mkdir -p $DIR/$tdir
2822 $LFS mkdir -i $MDTIDX $remote_dir ||
2823 error "create remote directory failed"
2825 touch $remote_dir/$tfile
2826 chmod 444 $remote_dir/$tfile
2827 chown $RUNAS_ID $remote_dir/$tfile
2829 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2831 chown $RUNAS_ID $remote_dir
2832 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2833 error "create" || true
2834 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2835 error "open RDWR" || true
2836 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2838 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2841 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2845 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2846 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2847 mkdir $DIR/$tdir/local_dir
2849 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2850 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2851 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2853 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2854 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2856 rmdir $DIR/$tdir/* || error "rmdir failed"
2859 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2860 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2861 mkdir $DIR/$tdir/local_dir
2863 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2864 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2865 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2867 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2868 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2870 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2873 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2874 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2875 mkdir $DIR/$tdir/local_dir
2877 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2878 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2879 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2881 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2882 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2884 run_test 33e "mkdir and striped directory should have same mode"
2888 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2892 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2893 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2896 chmod go+rwx $DIR/$tdir
2897 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2898 trap cleanup_33f EXIT
2900 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2901 error "cannot create striped directory"
2903 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2904 error "cannot create files in striped directory"
2906 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2907 error "cannot remove files in striped directory"
2909 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2910 error "cannot remove striped directory"
2914 run_test 33f "nonroot user can create, access, and remove a striped directory"
2917 mkdir -p $DIR/$tdir/dir2
2919 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2921 [[ $err =~ "exists" ]] || error "Not exists error"
2923 run_test 33g "nonroot user create already existing root created file"
2925 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2928 $MCREATE $DIR/f34 || error
2929 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2930 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2931 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2932 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2934 run_test 34a "truncate file that has not been opened ==========="
2937 [ ! -f $DIR/f34 ] && test_34a
2938 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2939 $OPENFILE -f O_RDONLY $DIR/f34
2940 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2941 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2943 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2946 [ ! -f $DIR/f34 ] && test_34a
2947 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2948 $OPENFILE -f O_RDWR $DIR/f34
2949 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2950 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2952 run_test 34c "O_RDWR opening file-with-size works =============="
2955 [ ! -f $DIR/f34 ] && test_34a
2956 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2957 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2960 run_test 34d "write to sparse file ============================="
2964 $MCREATE $DIR/f34e || error
2965 $TRUNCATE $DIR/f34e 1000 || error
2966 $CHECKSTAT -s 1000 $DIR/f34e || error
2967 $OPENFILE -f O_RDWR $DIR/f34e
2968 $CHECKSTAT -s 1000 $DIR/f34e || error
2970 run_test 34e "create objects, some with size and some without =="
2972 test_34f() { # bug 6242, 6243
2973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2976 $MCREATE $DIR/f34f || error
2977 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2978 dd if=$DIR/f34f of=$TMP/f34f
2979 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2980 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2981 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2982 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2983 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2985 run_test 34f "read from a file with no objects until EOF ======="
2988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2989 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2990 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2991 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2992 cancel_lru_locks osc
2993 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2994 error "wrong size after lock cancel"
2996 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2997 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2998 error "expanding truncate failed"
2999 cancel_lru_locks osc
3000 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
3001 error "wrong expanded size after lock cancel"
3003 run_test 34g "truncate long file ==============================="
3006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3010 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
3011 sync # Flush the cache so that multiop below does not block on cache
3012 # flush when getting the group lock
3013 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3016 # Since just timed wait is not good enough, let's do a sync write
3017 # that way we are sure enough time for a roundtrip + processing
3018 # passed + 2 seconds of extra margin.
3019 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
3023 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3024 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3028 local nsz=`stat -c %s $DIR/$tfile`
3029 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3031 run_test 34h "ftruncate file under grouplock should not block"
3034 cp /bin/sh $DIR/f35a
3036 chown $RUNAS_ID $DIR/f35a
3037 $RUNAS $DIR/f35a && error || true
3040 run_test 35a "exec file with mode 444 (should return and not leak) ====="
3044 utime $DIR/f36 || error
3046 run_test 36a "MDS utime check (mknod, utime) ==================="
3050 utime $DIR/f36 || error
3052 run_test 36b "OST utime check (open, utime) ===================="
3057 chown $RUNAS_ID $DIR/d36
3058 $RUNAS utime $DIR/d36/f36 || error
3060 run_test 36c "non-root MDS utime check (mknod, utime) =========="
3063 [ ! -d $DIR/d36 ] && test_36c
3064 echo "" > $DIR/d36/f36
3065 $RUNAS utime $DIR/d36/f36 || error
3067 run_test 36d "non-root OST utime check (open, utime) ==========="
3070 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3071 test_mkdir -p $DIR/$tdir
3072 touch $DIR/$tdir/$tfile
3073 $RUNAS utime $DIR/$tdir/$tfile && \
3074 error "utime worked, expected failure" || true
3076 run_test 36e "utime on non-owned file (should return error) ===="
3080 local LANG_SAVE=$LANG
3081 local LC_LANG_SAVE=$LC_LANG
3082 export LANG=C LC_LANG=C # for date language
3084 DATESTR="Dec 20 2000"
3085 test_mkdir -p $DIR/$tdir
3086 lctl set_param fail_loc=$fl
3088 cp /etc/hosts $DIR/$tdir/$tfile
3089 sync & # write RPC generated with "current" inode timestamp, but delayed
3091 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3092 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3093 cancel_lru_locks osc
3094 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3096 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3097 echo "BEFORE: $LS_BEFORE" && \
3098 echo "AFTER : $LS_AFTER" && \
3099 echo "WANT : $DATESTR" && \
3100 error "$DIR/$tdir/$tfile timestamps changed" || true
3102 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3107 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3108 subr_36fh "0x80000214"
3110 run_test 36f "utime on file racing with OST BRW write =========="
3113 remote_ost_nodsh && skip "remote OST with nodsh" && return
3114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3119 test_mkdir -p $DIR/$tdir
3120 fmd_max_age=$(do_facet ost1 \
3121 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3124 fmd_before=$(do_facet ost1 \
3125 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3126 touch $DIR/$tdir/$tfile
3127 sleep $((fmd_max_age + 12))
3128 fmd_after=$(do_facet ost1 \
3129 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3131 echo "fmd_before: $fmd_before"
3132 echo "fmd_after: $fmd_after"
3133 [[ $fmd_after -gt $fmd_before ]] &&
3134 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3135 error "fmd didn't expire after ping" || true
3137 run_test 36g "filter mod data cache expiry ====================="
3140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3141 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3142 subr_36fh "0x80000227"
3144 run_test 36h "utime on file racing with OST BRW write =========="
3147 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3149 test_mkdir $DIR/$tdir
3150 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3152 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3153 local new_mtime=$((mtime + 200))
3155 #change Modify time of striped dir
3156 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3157 error "change mtime failed"
3159 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3161 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3163 run_test 36i "change mtime on striped directory"
3165 # test_37 - duplicate with tests 32q 32r
3168 local file=$DIR/$tfile
3170 openfile -f O_DIRECTORY $file
3173 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3174 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3176 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3178 test_39a() { # was test_39
3180 touch $DIR/${tfile}2
3181 # ls -l $DIR/$tfile $DIR/${tfile}2
3182 # ls -lu $DIR/$tfile $DIR/${tfile}2
3183 # ls -lc $DIR/$tfile $DIR/${tfile}2
3185 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3186 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3188 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3190 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3192 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3193 error "O_TRUNC didn't change timestamps"
3196 run_test 39a "mtime changed on create ==========================="
3199 test_mkdir -p -c1 $DIR/$tdir
3200 cp -p /etc/passwd $DIR/$tdir/fopen
3201 cp -p /etc/passwd $DIR/$tdir/flink
3202 cp -p /etc/passwd $DIR/$tdir/funlink
3203 cp -p /etc/passwd $DIR/$tdir/frename
3204 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3207 echo "aaaaaa" >> $DIR/$tdir/fopen
3208 echo "aaaaaa" >> $DIR/$tdir/flink
3209 echo "aaaaaa" >> $DIR/$tdir/funlink
3210 echo "aaaaaa" >> $DIR/$tdir/frename
3212 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3213 local link_new=`stat -c %Y $DIR/$tdir/flink`
3214 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3215 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3217 cat $DIR/$tdir/fopen > /dev/null
3218 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3219 rm -f $DIR/$tdir/funlink2
3220 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3222 for (( i=0; i < 2; i++ )) ; do
3223 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3224 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3225 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3226 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3228 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3229 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3230 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3231 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3233 cancel_lru_locks osc
3234 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3237 run_test 39b "mtime change on open, link, unlink, rename ======"
3239 # this should be set to past
3240 TEST_39_MTIME=`date -d "1 year ago" +%s`
3246 local mtime0=`stat -c %Y $DIR1/$tfile`
3248 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3249 local mtime1=`stat -c %Y $DIR1/$tfile`
3250 [ "$mtime1" = $TEST_39_MTIME ] || \
3251 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3254 echo hello >> $DIR1/$tfile
3256 local mtime2=`stat -c %Y $DIR1/$tfile`
3257 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3258 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3260 mv $DIR1/$tfile $DIR1/$tfile-1
3262 for (( i=0; i < 2; i++ )) ; do
3263 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3264 [ "$mtime2" = "$mtime3" ] || \
3265 error "mtime ($mtime2) changed (to $mtime3) on rename"
3267 cancel_lru_locks osc
3268 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3271 run_test 39c "mtime change on rename ==========================="
3275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3278 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3280 for (( i=0; i < 2; i++ )) ; do
3281 local mtime=`stat -c %Y $DIR1/$tfile`
3282 [ $mtime = $TEST_39_MTIME ] || \
3283 error "mtime($mtime) is not set to $TEST_39_MTIME"
3285 cancel_lru_locks osc
3286 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3289 run_test 39d "create, utime, stat =============================="
3293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3295 local mtime1=`stat -c %Y $DIR1/$tfile`
3297 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3299 for (( i=0; i < 2; i++ )) ; do
3300 local mtime2=`stat -c %Y $DIR1/$tfile`
3301 [ $mtime2 = $TEST_39_MTIME ] || \
3302 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3304 cancel_lru_locks osc
3305 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3308 run_test 39e "create, stat, utime, stat ========================"
3312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3314 mtime1=`stat -c %Y $DIR1/$tfile`
3317 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3319 for (( i=0; i < 2; i++ )) ; do
3320 local mtime2=`stat -c %Y $DIR1/$tfile`
3321 [ $mtime2 = $TEST_39_MTIME ] || \
3322 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3324 cancel_lru_locks osc
3325 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3328 run_test 39f "create, stat, sleep, utime, stat ================="
3332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3333 echo hello >> $DIR1/$tfile
3334 local mtime1=`stat -c %Y $DIR1/$tfile`
3337 chmod o+r $DIR1/$tfile
3339 for (( i=0; i < 2; i++ )) ; do
3340 local mtime2=`stat -c %Y $DIR1/$tfile`
3341 [ "$mtime1" = "$mtime2" ] || \
3342 error "lost mtime: $mtime2, should be $mtime1"
3344 cancel_lru_locks osc
3345 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3348 run_test 39g "write, chmod, stat ==============================="
3352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3357 echo hello >> $DIR1/$tfile
3358 local mtime1=`stat -c %Y $DIR1/$tfile`
3360 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3362 if [ "$d1" != "$d2" ]; then
3363 echo "write and touch not within one second"
3365 for (( i=0; i < 2; i++ )) ; do
3366 local mtime2=`stat -c %Y $DIR1/$tfile`
3367 [ "$mtime2" = $TEST_39_MTIME ] || \
3368 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3370 cancel_lru_locks osc
3371 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3375 run_test 39h "write, utime within one second, stat ============="
3378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3382 echo hello >> $DIR1/$tfile
3383 local mtime1=`stat -c %Y $DIR1/$tfile`
3385 mv $DIR1/$tfile $DIR1/$tfile-1
3387 for (( i=0; i < 2; i++ )) ; do
3388 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3390 [ "$mtime1" = "$mtime2" ] || \
3391 error "lost mtime: $mtime2, should be $mtime1"
3393 cancel_lru_locks osc
3394 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3397 run_test 39i "write, rename, stat =============================="
3400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3401 start_full_debug_logging
3405 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3406 lctl set_param fail_loc=0x80000412
3407 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3408 error "multiop failed"
3410 local mtime1=`stat -c %Y $DIR1/$tfile`
3412 mv $DIR1/$tfile $DIR1/$tfile-1
3414 kill -USR1 $multipid
3415 wait $multipid || error "multiop close failed"
3417 for (( i=0; i < 2; i++ )) ; do
3418 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3419 [ "$mtime1" = "$mtime2" ] ||
3420 error "mtime is lost on close: $mtime2, " \
3423 cancel_lru_locks osc
3424 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3426 lctl set_param fail_loc=0
3427 stop_full_debug_logging
3429 run_test 39j "write, rename, close, stat ======================="
3432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3436 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3438 local mtime1=`stat -c %Y $DIR1/$tfile`
3440 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3442 kill -USR1 $multipid
3443 wait $multipid || error "multiop close failed"
3445 for (( i=0; i < 2; i++ )) ; do
3446 local mtime2=`stat -c %Y $DIR1/$tfile`
3448 [ "$mtime2" = $TEST_39_MTIME ] || \
3449 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3451 cancel_lru_locks osc
3452 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3455 run_test 39k "write, utime, close, stat ========================"
3457 # this should be set to future
3458 TEST_39_ATIME=`date -d "1 year" +%s`
3461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3462 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3463 local atime_diff=$(do_facet $SINGLEMDS \
3464 lctl get_param -n mdd.*MDT0000*.atime_diff)
3468 # test setting directory atime to future
3469 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3470 local atime=$(stat -c %X $DIR/$tdir)
3471 [ "$atime" = $TEST_39_ATIME ] ||
3472 error "atime is not set to future: $atime, $TEST_39_ATIME"
3474 # test setting directory atime from future to now
3475 local now=$(date +%s)
3476 touch -a -d @$now $DIR/$tdir
3478 atime=$(stat -c %X $DIR/$tdir)
3479 [ "$atime" -eq "$now" ] ||
3480 error "atime is not updated from future: $atime, $now"
3482 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3485 # test setting directory atime when now > dir atime + atime_diff
3486 local d1=$(date +%s)
3488 local d2=$(date +%s)
3489 cancel_lru_locks mdc
3490 atime=$(stat -c %X $DIR/$tdir)
3491 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3492 error "atime is not updated : $atime, should be $d2"
3494 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3497 # test not setting directory atime when now < dir atime + atime_diff
3499 cancel_lru_locks mdc
3500 atime=$(stat -c %X $DIR/$tdir)
3501 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3502 error "atime is updated to $atime, should remain $d1<atime<$d2"
3504 do_facet $SINGLEMDS \
3505 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3507 run_test 39l "directory atime update ==========================="
3510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3513 local far_past_mtime=$(date -d "May 29 1953" +%s)
3514 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3516 touch -m -d @$far_past_mtime $DIR1/$tfile
3517 touch -a -d @$far_past_atime $DIR1/$tfile
3519 for (( i=0; i < 2; i++ )) ; do
3520 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3521 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3522 error "atime or mtime set incorrectly"
3524 cancel_lru_locks osc
3525 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3528 run_test 39m "test atime and mtime before 1970"
3530 test_39n() { # LU-3832
3531 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3532 local atime_diff=$(do_facet $SINGLEMDS \
3533 lctl get_param -n mdd.*MDT0000*.atime_diff)
3538 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3541 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3542 atime0=$(stat -c %X $DIR/$tfile)
3545 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3546 atime1=$(stat -c %X $DIR/$tfile)
3549 cancel_lru_locks mdc
3550 cancel_lru_locks osc
3551 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3552 atime2=$(stat -c %X $DIR/$tfile)
3554 do_facet $SINGLEMDS \
3555 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3557 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3558 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3560 run_test 39n "check that O_NOATIME is honored"
3563 TESTDIR=$DIR/$tdir/$tfile
3564 [ -e $TESTDIR ] && rm -rf $TESTDIR
3571 links2=$(stat -c %h .)
3572 [ $(($links1 + 2)) != $links2 ] &&
3573 error "wrong links count $(($links1 + 2)) != $links2"
3575 links3=$(stat -c %h .)
3576 [ $(($links1 + 1)) != $links3 ] &&
3577 error "wrong links count $links1 != $links3"
3580 run_test 39o "directory cached attributes updated after create ========"
3583 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3585 TESTDIR=$DIR/$tdir/$tfile
3586 [ -e $TESTDIR ] && rm -rf $TESTDIR
3587 test_mkdir -p $TESTDIR
3591 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3592 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3594 links2=$(stat -c %h .)
3595 [ $(($links1 + 2)) != $links2 ] &&
3596 error "wrong links count $(($links1 + 2)) != $links2"
3598 links3=$(stat -c %h .)
3599 [ $(($links1 + 1)) != $links3 ] &&
3600 error "wrong links count $links1 != $links3"
3603 run_test 39p "remote directory cached attributes updated after create ========"
3606 test_39q() { # LU-8041
3607 local testdir=$DIR/$tdir
3609 multiop_bg_pause $testdir D_c || error "multiop failed"
3611 cancel_lru_locks mdc
3612 kill -USR1 $multipid
3613 local atime=$(stat -c %X $testdir)
3614 [ "$atime" -ne 0 ] || error "atime is zero"
3616 run_test 39q "close won't zero out atime"
3619 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3620 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3621 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3622 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3623 error "$tfile is not 4096 bytes in size"
3625 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3629 small_write $DIR/f41 18
3631 run_test 41 "test small file write + fstat ====================="
3633 count_ost_writes() {
3634 lctl get_param -n osc.*.stats |
3635 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3636 END { printf("%0.0f", writes) }'
3643 BG_DIRTY_RATIO_SAVE=10
3644 MAX_BG_DIRTY_RATIO=25
3648 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3649 # dirty_ratio, dirty_background_ratio
3650 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3651 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3652 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3653 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3655 # if file not here, we are a 2.4 kernel
3656 kill -CONT `pidof kupdated`
3661 # setup the trap first, so someone cannot exit the test at the
3662 # exact wrong time and mess up a machine
3663 trap start_writeback EXIT
3664 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3665 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3666 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3667 sysctl -w vm.dirty_writeback_centisecs=0
3668 sysctl -w vm.dirty_writeback_centisecs=0
3669 # save and increase /proc/sys/vm/dirty_ratio
3670 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3671 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3672 # save and increase /proc/sys/vm/dirty_background_ratio
3673 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3674 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3676 # if file not here, we are a 2.4 kernel
3677 kill -STOP `pidof kupdated`
3681 # ensure that all stripes have some grant before we test client-side cache
3683 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3684 dd if=/dev/zero of=$i bs=4k count=1
3689 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3690 # file truncation, and file removal.
3692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3694 cancel_lru_locks osc
3696 sync; sleep 1; sync # just to be safe
3697 BEFOREWRITES=`count_ost_writes`
3698 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3699 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3700 AFTERWRITES=`count_ost_writes`
3701 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3702 error "$BEFOREWRITES < $AFTERWRITES"
3705 run_test 42a "ensure that we don't flush on close"
3708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3710 cancel_lru_locks osc
3713 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3714 BEFOREWRITES=$(count_ost_writes)
3715 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3716 AFTERWRITES=$(count_ost_writes)
3717 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3718 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3720 BEFOREWRITES=$(count_ost_writes)
3721 sync || error "sync: $?"
3722 AFTERWRITES=$(count_ost_writes)
3723 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3724 error "$BEFOREWRITES < $AFTERWRITES on sync"
3726 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3730 run_test 42b "test destroy of file with cached dirty data ======"
3732 # if these tests just want to test the effect of truncation,
3733 # they have to be very careful. consider:
3734 # - the first open gets a {0,EOF}PR lock
3735 # - the first write conflicts and gets a {0, count-1}PW
3736 # - the rest of the writes are under {count,EOF}PW
3737 # - the open for truncate tries to match a {0,EOF}PR
3738 # for the filesize and cancels the PWs.
3739 # any number of fixes (don't get {0,EOF} on open, match
3740 # composite locks, do smarter file size management) fix
3741 # this, but for now we want these tests to verify that
3742 # the cancellation with truncate intent works, so we
3743 # start the file with a full-file pw lock to match against
3744 # until the truncate.
3749 cancel_lru_locks osc
3751 # prime the file with 0,EOF PW to match
3755 # now the real test..
3756 dd if=/dev/zero of=$file bs=1024 count=100
3757 BEFOREWRITES=`count_ost_writes`
3758 $TRUNCATE $file $offset
3759 cancel_lru_locks osc
3760 AFTERWRITES=`count_ost_writes`
3765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3767 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3768 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3771 run_test 42c "test partial truncate of file with cached dirty data"
3774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3776 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3777 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3780 run_test 42d "test complete truncate of file with cached dirty data"
3782 test_42e() { # bug22074
3783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3784 local TDIR=$DIR/${tdir}e
3785 local pagesz=$(page_size)
3786 local pages=16 # hardcoded 16 pages, don't change it.
3787 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3788 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3792 test_mkdir -p $DIR/${tdir}e
3793 $SETSTRIPE -c 1 $TDIR
3794 createmany -o $TDIR/f $files
3796 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3798 # we assume that with $OSTCOUNT files, at least one of them will
3799 # be allocated on OST0.
3800 warmup_files=$((OSTCOUNT * max_dirty_mb))
3801 createmany -o $TDIR/w $warmup_files
3803 # write a large amount of data into one file and sync, to get good
3804 # avail_grant number from OST.
3805 for ((i=0; i<$warmup_files; i++)); do
3806 idx=$($GETSTRIPE -i $TDIR/w$i)
3807 [ $idx -ne 0 ] && continue
3808 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3811 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3813 $LCTL get_param $proc_osc0/cur_dirty_bytes
3814 $LCTL get_param $proc_osc0/cur_grant_bytes
3816 # create as much dirty pages as we can while not to trigger the actual
3817 # RPCs directly. but depends on the env, VFS may trigger flush during this
3818 # period, hopefully we are good.
3819 for ((i=0; i<$warmup_files; i++)); do
3820 idx=$($GETSTRIPE -i $TDIR/w$i)
3821 [ $idx -ne 0 ] && continue
3822 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3824 $LCTL get_param $proc_osc0/cur_dirty_bytes
3825 $LCTL get_param $proc_osc0/cur_grant_bytes
3827 # perform the real test
3828 $LCTL set_param $proc_osc0/rpc_stats 0
3829 for ((;i<$files; i++)); do
3830 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3831 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3834 $LCTL get_param $proc_osc0/rpc_stats
3837 local have_ppr=false
3838 $LCTL get_param $proc_osc0/rpc_stats |
3839 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3840 # skip lines until we are at the RPC histogram data
3841 [ "$PPR" == "pages" ] && have_ppr=true && continue
3842 $have_ppr || continue
3844 # we only want the percent stat for < 16 pages
3845 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3847 percent=$((percent + WPCT))
3848 if [[ $percent -gt 15 ]]; then
3849 error "less than 16-pages write RPCs" \
3856 run_test 42e "verify sub-RPC writes are not done synchronously"
3858 test_43A() { # was test_43
3859 test_mkdir -p $DIR/$tdir
3860 cp -p /bin/ls $DIR/$tdir/$tfile
3861 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3863 # give multiop a chance to open
3866 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3869 run_test 43A "execution of file opened for write should return -ETXTBSY"
3872 test_mkdir $DIR/$tdir
3873 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3874 cp -p multiop $DIR/$tdir/multiop
3875 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3876 error "multiop open $TMP/$tfile.junk failed"
3878 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3879 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3880 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3882 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3885 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3886 test_mkdir $DIR/$tdir
3887 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3888 cp -p multiop $DIR/$tdir/multiop
3889 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3890 error "multiop open $TMP/$tfile.junk failed"
3892 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3893 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3894 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3896 run_test 43b "truncate of file being executed should return -ETXTBSY"
3899 local testdir="$DIR/$tdir"
3902 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3903 ( cd $testdir && md5sum -c )
3905 run_test 43c "md5sum of copy into lustre"
3907 test_44A() { # was test_44
3908 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3909 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3910 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3912 run_test 44A "zero length read from a sparse stripe"
3915 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3917 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3918 [[ $nstripe -gt $OSTCOUNT ]] &&
3919 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3921 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3923 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3924 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3928 OFFSETS="0 $((stride/2)) $((stride-1))"
3929 for offset in $OFFSETS; do
3930 for i in $(seq 0 $((nstripe-1))); do
3931 local GLOBALOFFSETS=""
3933 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3934 local myfn=$DIR/d44a-$size
3935 echo "--------writing $myfn at $size"
3936 ll_sparseness_write $myfn $size ||
3937 error "ll_sparseness_write"
3938 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3939 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3940 error "ll_sparseness_verify $GLOBALOFFSETS"
3942 for j in $(seq 0 $((nstripe-1))); do
3944 size=$((((j + $nstripe )*$stride + $offset)))
3945 ll_sparseness_write $myfn $size ||
3946 error "ll_sparseness_write"
3947 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3949 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3950 error "ll_sparseness_verify $GLOBALOFFSETS"
3955 run_test 44a "test sparse pwrite ==============================="
3959 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3965 before=`dirty_osc_total`
3966 echo executing "\"$*\""
3968 after=`dirty_osc_total`
3969 echo before $before, after $after
3972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3974 # Obtain grants from OST if it supports it
3975 echo blah > ${f}_grant
3978 do_dirty_record "echo blah > $f"
3979 [[ $before -eq $after ]] && error "write wasn't cached"
3980 do_dirty_record "> $f"
3981 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3982 do_dirty_record "echo blah > $f"
3983 [[ $before -eq $after ]] && error "write wasn't cached"
3984 do_dirty_record "sync"
3985 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3986 do_dirty_record "echo blah > $f"
3987 [[ $before -eq $after ]] && error "write wasn't cached"
3988 do_dirty_record "cancel_lru_locks osc"
3989 [[ $before -gt $after ]] ||
3990 error "lock cancellation didn't lower dirty count"
3993 run_test 45 "osc io page accounting ============================"
3995 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3996 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3997 # objects offset and an assert hit when an rpc was built with 1023's mapped
3998 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4004 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4006 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
4007 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4011 run_test 46 "dirtying a previously written page ================"
4013 # test_47 is removed "Device nodes check" is moved to test_28
4015 test_48a() { # bug 2399
4016 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
4017 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
4018 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
4020 test_mkdir $DIR/$tdir
4022 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4023 test_mkdir $DIR/$tdir || error "recreate directory failed"
4024 touch foo || error "'touch foo' failed after recreating cwd"
4025 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
4026 touch .foo || error "'touch .foo' failed after recreating cwd"
4027 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
4028 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4029 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4030 cd . || error "'cd .' failed after recreating cwd"
4031 test_mkdir . && error "'mkdir .' worked after recreating cwd"
4032 rmdir . && error "'rmdir .' worked after recreating cwd"
4033 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4034 cd .. || error "'cd ..' failed after recreating cwd"
4036 run_test 48a "Access renamed working dir (should return errors)="
4038 test_48b() { # bug 2399
4040 test_mkdir $DIR/$tdir
4042 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4043 touch foo && error "'touch foo' worked after removing cwd"
4044 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4045 touch .foo && error "'touch .foo' worked after removing cwd"
4046 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4047 ls . > /dev/null && error "'ls .' worked after removing cwd"
4048 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4049 test_mkdir . && error "'mkdir .' worked after removing cwd"
4050 rmdir . && error "'rmdir .' worked after removing cwd"
4051 ln -s . foo && error "'ln -s .' worked after removing cwd"
4052 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4054 run_test 48b "Access removed working dir (should return errors)="
4056 test_48c() { # bug 2350
4057 #lctl set_param debug=-1
4060 test_mkdir -p $DIR/$tdir/dir
4062 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4063 $TRACE touch foo && error "touch foo worked after removing cwd"
4064 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
4065 touch .foo && error "touch .foo worked after removing cwd"
4066 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
4067 $TRACE ls . && error "'ls .' worked after removing cwd"
4068 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4069 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
4070 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4071 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4072 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4074 run_test 48c "Access removed working subdir (should return errors)"
4076 test_48d() { # bug 2350
4077 #lctl set_param debug=-1
4080 test_mkdir -p $DIR/$tdir/dir
4082 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4083 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4084 $TRACE touch foo && error "'touch foo' worked after removing parent"
4085 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
4086 touch .foo && error "'touch .foo' worked after removing parent"
4087 test_mkdir .foo && error "mkdir .foo worked after removing parent"
4088 $TRACE ls . && error "'ls .' worked after removing parent"
4089 $TRACE ls .. && error "'ls ..' worked after removing parent"
4090 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
4091 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4092 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4095 run_test 48d "Access removed parent subdir (should return errors)"
4097 test_48e() { # bug 4134
4098 #lctl set_param debug=-1
4101 test_mkdir -p $DIR/$tdir/dir
4103 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4104 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4105 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4106 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4107 # On a buggy kernel addition of "touch foo" after cd .. will
4108 # produce kernel oops in lookup_hash_it
4109 touch ../foo && error "'cd ..' worked after recreate parent"
4111 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4113 run_test 48e "Access to recreated parent subdir (should return errors)"
4115 test_49() { # LU-1030
4116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4117 remote_ost_nodsh && skip "remote OST with nodsh" && return
4118 # get ost1 size - lustre-OST0000
4119 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4121 # write 800M at maximum
4122 [[ $ost1_size -lt 2 ]] && ost1_size=2
4123 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4125 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4126 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4129 # change max_pages_per_rpc while writing the file
4130 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4131 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4132 # loop until dd process exits
4133 while ps ax -opid | grep -wq $dd_pid; do
4134 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4135 sleep $((RANDOM % 5 + 1))
4137 # restore original max_pages_per_rpc
4138 $LCTL set_param $osc1_mppc=$orig_mppc
4139 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4141 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4145 test_mkdir $DIR/$tdir
4147 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4149 run_test 50 "special situations: /proc symlinks ==============="
4151 test_51a() { # was test_51
4152 # bug 1516 - create an empty entry right after ".." then split dir
4153 test_mkdir -c1 $DIR/$tdir
4154 touch $DIR/$tdir/foo
4155 $MCREATE $DIR/$tdir/bar
4157 createmany -m $DIR/$tdir/longfile 201
4159 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4160 $MCREATE $DIR/$tdir/longfile$FNUM
4165 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4167 run_test 51a "special situations: split htree with empty entry =="
4169 cleanup_print_lfs_df () {
4176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4177 local dir=$DIR/$tdir
4179 local nrdirs=$((65536 + 100))
4181 # cleanup the directory
4184 test_mkdir -p -c1 $dir
4188 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4189 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4190 [[ $numfree -lt $nrdirs ]] &&
4191 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4194 # need to check free space for the directories as well
4195 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4196 numfree=$(( blkfree / $(fs_inode_ksize) ))
4197 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4200 trap cleanup_print_lfs_df EXIT
4203 createmany -d $dir/d $nrdirs || {
4204 unlinkmany $dir/d $nrdirs
4205 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4209 nrdirs=$(ls -U $dir | wc -l)
4211 # unlink all but 100 subdirectories, then check it still works
4213 local delete=$((nrdirs - left))
4218 # for ldiskfs the nlink count should be 1, but this is OSD specific
4219 # and so this is listed for informational purposes only
4220 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4221 unlinkmany -d $dir/d $delete ||
4222 error "unlink of first $delete subdirs failed"
4224 echo "nlink between: $(stat -c %h $dir)"
4225 local found=$(ls -U $dir | wc -l)
4226 [ $found -ne $left ] &&
4227 error "can't find subdirs: found only $found, expected $left"
4229 unlinkmany -d $dir/d $delete $left ||
4230 error "unlink of second $left subdirs failed"
4231 # regardless of whether the backing filesystem tracks nlink accurately
4232 # or not, the nlink count shouldn't be more than "." and ".." here
4233 local after=$(stat -c %h $dir)
4234 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4235 echo "nlink after: $after"
4237 cleanup_print_lfs_df
4239 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4243 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4244 test_mkdir -p $DIR/$tdir
4245 createmany -o $DIR/$tdir/t- 1000
4246 $GETSTRIPE $DIR/$tdir > $TMP/$tfile
4247 for N in $(seq 0 $((OSTCOUNT - 1))); do
4248 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4249 END { printf("%0.0f", objs) }' $TMP/$tfile)
4250 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4251 '($1 == '$N') { objs += 1 } \
4252 END { printf("%0.0f", objs) }')
4253 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4255 unlinkmany $DIR/$tdir/t- 1000
4258 for N in $(seq 1 $((OSTCOUNT - 1))); do
4259 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4260 error "OST $N has less objects vs OST $NLAST" \
4261 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4262 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4263 error "OST $N has less objects vs OST $NLAST" \
4264 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4266 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4267 error "OST $N has less #0 objects vs OST $NLAST" \
4268 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4269 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4270 error "OST $N has less #0 objects vs OST $NLAST" \
4271 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4276 run_test 51d "check object distribution"
4279 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4280 skip "ldiskfs only test"
4284 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4285 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4287 touch $DIR/$tdir/d0/foo
4288 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4289 error "file exceed 65000 nlink limit!"
4290 unlinkmany $DIR/$tdir/d0/f- 65001
4293 run_test 51e "check file nlink limit"
4296 test_mkdir $DIR/$tdir
4299 local ulimit_old=$(ulimit -n)
4300 local spare=20 # number of spare fd's for scripts/libraries, etc.
4301 local mdt=$(lfs getstripe -M $DIR/$tdir)
4302 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4304 echo "MDT$mdt numfree=$numfree, max=$max"
4305 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4306 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4307 while ! ulimit -n $((numfree + spare)); do
4308 numfree=$((numfree * 3 / 4))
4310 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4312 echo "left ulimit at $ulimit_old"
4315 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4316 unlinkmany $DIR/$tdir/f $numfree
4317 error "create+open $numfree files in $DIR/$tdir failed"
4319 ulimit -n $ulimit_old
4321 # if createmany exits at 120s there will be fewer than $numfree files
4322 unlinkmany $DIR/$tdir/f $numfree || true
4324 run_test 51f "check many open files limit"
4327 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4328 test_mkdir -p $DIR/$tdir
4329 touch $DIR/$tdir/foo
4330 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4331 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4332 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4333 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4334 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4336 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4337 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4338 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4340 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4341 cp -r $DIR/$tdir $TMP/
4342 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4344 run_test 52a "append-only flag test (should return errors)"
4347 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4348 test_mkdir -p $DIR/$tdir
4349 touch $DIR/$tdir/foo
4350 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4351 cat test > $DIR/$tdir/foo && error "cat test worked"
4352 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4353 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4354 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4356 echo foo >> $DIR/$tdir/foo && error "echo worked"
4357 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4358 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4359 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4360 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4362 chattr -i $DIR/$tdir/foo || error "chattr failed"
4364 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4366 run_test 52b "immutable flag test (should return errors) ======="
4369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4370 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4371 remote_ost_nodsh && skip "remote OST with nodsh" && return
4384 local support_last_seq=true
4386 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4387 support_last_seq=false
4390 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4392 for value in $(do_facet $SINGLEMDS \
4393 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4394 param=$(echo ${value[0]} | cut -d "=" -f1)
4395 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4397 if $support_last_seq; then
4398 param_seq=$(echo $param |
4399 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4400 mds_last_seq=$(do_facet $SINGLEMDS \
4401 $LCTL get_param -n $param_seq)
4403 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4405 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4406 node=$(facet_active_host ost$((ostnum+1)))
4407 param="obdfilter.$ostname.last_id"
4408 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4409 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4410 ost_last_id=$ost_last
4412 if $support_last_seq; then
4413 ost_last_id=$(echo $ost_last |
4414 awk -F':' '{print $2}' |
4416 ost_last_seq=$(echo $ost_last |
4417 awk -F':' '{print $1}')
4418 [[ $ost_last_seq = $mds_last_seq ]] || continue
4421 if [[ $ost_last_id != $mds_last ]]; then
4422 error "$ost_last_id != $mds_last"
4429 $found || error "can not match last_seq/last_id for $mdtosc"
4432 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4435 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4437 $SOCKETSERVER $DIR/socket ||
4438 error "$SOCKETSERVER $DIR/socket failed: $?"
4439 $SOCKETCLIENT $DIR/socket ||
4440 error "$SOCKETCLIENT $DIR/socket failed: $?"
4441 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4443 run_test 54a "unix domain socket test =========================="
4449 dd if=/dev/zero of=$f bs=$(page_size) count=1
4451 run_test 54b "char device works in lustre ======================"
4454 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4455 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4456 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4458 for i in $(seq 3 7); do
4459 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4468 loopdev="$DIR/loop54c"
4471 $UMOUNT $DIR/$tdir || rc=$?
4472 losetup -d $loopdev || true
4473 losetup -d $LOOPDEV || true
4474 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4480 loopdev="$DIR/loop54c"
4483 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4484 trap cleanup_54c EXIT
4485 mknod $loopdev b 7 $LOOPNUM
4486 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4487 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4488 losetup $loopdev $DIR/$tfile ||
4489 error "can't set up $loopdev for $DIR/$tfile"
4490 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4491 test_mkdir -p $DIR/$tdir
4492 mount -t ext2 $loopdev $DIR/$tdir ||
4493 error "error mounting $loopdev on $DIR/$tdir"
4494 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4497 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4501 run_test 54c "block device works in lustre ====================="
4507 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4509 run_test 54d "fifo device works in lustre ======================"
4514 cp -aL /dev/console $f
4515 echo $string > $f || error "echo $string to $f failed"
4517 run_test 54e "console/tty device works in lustre ======================"
4519 #The test_55 used to be iopen test and it was removed by bz#24037.
4520 #run_test 55 "check iopen_connect_dentry() ======================"
4522 test_56a() { # was test_56
4525 test_mkdir -p $DIR/$tdir/dir
4527 NUMFILESx2=$(($NUMFILES * 2))
4528 for i in $(seq 1 $NUMFILES); do
4529 touch $DIR/$tdir/file$i
4530 touch $DIR/$tdir/dir/file$i
4533 # test lfs getstripe with --recursive
4534 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4535 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4536 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4537 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4538 [[ $FILENUM -eq $NUMFILES ]] ||
4539 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4540 echo "$GETSTRIPE --recursive passed."
4542 # test lfs getstripe with file instead of dir
4543 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4544 [[ $FILENUM -eq 1 ]] ||
4545 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4546 echo "$GETSTRIPE file1 passed."
4548 #test lfs getstripe with --verbose
4549 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4550 grep -c lmm_magic) -eq $NUMFILES ]] ||
4551 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4552 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4553 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4555 #test lfs getstripe with -v prints lmm_fid
4556 [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
4557 error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
4558 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
4559 error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
4560 echo "$GETSTRIPE --verbose passed."
4562 #check for FID information
4563 local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
4564 local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
4565 awk '/lmm_fid: / { print $2 }')
4566 local fid3=$($LFS path2fid $DIR/$tdir/file1)
4567 [ "$fid1" != "$fid2" ] &&
4568 error "getstripe --fid $fid1 != getstripe --verbose $fid2"
4569 [ "$fid1" != "$fid3" ] &&
4570 error "getstripe --fid $fid1 != lfs path2fid $fid3"
4571 echo "$GETSTRIPE --fid passed."
4573 #test lfs getstripe with --obd
4574 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4575 grep -q "unknown obduuid" ||
4576 error "$GETSTRIPE --obd wrong_uuid should return error message"
4578 [[ $OSTCOUNT -lt 2 ]] &&
4579 skip_env "skipping other $GETSTRIPE --obd test" && return
4582 OBDUUID=$(ostuuid_from_index $OSTIDX)
4583 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4584 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4585 [[ $FOUND -eq $FILENUM ]] ||
4586 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4587 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4588 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4589 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4590 error "$GETSTRIPE --obd: should not show file on other obd"
4591 echo "$GETSTRIPE --obd passed"
4593 run_test 56a "check $GETSTRIPE"
4596 test_mkdir $DIR/$tdir
4598 for i in $(seq 1 $NUMDIRS); do
4599 test_mkdir $DIR/$tdir/dir$i
4602 # test lfs getdirstripe default mode is non-recursion, which is
4603 # different from lfs getstripe
4604 dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
4605 [[ $dircnt -eq 1 ]] ||
4606 error "$LFS getdirstripe: found $dircnt, not 1"
4607 dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
4608 grep -c lmv_stripe_count)
4609 [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
4610 error "$LFS getdirstripe --recursive: found $dircnt, \
4611 not $((NUMDIRS + 1))"
4613 run_test 56b "check $LFS getdirstripe"
4617 local ost_name=$(ostname_from_index $ost_idx)
4619 local old_status=$(ost_dev_status $ost_idx)
4620 [[ -z "$old_status" ]] ||
4621 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4623 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4626 local new_status=$(ost_dev_status $ost_idx)
4627 [[ "$new_status" = "D" ]] ||
4628 error "OST $ost_name is in status of '$new_status', not 'D'"
4630 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4633 new_status=$(ost_dev_status $ost_idx)
4634 [[ -z "$new_status" ]] ||
4635 error "OST $ost_name is in status of '$new_status', not ''"
4637 run_test 56c "check 'lfs df' showing device status"
4642 local LOCAL_NUMFILES="$1"
4643 local LOCAL_NUMDIRS="$2"
4644 local MKDIR_PARAMS="$3"
4645 local DIR_STRIPE_PARAMS="$4"
4647 if [ ! -d "$TDIR" ] ; then
4648 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4649 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4650 for i in `seq 1 $LOCAL_NUMFILES` ; do
4653 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4654 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4655 for j in `seq 1 $LOCAL_NUMFILES` ; do
4656 touch $TDIR/dir$i/file$j
4662 setup_56_special() {
4666 if [ ! -e "$TDIR/loop1b" ] ; then
4667 for i in `seq 1 $LOCAL_NUMFILES` ; do
4668 mknod $TDIR/loop${i}b b 7 $i
4669 mknod $TDIR/null${i}c c 1 3
4670 ln -s $TDIR/file1 $TDIR/link${i}l
4672 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4673 mknod $TDIR/dir$i/loop${i}b b 7 $i
4674 mknod $TDIR/dir$i/null${i}c c 1 3
4675 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4684 setup_56 $NUMFILES $NUMDIRS
4686 EXPECTED=$(($NUMDIRS + 2))
4687 # test lfs find with -name
4688 for i in $(seq 1 $NUMFILES) ; do
4689 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4690 [ $NUMS -eq $EXPECTED ] ||
4691 error "lfs find -name \"*$i\" $TDIR wrong: "\
4692 "found $NUMS, expected $EXPECTED"
4695 run_test 56g "check lfs find -name ============================="
4701 setup_56 $NUMFILES $NUMDIRS
4703 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4704 # test lfs find with ! -name
4705 for i in $(seq 1 $NUMFILES) ; do
4706 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4707 [ $NUMS -eq $EXPECTED ] ||
4708 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4709 "found $NUMS, expected $EXPECTED"
4712 run_test 56h "check lfs find ! -name ============================="
4716 test_mkdir -p $DIR/$tdir
4717 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4718 CMD="$LFIND -ost $UUID $DIR/$tdir"
4720 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4722 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4726 setup_56_special $NUMFILES $NUMDIRS
4728 EXPECTED=$((NUMDIRS + 1))
4729 CMD="$LFIND -type d $TDIR"
4730 NUMS=$($CMD | wc -l)
4731 [ $NUMS -eq $EXPECTED ] ||
4732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4734 run_test 56j "check lfs find -type d ============================="
4738 setup_56_special $NUMFILES $NUMDIRS
4740 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4741 CMD="$LFIND -type f $TDIR"
4742 NUMS=$($CMD | wc -l)
4743 [ $NUMS -eq $EXPECTED ] ||
4744 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4746 run_test 56k "check lfs find -type f ============================="
4750 setup_56_special $NUMFILES $NUMDIRS
4752 EXPECTED=$((NUMDIRS + NUMFILES))
4753 CMD="$LFIND -type b $TDIR"
4754 NUMS=$($CMD | wc -l)
4755 [ $NUMS -eq $EXPECTED ] ||
4756 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4758 run_test 56l "check lfs find -type b ============================="
4762 setup_56_special $NUMFILES $NUMDIRS
4764 EXPECTED=$((NUMDIRS + NUMFILES))
4765 CMD="$LFIND -type c $TDIR"
4766 NUMS=$($CMD | wc -l)
4767 [ $NUMS -eq $EXPECTED ] ||
4768 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4770 run_test 56m "check lfs find -type c ============================="
4774 setup_56_special $NUMFILES $NUMDIRS
4776 EXPECTED=$((NUMDIRS + NUMFILES))
4777 CMD="$LFIND -type l $TDIR"
4778 NUMS=$($CMD | wc -l)
4779 [ $NUMS -eq $EXPECTED ] ||
4780 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4782 run_test 56n "check lfs find -type l ============================="
4786 setup_56 $NUMFILES $NUMDIRS
4787 utime $TDIR/file1 > /dev/null || error "utime (1)"
4788 utime $TDIR/file2 > /dev/null || error "utime (2)"
4789 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4790 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4791 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4792 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4795 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4796 [ $NUMS -eq $EXPECTED ] || \
4797 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4800 CMD="$LFIND -mtime 0 $TDIR"
4801 NUMS=$($CMD | wc -l)
4802 [ $NUMS -eq $EXPECTED ] ||
4803 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4805 run_test 56o "check lfs find -mtime for old files =========================="
4808 [ $RUNAS_ID -eq $UID ] &&
4809 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4812 setup_56 $NUMFILES $NUMDIRS
4814 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4816 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4817 NUMS=$($CMD | wc -l)
4818 [ $NUMS -eq $EXPECTED ] || \
4819 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4821 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4822 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4823 NUMS=$($CMD | wc -l)
4824 [ $NUMS -eq $EXPECTED ] || \
4825 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4827 run_test 56p "check lfs find -uid and ! -uid ==============================="
4830 [ $RUNAS_ID -eq $UID ] &&
4831 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4834 setup_56 $NUMFILES $NUMDIRS
4836 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4839 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4840 NUMS=$($CMD | wc -l)
4841 [ $NUMS -eq $EXPECTED ] ||
4842 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4844 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4845 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4846 NUMS=$($CMD | wc -l)
4847 [ $NUMS -eq $EXPECTED ] ||
4848 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4850 run_test 56q "check lfs find -gid and ! -gid ==============================="
4854 setup_56 $NUMFILES $NUMDIRS
4857 CMD="$LFIND -size 0 -type f $TDIR"
4858 NUMS=$($CMD | wc -l)
4859 [ $NUMS -eq $EXPECTED ] ||
4860 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4862 CMD="$LFIND ! -size 0 -type f $TDIR"
4863 NUMS=$($CMD | wc -l)
4864 [ $NUMS -eq $EXPECTED ] ||
4865 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4866 echo "test" > $TDIR/$tfile
4867 echo "test2" > $TDIR/$tfile.2 && sync
4869 CMD="$LFIND -size 5 -type f $TDIR"
4870 NUMS=$($CMD | wc -l)
4871 [ $NUMS -eq $EXPECTED ] ||
4872 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4874 CMD="$LFIND -size +5 -type f $TDIR"
4875 NUMS=$($CMD | wc -l)
4876 [ $NUMS -eq $EXPECTED ] ||
4877 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4879 CMD="$LFIND -size +0 -type f $TDIR"
4880 NUMS=$($CMD | wc -l)
4881 [ $NUMS -eq $EXPECTED ] ||
4882 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4884 CMD="$LFIND ! -size -5 -type f $TDIR"
4885 NUMS=$($CMD | wc -l)
4886 [ $NUMS -eq $EXPECTED ] ||
4887 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4889 CMD="$LFIND -size -5 -type f $TDIR"
4890 NUMS=$($CMD | wc -l)
4891 [ $NUMS -eq $EXPECTED ] ||
4892 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4894 run_test 56r "check lfs find -size works =========================="
4896 test_56s() { # LU-611
4901 for i in $(seq 1 $NUMDIRS); do
4902 $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile
4905 CMD="$LFIND -c $OSTCOUNT $TDIR"
4906 NUMS=$($CMD | wc -l)
4907 [ $NUMS -eq $EXPECTED ] || {
4909 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4913 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4914 if [[ $OSTCOUNT -gt 1 ]]; then
4915 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4919 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4923 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4924 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4925 NUMS=$($CMD | wc -l)
4926 [ $NUMS -eq $EXPECTED ] || {
4928 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4931 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4932 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4933 NUMS=$($CMD | wc -l)
4934 [ $NUMS -eq $EXPECTED ] || {
4936 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4940 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4941 NUMS=$($CMD | wc -l)
4942 [ $NUMS -eq $EXPECTED ] || {
4944 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4947 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4948 NUMS=$($CMD | wc -l)
4949 [ $NUMS -eq $EXPECTED ] || {
4951 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4955 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4956 NUMS=$($CMD | wc -l)
4957 [ $NUMS -eq $EXPECTED ] || {
4959 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4962 run_test 56s "check lfs find -stripe-count works"
4964 test_56t() { # LU-611
4969 for i in $(seq 1 $NUMDIRS); do
4970 $SETSTRIPE -S 4M $TDIR/dir$i/$tfile
4973 CMD="$LFIND -S 4M $TDIR"
4974 NUMS=$($CMD | wc -l)
4975 [ $NUMS -eq $EXPECTED ] || {
4977 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4981 setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
4983 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4985 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4986 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4987 NUMS=$($CMD | wc -l)
4988 [ $NUMS -eq $EXPECTED ] ||
4989 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4991 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4992 NUMS=$($CMD | wc -l)
4993 [ $NUMS -eq $EXPECTED ] ||
4994 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4996 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4997 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4998 NUMS=$($CMD | wc -l)
4999 [ $NUMS -eq $EXPECTED ] ||
5000 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5002 CMD="$LFIND -stripe-size -640k -type f $TDIR"
5003 NUMS=$($CMD | wc -l)
5004 [ $NUMS -eq $EXPECTED ] ||
5005 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5008 CMD="$LFIND -stripe-size 256k -type f $TDIR"
5009 NUMS=$($CMD | wc -l)
5010 [ $NUMS -eq $EXPECTED ] ||
5011 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5013 CMD="$LFIND -stripe-size -320k -type f $TDIR"
5014 NUMS=$($CMD | wc -l)
5015 [ $NUMS -eq $EXPECTED ] ||
5016 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5019 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
5020 NUMS=$($CMD | wc -l)
5021 [ $NUMS -eq $EXPECTED ] ||
5022 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5024 run_test 56t "check lfs find -stripe-size works"
5026 test_56u() { # LU-611
5028 setup_56 $NUMFILES $NUMDIRS "-i 0"
5030 if [[ $OSTCOUNT -gt 1 ]]; then
5031 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
5037 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
5038 CMD="$LFIND -stripe-index 0 -type f $TDIR"
5039 NUMS=$($CMD | wc -l)
5040 [ $NUMS -eq $EXPECTED ] ||
5041 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5044 CMD="$LFIND -stripe-index 1 -type f $TDIR"
5045 NUMS=$($CMD | wc -l)
5046 [ $NUMS -eq $EXPECTED ] ||
5047 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5049 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
5050 NUMS=$($CMD | wc -l)
5051 [ $NUMS -eq $EXPECTED ] ||
5052 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5055 # This should produce an error and not return any files
5056 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
5057 NUMS=$($CMD 2>/dev/null | wc -l)
5058 [ $NUMS -eq $EXPECTED ] ||
5059 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5061 if [[ $OSTCOUNT -gt 1 ]]; then
5062 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
5063 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
5064 NUMS=$($CMD | wc -l)
5065 [ $NUMS -eq $EXPECTED ] ||
5066 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5069 run_test 56u "check lfs find -stripe-index works"
5076 setup_56 $NUMFILES $NUMDIRS
5078 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
5079 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
5081 for file in $($LFIND -mdt $UUID $TDIR); do
5082 file_mdt_idx=$($GETSTRIPE -M $file)
5083 [ $file_mdt_idx -eq $MDT_IDX ] ||
5084 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
5087 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5090 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5094 rm -rf $TDIR || error "remove $TDIR failed"
5095 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5098 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
5099 error "$GETSTRIPE -S -d $TDIR failed"
5100 stripe_size=${stripe_size%% *}
5102 local file_size=$((stripe_size * OSTCOUNT))
5103 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5104 local required_space=$((file_num * file_size))
5106 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5108 [[ $free_space -le $((required_space / 1024)) ]] &&
5109 skip_env "need $required_space bytes, have $free_space KB" &&
5113 local dd_count=$((file_size / dd_bs))
5115 # write data into the files
5119 for i in $(seq 1 $NUMFILES); do
5121 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5122 error "write data into $file failed"
5124 for i in $(seq 1 $NUMDIRS); do
5125 for j in $(seq 1 $NUMFILES); do
5126 file=$TDIR/dir$i/file$j
5127 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5128 error "write data into $file failed"
5132 # $LFS_MIGRATE will fail if hard link migration is unsupported
5133 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5134 createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 ||
5135 error "creating links to $TDIR/dir1/file1 failed"
5139 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5142 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
5144 eval $cmd || error "$cmd failed"
5146 check_stripe_count $TDIR/file1 $expected
5148 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5150 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5151 # OST 1 if it is on OST 0. This file is small enough to
5152 # be on only one stripe.
5153 file=$TDIR/migr_1_ost
5154 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5155 error "write data into $file failed"
5156 local obdidx=$($LFS getstripe -i $file)
5157 local oldmd5=$(md5sum $file)
5159 [[ $obdidx -eq 0 ]] && newobdidx=1
5160 cmd="$LFS migrate -i $newobdidx $file"
5162 eval $cmd || error "$cmd failed"
5163 local realobdix=$($LFS getstripe -i $file)
5164 local newmd5=$(md5sum $file)
5165 [[ $newobdidx -ne $realobdix ]] &&
5166 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
5167 [[ "$oldmd5" != "$newmd5" ]] &&
5168 error "md5sum differ: $oldmd5, $newmd5"
5172 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
5174 eval $cmd || error "$cmd failed"
5176 for j in $(seq 1 $NUMFILES); do
5177 check_stripe_count $TDIR/dir1/file$j $expected
5180 # lfs_migrate works with lfs find
5181 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
5182 $LFS_MIGRATE -y -c $expected"
5184 eval $cmd || error "$cmd failed"
5186 for i in $(seq 2 $NUMFILES); do
5187 check_stripe_count $TDIR/file$i $expected
5189 for i in $(seq 2 $NUMDIRS); do
5190 for j in $(seq 1 $NUMFILES); do
5191 check_stripe_count $TDIR/dir$i/file$j $expected
5195 run_test 56w "check lfs_migrate -c stripe_count works"
5198 check_swap_layouts_support && return 0
5199 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5201 local dir0=$DIR/$tdir
5202 local ref1=/etc/passwd
5203 local file1=$dir0/file1
5205 test_mkdir $dir0 || error "creating dir $dir0"
5206 $LFS setstripe -c 2 $file1
5208 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5209 stripe=$($LFS getstripe -c $file1)
5210 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5211 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5216 run_test 56x "lfs migration support"
5219 check_swap_layouts_support && return 0
5220 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5222 local dir0=$DIR/$tdir/$testnum
5223 test_mkdir -p $dir0 || error "creating dir $dir0"
5225 local ref1=/etc/passwd
5226 local file1=$dir0/file1
5228 $LFS setstripe -c 2 $file1
5230 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5231 local stripe=$($LFS getstripe -c $file1)
5232 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5233 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5238 run_test 56xa "lfs migration --block support"
5240 check_migrate_links() {
5242 local file1="$dir/file1"
5245 local total_count=$(($begin + $count - 1))
5246 local symlink_count=10
5249 if [ ! -f "$file1" ]; then
5250 echo -n "creating initial file..."
5251 $LFS setstripe -c 1 -S "512k" "$file1" ||
5252 error "cannot setstripe initial file"
5255 echo -n "creating symlinks..."
5256 for s in $(seq 1 $symlink_count); do
5257 ln -s "$file1" "$dir/slink$s" ||
5258 error "cannot create symlinks"
5262 echo -n "creating nonlinked files..."
5263 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5264 error "cannot create nonlinked files"
5269 if [ ! -f "$dir/file$total_count" ]; then
5270 echo -n "creating hard links $begin:$total_count..."
5271 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5272 /dev/null || error "cannot create hard links"
5276 echo -n "checking number of hard links listed in xattrs..."
5277 local fid=$($LFS getstripe -F "$file1")
5278 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5281 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5282 echo "hard link list has unexpected size, skipping test"
5285 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5286 error "link names should exceed xattrs size"
5289 echo -n "migrating files..."
5290 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5292 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5295 # make sure all links have been properly migrated
5296 echo -n "verifying files..."
5297 fid=$($LFS getstripe -F "$file1") ||
5298 error "cannot get fid for file $file1"
5299 for i in $(seq 2 $total_count); do
5300 local fid2=$($LFS getstripe -F $dir/file$i)
5301 [ "$fid2" == "$fid" ] ||
5302 error "migrated hard link has mismatched FID"
5305 # make sure hard links were properly detected, and migration was
5306 # performed only once for the entire link set; nonlinked files should
5308 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5309 local expected=$(($uniq_count + 1))
5310 [ "$actual" -eq "$expected" ] ||
5311 error "hard links individually migrated ($actual != $expected)"
5313 # make sure the correct number of hard links are present
5314 local hardlinks=$(stat -c '%h' "$file1")
5315 [ $hardlinks -eq $total_count ] ||
5316 error "num hard links $hardlinks != $total_count"
5323 local dir0="$DIR/$tdir"
5325 test_mkdir "$dir0" || error "cannot create dir $dir0"
5327 echo "testing lfs migrate mode when all links fit within xattrs"
5328 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 2 99
5330 echo "testing rsync mode when all links fit within xattrs"
5331 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 2 99
5333 echo "testing lfs migrate mode when all links do not fit within xattrs"
5334 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 101 100
5336 echo "testing rsync mode when all links do not fit within xattrs"
5337 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 101 100
5342 run_test 56xb "lfs migration hard link support"
5345 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5346 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5350 local dir0=$DIR/$tdir/$testnum
5351 test_mkdir -p $dir0 || error "creating dir $dir0"
5352 local f1=$dir0/file1
5353 local f2=$dir0/file2
5355 touch $f1 || error "creating std file $f1"
5356 $MULTIOP $f2 H2c || error "creating released file $f2"
5358 # a directory can be raid0, so ask only for files
5359 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5360 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5362 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5363 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5365 # only files can be released, so no need to force file search
5366 res=$($LFIND $dir0 -L released)
5367 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5369 res=$($LFIND $dir0 \! -L released)
5370 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5373 run_test 56y "lfs find -L raid0|released"
5375 test_56z() { # LU-4824
5376 # This checks to make sure 'lfs find' continues after errors
5377 # There are two classes of errors that should be caught:
5378 # - If multiple paths are provided, all should be searched even if one
5380 # - If errors are encountered during the search, it should not terminate
5383 test_mkdir $DIR/$tdir
5384 for i in d{0..9}; do
5385 test_mkdir $DIR/$tdir/$i
5387 touch $DIR/$tdir/d{0..9}/$tfile
5388 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5389 error "$LFS find did not return an error"
5390 # Make a directory unsearchable. This should NOT be the last entry in
5391 # directory order. Arbitrarily pick the 6th entry
5392 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5393 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5394 # The user should be able to see 10 directories and 9 files
5395 [ $count == 19 ] || error "$LFS find did not continue after error"
5397 run_test 56z "lfs find should continue after an error"
5399 test_56aa() { # LU-5937
5400 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5403 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5405 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5406 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5408 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5410 run_test 56aa "lfs find --size under striped dir"
5413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5414 # note test will not do anything if MDS is not local
5415 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5416 skip "ldiskfs only test"
5420 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5421 local MNTDEV="osd*.*MDT*.mntdev"
5422 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5423 [ -z "$DEV" ] && error "can't access $MNTDEV"
5424 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5425 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5426 error "can't access $DEV"
5427 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5428 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5432 run_test 57a "verify MDS filesystem created with large inodes =="
5435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5436 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5437 skip "ldiskfs only test"
5441 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5442 local dir=$DIR/$tdir
5446 local FILEN=$dir/f$FILECOUNT
5448 rm -rf $dir || error "removing $dir"
5449 test_mkdir -p -c1 $dir || error "creating $dir"
5450 local mdtidx=$($LFS getstripe -M $dir)
5451 local mdtname=MDT$(printf %04x $mdtidx)
5452 local facet=mds$((mdtidx + 1))
5454 echo "mcreating $FILECOUNT files"
5455 createmany -m $dir/f 1 $FILECOUNT || \
5456 error "creating files in $dir"
5458 # verify that files do not have EAs yet
5459 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5460 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5464 df $dir #make sure we get new statfs data
5465 local MDSFREE=$(do_facet $facet \
5466 lctl get_param -n osd*.*$mdtname.kbytesfree)
5467 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5468 echo "opening files to create objects/EAs"
5470 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5471 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5474 # verify that files have EAs now
5475 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5476 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5478 sleep 1 #make sure we get new statfs data
5480 local MDSFREE2=$(do_facet $facet \
5481 lctl get_param -n osd*.*$mdtname.kbytesfree)
5482 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5483 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5484 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5485 error "MDC before $MDCFREE != after $MDCFREE2"
5487 echo "MDC before $MDCFREE != after $MDCFREE2"
5488 echo "unable to confirm if MDS has large inodes"
5493 run_test 57b "default LOV EAs are stored inside large inodes ==="
5496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5497 [ -z "$(which wiretest 2>/dev/null)" ] &&
5498 skip_env "could not find wiretest" && return
5501 run_test 58 "verify cross-platform wire constants =============="
5504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5505 echo "touch 130 files"
5506 createmany -o $DIR/f59- 130
5508 unlinkmany $DIR/f59- 130
5510 # wait for commitment of removal
5511 wait_delete_completed
5513 run_test 59 "verify cancellation of llog records async ========="
5515 TEST60_HEAD="test_60 run $RANDOM"
5517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5518 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5519 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5520 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5521 skip_env "missing subtest run-llog.sh" && return
5523 log "$TEST60_HEAD - from kernel mode"
5524 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5525 do_facet mgs sh run-llog.sh
5526 do_facet mgs $LCTL dk > $TMP/$tfile
5528 # LU-6388: test llog_reader
5529 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5530 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5531 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5532 skip_env "missing llog_reader" && return
5533 local fstype=$(facet_fstype mgs)
5534 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5535 skip_env "Only for ldiskfs or zfs type mgs" && return
5537 local mntpt=$(facet_mntpt mgs)
5538 local mgsdev=$(mgsdevname 1)
5550 #get fid and record list
5551 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5553 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5555 #remount mgs as ldiskfs or zfs type
5556 stop mgs || error "stop mgs failed"
5557 mount_fstype mgs || error "remount mgs failed"
5558 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5561 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5562 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5567 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5569 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5571 echo "obj_file is $obj_file"
5572 do_facet mgs $llog_reader $obj_file
5574 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5575 awk '{ print $3 }' | sed -e "s/^type=//g")
5576 if [ $rec_type != $rec ]; then
5577 echo "FAILED test_60a wrong record type $rec_type," \
5583 #check obj path if record type is LLOG_LOGID_MAGIC
5584 if [ "$rec" == "1064553b" ]; then
5585 path=$(do_facet mgs $llog_reader $obj_file |
5586 grep "path=" | awk '{ print $NF }' |
5587 sed -e "s/^path=//g")
5588 if [ $obj_file != $mntpt/$path ]; then
5589 echo "FAILED test_60a wrong obj path" \
5590 "$montpt/$path, should be $obj_file"
5597 #restart mgs before "error", otherwise it will block the next test
5598 stop mgs || error "stop mgs failed"
5599 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5600 $pass || error "test failed, see FAILED test_60a messages for specifics"
5602 run_test 60a "llog_test run from kernel module and test llog_reader"
5605 # test old logid format
5606 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5607 do_facet mgs $LCTL dl | grep MGS
5608 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5609 error "old llog_print failed"
5612 # test new logid format
5613 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5614 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5615 error "new llog_print failed"
5618 run_test 60aa "llog_print works with FIDs and simple names"
5620 test_60b() { # bug 6411
5621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5623 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5635 [[ $LLOG_COUNT -gt 100 ]] &&
5636 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5638 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5642 echo "create 5000 files"
5643 createmany -o $DIR/f60c- 5000
5644 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5645 lctl set_param fail_loc=0x80000137
5646 unlinkmany $DIR/f60c- 5000
5647 lctl set_param fail_loc=0
5649 run_test 60c "unlink file when mds full"
5652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5653 SAVEPRINTK=$(lctl get_param -n printk)
5655 # verify "lctl mark" is even working"
5656 MESSAGE="test message ID $RANDOM $$"
5657 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5658 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5660 lctl set_param printk=0 || error "set lnet.printk failed"
5661 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5662 MESSAGE="new test message ID $RANDOM $$"
5663 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5664 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5665 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5667 lctl set_param -n printk="$SAVEPRINTK"
5669 run_test 60d "test printk console message masking"
5672 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5673 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5675 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5676 do_facet mds1 lctl set_param fail_loc=0x15b
5679 run_test 60e "no space while new llog is being created"
5682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5684 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5685 cancel_lru_locks osc
5686 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5689 run_test 61 "mmap() writes don't make sync hang ================"
5691 # bug 2330 - insufficient obd_match error checking causes LBUG
5693 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5696 cancel_lru_locks osc
5697 lctl set_param fail_loc=0x405
5698 cat $f && error "cat succeeded, expect -EIO"
5699 lctl set_param fail_loc=0
5701 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5702 # match every page all of the time.
5703 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5705 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5706 # Though this test is irrelevant anymore, it helped to reveal some
5707 # other grant bugs (LU-4482), let's keep it.
5708 test_63a() { # was test_63
5709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5710 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5711 for i in `seq 10` ; do
5712 dd if=/dev/zero of=$DIR/f63 bs=8k &
5718 rm -f $DIR/f63 || true
5720 run_test 63a "Verify oig_wait interruption does not crash ======="
5722 # bug 2248 - async write errors didn't return to application on sync
5723 # bug 3677 - async write errors left page locked
5725 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5727 lctl set_param debug=-1
5729 # ensure we have a grant to do async writes
5730 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5733 sync # sync lest earlier test intercept the fail_loc
5735 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5736 lctl set_param fail_loc=0x80000406
5737 $MULTIOP $DIR/$tfile Owy && \
5738 error "sync didn't return ENOMEM"
5739 sync; sleep 2; sync # do a real sync this time to flush page
5740 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5741 error "locked page left in cache after async error" || true
5744 run_test 63b "async write errors should be returned to fsync ==="
5747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5749 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5751 run_test 64a "verify filter grant calculations (in kernel) ====="
5754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5755 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5757 run_test 64b "check out-of-space detection on client ==========="
5760 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5762 run_test 64c "verify grant shrink ========================------"
5764 # bug 1414 - set/get directories' stripe info
5766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5767 test_mkdir -p $DIR/$tdir
5769 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5771 run_test 65a "directory with no stripe info ===================="
5774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5775 test_mkdir -p $DIR/$tdir
5776 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5778 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5781 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5783 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5787 if [[ $OSTCOUNT -gt 1 ]]; then
5788 test_mkdir -p $DIR/$tdir
5789 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5791 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5792 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5794 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5797 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5800 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5801 test_mkdir -p $DIR/$tdir
5802 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5803 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5805 if [[ $STRIPECOUNT -le 0 ]]; then
5807 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5808 #LOV_MAX_STRIPE_COUNT is 2000
5809 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5811 sc=$(($STRIPECOUNT - 1))
5813 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5814 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5815 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5816 error "lverify failed"
5818 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5822 test_mkdir -p $DIR/$tdir
5824 $SETSTRIPE $DIR/$tdir || error "setstripe"
5825 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5826 error "no stripe info failed"
5828 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5830 run_test 65e "directory setstripe defaults ======================="
5833 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5834 test_mkdir -p $DIR/${tdir}f
5835 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5837 run_test 65f "dir setstripe permission (should return error) ==="
5840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5841 test_mkdir -p $DIR/$tdir
5842 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5844 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5846 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5847 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5848 error "delete default stripe failed"
5850 run_test 65g "directory setstripe -d ==========================="
5853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5854 test_mkdir -p $DIR/$tdir
5855 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5857 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5859 test_mkdir -p $DIR/$tdir/dd1
5860 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5861 error "stripe info inherit failed"
5863 run_test 65h "directory stripe info inherit ===================="
5865 test_65i() { # bug6367
5866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5867 $SETSTRIPE -S 65536 -c -1 $MOUNT
5869 run_test 65i "set non-default striping on root directory (bug 6367)="
5871 test_65ia() { # bug12836
5872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5873 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5875 run_test 65ia "getstripe on -1 default directory striping"
5877 test_65ib() { # bug12836
5878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5879 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5881 run_test 65ib "getstripe -v on -1 default directory striping"
5883 test_65ic() { # bug12836
5884 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5885 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5887 run_test 65ic "new find on -1 default directory striping"
5889 test_65j() { # bug6367
5890 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5892 # if we aren't already remounting for each test, do so for this test
5893 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5894 cleanup || error "failed to unmount"
5897 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5899 run_test 65j "set default striping on root directory (bug 6367)="
5901 test_65k() { # bug11679
5902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5903 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5904 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5906 local disable_precreate=true
5907 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
5908 disable_precreate=false
5910 echo "Check OST status: "
5911 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
5912 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
5914 for OSC in $MDS_OSCS; do
5915 echo $OSC "is active"
5916 do_facet $SINGLEMDS lctl --device %$OSC activate
5919 for INACTIVE_OSC in $MDS_OSCS; do
5920 local ost=$(osc_to_ost $INACTIVE_OSC)
5921 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
5922 lov.*md*.target_obd |
5923 awk -F: /$ost/'{ print $1 }' | head -n 1)
5926 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
5927 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
5929 echo "Deactivate: " $INACTIVE_OSC
5930 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5932 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
5933 osp.$ost*MDT0000.create_count")
5934 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
5935 osp.$ost*MDT0000.max_create_count")
5936 $disable_precreate &&
5937 do_facet $SINGLEMDS "lctl set_param -n \
5938 osp.$ost*MDT0000.max_create_count=0"
5940 for idx in $(seq 0 $((OSTCOUNT - 1))); do
5941 [ -f $DIR/$tdir/$idx ] && continue
5942 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
5943 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
5944 error "setstripe $idx should succeed"
5945 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
5947 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
5950 do_facet $SINGLEMDS "lctl set_param -n \
5951 osp.$ost*MDT0000.max_create_count=$max_count"
5952 do_facet $SINGLEMDS "lctl set_param -n \
5953 osp.$ost*MDT0000.create_count=$count"
5954 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5955 echo $INACTIVE_OSC "is Activate"
5957 wait_osc_import_state mds ost$ostnum FULL
5960 run_test 65k "validate manual striping works properly with deactivated OSCs"
5962 test_65l() { # bug 12836
5963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5964 test_mkdir -p $DIR/$tdir/test_dir
5965 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5966 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5968 run_test 65l "lfs find on -1 stripe dir ========================"
5971 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
5974 run_test 65m "normal user can't set filesystem default stripe"
5976 # bug 2543 - update blocks count on client
5978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5980 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5981 sync; sync_all_data; sync; sync_all_data
5982 cancel_lru_locks osc
5983 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5984 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5986 run_test 66 "update inode blocks count on client ==============="
5989 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5993 swapon -s | awk '($1 == "'$1'") { print $4 }'
5996 # bug5265, obdfilter oa2dentry return -ENOENT
5997 # #define OBD_FAIL_SRV_ENOENT 0x217
5999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6000 remote_ost_nodsh && skip "remote OST with nodsh" && return
6003 $SETSTRIPE -c 1 -i 0 $f
6005 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6007 do_facet ost1 lctl set_param fail_loc=0x217
6008 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6009 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6011 do_facet ost1 lctl set_param fail_loc=0
6012 $DIRECTIO write $f 0 2 || error "write error"
6014 cancel_lru_locks osc
6015 $DIRECTIO read $f 0 1 || error "read error"
6017 do_facet ost1 lctl set_param fail_loc=0x217
6018 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6020 do_facet ost1 lctl set_param fail_loc=0
6023 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6026 test_mkdir -p $DIR/$tdir
6027 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6028 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6030 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6032 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6034 [ "$RUNAS_ID" = "$UID" ] &&
6035 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6037 # Check that testing environment is properly set up. Skip if not
6038 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
6039 skip_env "User $RUNAS_ID does not exist - skipping"
6043 chmod 777 $DIR/$tfile
6044 chmod ug+s $DIR/$tfile
6045 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6046 error "$RUNAS dd $DIR/$tfile failed"
6047 # See if we are still setuid/sgid
6048 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6049 error "S/gid is not dropped on write"
6050 # Now test that MDS is updated too
6051 cancel_lru_locks mdc
6052 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6053 error "S/gid is not dropped on MDS"
6056 run_test 72a "Test that remove suid works properly (bug5695) ===="
6058 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6061 [ "$RUNAS_ID" = "$UID" ] && \
6062 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6063 [ "$RUNAS_ID" -eq 0 ] && \
6064 skip_env "RUNAS_ID = 0 -- skipping" && return
6066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6067 # Check that testing environment is properly set up. Skip if not
6068 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
6069 skip_env "User $RUNAS_ID does not exist - skipping"
6072 touch $DIR/${tfile}-f{g,u}
6073 test_mkdir $DIR/${tfile}-dg
6074 test_mkdir $DIR/${tfile}-du
6075 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6076 chmod g+s $DIR/${tfile}-{f,d}g
6077 chmod u+s $DIR/${tfile}-{f,d}u
6078 for perm in 777 2777 4777; do
6079 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6080 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6081 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6082 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6086 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6088 # bug 3462 - multiple simultaneous MDC requests
6090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6091 test_mkdir $DIR/d73-1
6092 test_mkdir $DIR/d73-2
6093 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6096 lctl set_param fail_loc=0x80000129
6097 $MULTIOP $DIR/d73-1/f73-2 Oc &
6099 lctl set_param fail_loc=0
6101 $MULTIOP $DIR/d73-2/f73-3 Oc &
6105 wait $pid1 || return 1
6109 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6110 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6111 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6115 run_test 73 "multiple MDC requests (should not deadlock)"
6117 test_74a() { # bug 6149, 6184
6118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6119 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6121 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6122 # will spin in a tight reconnection loop
6124 $LCTL set_param fail_loc=0x8000030e
6125 # get any lock that won't be difficult - lookup works.
6127 $LCTL set_param fail_loc=0
6131 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6133 test_74b() { # bug 13310
6134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6135 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6137 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6138 # will spin in a tight reconnection loop
6139 $LCTL set_param fail_loc=0x8000030e
6140 # get a "difficult" lock
6142 $LCTL set_param fail_loc=0
6146 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6150 #define OBD_FAIL_LDLM_NEW_LOCK
6151 $LCTL set_param fail_loc=0x319
6152 touch $DIR/$tfile && error "touch successful"
6153 $LCTL set_param fail_loc=0
6156 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6159 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6162 test_76() { # Now for bug 20433, added originally in bug 1443
6163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6164 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6165 cancel_lru_locks osc
6166 BEFORE_INODES=$(num_inodes)
6167 echo "before inodes: $BEFORE_INODES"
6169 [ "$SLOW" = "no" ] && COUNT=100
6170 for i in $(seq $COUNT); do
6174 cancel_lru_locks osc
6175 AFTER_INODES=$(num_inodes)
6176 echo "after inodes: $AFTER_INODES"
6178 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6180 AFTER_INODES=$(num_inodes)
6182 echo "wait $wait seconds inodes: $AFTER_INODES"
6183 if [ $wait -gt 30 ]; then
6184 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6188 run_test 76 "confirm clients recycle inodes properly ===="
6194 # Note: in sptlrpc modes which enable its own bulk checksum, the
6195 # original crc32_le bulk checksum will be automatically disabled,
6196 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6197 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6198 # In this case set_checksums() will not be no-op, because sptlrpc
6199 # bulk checksum will be enabled all through the test.
6201 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6202 lctl set_param -n osc.*.checksums $1
6206 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6207 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6208 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6209 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6212 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6213 log "set checksum type to $1"
6216 F77_TMP=$TMP/f77-temp
6219 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6220 error "error writing to $F77_TMP"
6223 test_77a() { # bug 10889
6224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6225 $GSS && skip "could not run with gss" && return
6226 [ ! -f $F77_TMP ] && setup_f77
6228 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6232 run_test 77a "normal checksum read/write operation"
6234 test_77b() { # bug 10889
6235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6236 $GSS && skip "could not run with gss" && return
6237 [ ! -f $F77_TMP ] && setup_f77
6238 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6239 $LCTL set_param fail_loc=0x80000409
6242 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6243 error "dd error: $?"
6244 $LCTL set_param fail_loc=0
6246 for algo in $CKSUM_TYPES; do
6247 cancel_lru_locks osc
6248 set_checksum_type $algo
6249 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6250 $LCTL set_param fail_loc=0x80000408
6251 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6252 $LCTL set_param fail_loc=0
6255 set_checksum_type $ORIG_CSUM_TYPE
6258 run_test 77b "checksum error on client write, read"
6263 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6265 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6266 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6267 $check_ost && [ -n $ost_file_prefix ] &&
6268 do_facet ost1 rm -f ${ost_file_prefix}\*
6272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6273 $GSS && skip "could not run with gss" && return
6276 local osc_file_prefix
6278 local check_ost=false
6279 local ost_file_prefix
6285 # ensure corruption will occur on first OSS/OST
6286 $LFS setstripe -i 0 $DIR/$tfile
6288 [ ! -f $F77_TMP ] && setup_f77
6289 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6290 error "dd write error: $?"
6291 fid=$($LFS path2fid $DIR/$tfile)
6293 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6296 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6297 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6299 echo "OSS do not support bulk pages dump upon error"
6302 osc_file_prefix=$($LCTL get_param -n debug_path)
6303 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6305 trap cleanup_77c EXIT
6308 # enable bulk pages dump upon error on Client
6309 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6310 # enable bulk pages dump upon error on OSS
6312 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6314 # flush Client cache to allow next read to reach OSS
6315 cancel_lru_locks osc
6317 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6318 $LCTL set_param fail_loc=0x80000408
6319 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6320 $LCTL set_param fail_loc=0
6324 # check cksum dump on Client
6325 osc_file=$(ls ${osc_file_prefix}*)
6326 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6327 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6328 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6329 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6330 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6332 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6333 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6334 error "dump content does not match on Client"
6336 $check_ost || { skip "No need to check cksum dump on OSS"; return 0; }
6338 # check cksum dump on OSS
6339 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6340 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6341 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6342 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6343 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6344 error "dump content does not match on OSS"
6348 run_test 77c "checksum error on client read with debug"
6350 test_77d() { # bug 10889
6351 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6352 $GSS && skip "could not run with gss" && return
6353 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6354 $LCTL set_param fail_loc=0x80000409
6356 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6357 error "direct write: rc=$?"
6358 $LCTL set_param fail_loc=0
6361 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6362 $LCTL set_param fail_loc=0x80000408
6364 cancel_lru_locks osc
6365 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6366 error "direct read: rc=$?"
6367 $LCTL set_param fail_loc=0
6370 run_test 77d "checksum error on OST direct write, read"
6372 test_77f() { # bug 10889
6373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6374 $GSS && skip "could not run with gss" && return
6376 for algo in $CKSUM_TYPES; do
6377 cancel_lru_locks osc
6378 set_checksum_type $algo
6379 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6380 $LCTL set_param fail_loc=0x409
6381 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6382 error "direct write succeeded"
6383 $LCTL set_param fail_loc=0
6385 set_checksum_type $ORIG_CSUM_TYPE
6388 run_test 77f "repeat checksum error on write (expect error)"
6390 test_77g() { # bug 10889
6391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6392 $GSS && skip "could not run with gss" && return
6393 remote_ost_nodsh && skip "remote OST with nodsh" && return
6395 [ ! -f $F77_TMP ] && setup_f77
6397 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6398 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6399 do_facet ost1 lctl set_param fail_loc=0x8000021a
6401 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6402 error "write error: rc=$?"
6403 do_facet ost1 lctl set_param fail_loc=0
6406 cancel_lru_locks osc
6407 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6408 do_facet ost1 lctl set_param fail_loc=0x8000021b
6410 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6411 do_facet ost1 lctl set_param fail_loc=0
6414 run_test 77g "checksum error on OST write, read"
6416 test_77j() { # bug 13805
6417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6418 $GSS && skip "could not run with gss" && return
6419 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6420 lctl set_param fail_loc=0x40c
6421 remount_client $MOUNT
6422 lctl set_param fail_loc=0
6423 # wait async osc connect to finish and reflect updated state value
6425 for (( i=0; i < OSTCOUNT; i++ )) ; do
6426 wait_osc_import_state client ost$((i+1)) FULL
6429 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6430 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6431 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6432 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6434 remount_client $MOUNT
6436 run_test 77j "client only supporting ADLER32"
6438 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6447 test_78() { # bug 10901
6448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6449 remote_ost || { skip_env "local OST" && return; }
6452 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6453 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6454 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6455 echo "MemTotal: $MEMTOTAL"
6457 # reserve 256MB of memory for the kernel and other running processes,
6458 # and then take 1/2 of the remaining memory for the read/write buffers.
6459 if [ $MEMTOTAL -gt 512 ] ;then
6460 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6462 # for those poor memory-starved high-end clusters...
6463 MEMTOTAL=$((MEMTOTAL / 2))
6465 echo "Mem to use for directio: $MEMTOTAL"
6467 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6468 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6469 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6470 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6472 echo "Smallest OST: $SMALLESTOST"
6473 [[ $SMALLESTOST -lt 10240 ]] &&
6474 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6476 trap cleanup_test_78 EXIT
6478 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6479 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6481 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6482 echo "File size: $F78SIZE"
6483 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6484 for i in $(seq 1 $NSEQ); do
6485 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6486 echo directIO rdwr round $i of $NSEQ
6487 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6492 run_test 78 "handle large O_DIRECT writes correctly ============"
6494 test_79() { # bug 12743
6495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6496 wait_delete_completed
6498 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6499 BKFREE=$(calc_osc_kbytes kbytesfree)
6500 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6502 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6503 DFTOTAL=`echo $STRING | cut -d, -f1`
6504 DFUSED=`echo $STRING | cut -d, -f2`
6505 DFAVAIL=`echo $STRING | cut -d, -f3`
6506 DFFREE=$(($DFTOTAL - $DFUSED))
6508 ALLOWANCE=$((64 * $OSTCOUNT))
6510 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6511 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6512 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6514 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6515 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6516 error "df free($DFFREE) mismatch OST free($BKFREE)"
6518 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6519 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6520 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6523 run_test 79 "df report consistency check ======================="
6525 test_80() { # bug 10718
6526 remote_ost_nodsh && skip "remote OST with nodsh" && return
6527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6528 # relax strong synchronous semantics for slow backends like ZFS
6529 local soc="obdfilter.*.sync_on_lock_cancel"
6530 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6532 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6533 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6534 facet_active_host $host; done | sort -u)
6535 do_nodes $hosts lctl set_param $soc=never
6538 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6540 local BEFORE=`date +%s`
6541 cancel_lru_locks osc
6542 local AFTER=`date +%s`
6543 local DIFF=$((AFTER-BEFORE))
6544 if [ $DIFF -gt 1 ] ; then
6545 error "elapsed for 1M@1T = $DIFF"
6548 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6552 run_test 80 "Page eviction is equally fast at high offsets too ===="
6554 test_81a() { # LU-456
6555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6556 remote_ost_nodsh && skip "remote OST with nodsh" && return
6557 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6558 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6559 do_facet ost1 lctl set_param fail_loc=0x80000228
6561 # write should trigger a retry and success
6562 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6563 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6565 if [ $RC -ne 0 ] ; then
6566 error "write should success, but failed for $RC"
6569 run_test 81a "OST should retry write when get -ENOSPC ==============="
6571 test_81b() { # LU-456
6572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6573 remote_ost_nodsh && skip "remote OST with nodsh" && return
6574 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6575 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6576 do_facet ost1 lctl set_param fail_loc=0x228
6578 # write should retry several times and return -ENOSPC finally
6579 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6580 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6583 if [ $RC -ne $ENOSPC ] ; then
6584 error "dd should fail for -ENOSPC, but succeed."
6587 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6589 test_82() { # LU-1031
6590 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6594 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6596 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6598 kill -USR1 $MULTIPID2
6600 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6601 error "First grouplock does not block second one"
6603 echo "Second grouplock blocks first one"
6605 kill -USR1 $MULTIPID1
6609 run_test 82 "Basic grouplock test ==============================="
6612 local sfile="/boot/System.map-$(uname -r)"
6613 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6614 $LCTL set_param fail_loc=0x140d
6615 cp $sfile $DIR/$tfile || error "write failed"
6616 diff -c $sfile $DIR/$tfile || error "files are different"
6617 $LCTL set_param fail_loc=0
6620 run_test 83 "Short write in ptask ==============================="
6623 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6625 test_mkdir -p $DIR/d99cvsroot
6626 chown $RUNAS_ID $DIR/d99cvsroot
6627 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6630 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6633 run_test 99a "cvs init ========================================="
6636 [ -z "$(which cvs 2>/dev/null)" ] &&
6637 skip_env "could not find cvs" && return
6638 [ ! -d $DIR/d99cvsroot ] && test_99a
6640 # some versions of cvs import exit(1) when asked to import links or
6641 # files they can't read. ignore those files.
6642 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6643 ! -perm /4 -printf '-I %f\n')
6644 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6645 d99reposname vtag rtag
6647 run_test 99b "cvs import ======================================="
6650 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6651 [ ! -d $DIR/d99cvsroot ] && test_99b
6653 test_mkdir -p $DIR/d99reposname
6654 chown $RUNAS_ID $DIR/d99reposname
6655 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6657 run_test 99c "cvs checkout ====================================="
6660 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6661 [ ! -d $DIR/d99cvsroot ] && test_99c
6662 cd $DIR/d99reposname
6664 $RUNAS cvs add -m 'addmsg' foo99
6666 run_test 99d "cvs add =========================================="
6669 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6670 [ ! -d $DIR/d99cvsroot ] && test_99c
6671 cd $DIR/d99reposname
6674 run_test 99e "cvs update ======================================="
6677 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6678 [ ! -d $DIR/d99cvsroot ] && test_99d
6679 cd $DIR/d99reposname
6680 $RUNAS cvs commit -m 'nomsg' foo99
6681 rm -fr $DIR/d99cvsroot
6683 run_test 99f "cvs commit ======================================="
6686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6687 [[ "$NETTYPE" =~ tcp ]] ||
6688 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
6691 remote_ost_nodsh && skip "remote OST with nodsh" && return
6692 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6694 { skip "useless for local single node setup" && return; }
6696 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6697 [ "$PROT" != "tcp" ] && continue
6698 RPORT=$(echo $REMOTE | cut -d: -f2)
6699 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6702 LPORT=`echo $LOCAL | cut -d: -f2`
6703 if [ $LPORT -ge 1024 ]; then
6704 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6706 error_exit "local: $LPORT > 1024, remote: $RPORT"
6709 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6711 run_test 100 "check local port using privileged port ==========="
6713 function get_named_value()
6722 echo $line | sed "s/^$tag[ ]*//"
6729 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6730 awk '/^max_cached_mb/ { print $2 }')
6733 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6739 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
6743 local cache_limit=32
6745 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6746 trap cleanup_101a EXIT
6747 $LCTL set_param -n llite.*.read_ahead_stats 0
6748 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6751 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6753 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6754 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6757 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6758 get_named_value 'read but discarded' | cut -d" " -f1); do
6759 discard=$(($discard + $s))
6763 if [[ $(($discard * 10)) -gt $nreads ]]; then
6764 $LCTL get_param osc.*-osc*.rpc_stats
6765 $LCTL get_param llite.*.read_ahead_stats
6766 error "too many ($discard) discarded pages"
6768 rm -f $DIR/$tfile || true
6770 run_test 101a "check read-ahead for random reads ================"
6773 test_mkdir -p $DIR/$tdir
6774 local STRIPE_SIZE=$1
6775 local FILE_LENGTH=$2
6778 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6780 local list=$(comma_list $(osts_nodes))
6781 set_osd_param $list '' read_cache_enable 0
6782 set_osd_param $list '' writethrough_cache_enable 0
6784 trap cleanup_test101bc EXIT
6785 # prepare the read-ahead file
6786 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6788 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6789 count=$FILE_SIZE_MB 2> /dev/null
6793 cleanup_test101bc() {
6798 local list=$(comma_list $(osts_nodes))
6799 set_osd_param $list '' read_cache_enable 1
6800 set_osd_param $list '' writethrough_cache_enable 1
6804 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6809 local STRIPE_SIZE=$2
6810 local FILE_LENGTH=$3
6811 local RA_INC=1048576
6812 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6813 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6814 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6815 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6816 get_named_value 'read but discarded' |
6817 cut -d" " -f1 | calc_total)
6818 if [[ $DISCARD -gt $discard_limit ]]; then
6819 $LCTL get_param llite.*.read_ahead_stats
6820 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6822 echo "Read-ahead success for size ${READ_SIZE}"
6827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6828 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6829 local STRIPE_SIZE=1048576
6830 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6831 if [ $SLOW == "yes" ]; then
6832 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6834 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6837 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6839 # prepare the read-ahead file
6840 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6841 cancel_lru_locks osc
6842 for BIDX in 2 4 8 16 32 64 128 256
6844 local BSIZE=$((BIDX*4096))
6845 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6846 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6847 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6848 $LCTL set_param -n llite.*.read_ahead_stats 0
6849 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6850 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6851 cancel_lru_locks osc
6852 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6857 run_test 101b "check stride-io mode read-ahead ================="
6860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6861 local STRIPE_SIZE=1048576
6862 local FILE_LENGTH=$((STRIPE_SIZE*100))
6866 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6868 cancel_lru_locks osc
6869 $LCTL set_param osc.*.rpc_stats 0
6870 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6871 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6872 local stats=$($LCTL get_param -n $osc_rpc_stats)
6873 local lines=$(echo "$stats" | awk 'END {print NR;}')
6876 if [ $lines -le 20 ]; then
6879 for size in 1 2 4 8; do
6880 local rpc=$(echo "$stats" |
6881 awk '($1 == "'$size':") {print $2; exit; }')
6883 error "Small $((size*4))k read IO $rpc !"
6885 echo "$osc_rpc_stats check passed!"
6890 run_test 101c "check stripe_size aligned read-ahead ================="
6893 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6894 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6898 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6899 local file=$DIR/$tfile
6900 local sz_MB=${FILESIZE_101d:-500}
6901 local ra_MB=${READAHEAD_MB:-40}
6903 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6904 [ $free_MB -lt $sz_MB ] &&
6905 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6907 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6908 $SETSTRIPE -c -1 $file || error "setstripe failed"
6910 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6911 echo Cancel LRU locks on lustre client to flush the client cache
6912 cancel_lru_locks osc
6914 echo Disable read-ahead
6915 local old_READAHEAD=$(set_read_ahead 0)
6917 echo Reading the test file $file with read-ahead disabled
6918 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6920 echo Cancel LRU locks on lustre client to flush the client cache
6921 cancel_lru_locks osc
6922 echo Enable read-ahead with ${ra_MB}MB
6923 set_read_ahead $ra_MB
6925 echo Reading the test file $file with read-ahead enabled
6926 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6928 echo "read-ahead disabled time read $raOFF"
6929 echo "read-ahead enabled time read $raON"
6931 set_read_ahead $old_READAHEAD
6933 wait_delete_completed
6935 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6936 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6938 run_test 101d "file read with and without read-ahead enabled"
6941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6942 local file=$DIR/$tfile
6943 local size_KB=500 #KB
6947 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6948 local need_KB=$((count * size_KB))
6949 [[ $free_KB -le $need_KB ]] &&
6950 skip_env "Need free space $need_KB, have $free_KB" && return
6952 echo "Creating $count ${size_KB}K test files"
6953 for ((i = 0; i < $count; i++)); do
6954 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6957 echo "Cancel LRU locks on lustre client to flush the client cache"
6958 cancel_lru_locks osc
6960 echo "Reset readahead stats"
6961 $LCTL set_param -n llite.*.read_ahead_stats 0
6963 for ((i = 0; i < $count; i++)); do
6964 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6967 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6968 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6970 for ((i = 0; i < $count; i++)); do
6971 rm -rf $file.$i 2>/dev/null
6974 #10000 means 20% reads are missing in readahead
6975 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6977 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6980 which iozone || { skip "no iozone installed" && return; }
6982 local old_debug=$($LCTL get_param debug)
6983 old_debug=${old_debug#*=}
6984 $LCTL set_param debug="reada mmap"
6986 # create a test file
6987 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
6989 echo Cancel LRU locks on lustre client to flush the client cache
6990 cancel_lru_locks osc
6992 echo Reset readahead stats
6993 $LCTL set_param -n llite.*.read_ahead_stats 0
6995 echo mmap read the file with small block size
6996 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
6999 echo checking missing pages
7000 $LCTL get_param llite.*.read_ahead_stats
7001 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7002 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7004 $LCTL set_param debug="$old_debug"
7005 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7008 run_test 101f "check mmap read performance"
7010 test_101g_brw_size_test() {
7012 local pages=$((mb * 1048576 / $(page_size)))
7014 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7015 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7016 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7017 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7021 $LCTL set_param -n osc.*.rpc_stats=0
7023 # 10 RPCs should be enough for the test
7025 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
7026 { error "dd write ${mb} MB blocks failed"; return 3; }
7027 cancel_lru_locks osc
7028 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
7029 { error "dd write ${mb} MB blocks failed"; return 4; }
7031 # calculate number of full-sized read and write RPCs
7032 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7033 sed -n '/pages per rpc/,/^$/p' |
7034 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7035 END { print reads,writes }'))
7036 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7038 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7046 local osts=$(get_facets OST)
7047 local list=$(comma_list $(osts_nodes))
7048 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7049 local brw_size="obdfilter.*.brw_size"
7050 local ostver=$(lustre_version_code ost1)
7052 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7054 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7055 if [ $ostver -ge $(version_code 2.8.52) ] ||
7056 [ $ostver -ge $(version_code 2.7.17) -a \
7057 $ostver -lt $(version_code 2.7.50) ]; then
7058 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7059 if [[ $orig_mb -lt 16 ]]; then
7060 save_lustre_params $osts "$brw_size" > $p
7061 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7062 error "set 16MB RPC size failed"
7064 echo "remount client to enable new RPC size"
7065 remount_client $MOUNT || error "remount_client failed"
7068 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7069 # should be able to set brw_size=12, but no rpc_stats for that
7070 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7073 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7075 if [[ $orig_mb -lt 16 ]]; then
7076 restore_lustre_params < $p
7077 remount_client $MOUNT || error "remount_client restore failed"
7080 rm -f $p $DIR/$tfile
7082 run_test 101g "Big bulk(4/16 MiB) readahead"
7085 test_mkdir $DIR/$tdir
7086 chown $RUNAS_ID $DIR/$tdir
7089 STRIPE_COUNT=$OSTCOUNT
7090 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7092 trap cleanup_test102 EXIT
7094 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7096 for num in 1 2 3 4; do
7097 for count in $(seq 1 $STRIPE_COUNT); do
7098 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7099 local size=`expr $STRIPE_SIZE \* $num`
7100 local file=file"$num-$idx-$count"
7101 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7107 $1 tar cf $TMP/f102.tar $tdir --xattrs
7113 rm -rf $DIR/d0.sanity/d102
7117 local testfile=$DIR/$tfile
7121 [ "$UID" != 0 ] && skip_env "must run as root" && return
7122 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7123 skip_env "must have user_xattr" && return
7125 [ -z "$(which setfattr 2>/dev/null)" ] &&
7126 skip_env "could not find setfattr" && return
7128 echo "set/get xattr..."
7129 setfattr -n trusted.name1 -v value1 $testfile ||
7130 error "setfattr -n trusted.name1=value1 $testfile failed"
7131 getfattr -n trusted.name1 $testfile 2> /dev/null |
7132 grep "trusted.name1=.value1" ||
7133 error "$testfile missing trusted.name1=value1"
7135 setfattr -n user.author1 -v author1 $testfile ||
7136 error "setfattr -n user.author1=author1 $testfile failed"
7137 getfattr -n user.author1 $testfile 2> /dev/null |
7138 grep "user.author1=.author1" ||
7139 error "$testfile missing trusted.author1=author1"
7142 setfattr -n trusted.name2 -v value2 $testfile ||
7143 error "$testfile unable to set trusted.name2"
7144 setfattr -n trusted.name3 -v value3 $testfile ||
7145 error "$testfile unable to set trusted.name3"
7146 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7147 grep "trusted.name" | wc -l) -eq 3 ] ||
7148 error "$testfile missing 3 trusted.name xattrs"
7150 setfattr -n user.author2 -v author2 $testfile ||
7151 error "$testfile unable to set user.author2"
7152 setfattr -n user.author3 -v author3 $testfile ||
7153 error "$testfile unable to set user.author3"
7154 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7155 grep "user.author" | wc -l) -eq 3 ] ||
7156 error "$testfile missing 3 user.author xattrs"
7158 echo "remove xattr..."
7159 setfattr -x trusted.name1 $testfile ||
7160 error "$testfile error deleting trusted.name1"
7161 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7162 error "$testfile did not delete trusted.name1 xattr"
7164 setfattr -x user.author1 $testfile ||
7165 error "$testfile error deleting user.author1"
7166 echo "set lustre special xattr ..."
7167 $LFS setstripe -c1 $testfile
7168 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7169 awk -F "=" '/trusted.lov/ { print $2 }' )
7170 setfattr -n "trusted.lov" -v $lovea $testfile ||
7171 error "$testfile doesn't ignore setting trusted.lov again"
7172 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7173 error "$testfile allow setting invalid trusted.lov"
7176 run_test 102a "user xattr test =================================="
7179 [ -z "$(which setfattr 2>/dev/null)" ] &&
7180 skip_env "could not find setfattr" && return
7182 # b10930: get/set/list trusted.lov xattr
7183 echo "get/set/list trusted.lov xattr ..."
7184 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7185 local testfile=$DIR/$tfile
7186 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7187 error "setstripe failed"
7188 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7189 error "getstripe failed"
7190 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7191 error "can't get trusted.lov from $testfile"
7193 local testfile2=${testfile}2
7194 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7195 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7198 setfattr -n trusted.lov -v $value $testfile2
7199 local stripe_size=$($GETSTRIPE -S $testfile2)
7200 local stripe_count=$($GETSTRIPE -c $testfile2)
7201 [[ $stripe_size -eq 65536 ]] ||
7202 error "stripe size $stripe_size != 65536"
7203 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7204 error "stripe count $stripe_count != $STRIPECOUNT"
7207 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7210 [ -z "$(which setfattr 2>/dev/null)" ] &&
7211 skip_env "could not find setfattr" && return
7213 # b10930: get/set/list lustre.lov xattr
7214 echo "get/set/list lustre.lov xattr ..."
7215 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7216 test_mkdir $DIR/$tdir
7217 chown $RUNAS_ID $DIR/$tdir
7218 local testfile=$DIR/$tdir/$tfile
7219 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7220 error "setstripe failed"
7221 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7222 error "getstripe failed"
7223 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7224 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7226 local testfile2=${testfile}2
7227 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7228 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7230 $RUNAS $MCREATE $testfile2
7231 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7232 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7233 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7234 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7235 [ $stripe_count -eq $STRIPECOUNT ] ||
7236 error "stripe count $stripe_count != $STRIPECOUNT"
7238 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7240 compare_stripe_info1() {
7241 local stripe_index_all_zero=true
7243 for num in 1 2 3 4; do
7244 for count in $(seq 1 $STRIPE_COUNT); do
7245 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7246 local size=$((STRIPE_SIZE * num))
7247 local file=file"$num-$offset-$count"
7248 stripe_size=$($LFS getstripe -S $PWD/$file)
7249 [[ $stripe_size -ne $size ]] &&
7250 error "$file: size $stripe_size != $size"
7251 stripe_count=$($LFS getstripe -c $PWD/$file)
7252 # allow fewer stripes to be created, ORI-601
7253 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7254 error "$file: count $stripe_count != $count"
7255 stripe_index=$($LFS getstripe -i $PWD/$file)
7256 [[ $stripe_index -ne 0 ]] &&
7257 stripe_index_all_zero=false
7261 $stripe_index_all_zero &&
7262 error "all files are being extracted starting from OST index 0"
7266 have_xattrs_include() {
7267 tar --help | grep -q xattrs-include &&
7268 echo --xattrs-include="lustre.*"
7272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7273 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7274 local xinc=$(have_xattrs_include)
7276 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7278 compare_stripe_info1
7280 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
7283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7284 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7285 local xinc=$(have_xattrs_include)
7287 test_mkdir $DIR/$tdir.restore
7289 tar cf - --xattrs $tdir | tar xf - \
7290 -C $DIR/$tdir.restore --xattrs $xinc
7291 cd $DIR/$tdir.restore/$tdir
7292 compare_stripe_info1
7294 run_test 102f "tar copy files, not keep osts ==========="
7297 local xsize=${1:-1024} # in bytes
7298 local file=$DIR/$tfile
7300 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7301 skip "must have user_xattr" && return 0
7302 [ -z "$(which setfattr 2>/dev/null)" ] &&
7303 skip_env "could not find setfattr" && return 0
7304 [ -z "$(which getfattr 2>/dev/null)" ] &&
7305 skip_env "could not find getfattr" && return 0
7309 local value="$(generate_string $xsize)"
7311 local xbig=trusted.big
7312 log "save $xbig on $file"
7313 setfattr -n $xbig -v $value $file ||
7314 error "saving $xbig on $file failed"
7316 local orig=$(get_xattr_value $xbig $file)
7317 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7319 local xsml=trusted.sml
7320 log "save $xsml on $file"
7321 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7323 local new=$(get_xattr_value $xbig $file)
7324 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7326 log "grow $xsml on $file"
7327 setfattr -n $xsml -v "$value" $file ||
7328 error "growing $xsml on $file failed"
7330 new=$(get_xattr_value $xbig $file)
7331 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7332 log "$xbig still valid after growing $xsml"
7337 test_102h() { # bug 15777
7340 run_test 102h "grow xattr from inside inode to external block"
7343 large_xattr_enabled || { skip "ea_inode feature disabled" && return; }
7344 grow_xattr $(max_xattr_size)
7346 run_test 102ha "grow xattr from inside inode to external inode"
7348 test_102i() { # bug 17038
7349 [ -z "$(which getfattr 2>/dev/null)" ] &&
7350 skip "could not find getfattr" && return
7352 ln -s $DIR/$tfile $DIR/${tfile}link
7353 getfattr -n trusted.lov $DIR/$tfile ||
7354 error "lgetxattr on $DIR/$tfile failed"
7355 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7356 grep -i "no such attr" ||
7357 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7358 rm -f $DIR/$tfile $DIR/${tfile}link
7360 run_test 102i "lgetxattr test on symbolic link ============"
7363 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7364 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7365 local xinc=$(have_xattrs_include)
7366 setup_test102 "$RUNAS"
7367 chown $RUNAS_ID $DIR/$tdir
7368 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $xinc
7370 compare_stripe_info1 "$RUNAS"
7372 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7375 [ -z "$(which setfattr 2>/dev/null)" ] &&
7376 skip "could not find setfattr" && return
7378 # b22187 just check that does not crash for regular file.
7379 setfattr -n trusted.lov $DIR/$tfile
7380 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
7381 local test_kdir=$DIR/$tdir
7382 test_mkdir $test_kdir
7383 local default_size=`$GETSTRIPE -S $test_kdir`
7384 local default_count=`$GETSTRIPE -c $test_kdir`
7385 local default_offset=`$GETSTRIPE -i $test_kdir`
7386 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7387 error 'dir setstripe failed'
7388 setfattr -n trusted.lov $test_kdir
7389 local stripe_size=`$GETSTRIPE -S $test_kdir`
7390 local stripe_count=`$GETSTRIPE -c $test_kdir`
7391 local stripe_offset=`$GETSTRIPE -i $test_kdir`
7392 [ $stripe_size -eq $default_size ] ||
7393 error "stripe size $stripe_size != $default_size"
7394 [ $stripe_count -eq $default_count ] ||
7395 error "stripe count $stripe_count != $default_count"
7396 [ $stripe_offset -eq $default_offset ] ||
7397 error "stripe offset $stripe_offset != $default_offset"
7398 rm -rf $DIR/$tfile $test_kdir
7400 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7403 [ -z "$(which getfattr 2>/dev/null)" ] &&
7404 skip "could not find getfattr" && return
7406 # LU-532 trusted. xattr is invisible to non-root
7407 local testfile=$DIR/$tfile
7411 echo "listxattr as user..."
7412 chown $RUNAS_ID $testfile
7413 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7414 grep -q "trusted" &&
7415 error "$testfile trusted xattrs are user visible"
7419 run_test 102l "listxattr size test =================================="
7421 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7422 local path=$DIR/$tfile
7425 listxattr_size_check $path || error "listattr_size_check $path failed"
7427 run_test 102m "Ensure listxattr fails on small bufffer ========"
7431 getxattr() { # getxattr path name
7432 # Return the base64 encoding of the value of xattr name on path.
7436 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7438 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7440 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7442 getfattr --absolute-names --encoding=base64 --name=$name $path |
7443 awk -F= -v name=$name '$1 == name {
7444 print substr($0, index($0, "=") + 1);
7448 test_102n() { # LU-4101 mdt: protect internal xattrs
7449 [ -z "$(which setfattr 2>/dev/null)" ] &&
7450 skip "could not find setfattr" && return
7451 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7453 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7457 local file0=$DIR/$tfile.0
7458 local file1=$DIR/$tfile.1
7459 local xattr0=$TMP/$tfile.0
7460 local xattr1=$TMP/$tfile.1
7461 local namelist="lov lma lmv link fid version som hsm"
7465 rm -rf $file0 $file1 $xattr0 $xattr1
7468 # Get 'before' xattrs of $file1.
7469 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7471 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7472 namelist+=" lfsck_namespace"
7473 for name in $namelist; do
7474 # Try to copy xattr from $file0 to $file1.
7475 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7477 setfattr --name=trusted.$name --value="$value" $file1 ||
7478 error "setxattr 'trusted.$name' failed"
7480 # Try to set a garbage xattr.
7481 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7483 if [[ x$name == "xlov" ]]; then
7484 setfattr --name=trusted.lov --value="$value" $file1 &&
7485 error "setxattr invalid 'trusted.lov' success"
7487 setfattr --name=trusted.$name --value="$value" $file1 ||
7488 error "setxattr invalid 'trusted.$name' failed"
7491 # Try to remove the xattr from $file1. We don't care if this
7492 # appears to succeed or fail, we just don't want there to be
7493 # any changes or crashes.
7494 setfattr --remove=$trusted.$name $file1 2> /dev/null
7497 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7500 # Try to copy xattr from $file0 to $file1.
7501 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7503 setfattr --name=trusted.$name --value="$value" $file1 ||
7504 error "setxattr 'trusted.$name' failed"
7506 # Try to set a garbage xattr.
7507 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7509 setfattr --name=trusted.$name --value="$value" $file1 ||
7510 error "setxattr 'trusted.$name' failed"
7512 # Try to remove the xattr from $file1. We don't care if this
7513 # appears to succeed or fail, we just don't want there to be
7514 # any changes or crashes.
7515 setfattr --remove=$trusted.$name $file1 2> /dev/null
7518 # Get 'after' xattrs of file1.
7519 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7521 if ! diff $xattr0 $xattr1; then
7522 error "before and after xattrs of '$file1' differ"
7525 rm -rf $file0 $file1 $xattr0 $xattr1
7529 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7531 test_102p() { # LU-4703 setxattr did not check ownership
7532 local testfile=$DIR/$tfile
7534 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7535 skip "MDS needs to be at least 2.5.56" && return
7539 echo "setfacl as user..."
7540 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7541 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7543 echo "setfattr as user..."
7544 setfacl -m "u:$RUNAS_ID:---" $testfile
7545 $RUNAS setfattr -x system.posix_acl_access $testfile
7546 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7548 run_test 102p "check setxattr(2) correctly fails without permission"
7551 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7552 skip "MDS needs to be at least 2.6.92" && return
7553 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7555 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7558 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7559 skip "MDS needs to be at least 2.6.93" && return
7560 touch $DIR/$tfile || error "touch"
7561 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7562 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7563 rm $DIR/$tfile || error "rm"
7566 mkdir -p $DIR/$tdir || error "mkdir"
7567 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7568 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7569 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7570 error "$testfile error deleting user.author1"
7571 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7572 grep "user.$(basename $tdir)" &&
7573 error "$tdir did not delete user.$(basename $tdir)"
7574 rmdir $DIR/$tdir || error "rmdir"
7577 test_mkdir $DIR/$tdir || error "make striped dir"
7578 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7579 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7580 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7581 error "$testfile error deleting user.author1"
7582 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7583 grep "user.$(basename $tdir)" &&
7584 error "$tdir did not delete user.$(basename $tdir)"
7585 rmdir $DIR/$tdir || error "rm striped dir"
7587 run_test 102r "set EAs with empty values"
7590 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
7591 skip "MDS needs to be at least 2.11.52"
7593 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
7595 save_lustre_params client "llite.*.xattr_cache" > $save
7597 for cache in 0 1; do
7598 lctl set_param llite.*.xattr_cache=$cache
7601 touch $DIR/$tfile || error "touch"
7602 for prefix in lustre security system trusted user; do
7603 # Note getxattr() may fail with 'Operation not
7604 # supported' or 'No such attribute' depending
7605 # on prefix and cache.
7606 getfattr -n $prefix.n102s $DIR/$tfile &&
7607 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
7611 restore_lustre_params < $save
7613 run_test 102s "getting nonexistent xattrs should fail"
7617 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7622 [ "$UID" != 0 ] && skip_env "must run as root" && return
7623 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7624 skip "must have acl enabled" && return
7625 [ -z "$(which setfacl 2>/dev/null)" ] &&
7626 skip_env "could not find setfacl" && return
7627 $GSS && skip "could not run under gss" && return
7628 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7630 gpasswd -a daemon bin # LU-5641
7631 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7633 declare -a identity_old
7635 for num in $(seq $MDSCOUNT); do
7636 switch_identity $num true || identity_old[$num]=$?
7644 echo "performing cp ..."
7645 run_acl_subtest cp || error "run_acl_subtest cp failed"
7646 echo "performing getfacl-noacl..."
7647 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7648 echo "performing misc..."
7649 run_acl_subtest misc || error "misc test failed"
7650 echo "performing permissions..."
7651 run_acl_subtest permissions || error "permissions failed"
7652 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7653 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7654 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7655 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7657 echo "performing permissions xattr..."
7658 run_acl_subtest permissions_xattr ||
7659 error "permissions_xattr failed"
7661 echo "performing setfacl..."
7662 run_acl_subtest setfacl || error "setfacl test failed"
7664 # inheritance test got from HP
7665 echo "performing inheritance..."
7666 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7667 chmod +x make-tree || error "chmod +x failed"
7668 run_acl_subtest inheritance || error "inheritance test failed"
7671 echo "LU-974 ignore umask when acl is enabled..."
7672 run_acl_subtest 974 || error "LU-974 umask test failed"
7673 if [ $MDSCOUNT -ge 2 ]; then
7674 run_acl_subtest 974_remote ||
7675 error "LU-974 umask test failed under remote dir"
7678 echo "LU-2561 newly created file is same size as directory..."
7679 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7680 run_acl_subtest 2561 || error "LU-2561 test failed"
7682 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7685 run_acl_subtest 4924 || error "LU-4924 test failed"
7690 for num in $(seq $MDSCOUNT); do
7691 if [ "${identity_old[$num]}" = 1 ]; then
7692 switch_identity $num false || identity_old[$num]=$?
7696 run_test 103a "acl test ========================================="
7699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7701 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7702 local mountopts=$MDS_MOUNT_OPTS
7704 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7708 stop $SINGLEMDS || error "failed to stop MDT."
7710 if [ -z "$MDS_MOUNT_OPTS" ]; then
7711 MDS_MOUNT_OPTS="-o noacl"
7713 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7715 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7716 error "failed to start MDT."
7717 MDS_MOUNT_OPTS=$mountopts
7721 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7725 stop $SINGLEMDS || error "failed to stop MDT."
7727 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7728 error "failed to start MDT."
7733 run_test 103b "MDS mount option 'noacl'"
7737 cp -rp $DIR/$tdir $DIR/$tdir.bak
7739 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7740 error "$DIR/$tdir shouldn't contain default ACL"
7741 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7742 error "$DIR/$tdir.bak shouldn't contain default ACL"
7745 run_test 103c "'cp -rp' won't set empty acl"
7748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7750 lfs df || error "lfs df failed"
7751 lfs df -ih || error "lfs df -ih failed"
7752 lfs df -h $DIR || error "lfs df -h $DIR failed"
7753 lfs df -i $DIR || error "lfs df -i $DIR failed"
7754 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7755 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7757 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7758 lctl --device %$OSC deactivate
7759 lfs df || error "lfs df with deactivated OSC failed"
7760 lctl --device %$OSC activate
7761 # wait the osc back to normal
7762 wait_osc_import_state client ost FULL
7764 lfs df || error "lfs df with reactivated OSC failed"
7767 run_test 104a "lfs df [-ih] [path] test ========================="
7770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7771 [ $RUNAS_ID -eq $UID ] &&
7772 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7774 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7775 grep "Permission denied" | wc -l)))
7776 if [ $denied_cnt -ne 0 ]; then
7777 error "lfs check servers test failed"
7780 run_test 104b "$RUNAS lfs check servers test ===================="
7783 # doesn't work on 2.4 kernels
7785 if $(flock_is_enabled); then
7786 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7788 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7792 run_test 105a "flock when mounted without -o flock test ========"
7796 if $(flock_is_enabled); then
7797 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7799 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7803 run_test 105b "fcntl when mounted without -o flock test ========"
7807 if $(flock_is_enabled); then
7808 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7810 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7814 run_test 105c "lockf when mounted without -o flock test ========"
7816 test_105d() { # bug 15924
7817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7818 test_mkdir -p $DIR/$tdir
7819 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7820 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7821 $LCTL set_param fail_loc=0x80000315
7822 flocks_test 2 $DIR/$tdir
7824 run_test 105d "flock race (should not freeze) ========"
7826 test_105e() { # bug 22660 && 22040
7827 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7829 flocks_test 3 $DIR/$tfile
7831 run_test 105e "Two conflicting flocks from same process ======="
7833 test_106() { #bug 10921
7834 test_mkdir -p $DIR/$tdir
7835 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7836 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7838 run_test 106 "attempt exec of dir followed by chown of that dir"
7841 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7848 local save_pattern=$(sysctl -n kernel.core_pattern)
7849 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7850 sysctl -w kernel.core_pattern=$file
7851 sysctl -w kernel.core_uses_pid=0
7859 kill -s 11 $SLEEPPID
7861 if [ -e $file ]; then
7862 size=`stat -c%s $file`
7863 [ $size -eq 0 ] && error "Fail to create core file $file"
7865 error "Fail to create core file $file"
7868 sysctl -w kernel.core_pattern=$save_pattern
7869 sysctl -w kernel.core_uses_pid=$save_uses_pid
7872 run_test 107 "Coredump on SIG"
7875 test_mkdir -p $DIR/$tdir
7876 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7877 error "mkdir with 255 char failed"
7878 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7879 error "mkdir with 256 char should fail, but did not"
7880 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7881 error "create with 255 char failed"
7882 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7883 error "create with 256 char should fail, but did not"
7888 run_test 110 "filename length checking"
7891 # Purpose: To verify dynamic thread (OSS) creation.
7894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7895 remote_ost_nodsh && skip "remote OST with nodsh" && return
7897 # Lustre does not stop service threads once they are started.
7898 # Reset number of running threads to default.
7903 local save_params="$TMP/sanity-$TESTNAME.parameters"
7905 # Get ll_ost_io count before I/O
7906 OSTIO_pre=$(do_facet ost1 \
7907 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
7908 # Exit if lustre is not running (ll_ost_io not running).
7909 [ -z "$OSTIO_pre" ] && error "no OSS threads"
7911 echo "Starting with $OSTIO_pre threads"
7912 local thread_max=$((OSTIO_pre * 2))
7913 local rpc_in_flight=$((thread_max * 2))
7914 # Number of I/O Process proposed to be started.
7916 local facets=$(get_facets OST)
7918 save_lustre_params client \
7919 "osc.*OST*.max_rpcs_in_flight" > $save_params
7920 save_lustre_params $facets \
7921 "ost.OSS.ost_io.threads_max" >> $save_params
7923 # Set in_flight to $rpc_in_flight
7924 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
7925 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
7926 nfiles=${rpc_in_flight}
7927 # Set ost thread_max to $thread_max
7929 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
7931 # 5 Minutes should be sufficient for max number of OSS
7932 # threads(thread_max) to be created.
7936 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
7938 for i in $(seq $nfiles); do
7939 local file=$DIR/$tdir/${tfile}-$i
7940 $LFS setstripe -c -1 -i 0 $file
7941 ($WTL $file $timeout)&
7944 # I/O Started - Wait for thread_started to reach thread_max or report
7945 # error if thread_started is more than thread_max.
7946 echo "Waiting for thread_started to reach thread_max"
7947 local thread_started=0
7948 local end_time=$((SECONDS + timeout))
7950 while [ $SECONDS -le $end_time ] ; do
7952 # Get ost i/o thread_started count.
7953 thread_started=$(do_facet ost1 \
7955 ost.OSS.ost_io.threads_started | cut -d= -f2")
7956 # Break out if thread_started is equal/greater than thread_max
7957 if [[ $thread_started -ge $thread_max ]]; then
7958 echo ll_ost_io thread_started $thread_started, \
7959 equal/greater than thread_max $thread_max
7965 # Cleanup - We have the numbers, Kill i/o jobs if running.
7966 jobcount=($(jobs -p))
7967 for i in $(seq 0 $((${#jobcount[@]}-1)))
7969 kill -9 ${jobcount[$i]}
7970 if [ $? -ne 0 ] ; then
7972 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
7976 # Cleanup files left by WTL binary.
7977 for i in $(seq $nfiles); do
7978 local file=$DIR/$tdir/${tfile}-$i
7980 if [ $? -ne 0 ] ; then
7981 echo "Warning: Failed to delete file $file"
7985 restore_lustre_params <$save_params
7986 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
7988 # Error out if no new thread has started or Thread started is greater
7990 if [[ $thread_started -le $OSTIO_pre ||
7991 $thread_started -gt $thread_max ]]; then
7992 error "ll_ost_io: thread_started $thread_started" \
7993 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
7994 "No new thread started or thread started greater " \
7998 run_test 115 "verify dynamic thread creation===================="
8001 wait_delete_completed
8002 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8003 echo "OST kbytes available: ${AVAIL[@]}"
8008 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8009 #echo OST $i: ${AVAIL[i]}kb
8010 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8014 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8019 echo "Min free space: OST $MINI: $MINV"
8020 echo "Max free space: OST $MAXI: $MAXV"
8023 test_116a() { # was previously test_116()
8024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8025 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8027 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8029 echo -n "Free space priority "
8030 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
8035 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
8036 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
8038 trap simple_cleanup_common EXIT
8041 # Check if we need to generate uneven OSTs
8042 test_mkdir -p $DIR/$tdir/OST${MINI}
8043 local FILL=$((MINV / 4))
8044 local DIFF=$((MAXV - MINV))
8045 local DIFF2=$((DIFF * 100 / MINV))
8047 local threshold=$(do_facet $SINGLEMDS \
8048 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
8049 threshold=${threshold%%%}
8050 echo -n "Check for uneven OSTs: "
8051 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
8053 if [[ $DIFF2 -gt $threshold ]]; then
8055 echo "Don't need to fill OST$MINI"
8057 # generate uneven OSTs. Write 2% over the QOS threshold value
8059 DIFF=$((threshold - DIFF2 + 2))
8060 DIFF2=$((MINV * DIFF / 100))
8061 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
8062 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
8063 error "setstripe failed"
8064 DIFF=$((DIFF2 / 2048))
8066 while [ $i -lt $DIFF ]; do
8068 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8069 bs=2M count=1 2>/dev/null
8078 DIFF=$((MAXV - MINV))
8079 DIFF2=$((DIFF * 100 / MINV))
8080 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8081 if [ $DIFF2 -gt $threshold ]; then
8084 echo "failed - QOS mode won't be used"
8085 skip "QOS imbalance criteria not met"
8086 simple_cleanup_common
8095 # now fill using QOS
8096 $SETSTRIPE -c 1 $DIR/$tdir
8097 FILL=$((FILL / 200))
8098 if [ $FILL -gt 600 ]; then
8101 echo "writing $FILL files to QOS-assigned OSTs"
8103 while [ $i -lt $FILL ]; do
8105 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8109 echo "wrote $i 200k files"
8113 echo "Note: free space may not be updated, so measurements might be off"
8115 DIFF2=$((MAXV - MINV))
8116 echo "free space delta: orig $DIFF final $DIFF2"
8117 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8118 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8119 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8120 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8121 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8122 if [[ $DIFF -gt 0 ]]; then
8123 FILL=$((DIFF2 * 100 / DIFF - 100))
8124 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8127 # Figure out which files were written where
8128 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8129 awk '/'$MINI1': / {print $2; exit}')
8131 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8132 echo "$MINC files created on smaller OST $MINI1"
8133 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8134 awk '/'$MAXI1': / {print $2; exit}')
8136 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8137 echo "$MAXC files created on larger OST $MAXI1"
8138 if [[ $MINC -gt 0 ]]; then
8139 FILL=$((MAXC * 100 / MINC - 100))
8140 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8142 [[ $MAXC -gt $MINC ]] ||
8143 error_ignore LU-9 "stripe QOS didn't balance free space"
8144 simple_cleanup_common
8146 run_test 116a "stripe QOS: free space balance ==================="
8148 test_116b() { # LU-2093
8149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8150 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8152 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8153 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8154 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8155 [ -z "$old_rr" ] && skip "no QOS" && return 0
8156 do_facet $SINGLEMDS lctl set_param \
8157 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8159 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8160 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8161 do_facet $SINGLEMDS lctl set_param fail_loc=0
8163 do_facet $SINGLEMDS lctl set_param \
8164 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8166 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8168 test_117() # bug 10891
8170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8171 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8172 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8173 lctl set_param fail_loc=0x21e
8174 > $DIR/$tfile || error "truncate failed"
8175 lctl set_param fail_loc=0
8176 echo "Truncate succeeded."
8179 run_test 117 "verify osd extend =========="
8181 NO_SLOW_RESENDCOUNT=4
8182 export OLD_RESENDCOUNT=""
8183 set_resend_count () {
8184 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8185 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8186 lctl set_param -n $PROC_RESENDCOUNT $1
8187 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8190 # for reduce test_118* time (b=14842)
8191 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8193 # Reset async IO behavior after error case
8195 FILE=$DIR/reset_async
8197 # Ensure all OSCs are cleared
8198 $SETSTRIPE -c -1 $FILE
8199 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8204 test_118a() #bug 11710
8206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8209 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8210 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8211 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8213 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8214 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8219 run_test 118a "verify O_SYNC works =========="
8223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8224 remote_ost_nodsh && skip "remote OST with nodsh" && return
8228 #define OBD_FAIL_SRV_ENOENT 0x217
8229 set_nodes_failloc "$(osts_nodes)" 0x217
8230 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8232 set_nodes_failloc "$(osts_nodes)" 0
8233 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8234 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8237 if [[ $RC -eq 0 ]]; then
8238 error "Must return error due to dropped pages, rc=$RC"
8242 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8243 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8247 echo "Dirty pages not leaked on ENOENT"
8249 # Due to the above error the OSC will issue all RPCs syncronously
8250 # until a subsequent RPC completes successfully without error.
8251 $MULTIOP $DIR/$tfile Ow4096yc
8256 run_test 118b "Reclaim dirty pages on fatal error =========="
8260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8262 # for 118c, restore the original resend count, LU-1940
8263 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8264 set_resend_count $OLD_RESENDCOUNT
8265 remote_ost_nodsh && skip "remote OST with nodsh" && return
8269 #define OBD_FAIL_OST_EROFS 0x216
8270 set_nodes_failloc "$(osts_nodes)" 0x216
8272 # multiop should block due to fsync until pages are written
8273 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8277 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8278 error "Multiop failed to block on fsync, pid=$MULTIPID"
8281 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8283 if [[ $WRITEBACK -eq 0 ]]; then
8284 error "No page in writeback, writeback=$WRITEBACK"
8287 set_nodes_failloc "$(osts_nodes)" 0
8290 if [[ $RC -ne 0 ]]; then
8291 error "Multiop fsync failed, rc=$RC"
8294 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8295 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8297 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8298 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8302 echo "Dirty pages flushed via fsync on EROFS"
8305 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8307 # continue to use small resend count to reduce test_118* time (b=14842)
8308 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8313 remote_ost_nodsh && skip "remote OST with nodsh" && return
8317 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8318 set_nodes_failloc "$(osts_nodes)" 0x214
8319 # multiop should block due to fsync until pages are written
8320 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8324 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8325 error "Multiop failed to block on fsync, pid=$MULTIPID"
8328 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8330 if [[ $WRITEBACK -eq 0 ]]; then
8331 error "No page in writeback, writeback=$WRITEBACK"
8334 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8335 set_nodes_failloc "$(osts_nodes)" 0
8337 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8338 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8340 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8341 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8345 echo "Dirty pages gaurenteed flushed via fsync"
8348 run_test 118d "Fsync validation inject a delay of the bulk =========="
8351 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8354 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8355 lctl set_param fail_loc=0x8000040a
8357 # Should simulate EINVAL error which is fatal
8358 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8360 if [[ $RC -eq 0 ]]; then
8361 error "Must return error due to dropped pages, rc=$RC"
8364 lctl set_param fail_loc=0x0
8366 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8367 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8368 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8370 if [[ $LOCKED -ne 0 ]]; then
8371 error "Locked pages remain in cache, locked=$LOCKED"
8374 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8375 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8379 echo "No pages locked after fsync"
8384 run_test 118f "Simulate unrecoverable OSC side error =========="
8387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8390 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8391 lctl set_param fail_loc=0x406
8393 # simulate local -ENOMEM
8394 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8397 lctl set_param fail_loc=0
8398 if [[ $RC -eq 0 ]]; then
8399 error "Must return error due to dropped pages, rc=$RC"
8402 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8403 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8404 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8406 if [[ $LOCKED -ne 0 ]]; then
8407 error "Locked pages remain in cache, locked=$LOCKED"
8410 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8411 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8415 echo "No pages locked after fsync"
8420 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8424 remote_ost_nodsh && skip "remote OST with nodsh" && return
8428 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8429 set_nodes_failloc "$(osts_nodes)" 0x20e
8430 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8431 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8434 set_nodes_failloc "$(osts_nodes)" 0
8435 if [[ $RC -eq 0 ]]; then
8436 error "Must return error due to dropped pages, rc=$RC"
8439 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8440 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8441 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8443 if [[ $LOCKED -ne 0 ]]; then
8444 error "Locked pages remain in cache, locked=$LOCKED"
8447 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8448 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8452 echo "No pages locked after fsync"
8456 run_test 118h "Verify timeout in handling recoverables errors =========="
8458 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8462 remote_ost_nodsh && skip "remote OST with nodsh" && return
8466 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8467 set_nodes_failloc "$(osts_nodes)" 0x20e
8469 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8470 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8473 set_nodes_failloc "$(osts_nodes)" 0
8477 if [[ $RC -ne 0 ]]; then
8478 error "got error, but should be not, rc=$RC"
8481 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8482 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8483 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8484 if [[ $LOCKED -ne 0 ]]; then
8485 error "Locked pages remain in cache, locked=$LOCKED"
8488 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8489 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8493 echo "No pages locked after fsync"
8497 run_test 118i "Fix error before timeout in recoverable error =========="
8499 [ "$SLOW" = "no" ] && set_resend_count 4
8502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8503 remote_ost_nodsh && skip "remote OST with nodsh" && return
8507 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8508 set_nodes_failloc "$(osts_nodes)" 0x220
8510 # return -EIO from OST
8511 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8513 set_nodes_failloc "$(osts_nodes)" 0x0
8514 if [[ $RC -eq 0 ]]; then
8515 error "Must return error due to dropped pages, rc=$RC"
8518 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8519 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8520 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8521 if [[ $LOCKED -ne 0 ]]; then
8522 error "Locked pages remain in cache, locked=$LOCKED"
8525 # in recoverable error on OST we want resend and stay until it finished
8526 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8527 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8531 echo "No pages locked after fsync"
8535 run_test 118j "Simulate unrecoverable OST side error =========="
8539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8540 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8542 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8543 set_nodes_failloc "$(osts_nodes)" 0x20e
8544 test_mkdir -p $DIR/$tdir
8546 for ((i=0;i<10;i++)); do
8547 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8548 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8555 set_nodes_failloc "$(osts_nodes)" 0
8558 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8564 test_mkdir -p $DIR/$tdir
8565 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8568 run_test 118l "fsync dir ========="
8570 test_118m() # LU-3066
8572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8573 test_mkdir -p $DIR/$tdir
8574 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8577 run_test 118m "fdatasync dir ========="
8579 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8581 test_119a() # bug 11737
8583 BSIZE=$((512 * 1024))
8584 directio write $DIR/$tfile 0 1 $BSIZE
8585 # We ask to read two blocks, which is more than a file size.
8586 # directio will indicate an error when requested and actual
8587 # sizes aren't equeal (a normal situation in this case) and
8588 # print actual read amount.
8589 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8590 if [ "$NOB" != "$BSIZE" ]; then
8591 error "read $NOB bytes instead of $BSIZE"
8595 run_test 119a "Short directIO read must return actual read amount"
8597 test_119b() # bug 11737
8599 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8601 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8602 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8604 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8605 error "direct read failed"
8608 run_test 119b "Sparse directIO read must return actual read amount"
8610 test_119c() # bug 13099
8613 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8614 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8617 run_test 119c "Testing for direct read hitting hole"
8619 test_119d() # bug 15950
8621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8622 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8623 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8625 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8626 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8627 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8628 lctl set_param fail_loc=0x40d
8629 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8632 cat $DIR/$tfile > /dev/null &
8633 lctl set_param fail_loc=0
8636 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8638 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8639 error "the read rpcs have not completed in 2s"
8641 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8643 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8648 test_mkdir -p $DIR/$tdir
8649 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8650 skip "no early lock cancel on server" && return 0
8652 lru_resize_disable mdc
8653 lru_resize_disable osc
8654 cancel_lru_locks mdc
8655 # asynchronous object destroy at MDT could cause bl ast to client
8656 cancel_lru_locks osc
8658 stat $DIR/$tdir > /dev/null
8659 can1=$(do_facet $SINGLEMDS \
8660 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8661 awk '/ldlm_cancel/ {print $2}')
8662 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8663 awk '/ldlm_bl_callback/ {print $2}')
8664 test_mkdir -c1 $DIR/$tdir/d1
8665 can2=$(do_facet $SINGLEMDS \
8666 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8667 awk '/ldlm_cancel/ {print $2}')
8668 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8669 awk '/ldlm_bl_callback/ {print $2}')
8670 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8671 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8672 lru_resize_enable mdc
8673 lru_resize_enable osc
8675 run_test 120a "Early Lock Cancel: mkdir test"
8678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8679 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8680 test_mkdir $DIR/$tdir
8681 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8682 skip "no early lock cancel on server" && return 0
8683 lru_resize_disable mdc
8684 lru_resize_disable osc
8685 cancel_lru_locks mdc
8686 stat $DIR/$tdir > /dev/null
8687 can1=$(do_facet $SINGLEMDS \
8688 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8689 awk '/ldlm_cancel/ {print $2}')
8690 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8691 awk '/ldlm_bl_callback/ {print $2}')
8693 can2=$(do_facet $SINGLEMDS \
8694 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8695 awk '/ldlm_cancel/ {print $2}')
8696 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8697 awk '/ldlm_bl_callback/ {print $2}')
8698 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8699 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8700 lru_resize_enable mdc
8701 lru_resize_enable osc
8703 run_test 120b "Early Lock Cancel: create test"
8706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8707 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8708 test_mkdir -c1 $DIR/$tdir
8709 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8710 skip "no early lock cancel on server" && return 0
8711 lru_resize_disable mdc
8712 lru_resize_disable osc
8713 test_mkdir -p -c1 $DIR/$tdir/d1
8714 test_mkdir -p -c1 $DIR/$tdir/d2
8715 touch $DIR/$tdir/d1/f1
8716 cancel_lru_locks mdc
8717 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8718 can1=$(do_facet $SINGLEMDS \
8719 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8720 awk '/ldlm_cancel/ {print $2}')
8721 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8722 awk '/ldlm_bl_callback/ {print $2}')
8723 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8724 can2=$(do_facet $SINGLEMDS \
8725 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8726 awk '/ldlm_cancel/ {print $2}')
8727 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8728 awk '/ldlm_bl_callback/ {print $2}')
8729 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8730 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8731 lru_resize_enable mdc
8732 lru_resize_enable osc
8734 run_test 120c "Early Lock Cancel: link test"
8737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8738 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8739 test_mkdir -p -c1 $DIR/$tdir
8740 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8741 skip "no early lock cancel on server" && return 0
8742 lru_resize_disable mdc
8743 lru_resize_disable osc
8745 cancel_lru_locks mdc
8746 stat $DIR/$tdir > /dev/null
8747 can1=$(do_facet $SINGLEMDS \
8748 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8749 awk '/ldlm_cancel/ {print $2}')
8750 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8751 awk '/ldlm_bl_callback/ {print $2}')
8752 chmod a+x $DIR/$tdir
8753 can2=$(do_facet $SINGLEMDS \
8754 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8755 awk '/ldlm_cancel/ {print $2}')
8756 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8757 awk '/ldlm_bl_callback/ {print $2}')
8758 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8759 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8760 lru_resize_enable mdc
8761 lru_resize_enable osc
8763 run_test 120d "Early Lock Cancel: setattr test"
8766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8767 ! $($LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_can) &&
8768 skip "no early lock cancel on server" && return 0
8769 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8770 local dlmtrace_set=false
8772 test_mkdir -p -c1 $DIR/$tdir
8773 lru_resize_disable mdc
8774 lru_resize_disable osc
8775 ! $LCTL get_param debug | grep -q dlmtrace &&
8776 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8777 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8778 cancel_lru_locks mdc
8779 cancel_lru_locks osc
8780 dd if=$DIR/$tdir/f1 of=/dev/null
8781 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8782 # XXX client can not do early lock cancel of OST lock
8783 # during unlink (LU-4206), so cancel osc lock now.
8785 cancel_lru_locks osc
8786 can1=$(do_facet $SINGLEMDS \
8787 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8788 awk '/ldlm_cancel/ {print $2}')
8789 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8790 awk '/ldlm_bl_callback/ {print $2}')
8791 unlink $DIR/$tdir/f1
8793 can2=$(do_facet $SINGLEMDS \
8794 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8795 awk '/ldlm_cancel/ {print $2}')
8796 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8797 awk '/ldlm_bl_callback/ {print $2}')
8798 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8799 $LCTL dk $TMP/cancel.debug.txt
8800 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8801 $LCTL dk $TMP/blocking.debug.txt
8802 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8803 lru_resize_enable mdc
8804 lru_resize_enable osc
8806 run_test 120e "Early Lock Cancel: unlink test"
8809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8810 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8811 skip "no early lock cancel on server" && return 0
8812 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8813 test_mkdir -p -c1 $DIR/$tdir
8814 lru_resize_disable mdc
8815 lru_resize_disable osc
8816 test_mkdir -p -c1 $DIR/$tdir/d1
8817 test_mkdir -p -c1 $DIR/$tdir/d2
8818 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8819 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8820 cancel_lru_locks mdc
8821 cancel_lru_locks osc
8822 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8823 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8824 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8825 # XXX client can not do early lock cancel of OST lock
8826 # during rename (LU-4206), so cancel osc lock now.
8828 cancel_lru_locks osc
8829 can1=$(do_facet $SINGLEMDS \
8830 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8831 awk '/ldlm_cancel/ {print $2}')
8832 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8833 awk '/ldlm_bl_callback/ {print $2}')
8834 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8836 can2=$(do_facet $SINGLEMDS \
8837 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8838 awk '/ldlm_cancel/ {print $2}')
8839 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8840 awk '/ldlm_bl_callback/ {print $2}')
8841 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8842 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8843 lru_resize_enable mdc
8844 lru_resize_enable osc
8846 run_test 120f "Early Lock Cancel: rename test"
8849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8850 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8851 skip "no early lock cancel on server" && return 0
8852 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8853 lru_resize_disable mdc
8854 lru_resize_disable osc
8856 echo create $count files
8857 test_mkdir -p $DIR/$tdir
8858 cancel_lru_locks mdc
8859 cancel_lru_locks osc
8862 can0=$(do_facet $SINGLEMDS \
8863 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8864 awk '/ldlm_cancel/ {print $2}')
8865 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8866 awk '/ldlm_bl_callback/ {print $2}')
8867 createmany -o $DIR/$tdir/f $count
8869 can1=$(do_facet $SINGLEMDS \
8870 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8871 awk '/ldlm_cancel/ {print $2}')
8872 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8873 awk '/ldlm_bl_callback/ {print $2}')
8875 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8876 echo rm $count files
8879 can2=$(do_facet $SINGLEMDS \
8880 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8881 awk '/ldlm_cancel/ {print $2}')
8882 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8883 awk '/ldlm_bl_callback/ {print $2}')
8885 echo total: $count removes in $((t2-t1))
8886 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8888 # wait for commitment of removal
8889 lru_resize_enable mdc
8890 lru_resize_enable osc
8892 run_test 120g "Early Lock Cancel: performance test"
8894 test_121() { #bug #10589
8895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8897 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8898 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8899 lctl set_param fail_loc=0x310
8900 cancel_lru_locks osc > /dev/null
8901 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8902 lctl set_param fail_loc=0
8903 [[ $reads -eq $writes ]] ||
8904 error "read $reads blocks, must be $writes blocks"
8906 run_test 121 "read cancel race ========="
8908 test_123a() { # was test 123, statahead(bug 11401)
8909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8911 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8912 log "testing on UP system. Performance may be not as good as expected."
8917 test_mkdir -p $DIR/$tdir
8918 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8919 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8921 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8922 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8924 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8925 lctl set_param -n llite.*.statahead_max 0
8926 lctl get_param llite.*.statahead_max
8927 cancel_lru_locks mdc
8928 cancel_lru_locks osc
8930 time ls -l $DIR/$tdir | wc -l
8932 delta=$((etime - stime))
8933 log "ls $i files without statahead: $delta sec"
8934 lctl set_param llite.*.statahead_max=$max
8936 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8937 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8938 cancel_lru_locks mdc
8939 cancel_lru_locks osc
8941 time ls -l $DIR/$tdir | wc -l
8943 delta_sa=$((etime - stime))
8944 log "ls $i files with statahead: $delta_sa sec"
8945 lctl get_param -n llite.*.statahead_stats
8946 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8948 [[ $swrong -lt $ewrong ]] &&
8949 log "statahead was stopped, maybe too many locks held!"
8950 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8952 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8953 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8954 lctl set_param -n llite.*.statahead_max 0
8955 lctl get_param llite.*.statahead_max
8956 cancel_lru_locks mdc
8957 cancel_lru_locks osc
8959 time ls -l $DIR/$tdir | wc -l
8961 delta=$((etime - stime))
8962 log "ls $i files again without statahead: $delta sec"
8963 lctl set_param llite.*.statahead_max=$max
8964 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8965 if [ $SLOWOK -eq 0 ]; then
8966 error "ls $i files is slower with statahead!"
8968 log "ls $i files is slower with statahead!"
8974 [ $delta -gt 20 ] && break
8975 [ $delta -gt 8 ] && MULT=$((50 / delta))
8976 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8984 delta=$((etime - stime))
8985 log "rm -r $DIR/$tdir/: $delta seconds"
8987 lctl get_param -n llite.*.statahead_stats
8989 run_test 123a "verify statahead work"
8991 test_123b () { # statahead(bug 15027)
8992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8993 test_mkdir -p $DIR/$tdir
8994 createmany -o $DIR/$tdir/$tfile-%d 1000
8996 cancel_lru_locks mdc
8997 cancel_lru_locks osc
8999 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
9000 lctl set_param fail_loc=0x80000803
9001 ls -lR $DIR/$tdir > /dev/null
9003 lctl set_param fail_loc=0x0
9004 lctl get_param -n llite.*.statahead_stats
9009 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
9012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9013 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9014 skip "no lru resize on server" && return 0
9016 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9018 log "create $NR files at $DIR/$tdir"
9019 createmany -o $DIR/$tdir/f $NR ||
9020 error "failed to create $NR files in $DIR/$tdir"
9022 cancel_lru_locks mdc
9023 ls -l $DIR/$tdir > /dev/null
9027 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
9028 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
9029 LRU_SIZE=$($LCTL get_param -n $PARAM)
9030 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
9031 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
9033 log "NS=$(basename $NSDIR)"
9038 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9039 skip "Not enough cached locks created!"
9046 # We know that lru resize allows one client to hold $LIMIT locks
9047 # for 10h. After that locks begin to be killed by client.
9049 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9051 if [ $LIMIT -lt $LRU_SIZE ]; then
9052 skip "Limit is too small $LIMIT"
9056 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9057 # killing locks. Some time was spent for creating locks. This means
9058 # that up to the moment of sleep finish we must have killed some of
9059 # them (10-100 locks). This depends on how fast ther were created.
9060 # Many of them were touched in almost the same moment and thus will
9061 # be killed in groups.
9062 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9064 # Use $LRU_SIZE_B here to take into account real number of locks
9065 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9066 local LRU_SIZE_B=$LRU_SIZE
9068 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9069 log "OLD_LVF=$OLD_LVF"
9070 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9072 # Let's make sure that we really have some margin. Client checks
9073 # cached locks every 10 sec.
9075 log "Sleep ${SLEEP} sec"
9077 while ((SEC<$SLEEP)); do
9081 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9085 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9086 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9088 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9089 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9090 unlinkmany $DIR/$tdir/f $NR
9094 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9095 log "unlink $NR files at $DIR/$tdir"
9096 unlinkmany $DIR/$tdir/f $NR
9098 run_test 124a "lru resize ======================================="
9100 get_max_pool_limit()
9102 local limit=$($LCTL get_param \
9103 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9106 if [[ $l -gt $max ]]; then
9114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9115 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9116 skip "no lru resize on server" && return 0
9118 LIMIT=$(get_max_pool_limit)
9120 NR=$(($(default_lru_size)*20))
9121 if [[ $NR -gt $LIMIT ]]; then
9122 log "Limit lock number by $LIMIT locks"
9126 IFree=$(mdsrate_inodes_available)
9127 if [ $IFree -lt $NR ]; then
9128 log "Limit lock number by $IFree inodes"
9132 lru_resize_disable mdc
9133 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
9134 error "failed to create $DIR/$tdir/disable_lru_resize"
9136 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9137 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9138 cancel_lru_locks mdc
9141 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9144 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9147 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9151 nolruresize_delta=$((etime-stime))
9152 log "ls -la time: $nolruresize_delta seconds"
9153 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9154 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9156 lru_resize_enable mdc
9157 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
9158 error "failed to create $DIR/$tdir/enable_lru_resize"
9160 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9161 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9162 cancel_lru_locks mdc
9165 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9168 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9171 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9175 lruresize_delta=$((etime-stime))
9176 log "ls -la time: $lruresize_delta seconds"
9177 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9179 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9180 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9181 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9182 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9184 log "lru resize performs the same with no lru resize"
9186 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9188 run_test 124b "lru resize (performance test) ======================="
9191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9192 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
9193 skip "no lru resize on server" && return 0
9195 # cache ununsed locks on client
9197 cancel_lru_locks mdc
9198 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9199 createmany -o $DIR/$tdir/f $nr ||
9200 error "failed to create $nr files in $DIR/$tdir"
9201 ls -l $DIR/$tdir > /dev/null
9203 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9204 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9205 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9206 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9207 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9209 # set lru_max_age to 1 sec
9210 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9211 echo "sleep $((recalc_p * 2)) seconds..."
9212 sleep $((recalc_p * 2))
9214 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9215 # restore lru_max_age
9216 $LCTL set_param -n $nsdir.lru_max_age $max_age
9217 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9218 unlinkmany $DIR/$tdir/f $nr
9220 run_test 124c "LRUR cancel very aged locks"
9222 test_125() { # 13358
9223 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9224 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
9225 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9226 test_mkdir -p $DIR/d125 || error "mkdir failed"
9227 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
9228 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
9229 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
9231 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9233 test_126() { # bug 12829/13455
9234 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
9235 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
9236 $GSS && skip "must run as gss disabled" && return
9238 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9239 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9241 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9243 run_test 126 "check that the fsgid provided by the client is taken into account"
9245 test_127a() { # bug 15521
9246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9247 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9248 $LCTL set_param osc.*.stats=0
9249 FSIZE=$((2048 * 1024))
9250 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9251 cancel_lru_locks osc
9252 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9254 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9255 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9256 echo "got $COUNT $NAME"
9257 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9258 eval $NAME=$COUNT || error "Wrong proc format"
9261 read_bytes|write_bytes)
9262 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9263 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9264 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9265 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9266 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9267 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9268 error "sumsquare is too small: $SUMSQ"
9269 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9270 error "sumsquare is too big: $SUMSQ"
9274 done < $DIR/${tfile}.tmp
9276 #check that we actually got some stats
9277 [ "$read_bytes" ] || error "Missing read_bytes stats"
9278 [ "$write_bytes" ] || error "Missing write_bytes stats"
9279 [ "$read_bytes" != 0 ] || error "no read done"
9280 [ "$write_bytes" != 0 ] || error "no write done"
9282 run_test 127a "verify the client stats are sane"
9284 test_127b() { # bug LU-333
9285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9286 $LCTL set_param llite.*.stats=0
9287 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9288 # perform 2 reads and writes so MAX is different from SUM.
9289 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9290 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9291 cancel_lru_locks osc
9292 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9293 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9295 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9296 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9297 echo "got $COUNT $NAME"
9298 eval $NAME=$COUNT || error "Wrong proc format"
9302 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9303 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9304 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9305 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9308 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9309 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9310 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9311 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9315 done < $TMP/${tfile}.tmp
9317 #check that we actually got some stats
9318 [ "$read_bytes" ] || error "Missing read_bytes stats"
9319 [ "$write_bytes" ] || error "Missing write_bytes stats"
9320 [ "$read_bytes" != 0 ] || error "no read done"
9321 [ "$write_bytes" != 0 ] || error "no write done"
9323 rm -f $TMP/${tfile}.tmp
9325 run_test 127b "verify the llite client stats are sane"
9327 test_128() { # bug 15212
9329 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9334 result=$(grep error $TMP/$tfile.log)
9335 rm -f $DIR/$tfile $TMP/$tfile.log
9337 error "consecutive find's under interactive lfs failed"
9339 run_test 128 "interactive lfs for 2 consecutive find's"
9346 local ldproc=/proc/fs/ldiskfs
9347 local facets=$(get_facets MDS)
9349 for facet in ${facets//,/ }; do
9350 canondev=$(ldiskfs_canon \
9351 *.$(convert_facet2label $facet).mntdev $facet)
9352 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9353 ldproc=/sys/fs/ldiskfs
9354 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9355 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9360 local facets=$(get_facets MDS)
9361 for facet in ${facets//,/ }; do
9362 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9368 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9369 { skip "Need MDS version with at least 2.5.56"; return 0; }
9371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9372 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9373 skip "ldiskfs only test"
9376 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9379 local has_warning=false
9384 # block size of mds1
9385 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9386 set_dir_limits $maxsize $maxsize
9387 local dirsize=$(stat -c%s "$DIR/$tdir")
9389 while [[ $dirsize -le $maxsize ]]; do
9390 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9392 if ! $has_warning; then
9393 check_mds_dmesg '"is approaching"' && has_warning=true
9396 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9397 # EFBIG for previous versions included in ldiskfs series
9398 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9400 echo "return code $rc received as expected"
9402 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9403 error_exit "create failed w/o dir size limit"
9405 check_mds_dmesg '"has reached"' ||
9406 error_exit "reached message should be output"
9408 [ $has_warning = "false" ] &&
9409 error_exit "warning message should be output"
9411 dirsize=$(stat -c%s "$DIR/$tdir")
9413 [[ $dirsize -ge $maxsize ]] && return 0
9414 error_exit "current dir size $dirsize, " \
9415 "previous limit $maxsize"
9416 elif [ $rc -ne 0 ]; then
9418 error_exit "return $rc received instead of expected " \
9419 "$EFBIG or $ENOSPC, files in dir $dirsize"
9421 nfiles=$((nfiles + 1))
9422 dirsize=$(stat -c%s "$DIR/$tdir")
9426 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9428 run_test 129 "test directory size limit ========================"
9437 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9438 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9441 trap cleanup_130 EXIT RETURN
9443 local fm_file=$DIR/$tfile
9444 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9445 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9446 error "dd failed for $fm_file"
9448 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9449 filefrag -ves $fm_file
9451 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9452 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9453 [ $RC != 0 ] && error "filefrag $fm_file failed"
9455 filefrag_op=$(filefrag -ve $fm_file |
9456 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9457 lun=$($GETSTRIPE -i $fm_file)
9459 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9462 for line in $filefrag_op
9464 frag_lun=`echo $line | cut -d: -f5`
9465 ext_len=`echo $line | cut -d: -f4`
9466 if (( $frag_lun != $lun )); then
9468 error "FIEMAP on 1-stripe file($fm_file) failed"
9471 (( tot_len += ext_len ))
9474 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9476 error "FIEMAP on 1-stripe file($fm_file) failed;"
9482 echo "FIEMAP on single striped file succeeded"
9484 run_test 130a "FIEMAP (1-stripe file)"
9487 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9489 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9490 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9493 trap cleanup_130 EXIT RETURN
9495 local fm_file=$DIR/$tfile
9496 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9497 error "setstripe on $fm_file"
9498 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9499 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9501 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9502 error "dd failed on $fm_file"
9504 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9505 filefrag_op=$(filefrag -ve $fm_file |
9506 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9508 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9509 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9514 for line in $filefrag_op
9516 frag_lun=$(echo $line | cut -d: -f5 |
9517 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9518 ext_len=$(echo $line | cut -d: -f4)
9519 if (( $frag_lun != $last_lun )); then
9520 if (( tot_len != 1024 )); then
9522 error "FIEMAP on $fm_file failed; returned " \
9523 "len $tot_len for OST $last_lun instead of 1024"
9530 (( tot_len += ext_len ))
9533 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9535 error "FIEMAP on $fm_file failed; returned wrong number of " \
9536 "luns or wrong len for OST $last_lun"
9542 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9544 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9547 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9549 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9550 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9553 trap cleanup_130 EXIT RETURN
9555 local fm_file=$DIR/$tfile
9556 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9557 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9558 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9560 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9561 error "dd failed on $fm_file"
9563 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9564 filefrag_op=$(filefrag -ve $fm_file |
9565 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9567 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9568 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9573 for line in $filefrag_op
9575 frag_lun=$(echo $line | cut -d: -f5 |
9576 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9577 ext_len=$(echo $line | cut -d: -f4)
9578 if (( $frag_lun != $last_lun )); then
9579 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9580 if (( logical != 512 )); then
9582 error "FIEMAP on $fm_file failed; returned " \
9583 "logical start for lun $logical instead of 512"
9586 if (( tot_len != 512 )); then
9588 error "FIEMAP on $fm_file failed; returned " \
9589 "len $tot_len for OST $last_lun instead of 1024"
9596 (( tot_len += ext_len ))
9599 if (( num_luns != 2 || tot_len != 512 )); then
9601 error "FIEMAP on $fm_file failed; returned wrong number of " \
9602 "luns or wrong len for OST $last_lun"
9608 echo "FIEMAP on 2-stripe file with hole succeeded"
9610 run_test 130c "FIEMAP (2-stripe file with hole)"
9613 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9615 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9616 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9619 trap cleanup_130 EXIT RETURN
9621 local fm_file=$DIR/$tfile
9622 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9623 error "setstripe on $fm_file"
9624 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9625 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9627 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
9628 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
9629 error "dd failed on $fm_file"
9631 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9632 filefrag_op=$(filefrag -ve $fm_file |
9633 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9635 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9636 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9641 for line in $filefrag_op
9643 frag_lun=$(echo $line | cut -d: -f5 |
9644 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9645 ext_len=$(echo $line | cut -d: -f4)
9646 if (( $frag_lun != $last_lun )); then
9647 if (( tot_len != 1024 )); then
9649 error "FIEMAP on $fm_file failed; returned " \
9650 "len $tot_len for OST $last_lun instead of 1024"
9657 (( tot_len += ext_len ))
9660 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
9662 error "FIEMAP on $fm_file failed; returned wrong number of " \
9663 "luns or wrong len for OST $last_lun"
9669 echo "FIEMAP on N-stripe file succeeded"
9671 run_test 130d "FIEMAP (N-stripe file)"
9674 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9676 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9677 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9679 trap cleanup_130 EXIT RETURN
9681 local fm_file=$DIR/$tfile
9682 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9683 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9684 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9687 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9688 for ((i = 0; i < $NUM_BLKS; i++))
9690 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9693 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9694 filefrag_op=$(filefrag -ve $fm_file |
9695 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9697 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9698 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9703 for line in $filefrag_op
9705 frag_lun=$(echo $line | cut -d: -f5 |
9706 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9707 ext_len=$(echo $line | cut -d: -f4)
9708 if (( $frag_lun != $last_lun )); then
9709 if (( tot_len != $EXPECTED_LEN )); then
9711 error "FIEMAP on $fm_file failed; returned " \
9712 "len $tot_len for OST $last_lun instead " \
9720 (( tot_len += ext_len ))
9723 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9725 error "FIEMAP on $fm_file failed; returned wrong number " \
9726 "of luns or wrong len for OST $last_lun"
9732 echo "FIEMAP with continuation calls succeeded"
9734 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9736 # Test for writev/readv
9738 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
9739 error "writev test failed"
9740 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
9741 error "readv failed"
9744 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9747 local fsize=$((524288 + 1048576 + 1572864))
9748 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
9749 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9750 error "append writev test failed"
9752 ((fsize += 1572864 + 1048576))
9753 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
9754 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9755 error "append writev test failed"
9758 run_test 131b "test append writev"
9761 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9764 run_test 131c "test read/write on file w/o objects"
9767 rwv -f $DIR/$tfile -w -n 1 1572864
9768 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9769 if [ "$NOB" != 1572864 ]; then
9770 error "Short read filed: read $NOB bytes instead of 1572864"
9774 run_test 131d "test short read"
9777 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9778 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9779 error "read hitting hole failed"
9782 run_test 131e "test read hitting hole"
9791 mds*) res=$(do_facet $facet \
9792 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9794 ost*) res=$(do_facet $facet \
9795 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9797 *) error "Wrong facet '$facet'" ;;
9800 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9801 # if the argument $3 is zero, it means any stat increment is ok.
9802 if [[ $want -gt 0 ]]; then
9803 local count=$(echo $res | awk '{ print $2 }')
9804 [[ $count -ne $want ]] &&
9805 error "The $op counter on $facet is $count, not $want"
9810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9811 remote_ost_nodsh && skip "remote OST with nodsh" && return
9812 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9814 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9815 { skip "MDS doesn't support rename stats"; return; }
9816 local testdir=$DIR/${tdir}/stats_testdir
9817 mkdir -p $DIR/${tdir}
9820 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9821 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9823 # verify mdt stats first.
9824 mkdir ${testdir} || error "mkdir failed"
9825 check_stats $SINGLEMDS "mkdir" 1
9826 touch ${testdir}/${tfile} || error "touch failed"
9827 check_stats $SINGLEMDS "open" 1
9828 check_stats $SINGLEMDS "close" 1
9829 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
9830 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
9831 check_stats $SINGLEMDS "mknod" 2
9833 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
9834 check_stats $SINGLEMDS "unlink" 1
9835 rm -f ${testdir}/${tfile} || error "file remove failed"
9836 check_stats $SINGLEMDS "unlink" 2
9838 # remove working dir and check mdt stats again.
9839 rmdir ${testdir} || error "rmdir failed"
9840 check_stats $SINGLEMDS "rmdir" 1
9842 local testdir1=$DIR/${tdir}/stats_testdir1
9844 mkdir -p ${testdir1}
9845 touch ${testdir1}/test1
9846 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9847 check_stats $SINGLEMDS "crossdir_rename" 1
9849 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9850 check_stats $SINGLEMDS "samedir_rename" 1
9854 run_test 133a "Verifying MDT stats ========================================"
9857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9858 remote_ost_nodsh && skip "remote OST with nodsh" && return
9859 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9860 local testdir=$DIR/${tdir}/stats_testdir
9861 mkdir -p ${testdir} || error "mkdir failed"
9862 touch ${testdir}/${tfile} || error "touch failed"
9863 cancel_lru_locks mdc
9866 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9867 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9869 # extra mdt stats verification.
9870 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9871 check_stats $SINGLEMDS "setattr" 1
9872 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9873 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9875 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9876 check_stats $SINGLEMDS "getattr" 1
9878 $LFS df || error "lfs failed"
9879 check_stats $SINGLEMDS "statfs" 1
9883 run_test 133b "Verifying extra MDT stats =================================="
9886 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9887 remote_ost_nodsh && skip "remote OST with nodsh" && return
9888 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9889 local testdir=$DIR/${tdir}/stats_testdir
9890 test_mkdir -p ${testdir} || error "mkdir failed"
9892 # verify obdfilter stats.
9893 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9895 cancel_lru_locks osc
9896 wait_delete_completed
9899 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9900 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9902 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9904 cancel_lru_locks osc
9905 check_stats ost1 "write" 1
9907 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9908 check_stats ost1 "read" 1
9910 > ${testdir}/${tfile} || error "truncate failed"
9911 check_stats ost1 "punch" 1
9913 rm -f ${testdir}/${tfile} || error "file remove failed"
9914 wait_delete_completed
9915 check_stats ost1 "destroy" 1
9919 run_test 133c "Verifying OST stats ========================================"
9926 while [ $value -ge 2 ]; do
9931 if [ $orig -gt $order ]; then
9939 local size=('K' 'M' 'G' 'T');
9941 local size_string=$value
9943 while [ $value -ge 1024 ]; do
9944 if [ $i -gt 3 ]; then
9945 #T is the biggest unit we get here, if that is bigger,
9947 size_string=${value}T
9950 value=$((value >> 10))
9951 if [ $value -lt 1024 ]; then
9952 size_string=${value}${size[$i]}
9963 local context=${2:-.}
9964 local sample=$(do_facet $SINGLEMDS $LCTL \
9965 get_param mdt.$FSNAME-MDT0000.rename_stats |
9967 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9973 remote_ost_nodsh && skip "remote OST with nodsh" && return
9974 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9975 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9976 { skip "MDS doesn't support rename stats"; return; }
9978 local testdir1=$DIR/${tdir}/stats_testdir1
9979 local testdir2=$DIR/${tdir}/stats_testdir2
9980 mkdir -p $DIR/${tdir}
9982 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9984 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
9985 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
9987 createmany -o $testdir1/test 512 || error "createmany failed"
9989 # check samedir rename size
9990 mv ${testdir1}/test0 ${testdir1}/test_0
9992 local testdir1_size=$(ls -l $DIR/${tdir} |
9993 awk '/stats_testdir1/ {print $5}')
9994 local testdir2_size=$(ls -l $DIR/${tdir} |
9995 awk '/stats_testdir2/ {print $5}')
9997 testdir1_size=$(order_2 $testdir1_size)
9998 testdir2_size=$(order_2 $testdir2_size)
10000 testdir1_size=$(size_in_KMGT $testdir1_size)
10001 testdir2_size=$(size_in_KMGT $testdir2_size)
10003 echo "source rename dir size: ${testdir1_size}"
10004 echo "target rename dir size: ${testdir2_size}"
10006 local cmd="do_facet $SINGLEMDS $LCTL "
10007 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
10009 eval $cmd || error "$cmd failed"
10010 local samedir=$($cmd | grep 'same_dir')
10011 local same_sample=$(get_rename_size $testdir1_size)
10012 [ -z "$samedir" ] && error "samedir_rename_size count error"
10013 [[ $same_sample -eq 1 ]] ||
10014 error "samedir_rename_size error $same_sample"
10015 echo "Check same dir rename stats success"
10017 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10019 # check crossdir rename size
10020 mv ${testdir1}/test_0 ${testdir2}/test_0
10022 testdir1_size=$(ls -l $DIR/${tdir} |
10023 awk '/stats_testdir1/ {print $5}')
10024 testdir2_size=$(ls -l $DIR/${tdir} |
10025 awk '/stats_testdir2/ {print $5}')
10027 testdir1_size=$(order_2 $testdir1_size)
10028 testdir2_size=$(order_2 $testdir2_size)
10030 testdir1_size=$(size_in_KMGT $testdir1_size)
10031 testdir2_size=$(size_in_KMGT $testdir2_size)
10033 echo "source rename dir size: ${testdir1_size}"
10034 echo "target rename dir size: ${testdir2_size}"
10036 eval $cmd || error "$cmd failed"
10037 local crossdir=$($cmd | grep 'crossdir')
10038 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10039 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10040 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10041 [[ $src_sample -eq 1 ]] ||
10042 error "crossdir_rename_size error $src_sample"
10043 [[ $tgt_sample -eq 1 ]] ||
10044 error "crossdir_rename_size error $tgt_sample"
10045 echo "Check cross dir rename stats success"
10046 rm -rf $DIR/${tdir}
10048 run_test 133d "Verifying rename_stats ========================================"
10051 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10052 remote_ost_nodsh && skip "remote OST with nodsh" && return
10053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10054 local testdir=$DIR/${tdir}/stats_testdir
10055 local ctr f0 f1 bs=32768 count=42 sum
10057 mkdir -p ${testdir} || error "mkdir failed"
10059 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10061 for ctr in {write,read}_bytes; do
10063 cancel_lru_locks osc
10065 do_facet ost1 $LCTL set_param -n \
10066 "obdfilter.*.exports.clear=clear"
10068 if [ $ctr = write_bytes ]; then
10070 f1=${testdir}/${tfile}
10072 f0=${testdir}/${tfile}
10076 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10079 cancel_lru_locks osc
10081 sum=$(do_facet ost1 $LCTL get_param \
10082 "obdfilter.*.exports.*.stats" |
10083 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10084 $1 == ctr { sum += $7 }
10085 END { printf("%0.0f", sum) }')
10087 if ((sum != bs * count)); then
10088 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10092 rm -rf $DIR/${tdir}
10094 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10096 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10099 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10100 remote_ost_nodsh && skip "remote OST with nodsh" && return
10101 # First without trusting modes.
10102 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10103 echo "proc_dirs='$proc_dirs'"
10104 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10105 find $proc_dirs -exec cat '{}' \; &> /dev/null
10107 # Second verifying readability.
10108 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10110 # eventually, this can also be replaced with "lctl get_param -R",
10111 # but not until that option is always available on the server
10113 for facet in mds1 ost1; do
10114 local facet_proc_dirs=$(do_facet $facet \
10115 \\\ls -d $proc_regexp 2>/dev/null)
10116 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10117 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10118 do_facet $facet find $facet_proc_dirs \
10119 ! -name req_history \
10120 -exec cat '{}' \\\; &> /dev/null
10122 do_facet $facet find $facet_proc_dirs \
10123 ! -name req_history \
10125 -exec cat '{}' \\\; &> /dev/null ||
10126 error "proc file read failed"
10129 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
10132 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10133 remote_ost_nodsh && skip "remote OST with nodsh" && return
10134 # Second verifying writability.
10135 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10136 echo "proc_dirs='$proc_dirs'"
10137 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10140 -not -name force_lbug \
10141 -not -name changelog_mask \
10142 -exec badarea_io '{}' \; &> /dev/null ||
10143 error "find $proc_dirs failed"
10146 for facet in mds1 ost1; do
10147 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10148 skip "Too old lustre on $facet" && continue
10149 local facet_proc_dirs=$(do_facet $facet \
10150 \\\ls -d $proc_regexp 2> /dev/null)
10151 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10152 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10153 do_facet $facet find $facet_proc_dirs \
10155 -not -name force_lbug \
10156 -not -name changelog_mask \
10157 -exec badarea_io '{}' \\\; &> /dev/null ||
10158 error "$facet find $facet_proc_dirs failed"
10161 # remount the FS in case writes/reads /proc break the FS
10162 cleanup || error "failed to unmount"
10163 setup || error "failed to setup"
10166 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
10169 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10170 remote_ost_nodsh && skip "remote OST with nodsh" && return
10171 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10172 skip "Need MDS version at least 2.9.54" && return
10175 for facet in client mds1 ost1; do
10176 local facet_proc_dirs=$(do_facet $facet \
10177 \\\ls -d $proc_regexp 2> /dev/null)
10178 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10179 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10180 # Get the list of files that are missing the terminating newline
10181 local missing=($(do_facet $facet \
10182 find ${facet_proc_dirs} -type f \| \
10183 while read F\; do \
10184 awk -v FS='\v' -v RS='\v\v' \
10185 "'END { if(NR>0 && \
10186 \\\$NF !~ /.*\\\n\$/) \
10187 print FILENAME}'" \
10190 [ ${#missing[*]} -eq 0 ] ||
10191 error "files do not end with newline: ${missing[*]}"
10194 run_test 133h "Proc files should end with newlines"
10197 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10198 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10199 skip "Need MDS version at least 2.7.54" && return
10201 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10202 cancel_lru_locks mdc
10204 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10205 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10206 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10209 createmany -o $DIR/$tdir/f $nr ||
10210 error "failed to create $nr files in $DIR/$tdir"
10211 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10213 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10214 do_facet mds1 $LCTL set_param fail_loc=0x327
10215 do_facet mds1 $LCTL set_param fail_val=500
10218 echo "sleep 10 seconds ..."
10220 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10222 do_facet mds1 $LCTL set_param fail_loc=0
10223 do_facet mds1 $LCTL set_param fail_val=0
10224 [ $lck_cnt -lt $unused ] ||
10225 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10228 unlinkmany $DIR/$tdir/f $nr
10230 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10233 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10234 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10235 skip "Need MDS version at least 2.7.54" && return
10237 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10238 cancel_lru_locks mdc
10240 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10241 ldlm.lock_reclaim_threshold_mb)
10242 # disable reclaim temporarily
10243 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10245 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10246 do_facet mds1 $LCTL set_param fail_loc=0x328
10247 do_facet mds1 $LCTL set_param fail_val=500
10249 $LCTL set_param debug=+trace
10252 createmany -o $DIR/$tdir/f $nr &
10253 local create_pid=$!
10255 echo "Sleep $TIMEOUT seconds ..."
10257 if ! ps -p $create_pid > /dev/null 2>&1; then
10258 do_facet mds1 $LCTL set_param fail_loc=0
10259 do_facet mds1 $LCTL set_param fail_val=0
10260 do_facet mds1 $LCTL set_param \
10261 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10262 error "createmany finished incorrectly!"
10264 do_facet mds1 $LCTL set_param fail_loc=0
10265 do_facet mds1 $LCTL set_param fail_val=0
10266 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10267 wait $create_pid || return 1
10269 unlinkmany $DIR/$tdir/f $nr
10271 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10273 test_140() { #bug-17379
10274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10275 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
10276 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10277 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10279 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10280 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10282 while i=`expr $i + 1`; do
10283 test_mkdir -p $i || error "Creating dir $i"
10284 cd $i || error "Changing to $i"
10285 ln -s ../stat stat || error "Creating stat symlink"
10286 # Read the symlink until ELOOP present,
10287 # not LBUGing the system is considered success,
10288 # we didn't overrun the stack.
10289 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10290 [ $ret -ne 0 ] && {
10291 if [ $ret -eq 40 ]; then
10294 error "Open stat symlink"
10300 echo "The symlink depth = $i"
10301 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10302 error "Invalid symlink depth"
10304 # Test recursive symlink
10305 ln -s symlink_self symlink_self
10306 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10307 echo "open symlink_self returns $ret"
10308 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10310 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10314 local TF="$TMP/$tfile"
10316 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10318 cancel_lru_locks osc
10319 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10320 remount_client $MOUNT
10322 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10325 $TRUNCATE $DIR/$tfile 6000
10326 cancel_lru_locks osc
10327 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10330 echo "12345" >>$DIR/$tfile
10331 cancel_lru_locks osc
10332 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10335 echo "12345" >>$DIR/$tfile
10336 cancel_lru_locks osc
10337 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10342 run_test 150 "truncate/append tests"
10344 #LU-2902 roc_hit was not able to read all values from lproc
10345 function roc_hit_init() {
10346 local list=$(comma_list $(osts_nodes))
10347 local dir=$DIR/$tdir-check
10348 local file=$dir/file
10354 #use setstripe to do a write to every ost
10355 for i in $(seq 0 $((OSTCOUNT-1))); do
10356 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10357 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10358 idx=$(printf %04x $i)
10359 BEFORE=$(get_osd_param $list *OST*$idx stats |
10360 awk '$1 == "cache_access" {sum += $7}
10361 END { printf("%0.0f", sum) }')
10363 cancel_lru_locks osc
10364 cat $file >/dev/null
10366 AFTER=$(get_osd_param $list *OST*$idx stats |
10367 awk '$1 == "cache_access" {sum += $7}
10368 END { printf("%0.0f", sum) }')
10370 echo BEFORE:$BEFORE AFTER:$AFTER
10371 if ! let "AFTER - BEFORE == 4"; then
10373 error "roc_hit is not safe to use"
10381 function roc_hit() {
10382 local list=$(comma_list $(osts_nodes))
10383 echo $(get_osd_param $list '' stats |
10384 awk '$1 == "cache_hit" {sum += $7}
10385 END { printf("%0.0f", sum) }')
10388 function set_cache() {
10391 if [ "$2" == "off" ]; then
10394 local list=$(comma_list $(osts_nodes))
10395 set_osd_param $list '' $1_cache_enable $on
10397 cancel_lru_locks osc
10401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10402 remote_ost_nodsh && skip "remote OST with nodsh" && return
10405 local list=$(comma_list $(osts_nodes))
10407 # check whether obdfilter is cache capable at all
10408 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10409 echo "not cache-capable obdfilter"
10413 # check cache is enabled on all obdfilters
10414 if get_osd_param $list '' read_cache_enable | grep 0; then
10415 echo "oss cache is disabled"
10419 set_osd_param $list '' writethrough_cache_enable 1
10421 # check write cache is enabled on all obdfilters
10422 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10423 echo "oss write cache is NOT enabled"
10429 #define OBD_FAIL_OBD_NO_LRU 0x609
10430 do_nodes $list $LCTL set_param fail_loc=0x609
10432 # pages should be in the case right after write
10433 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10436 local BEFORE=$(roc_hit)
10437 cancel_lru_locks osc
10438 cat $DIR/$tfile >/dev/null
10439 local AFTER=$(roc_hit)
10441 do_nodes $list $LCTL set_param fail_loc=0
10443 if ! let "AFTER - BEFORE == CPAGES"; then
10444 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10447 # the following read invalidates the cache
10448 cancel_lru_locks osc
10449 set_osd_param $list '' read_cache_enable 0
10450 cat $DIR/$tfile >/dev/null
10452 # now data shouldn't be found in the cache
10454 cancel_lru_locks osc
10455 cat $DIR/$tfile >/dev/null
10457 if let "AFTER - BEFORE != 0"; then
10458 error "IN CACHE: before: $BEFORE, after: $AFTER"
10461 set_osd_param $list '' read_cache_enable 1
10464 run_test 151 "test cache on oss and controls ==============================="
10467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10468 local TF="$TMP/$tfile"
10470 # simulate ENOMEM during write
10471 #define OBD_FAIL_OST_NOMEM 0x226
10472 lctl set_param fail_loc=0x80000226
10473 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10475 sync || error "sync failed"
10476 lctl set_param fail_loc=0
10478 # discard client's cache
10479 cancel_lru_locks osc
10481 # simulate ENOMEM during read
10482 lctl set_param fail_loc=0x80000226
10483 cmp $TF $DIR/$tfile || error "cmp failed"
10484 lctl set_param fail_loc=0
10488 run_test 152 "test read/write with enomem ============================"
10491 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10493 run_test 153 "test if fdatasync does not crash ======================="
10495 dot_lustre_fid_permission_check() {
10497 local ffid=$MOUNT/.lustre/fid/$fid
10500 echo "stat fid $fid"
10501 stat $ffid > /dev/null || error "stat $ffid failed."
10502 echo "touch fid $fid"
10503 touch $ffid || error "touch $ffid failed."
10504 echo "write to fid $fid"
10505 cat /etc/hosts > $ffid || error "write $ffid failed."
10506 echo "read fid $fid"
10507 diff /etc/hosts $ffid || error "read $ffid failed."
10508 echo "append write to fid $fid"
10509 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10510 echo "rename fid $fid"
10511 mv $ffid $test_dir/$tfile.1 &&
10512 error "rename $ffid to $tfile.1 should fail."
10513 touch $test_dir/$tfile.1
10514 mv $test_dir/$tfile.1 $ffid &&
10515 error "rename $tfile.1 to $ffid should fail."
10516 rm -f $test_dir/$tfile.1
10517 echo "truncate fid $fid"
10518 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10519 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10520 echo "link fid $fid"
10521 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10523 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10524 echo "setfacl fid $fid"
10525 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10526 echo "getfacl fid $fid"
10527 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10529 echo "unlink fid $fid"
10530 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10531 echo "mknod fid $fid"
10532 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10534 fid=[0xf00000400:0x1:0x0]
10535 ffid=$MOUNT/.lustre/fid/$fid
10537 echo "stat non-exist fid $fid"
10538 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10539 echo "write to non-exist fid $fid"
10540 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10541 echo "link new fid $fid"
10542 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10544 mkdir -p $test_dir/$tdir
10545 touch $test_dir/$tdir/$tfile
10546 fid=$($LFS path2fid $test_dir/$tdir)
10549 error "error: could not get fid for $test_dir/$dir/$tfile."
10551 ffid=$MOUNT/.lustre/fid/$fid
10554 ls $ffid > /dev/null || error "ls $ffid failed."
10555 echo "touch $fid/$tfile.1"
10556 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10558 echo "touch $MOUNT/.lustre/fid/$tfile"
10559 touch $MOUNT/.lustre/fid/$tfile && \
10560 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10562 echo "setxattr to $MOUNT/.lustre/fid"
10563 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10565 echo "listxattr for $MOUNT/.lustre/fid"
10566 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10568 echo "delxattr from $MOUNT/.lustre/fid"
10569 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10571 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10572 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10573 error "touch invalid fid should fail."
10575 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10576 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10577 error "touch non-normal fid should fail."
10579 echo "rename $tdir to $MOUNT/.lustre/fid"
10580 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10581 error "rename to $MOUNT/.lustre/fid should fail."
10583 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10585 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10586 local new_obf_mode=777
10588 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10589 chmod $new_obf_mode $DIR/.lustre/fid ||
10590 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10592 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10593 [ $obf_mode -eq $new_obf_mode ] ||
10594 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10596 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10597 chmod $old_obf_mode $DIR/.lustre/fid ||
10598 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10601 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10602 fid=$($LFS path2fid $test_dir/$tfile-2)
10604 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10606 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10607 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10608 error "create lov data thru .lustre failed"
10610 echo "cp /etc/passwd $test_dir/$tfile-2"
10611 cp /etc/passwd $test_dir/$tfile-2 ||
10612 error "copy to $test_dir/$tfile-2 failed."
10613 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10614 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10615 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10617 rm -rf $test_dir/tfile.lnk
10618 rm -rf $test_dir/$tfile-2
10622 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10623 skip "Need MDS version at least 2.4.1" && return
10625 local tf=$DIR/$tfile
10628 local fid=$($LFS path2fid $tf)
10629 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10631 # check that we get the same pathname back
10632 local found=$($LFS fid2path $MOUNT "$fid")
10633 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10634 [ "$found" == "$tf" ] ||
10635 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10637 run_test 154A "lfs path2fid and fid2path basic checks"
10640 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10641 skip "Need MDS version at least 2.4.1" && return
10643 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10644 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10645 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10646 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10648 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10649 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10651 # check that we get the same pathname
10652 echo "PFID: $PFID, name: $name"
10653 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10654 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10655 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10656 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10658 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10660 run_test 154B "verify the ll_decode_linkea tool"
10663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10664 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10665 { skip "Need MDS version at least 2.2.51"; return 0; }
10666 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10667 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10669 cp /etc/hosts $DIR/$tfile
10671 fid=$($LFS path2fid $DIR/$tfile)
10673 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10675 dot_lustre_fid_permission_check "$fid" $DIR ||
10676 error "dot lustre permission check $fid failed"
10678 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10680 touch $MOUNT/.lustre/file &&
10681 error "creation is not allowed under .lustre"
10683 mkdir $MOUNT/.lustre/dir &&
10684 error "mkdir is not allowed under .lustre"
10688 run_test 154a "Open-by-FID"
10691 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10692 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10693 { skip "Need MDS version at least 2.2.51"; return 0; }
10694 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10696 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10698 local remote_dir=$DIR/$tdir/remote_dir
10702 mkdir -p $DIR/$tdir
10703 $LFS mkdir -i $MDTIDX $remote_dir ||
10704 error "create remote directory failed"
10706 cp /etc/hosts $remote_dir/$tfile
10708 fid=$($LFS path2fid $remote_dir/$tfile)
10710 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10712 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10713 error "dot lustre permission check $fid failed"
10716 run_test 154b "Open-by-FID for remote directory"
10719 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10720 skip "Need MDS version at least 2.4.1" && return
10722 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10723 local FID1=$($LFS path2fid $DIR/$tfile.1)
10724 local FID2=$($LFS path2fid $DIR/$tfile.2)
10725 local FID3=$($LFS path2fid $DIR/$tfile.3)
10728 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10729 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10730 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10732 [ "$FID" = "${!want}" ] ||
10733 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10737 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10739 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10740 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10744 run_test 154c "lfs path2fid and fid2path multiple arguments"
10747 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10748 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10749 skip "Need MDS version at least 2.5.53" && return
10751 if remote_mds; then
10752 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10756 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10763 local fid=$($LFS path2fid $DIR/$tfile)
10766 cmd="exec $fd<$DIR/$tfile"
10768 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10769 echo "$fid_list" | grep "$fid"
10772 cmd="exec $fd>/dev/null"
10774 if [ $rc -ne 0 ]; then
10775 error "FID $fid not found in open files list $fid_list"
10778 run_test 154d "Verify open file fid"
10782 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10783 skip "Need MDS version at least 2.6.50" && return
10785 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10786 error ".lustre returned by readdir"
10789 run_test 154e ".lustre is not returned by readdir"
10792 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10793 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10794 test_mkdir -p -c1 $DIR/$tdir/d
10795 # test dirs inherit from its stripe
10796 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10797 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10798 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10799 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10802 # get fid of parents
10803 local FID0=$($LFS path2fid $DIR/$tdir/d)
10804 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10805 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10806 local FID3=$($LFS path2fid $DIR)
10808 # check that path2fid --parents returns expected <parent_fid>/name
10809 # 1) test for a directory (single parent)
10810 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10811 [ "$parent" == "$FID0/foo1" ] ||
10812 error "expected parent: $FID0/foo1, got: $parent"
10814 # 2) test for a file with nlink > 1 (multiple parents)
10815 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10816 echo "$parent" | grep -F "$FID1/$tfile" ||
10817 error "$FID1/$tfile not returned in parent list"
10818 echo "$parent" | grep -F "$FID2/link" ||
10819 error "$FID2/link not returned in parent list"
10821 # 3) get parent by fid
10822 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10823 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10824 echo "$parent" | grep -F "$FID1/$tfile" ||
10825 error "$FID1/$tfile not returned in parent list (by fid)"
10826 echo "$parent" | grep -F "$FID2/link" ||
10827 error "$FID2/link not returned in parent list (by fid)"
10829 # 4) test for entry in root directory
10830 parent=$($LFS path2fid --parents $DIR/f)
10831 echo "$parent" | grep -F "$FID3/f" ||
10832 error "$FID3/f not returned in parent list"
10834 # 5) test it on root directory
10835 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10836 error "$MOUNT should not have parents"
10838 # enable xattr caching and check that linkea is correctly updated
10839 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10840 save_lustre_params client "llite.*.xattr_cache" > $save
10841 lctl set_param llite.*.xattr_cache 1
10843 # 6.1) linkea update on rename
10844 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10846 # get parents by fid
10847 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10848 # foo1 should no longer be returned in parent list
10849 echo "$parent" | grep -F "$FID1" &&
10850 error "$FID1 should no longer be in parent list"
10851 # the new path should appear
10852 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10853 error "$FID2/$tfile.moved is not in parent list"
10855 # 6.2) linkea update on unlink
10856 rm -f $DIR/$tdir/d/foo2/link
10857 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10858 # foo2/link should no longer be returned in parent list
10859 echo "$parent" | grep -F "$FID2/link" &&
10860 error "$FID2/link should no longer be in parent list"
10864 restore_lustre_params < $save
10867 run_test 154f "get parent fids by reading link ea"
10871 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
10872 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
10873 { skip "Need MDS version at least 2.6.92"; return 0; }
10874 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10876 mkdir -p $DIR/$tdir
10877 llapi_fid_test -d $DIR/$tdir
10879 run_test 154g "various llapi FID tests"
10881 test_155_small_load() {
10882 local temp=$TMP/$tfile
10883 local file=$DIR/$tfile
10885 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10886 error "dd of=$temp bs=6096 count=1 failed"
10888 cancel_lru_locks osc
10889 cmp $temp $file || error "$temp $file differ"
10891 $TRUNCATE $temp 6000
10892 $TRUNCATE $file 6000
10893 cmp $temp $file || error "$temp $file differ (truncate1)"
10895 echo "12345" >>$temp
10896 echo "12345" >>$file
10897 cmp $temp $file || error "$temp $file differ (append1)"
10899 echo "12345" >>$temp
10900 echo "12345" >>$file
10901 cmp $temp $file || error "$temp $file differ (append2)"
10907 test_155_big_load() {
10908 remote_ost_nodsh && skip "remote OST with nodsh" && return
10909 local temp=$TMP/$tfile
10910 local file=$DIR/$tfile
10913 local cache_size=$(do_facet ost$((MAXI+1)) \
10914 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10915 local large_file_size=$((cache_size * 2))
10917 echo "OSS cache size: $cache_size KB"
10918 echo "Large file size: $large_file_size KB"
10920 [ $MAXV -le $large_file_size ] && \
10921 skip_env "max available OST size needs > $large_file_size KB" && \
10924 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10926 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10927 error "dd of=$temp bs=$large_file_size count=1k failed"
10930 cancel_lru_locks osc
10931 cmp $temp $file || error "$temp $file differ"
10937 save_writethrough() {
10938 local facets=$(get_facets OST)
10940 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
10941 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
10945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10946 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10947 save_writethrough $p
10950 set_cache writethrough on
10951 test_155_small_load
10952 restore_lustre_params < $p
10955 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10959 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10960 save_writethrough $p
10963 set_cache writethrough off
10964 test_155_small_load
10965 restore_lustre_params < $p
10968 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10972 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10973 save_writethrough $p
10976 set_cache writethrough on
10977 test_155_small_load
10978 restore_lustre_params < $p
10981 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10985 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10986 save_writethrough $p
10989 set_cache writethrough off
10990 test_155_small_load
10991 restore_lustre_params < $p
10994 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10998 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10999 save_writethrough $p
11002 set_cache writethrough on
11004 restore_lustre_params < $p
11007 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11011 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11012 save_writethrough $p
11015 set_cache writethrough off
11017 restore_lustre_params < $p
11020 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11024 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11025 save_writethrough $p
11028 set_cache writethrough on
11030 restore_lustre_params < $p
11033 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11037 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11038 save_writethrough $p
11041 set_cache writethrough off
11043 restore_lustre_params < $p
11046 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11049 remote_ost_nodsh && skip "remote OST with nodsh" && return
11050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11054 local file="$DIR/$tfile"
11055 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11057 [ "$(facet_fstype ost1)" = "zfs" -a \
11058 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11059 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
11062 save_writethrough $p
11065 log "Turn on read and write cache"
11067 set_cache writethrough on
11069 log "Write data and read it back."
11070 log "Read should be satisfied from the cache."
11071 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11073 cancel_lru_locks osc
11074 cat $file >/dev/null
11076 if ! let "AFTER - BEFORE == CPAGES"; then
11077 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11079 log "cache hits:: before: $BEFORE, after: $AFTER"
11082 log "Read again; it should be satisfied from the cache."
11084 cancel_lru_locks osc
11085 cat $file >/dev/null
11087 if ! let "AFTER - BEFORE == CPAGES"; then
11088 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11090 log "cache hits:: before: $BEFORE, after: $AFTER"
11093 log "Turn off the read cache and turn on the write cache"
11095 set_cache writethrough on
11097 log "Read again; it should be satisfied from the cache."
11099 cancel_lru_locks osc
11100 cat $file >/dev/null
11102 if ! let "AFTER - BEFORE == CPAGES"; then
11103 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11105 log "cache hits:: before: $BEFORE, after: $AFTER"
11108 log "Read again; it should not be satisfied from the cache."
11110 cancel_lru_locks osc
11111 cat $file >/dev/null
11113 if ! let "AFTER - BEFORE == 0"; then
11114 error "IN CACHE: before: $BEFORE, after: $AFTER"
11116 log "cache hits:: before: $BEFORE, after: $AFTER"
11119 log "Write data and read it back."
11120 log "Read should be satisfied from the cache."
11121 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11123 cancel_lru_locks osc
11124 cat $file >/dev/null
11126 if ! let "AFTER - BEFORE == CPAGES"; then
11127 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11129 log "cache hits:: before: $BEFORE, after: $AFTER"
11132 log "Read again; it should not be satisfied from the cache."
11134 cancel_lru_locks osc
11135 cat $file >/dev/null
11137 if ! let "AFTER - BEFORE == 0"; then
11138 error "IN CACHE: before: $BEFORE, after: $AFTER"
11140 log "cache hits:: before: $BEFORE, after: $AFTER"
11143 log "Turn off read and write cache"
11145 set_cache writethrough off
11147 log "Write data and read it back"
11148 log "It should not be satisfied from the cache."
11150 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11151 cancel_lru_locks osc
11153 cat $file >/dev/null
11155 if ! let "AFTER - BEFORE == 0"; then
11156 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11158 log "cache hits:: before: $BEFORE, after: $AFTER"
11161 log "Turn on the read cache and turn off the write cache"
11163 set_cache writethrough off
11165 log "Write data and read it back"
11166 log "It should not be satisfied from the cache."
11168 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11170 cancel_lru_locks osc
11171 cat $file >/dev/null
11173 if ! let "AFTER - BEFORE == 0"; then
11174 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11176 log "cache hits:: before: $BEFORE, after: $AFTER"
11179 log "Read again; it should be satisfied from the cache."
11181 cancel_lru_locks osc
11182 cat $file >/dev/null
11184 if ! let "AFTER - BEFORE == CPAGES"; then
11185 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11187 log "cache hits:: before: $BEFORE, after: $AFTER"
11191 restore_lustre_params < $p
11194 run_test 156 "Verification of tunables"
11197 cleanup_changelog () {
11199 echo "Deregistering changelog client $CL_USER"
11200 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11204 if [[ $MDSCOUNT -gt 1 ]]; then
11205 error_ignore bz17935 $*
11213 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11215 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11217 if [ $MASK -eq 1 ]; then
11218 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11220 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11224 changelog_extract_field() {
11228 local identifier=$4
11230 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11231 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11237 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11238 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11239 { skip "Need MDS version at least 2.2.0"; return; }
11241 local CL_USERS="mdd.$MDT0.changelog_users"
11242 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11243 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11244 changelog_register -n)
11245 echo "Registered as changelog user $CL_USER"
11246 trap cleanup_changelog EXIT
11247 $GET_CL_USERS | grep -q $CL_USER ||
11248 error "User $CL_USER not found in changelog_users"
11251 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11252 touch $DIR/$tdir/pics/2008/zachy/timestamp
11253 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11254 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11255 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11256 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11257 rm $DIR/$tdir/pics/desktop.jpg
11259 $LFS changelog $MDT0 | tail -5
11261 echo "verifying changelog mask"
11262 changelog_chmask "MKDIR"
11263 changelog_chmask "CLOSE"
11265 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11266 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11268 changelog_chmask "MKDIR"
11269 changelog_chmask "CLOSE"
11271 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11272 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11274 $LFS changelog $MDT0
11275 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11276 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11277 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11278 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11281 echo "verifying target fid"
11282 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11283 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11284 [ "$fidc" == "$fidf" ] ||
11285 err17935 "fid in changelog $fidc != file fid $fidf"
11286 echo "verifying parent fid"
11287 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11288 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11289 [ "$fidc" == "$fidf" ] ||
11290 err17935 "pfid in changelog $fidc != dir fid $fidf"
11292 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11293 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11294 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11295 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11296 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11297 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11299 MIN_REC=$($GET_CL_USERS |
11300 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11301 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11302 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11303 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11304 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11306 # LU-3446 changelog index reset on MDT restart
11307 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11308 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11309 $LFS changelog_clear $MDT0 $CL_USER 0
11310 stop $SINGLEMDS || error "Fail to stop MDT."
11311 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11312 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11313 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11314 [ $CUR_REC1 == $CUR_REC2 ] ||
11315 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11317 echo "verifying user deregister"
11319 $GET_CL_USERS | grep -q $CL_USER &&
11320 error "User $CL_USER still in changelog_users"
11322 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11323 if [ $CL_USER -eq 0 ]; then
11324 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11325 touch $DIR/$tdir/chloe
11326 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11327 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11328 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11330 echo "$CL_USER other changelog users; can't verify off"
11333 run_test 160a "changelog sanity"
11335 test_160b() { # LU-3587
11336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11337 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11338 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11339 { skip "Need MDS version at least 2.2.0"; return; }
11341 local CL_USERS="mdd.$MDT0.changelog_users"
11342 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11343 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11344 changelog_register -n)
11345 echo "Registered as changelog user $CL_USER"
11346 trap cleanup_changelog EXIT
11347 $GET_CL_USERS | grep -q $CL_USER ||
11348 error "User $CL_USER not found in changelog_users"
11350 local LONGNAME1=$(str_repeat a 255)
11351 local LONGNAME2=$(str_repeat b 255)
11354 echo "creating very long named file"
11355 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11356 echo "moving very long named file"
11357 mv $LONGNAME1 $LONGNAME2
11359 $LFS changelog $MDT0 | grep RENME
11363 run_test 160b "Verify that very long rename doesn't crash in changelog"
11366 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11369 local server_version=$(lustre_version_code $SINGLEMDS)
11371 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11372 [[ $server_version -gt $(version_code 2.5.1) &&
11373 $server_version -lt $(version_code 2.5.50) ]] ||
11374 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11375 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11377 # Registration step
11378 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11379 changelog_register -n)
11380 trap cleanup_changelog EXIT
11383 mkdir -p $DIR/$tdir
11384 $MCREATE $DIR/$tdir/foo_160c
11385 changelog_chmask "TRUNC"
11386 $TRUNCATE $DIR/$tdir/foo_160c 200
11387 changelog_chmask "TRUNC"
11388 $TRUNCATE $DIR/$tdir/foo_160c 199
11389 $LFS changelog $MDT0
11390 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11391 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11392 $LFS changelog_clear $MDT0 $CL_USER 0
11394 # Deregistration step
11397 run_test 160c "verify that changelog log catch the truncate event"
11400 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11401 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11403 local server_version=$(lustre_version_code mds1)
11404 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11406 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11407 { skip "Need MDS version at least 2.7.60+"; return; }
11408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11410 # Registration step
11411 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11412 changelog_register -n)
11414 trap cleanup_changelog EXIT
11415 mkdir -p $DIR/$tdir/migrate_dir
11416 $LFS changelog_clear $MDT0 $CL_USER 0
11418 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11419 $LFS changelog $MDT0
11420 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11421 $LFS changelog_clear $MDT0 $CL_USER 0
11422 [ $MIGRATES -eq 1 ] ||
11423 error "MIGRATE changelog mask count $MIGRATES != 1"
11425 # Deregistration step
11428 run_test 160d "verify that changelog log catch the migrate event"
11431 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11434 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11435 changelog_register -n)
11436 echo "Registered as changelog user $CL_USER"
11437 trap cleanup_changelog EXIT
11439 # Delete a future user (expect fail)
11440 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11443 if [ $rc -eq 0 ]; then
11444 error "Deleted non-existant user cl77"
11445 elif [ $rc -ne 2 ]; then
11446 error "changelog_deregister failed with $rc, " \
11447 "expected 2 (ENOENT)"
11450 # Clear to a bad index (1 billion should be safe)
11451 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11454 if [ $rc -eq 0 ]; then
11455 error "Successfully cleared to invalid CL index"
11456 elif [ $rc -ne 22 ]; then
11457 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11460 run_test 160e "changelog negative testing"
11463 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11464 test_mkdir -p -c1 $DIR/$tdir
11465 cp /etc/hosts $DIR/$tdir/$tfile
11466 test_mkdir -c1 $DIR/$tdir/foo1
11467 test_mkdir -c1 $DIR/$tdir/foo2
11468 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11469 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11470 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11471 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11472 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11473 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11474 $LFS fid2path $DIR $FID
11475 err17935 "bad link ea"
11478 rm $DIR/$tdir/foo2/zachary
11480 rm $DIR/$tdir/foo2/thor
11482 rm $DIR/$tdir/$tfile
11484 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11485 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11487 $LFS fid2path $DIR $FID
11488 err17935 "bad link rename"
11490 rm $DIR/$tdir/foo2/maggie
11493 local longname=filename_avg_len_is_thirty_two_
11494 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11495 error "failed to hardlink many files"
11496 links=$($LFS fid2path $DIR $FID | wc -l)
11497 echo -n "${links}/1000 links in link EA"
11498 [[ $links -gt 60 ]] ||
11499 err17935 "expected at least 60 links in link EA"
11500 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11501 error "failed to unlink many hardlinks"
11503 run_test 161a "link ea sanity"
11506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11507 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11509 local remote_dir=$DIR/$tdir/remote_dir
11511 mkdir -p $DIR/$tdir
11512 $LFS mkdir -i $MDTIDX $remote_dir ||
11513 error "create remote directory failed"
11515 cp /etc/hosts $remote_dir/$tfile
11516 mkdir -p $remote_dir/foo1
11517 mkdir -p $remote_dir/foo2
11518 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11519 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11520 ln $remote_dir/$tfile $remote_dir/foo1/luna
11521 ln $remote_dir/$tfile $remote_dir/foo2/thor
11523 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11525 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11526 $LFS fid2path $DIR $FID
11527 err17935 "bad link ea"
11530 rm $remote_dir/foo2/zachary
11532 rm $remote_dir/foo2/thor
11534 rm $remote_dir/$tfile
11536 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11537 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11538 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11539 $LFS fid2path $DIR $FID
11540 err17935 "bad link rename"
11542 rm $remote_dir/foo2/maggie
11545 local longname=filename_avg_len_is_thirty_two_
11546 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11547 error "failed to hardlink many files"
11548 links=$($LFS fid2path $DIR $FID | wc -l)
11549 echo -n "${links}/1000 links in link EA"
11550 [[ ${links} -gt 60 ]] ||
11551 err17935 "expected at least 60 links in link EA"
11552 unlinkmany $remote_dir/foo2/$longname 1000 ||
11553 error "failed to unlink many hardlinks"
11555 run_test 161b "link ea sanity under remote directory"
11558 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11560 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11561 skip "Need MDS version at least 2.1.5" && return
11563 # define CLF_RENAME_LAST 0x0001
11564 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11565 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11566 changelog_register -n)
11568 trap cleanup_changelog EXIT
11570 mkdir -p $DIR/$tdir
11571 touch $DIR/$tdir/foo_161c
11572 touch $DIR/$tdir/bar_161c
11573 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11574 $LFS changelog $MDT0 | grep RENME
11575 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11577 $LFS changelog_clear $MDT0 $CL_USER 0
11578 if [ x$flags != "x0x1" ]; then
11579 error "flag $flags is not 0x1"
11581 echo "rename overwrite a target having nlink = 1," \
11582 "changelog record has flags of $flags"
11584 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11585 touch $DIR/$tdir/foo_161c
11586 touch $DIR/$tdir/bar_161c
11587 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11588 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11589 $LFS changelog $MDT0 | grep RENME
11590 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11591 $LFS changelog_clear $MDT0 $CL_USER 0
11592 if [ x$flags != "x0x0" ]; then
11593 error "flag $flags is not 0x0"
11595 echo "rename overwrite a target having nlink > 1," \
11596 "changelog record has flags of $flags"
11598 # rename doesn't overwrite a target (changelog flag 0x0)
11599 touch $DIR/$tdir/foo_161c
11600 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11601 $LFS changelog $MDT0 | grep RENME
11602 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11603 $LFS changelog_clear $MDT0 $CL_USER 0
11604 if [ x$flags != "x0x0" ]; then
11605 error "flag $flags is not 0x0"
11607 echo "rename doesn't overwrite a target," \
11608 "changelog record has flags of $flags"
11610 # define CLF_UNLINK_LAST 0x0001
11611 # unlink a file having nlink = 1 (changelog flag 0x1)
11612 rm -f $DIR/$tdir/foo2_161c
11613 $LFS changelog $MDT0 | grep UNLNK
11614 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11615 $LFS changelog_clear $MDT0 $CL_USER 0
11616 if [ x$flags != "x0x1" ]; then
11617 error "flag $flags is not 0x1"
11619 echo "unlink a file having nlink = 1," \
11620 "changelog record has flags of $flags"
11622 # unlink a file having nlink > 1 (changelog flag 0x0)
11623 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11624 rm -f $DIR/$tdir/foobar_161c
11625 $LFS changelog $MDT0 | grep UNLNK
11626 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11627 $LFS changelog_clear $MDT0 $CL_USER 0
11628 if [ x$flags != "x0x0" ]; then
11629 error "flag $flags is not 0x0"
11631 echo "unlink a file having nlink > 1," \
11632 "changelog record has flags of $flags"
11635 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11642 # cleanup previous run
11643 rm -rf $DIR/$tdir/$tfile
11645 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11646 changelog_register -n)
11647 [[ $? -eq 0 ]] || error "changelog_register failed"
11649 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11650 # interfer with $MOUNT/.lustre/fid/ access
11652 [[ $? -eq 0 ]] || error "mkdir failed"
11654 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11655 $LCTL set_param fail_loc=0x8000140c
11657 $LCTL set_param fail_val=5
11660 echo foofoo > $DIR/$tdir/$tfile &
11663 # wait for create to be delayed
11667 [[ $? -eq 0 ]] || error "create should be blocked"
11669 local tempfile=$(mktemp)
11670 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11671 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11672 # some delay may occur during ChangeLog publishing and file read just
11673 # above, that could allow file write to happen finally
11674 [[ -s $tempfile ]] && echo "file should be empty"
11676 $LCTL set_param fail_loc=0
11679 [[ $? -eq 0 ]] || error "create failed"
11681 $LFS changelog_clear $MDT0 $user 0
11682 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11684 run_test 161d "create with concurrent .lustre/fid access"
11691 local path=$(${LFS} fid2path $*)
11692 # Remove the '//' indicating a remote directory
11693 path=$(echo $path | sed 's#//#/#g')
11696 if [ $RC -ne 0 ]; then
11697 err17935 "path looked up of $expected failed. Error $RC"
11699 elif [ "${path}" != "${expected}" ]; then
11700 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11703 echo "fid $fid resolves to path $path (expected $expected)"
11706 test_162a() { # was test_162
11707 # Make changes to filesystem
11708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11709 test_mkdir -p -c1 $DIR/$tdir/d2
11710 touch $DIR/$tdir/d2/$tfile
11711 touch $DIR/$tdir/d2/x1
11712 touch $DIR/$tdir/d2/x2
11713 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11714 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11716 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11717 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11718 error "check path $tdir/d2/$tfile failed"
11721 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11722 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11723 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11724 error "check path $tdir/d2/p/q/r/slink failed"
11726 # softlink to wrong file
11727 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11728 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11729 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11730 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11733 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11734 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11735 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11736 # fid2path dir/fsname should both work
11737 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11738 error "check path $tdir/d2/a/b/c/new_file failed"
11739 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11740 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11742 # hardlink count: check that there are 2 links
11743 # Doesnt work with CMD yet: 17935
11744 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11745 err17935 "expected 2 links"
11747 # hardlink indexing: remove the first link
11748 rm $DIR/$tdir/d2/p/q/r/hlink
11749 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11750 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11754 run_test 162a "path lookup sanity"
11757 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11758 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11761 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11762 error "create striped dir failed"
11764 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11765 tail -n 1 | awk '{print $2}')
11766 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11768 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11769 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11772 for ((i=0;i<5;i++)); do
11773 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11774 error "get fid for f$i failed"
11775 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11776 error "check path $tdir/striped_dir/f$i failed"
11778 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11779 error "get fid for d$i failed"
11780 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11781 error "check path $tdir/striped_dir/d$i failed"
11786 run_test 162b "striped directory path lookup sanity"
11788 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11790 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11791 skip "Need MDS version at least 2.7.51" && return
11792 test_mkdir $DIR/$tdir.local
11793 test_mkdir $DIR/$tdir.remote
11794 local lpath=$tdir.local
11795 local rpath=$tdir.remote
11797 for ((i = 0; i <= 101; i++)); do
11800 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11801 error "get fid for local directory $DIR/$lpath failed"
11802 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11803 error "check path for local directory $DIR/$lpath failed"
11806 test_mkdir $DIR/$rpath
11807 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11808 error "get fid for remote directory $DIR/$rpath failed"
11809 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11810 error "check path for remote directory $DIR/$rpath failed"
11815 run_test 162c "fid2path works with paths 100 or more directories deep"
11818 # do directio so as not to populate the page cache
11819 log "creating a 10 Mb file"
11820 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11821 log "starting reads"
11822 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11823 log "truncating the file"
11824 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11826 kill %+ || true # reads might have finished
11827 echo "wait until dd is finished"
11829 log "removing the temporary file"
11830 rm -rf $DIR/$tfile || error "tmp file removal failed"
11832 run_test 169 "parallel read and truncate should not deadlock"
11835 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11836 $LCTL clear # bug 18514
11837 $LCTL debug_daemon start $TMP/${tfile}_log_good
11839 $LCTL debug_daemon stop
11840 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11841 error "sed failed to read log_good"
11843 $LCTL debug_daemon start $TMP/${tfile}_log_good
11845 $LCTL debug_daemon stop
11847 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11848 error "lctl df log_bad failed"
11850 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11851 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11853 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11854 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11856 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11857 error "bad_line good_line1 good_line2 are empty"
11859 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11860 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11861 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11863 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11864 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11865 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11867 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11868 error "bad_line_new good_line_new are empty"
11870 local expected_good=$((good_line1 + good_line2*2))
11872 rm -f $TMP/${tfile}*
11873 # LU-231, short malformed line may not be counted into bad lines
11874 if [ $bad_line -ne $bad_line_new ] &&
11875 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11876 error "expected $bad_line bad lines, but got $bad_line_new"
11880 if [ $expected_good -ne $good_line_new ]; then
11881 error "expected $expected_good good lines, but got $good_line_new"
11886 run_test 170 "test lctl df to handle corrupted log ====================="
11888 test_171() { # bug20592
11889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11890 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11891 $LCTL set_param fail_loc=0x50e
11892 $LCTL set_param fail_val=3000
11893 multiop_bg_pause $DIR/$tfile O_s || true
11895 kill -USR1 $MULTIPID
11899 if dmesg | grep "recursive fault"; then
11900 error "caught a recursive fault"
11902 $LCTL set_param fail_loc=0
11905 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11907 # it would be good to share it with obdfilter-survey/iokit-libecho code
11908 setup_obdecho_osc () {
11911 local obdfilter_name=$2
11912 echo "Creating new osc for $obdfilter_name on $ost_nid"
11913 # make sure we can find loopback nid
11914 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11916 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11917 ${obdfilter_name}_osc_UUID || rc=2; }
11918 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11919 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11923 cleanup_obdecho_osc () {
11924 local obdfilter_name=$1
11925 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11926 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11933 local pages=${3:-64}
11938 local obd_size=$(get_obd_size $node $OBD)
11939 local page_size=$(get_page_size $node)
11940 if [[ -n "$obd_size" ]]; then
11941 local new_count=$((obd_size / (pages * page_size / 1024)))
11942 [[ $new_count -ge $count ]] || count=$new_count
11945 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11946 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11948 if [ $rc -eq 0 ]; then
11949 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11950 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11952 echo "New object id is $id"
11953 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11955 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11956 "test_brw $count w v $pages $id" || rc=4; }
11957 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11959 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11960 "cleanup" || rc=5; }
11961 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11962 "detach" || rc=6; }
11963 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11969 remote_ost_nodsh && skip "remote OST with nodsh" && return
11971 local rmmod_local=0
11973 if ! module_loaded obdecho; then
11974 load_module obdecho/obdecho
11978 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11979 local host=$(lctl get_param -n osc.$osc.import |
11980 awk '/current_connection:/ {print $2}' )
11981 local target=$(lctl get_param -n osc.$osc.import |
11982 awk '/target:/ {print $2}' )
11983 target=${target%_UUID}
11985 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11986 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11987 [[ -n $target ]] && cleanup_obdecho_osc $target
11988 [ $rmmod_local -eq 1 ] && rmmod obdecho
11991 run_test 180a "test obdecho on osc"
11994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11995 remote_ost_nodsh && skip "remote OST with nodsh" && return
11997 local rmmod_remote=0
11999 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12000 rmmod_remote=true || error "failed to load module obdecho"
12001 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
12002 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12003 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12006 run_test 180b "test obdecho directly on obdfilter"
12008 test_180c() { # LU-2598
12009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12010 remote_ost_nodsh && skip "remote OST with nodsh" && return
12011 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12012 skip "Need MDS version at least 2.4.0" && return
12015 local rmmod_remote=false
12016 local pages=16384 # 64MB bulk I/O RPC size
12019 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12020 rmmod_remote=true || error "failed to load module obdecho"
12022 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
12024 if [ -n "$target" ]; then
12025 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12027 echo "there is no obdfilter target on ost1"
12030 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12033 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12035 test_181() { # bug 22177
12036 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12037 # create enough files to index the directory
12038 createmany -o $DIR/$tdir/foobar 4000
12039 # print attributes for debug purpose
12042 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12044 # remove the files & current working dir
12045 unlinkmany $DIR/$tdir/foobar 4000
12047 kill -USR1 $MULTIPID
12049 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12052 run_test 181 "Test open-unlinked dir ========================"
12058 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12060 $LCTL set_param mdc.*.rpc_stats=clear
12062 for (( i = 0; i < $tcount; i++ )) ; do
12063 mkdir $DIR/$tdir/$i
12066 for (( i = 0; i < $tcount; i++ )) ; do
12067 createmany -o $DIR/$tdir/$i/f- $fcount &
12071 for (( i = 0; i < $tcount; i++ )) ; do
12072 unlinkmany $DIR/$tdir/$i/f- $fcount &
12076 $LCTL get_param mdc.*.rpc_stats
12080 run_test 182 "Test parallel modify metadata operations ================"
12082 test_183() { # LU-2275
12083 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12084 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12085 skip "Need MDS version at least 2.3.56" && return
12087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12088 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12089 echo aaa > $DIR/$tdir/$tfile
12091 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12092 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12094 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12095 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12097 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12099 # Flush negative dentry cache
12100 touch $DIR/$tdir/$tfile
12102 # We are not checking for any leaked references here, they'll
12103 # become evident next time we do cleanup with module unload.
12106 run_test 183 "No crash or request leak in case of strange dispositions ========"
12108 # test suite 184 is for LU-2016, LU-2017
12110 check_swap_layouts_support && return 0
12112 dir0=$DIR/$tdir/$testnum
12113 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
12118 $SETSTRIPE -c1 $file1
12120 $SETSTRIPE -c2 $file2
12122 gen1=$($GETSTRIPE -g $file1)
12123 gen2=$($GETSTRIPE -g $file2)
12125 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12126 gen=$($GETSTRIPE -g $file1)
12127 [[ $gen1 != $gen ]] ||
12128 "Layout generation on $file1 does not change"
12129 gen=$($GETSTRIPE -g $file2)
12130 [[ $gen2 != $gen ]] ||
12131 "Layout generation on $file2 does not change"
12133 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12134 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12136 run_test 184a "Basic layout swap"
12139 check_swap_layouts_support && return 0
12141 dir0=$DIR/$tdir/$testnum
12142 mkdir -p $dir0 || error "creating dir $dir0"
12149 $SETSTRIPE -c1 $file1
12150 $SETSTRIPE -c2 $file2
12151 $SETSTRIPE -c1 $file3
12152 chown $RUNAS_ID $file3
12153 gen1=$($GETSTRIPE -g $file1)
12154 gen2=$($GETSTRIPE -g $file2)
12156 $LFS swap_layouts $dir1 $dir2 &&
12157 error "swap of directories layouts should fail"
12158 $LFS swap_layouts $dir1 $file1 &&
12159 error "swap of directory and file layouts should fail"
12160 $RUNAS $LFS swap_layouts $file1 $file2 &&
12161 error "swap of file we cannot write should fail"
12162 $LFS swap_layouts $file1 $file3 &&
12163 error "swap of file with different owner should fail"
12164 /bin/true # to clear error code
12166 run_test 184b "Forbidden layout swap (will generate errors)"
12169 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12170 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12171 check_swap_layouts_support && return 0
12173 local dir0=$DIR/$tdir/$testnum
12174 mkdir -p $dir0 || error "creating dir $dir0"
12176 local ref1=$dir0/ref1
12177 local ref2=$dir0/ref2
12178 local file1=$dir0/file1
12179 local file2=$dir0/file2
12180 # create a file large enough for the concurrent test
12181 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12182 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12183 echo "ref file size: ref1($(stat -c %s $ref1))," \
12184 "ref2($(stat -c %s $ref2))"
12187 dd if=$ref1 of=$file1 bs=16k &
12190 # Make sure dd starts to copy file
12191 while [ ! -f $file1 ]; do sleep 0.1; done
12193 $LFS swap_layouts $file1 $file2
12196 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12197 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12199 # how many bytes copied before swapping layout
12200 local copied=$(stat -c %s $file2)
12201 local remaining=$(stat -c %s $ref1)
12202 remaining=$((remaining - copied))
12203 echo "Copied $copied bytes before swapping layout..."
12205 cmp -n $copied $file1 $ref2 | grep differ &&
12206 error "Content mismatch [0, $copied) of ref2 and file1"
12207 cmp -n $copied $file2 $ref1 ||
12208 error "Content mismatch [0, $copied) of ref1 and file2"
12209 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12210 error "Content mismatch [$copied, EOF) of ref1 and file1"
12213 rm -f $ref1 $ref2 $file1 $file2
12215 run_test 184c "Concurrent write and layout swap"
12218 check_swap_layouts_support && return 0
12219 [ -z "$(which getfattr 2>/dev/null)" ] &&
12220 skip "no getfattr command" && return 0
12222 local file1=$DIR/$tdir/$tfile-1
12223 local file2=$DIR/$tdir/$tfile-2
12224 local file3=$DIR/$tdir/$tfile-3
12228 mkdir -p $DIR/$tdir
12229 touch $file1 || error "create $file1 failed"
12230 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12231 error "create $file2 failed"
12232 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12233 error "create $file3 failed"
12234 lovea1=$(get_layout_param $file1)
12236 $LFS swap_layouts $file2 $file3 ||
12237 error "swap $file2 $file3 layouts failed"
12238 $LFS swap_layouts $file1 $file2 ||
12239 error "swap $file1 $file2 layouts failed"
12241 lovea2=$(get_layout_param $file2)
12244 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12246 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12247 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12249 run_test 184d "allow stripeless layouts swap"
12252 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12253 { skip "Need MDS version at least 2.6.94"; return 0; }
12254 check_swap_layouts_support && return 0
12255 [ -z "$(which getfattr 2>/dev/null)" ] &&
12256 skip "no getfattr command" && return 0
12258 local file1=$DIR/$tdir/$tfile-1
12259 local file2=$DIR/$tdir/$tfile-2
12260 local file3=$DIR/$tdir/$tfile-3
12263 mkdir -p $DIR/$tdir
12264 touch $file1 || error "create $file1 failed"
12265 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12266 error "create $file2 failed"
12267 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12268 error "create $file3 failed"
12270 $LFS swap_layouts $file1 $file2 ||
12271 error "swap $file1 $file2 layouts failed"
12273 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12274 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12276 echo 123 > $file1 || error "Should be able to write into $file1"
12278 $LFS swap_layouts $file1 $file3 ||
12279 error "swap $file1 $file3 layouts failed"
12281 echo 123 > $file1 || error "Should be able to write into $file1"
12283 rm -rf $file1 $file2 $file3
12285 run_test 184e "Recreate layout after stripeless layout swaps"
12287 test_185() { # LU-2441
12288 # LU-3553 - no volatile file support in old servers
12289 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12290 { skip "Need MDS version at least 2.3.60"; return 0; }
12292 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12293 touch $DIR/$tdir/spoo
12294 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12295 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12296 error "cannot create/write a volatile file"
12297 [ "$FILESET" == "" ] &&
12298 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12299 error "FID is still valid after close"
12301 multiop_bg_pause $DIR/$tdir vVw4096_c
12308 # assume that the next FID for this client is sequential, since stdout
12309 # is unfortunately eaten by multiop_bg_pause
12310 local n=$((${fidv[1]} + 1))
12311 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12312 if [ "$FILESET" == "" ]; then
12313 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12314 error "FID is missing before close"
12316 kill -USR1 $multi_pid
12317 # 1 second delay, so if mtime change we will see it
12319 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12320 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12322 run_test 185 "Volatile file support"
12325 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12326 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12327 skip "Need MDS version at least 2.3.0" && return
12329 local dir0=$DIR/$tdir/$testnum
12330 mkdir -p $dir0 || error "creating dir $dir0"
12332 local file=$dir0/file1
12333 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12334 local dv1=$($LFS data_version $file)
12335 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12336 local dv2=$($LFS data_version $file)
12337 [[ $dv1 != $dv2 ]] ||
12338 error "data version did not change on write $dv1 == $dv2"
12343 run_test 187a "Test data version change"
12346 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12347 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12348 skip "Need MDS version at least 2.3.0" && return
12350 local dir0=$DIR/$tdir/$testnum
12351 mkdir -p $dir0 || error "creating dir $dir0"
12353 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12354 [[ ${DV[0]} != ${DV[1]} ]] ||
12355 error "data version did not change on write"\
12356 " ${DV[0]} == ${DV[1]}"
12361 run_test 187b "Test data version change on volatile file"
12364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12365 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12366 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12368 local POOL=${POOL:-cea1}
12369 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12370 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12373 local last_ost=$(($OSTCOUNT - 1))
12375 local ost_list=$(seq $first_ost $ost_step $last_ost)
12376 local ost_range="$first_ost $last_ost $ost_step"
12377 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12378 local file_dir=$POOL_ROOT/file_tst
12379 local subdir=$test_path/subdir
12382 if ! combined_mgs_mds ; then
12387 # former test_200a test_200b
12388 pool_add $POOL || { rc=$? ; break; }
12389 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12390 # former test_200c test_200d
12391 mkdir -p $test_path
12392 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12393 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12395 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12396 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12397 || { rc=$? ; break; }
12398 # former test_200e test_200f
12399 local files=$((OSTCOUNT*3))
12400 pool_alloc_files $POOL $test_path $files "$ost_list" \
12401 || { rc=$? ; break; }
12402 pool_create_files $POOL $file_dir $files "$ost_list" \
12403 || { rc=$? ; break; }
12404 # former test_200g test_200h
12405 pool_lfs_df $POOL || { rc=$? ; break; }
12406 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12408 # former test_201a test_201b test_201c
12409 pool_remove_first_target $POOL || { rc=$? ; break; }
12411 local f=$test_path/$tfile
12412 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12413 pool_remove $POOL $f || { rc=$? ; break; }
12419 if ! combined_mgs_mds ; then
12424 run_test 200 "OST pools"
12426 # usage: default_attr <count | size | offset>
12428 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12431 # usage: check_default_stripe_attr
12432 check_default_stripe_attr() {
12433 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12436 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12438 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12442 error "unknown getstripe attr '$1'"
12445 [ $ACTUAL != $EXPECTED ] &&
12446 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12450 test_mkdir -p $DIR/$tdir
12451 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12453 check_default_stripe_attr --stripe-count
12454 check_default_stripe_attr --stripe-size
12455 check_default_stripe_attr --stripe-index
12459 run_test 204a "Print default stripe attributes ================="
12462 test_mkdir -p $DIR/$tdir
12463 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12465 check_default_stripe_attr --stripe-size
12466 check_default_stripe_attr --stripe-index
12470 run_test 204b "Print default stripe size and offset ==========="
12473 test_mkdir -p $DIR/$tdir
12474 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12476 check_default_stripe_attr --stripe-count
12477 check_default_stripe_attr --stripe-index
12481 run_test 204c "Print default stripe count and offset ==========="
12484 test_mkdir -p $DIR/$tdir
12485 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12487 check_default_stripe_attr --stripe-count
12488 check_default_stripe_attr --stripe-size
12492 run_test 204d "Print default stripe count and size ============="
12495 test_mkdir -p $DIR/$tdir
12496 $SETSTRIPE -d $DIR/$tdir
12498 check_default_stripe_attr --stripe-count --raw
12499 check_default_stripe_attr --stripe-size --raw
12500 check_default_stripe_attr --stripe-index --raw
12504 run_test 204e "Print raw stripe attributes ================="
12507 test_mkdir -p $DIR/$tdir
12508 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12510 check_default_stripe_attr --stripe-size --raw
12511 check_default_stripe_attr --stripe-index --raw
12515 run_test 204f "Print raw stripe size and offset ==========="
12518 test_mkdir -p $DIR/$tdir
12519 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12521 check_default_stripe_attr --stripe-count --raw
12522 check_default_stripe_attr --stripe-index --raw
12526 run_test 204g "Print raw stripe count and offset ==========="
12529 test_mkdir -p $DIR/$tdir
12530 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12532 check_default_stripe_attr --stripe-count --raw
12533 check_default_stripe_attr --stripe-size --raw
12537 run_test 204h "Print raw stripe count and size ============="
12539 # Figure out which job scheduler is being used, if any,
12540 # or use a fake one
12541 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12542 JOBENV=SLURM_JOB_ID
12543 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12545 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12547 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12548 JOBENV=LOADL_STEP_ID
12549 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12552 $LCTL list_param jobid_name > /dev/null 2>&1
12553 if [ $? -eq 0 ]; then
12560 verify_jobstats() {
12565 # we don't really need to clear the stats for this test to work, since each
12566 # command has a unique jobid, but it makes debugging easier if needed.
12567 # for facet in $facets; do
12568 # local dev=$(convert_facet2label $facet)
12569 # # clear old jobstats
12570 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12573 # use a new JobID for each test, or we might see an old one
12574 [ "$JOBENV" = "FAKE_JOBID" ] &&
12575 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12579 [ "$JOBENV" = "nodelocal" ] && {
12580 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12581 $LCTL set_param jobid_name=$FAKE_JOBID
12585 log "Test: ${cmd[*]}"
12586 log "Using JobID environment variable $JOBENV=$JOBVAL"
12588 if [ $JOBENV = "FAKE_JOBID" ]; then
12589 FAKE_JOBID=$JOBVAL ${cmd[*]}
12594 # all files are created on OST0000
12595 for facet in $facets; do
12596 local stats="*.$(convert_facet2label $facet).job_stats"
12597 if [ $(do_facet $facet lctl get_param $stats |
12598 grep -c $JOBVAL) -ne 1 ]; then
12599 do_facet $facet lctl get_param $stats
12600 error "No jobstats for $JOBVAL found on $facet::$stats"
12607 NEW_JOBENV=${1:-$OLD_JOBENV}
12608 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12609 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12614 do_facet $SINGLEMDS \
12615 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12616 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12620 test_205() { # Job stats
12621 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12622 { skip "Need MDS version with at least 2.7.1"; return 0; }
12624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12625 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12626 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12627 remote_ost_nodsh && skip "remote OST with nodsh" && return
12629 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12630 skip "Server doesn't support jobstats" && return 0
12631 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12633 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12634 if [ $OLD_JOBENV != $JOBENV ]; then
12635 jobstats_set $JOBENV
12636 trap cleanup_205 EXIT
12639 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12640 echo "Registered as changelog user $CL_USER"
12642 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12643 lctl get_param -n mdt.*.job_cleanup_interval)
12644 local interval_new=5
12645 do_facet $SINGLEMDS \
12646 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12647 local start=$SECONDS
12651 cmd="mkdir $DIR/$tdir"
12652 verify_jobstats "$cmd" "$SINGLEMDS"
12654 cmd="rmdir $DIR/$tdir"
12655 verify_jobstats "$cmd" "$SINGLEMDS"
12656 # mkdir on secondary MDT
12657 if [ $MDSCOUNT -gt 1 ]; then
12658 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12659 verify_jobstats "$cmd" "mds2"
12662 cmd="mknod $DIR/$tfile c 1 3"
12663 verify_jobstats "$cmd" "$SINGLEMDS"
12665 cmd="rm -f $DIR/$tfile"
12666 verify_jobstats "$cmd" "$SINGLEMDS"
12667 # create all files on OST0000 so verify_jobstats can find OST stats
12669 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12670 verify_jobstats "$cmd" "$SINGLEMDS"
12672 cmd="touch $DIR/$tfile"
12673 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12675 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12676 verify_jobstats "$cmd" "ost1"
12678 cancel_lru_locks osc
12679 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12680 verify_jobstats "$cmd" "ost1"
12682 cmd="$TRUNCATE $DIR/$tfile 0"
12683 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12685 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12686 verify_jobstats "$cmd" "$SINGLEMDS"
12687 # jobstats expiry - sleep until old stats should be expired
12688 local left=$((interval_new + 5 - (SECONDS - start)))
12689 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12690 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12692 cmd="mkdir $DIR/$tdir.expire"
12693 verify_jobstats "$cmd" "$SINGLEMDS"
12694 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12695 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12697 # Ensure that jobid are present in changelog (if supported by MDS)
12698 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12700 $LFS changelog $MDT0 | tail -9
12701 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12702 [ $jobids -eq 9 ] ||
12703 error "Wrong changelog jobid count $jobids != 9"
12707 jobstats_set $JOBENV
12709 $LFS changelog $MDT0 | tail -1
12710 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12711 [ $jobids -eq 0 ] ||
12712 error "Unexpected jobids when jobid_var=$JOBENV"
12717 run_test 205 "Verify job stats"
12719 # LU-1480, LU-1773 and LU-1657
12721 mkdir -p $DIR/$tdir
12722 $SETSTRIPE -c -1 $DIR/$tdir
12723 #define OBD_FAIL_LOV_INIT 0x1403
12724 $LCTL set_param fail_loc=0xa0001403
12725 $LCTL set_param fail_val=1
12726 touch $DIR/$tdir/$tfile || true
12728 run_test 206 "fail lov_init_raid0() doesn't lbug"
12731 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12732 local fsz=`stat -c %s $DIR/$tfile`
12733 cancel_lru_locks mdc
12735 # do not return layout in getattr intent
12736 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12737 $LCTL set_param fail_loc=0x170
12738 local sz=`stat -c %s $DIR/$tfile`
12740 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12744 run_test 207a "can refresh layout at glimpse"
12747 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12748 local cksum=`md5sum $DIR/$tfile`
12749 local fsz=`stat -c %s $DIR/$tfile`
12750 cancel_lru_locks mdc
12751 cancel_lru_locks osc
12753 # do not return layout in getattr intent
12754 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12755 $LCTL set_param fail_loc=0x171
12757 # it will refresh layout after the file is opened but before read issues
12758 echo checksum is "$cksum"
12759 echo "$cksum" |md5sum -c --quiet || error "file differs"
12763 run_test 207b "can refresh layout at open"
12766 # FIXME: in this test suite, only RD lease is used. This is okay
12767 # for now as only exclusive open is supported. After generic lease
12768 # is done, this test suite should be revised. - Jinshan
12770 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12771 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12772 { skip "Need MDS version at least 2.4.52"; return 0; }
12774 echo "==== test 1: verify get lease work"
12775 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12777 echo "==== test 2: verify lease can be broken by upcoming open"
12778 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12782 $MULTIOP $DIR/$tfile oO_RDONLY:c
12783 kill -USR1 $PID && wait $PID || error "break lease error"
12785 echo "==== test 3: verify lease can't be granted if an open already exists"
12786 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12790 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12791 kill -USR1 $PID && wait $PID || error "open file error"
12793 echo "==== test 4: lease can sustain over recovery"
12794 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12800 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12802 echo "==== test 5: lease broken can't be regained by replay"
12803 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12807 # open file to break lease and then recovery
12808 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12811 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12815 run_test 208 "Exclusive open"
12818 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12819 skip_env "must have disp_stripe" && return
12822 sync; sleep 5; sync;
12824 echo 3 > /proc/sys/vm/drop_caches
12825 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12827 # open/close 500 times
12828 for i in $(seq 500); do
12832 echo 3 > /proc/sys/vm/drop_caches
12833 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12835 echo "before: $req_before, after: $req_after"
12836 [ $((req_after - req_before)) -ge 300 ] &&
12837 error "open/close requests are not freed"
12840 run_test 209 "read-only open/close requests should be freed promptly"
12844 size=$((size % 8192 + 1))
12845 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12846 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12847 rm -f $DIR/f212 $DIR/f212.xyz
12849 run_test 212 "Sendfile test ============================================"
12852 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12853 cancel_lru_locks osc
12854 lctl set_param fail_loc=0x8000040f
12855 # generate a read lock
12856 cat $DIR/$tfile > /dev/null
12857 # write to the file, it will try to cancel the above read lock.
12858 cat /etc/hosts >> $DIR/$tfile
12860 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12862 test_214() { # for bug 20133
12863 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12864 for (( i=0; i < 340; i++ )) ; do
12865 touch $DIR/$tdir/d214c/a$i
12868 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12869 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12870 ls $DIR/d214c || error "ls $DIR/d214c failed"
12871 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12872 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12874 run_test 214 "hash-indexed directory test - bug 20133"
12876 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12877 create_lnet_proc_files() {
12878 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
12879 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
12881 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12882 rm -f "$TMP/lnet_$1.sys_tmp"
12885 # counterpart of create_lnet_proc_files
12886 remove_lnet_proc_files() {
12887 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12890 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12891 # 3rd arg as regexp for body
12892 check_lnet_proc_stats() {
12893 local l=$(cat "$TMP/lnet_$1" |wc -l)
12894 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12896 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12899 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12900 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12901 # optional and can be regexp for 2nd line (lnet.routes case)
12902 check_lnet_proc_entry() {
12903 local blp=2 # blp stands for 'position of 1st line of body'
12904 [ -z "$5" ] || blp=3 # lnet.routes case
12906 local l=$(cat "$TMP/lnet_$1" |wc -l)
12907 # subtracting one from $blp because the body can be empty
12908 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12910 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12911 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12913 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12914 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12916 # bail out if any unexpected line happened
12917 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12918 [ "$?" != 0 ] || error "$2 misformatted"
12921 test_215() { # for bugs 18102, 21079, 21517
12922 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12923 local N='(0|[1-9][0-9]*)' # non-negative numeric
12924 local P='[1-9][0-9]*' # positive numeric
12925 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12926 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12927 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12928 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12930 local L1 # regexp for 1st line
12931 local L2 # regexp for 2nd line (optional)
12932 local BR # regexp for the rest (body)
12934 # lnet.stats should look as 11 space-separated non-negative numerics
12935 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12936 create_lnet_proc_files "stats"
12937 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12938 remove_lnet_proc_files "stats"
12940 # lnet.routes should look like this:
12941 # Routing disabled/enabled
12942 # net hops priority state router
12943 # where net is a string like tcp0, hops > 0, priority >= 0,
12944 # state is up/down,
12945 # router is a string like 192.168.1.1@tcp2
12946 L1="^Routing (disabled|enabled)$"
12947 L2="^net +hops +priority +state +router$"
12948 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12949 create_lnet_proc_files "routes"
12950 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12951 remove_lnet_proc_files "routes"
12953 # lnet.routers should look like this:
12954 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12955 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12956 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12957 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12958 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12959 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12960 create_lnet_proc_files "routers"
12961 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12962 remove_lnet_proc_files "routers"
12964 # lnet.peers should look like this:
12965 # nid refs state last max rtr min tx min queue
12966 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12967 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12968 # numeric (0 or >0 or <0), queue >= 0.
12969 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12970 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12971 create_lnet_proc_files "peers"
12972 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12973 remove_lnet_proc_files "peers"
12975 # lnet.buffers should look like this:
12976 # pages count credits min
12977 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12978 L1="^pages +count +credits +min$"
12979 BR="^ +$N +$N +$I +$I$"
12980 create_lnet_proc_files "buffers"
12981 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12982 remove_lnet_proc_files "buffers"
12984 # lnet.nis should look like this:
12985 # nid status alive refs peer rtr max tx min
12986 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12987 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12988 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12989 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12990 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12991 create_lnet_proc_files "nis"
12992 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12993 remove_lnet_proc_files "nis"
12995 # can we successfully write to lnet.stats?
12996 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12997 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12999 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
13001 test_216() { # bug 20317
13002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13003 remote_ost_nodsh && skip "remote OST with nodsh" && return
13006 local facets=$(get_facets OST)
13007 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13009 save_lustre_params client "osc.*.contention_seconds" > $p
13010 save_lustre_params $facets \
13011 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13012 save_lustre_params $facets \
13013 "ldlm.namespaces.filter-*.contended_locks" >> $p
13014 save_lustre_params $facets \
13015 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13016 clear_stats osc.*.osc_stats
13018 # agressive lockless i/o settings
13019 do_nodes $(comma_list $(osts_nodes)) \
13020 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13021 ldlm.namespaces.filter-*.contended_locks=0 \
13022 ldlm.namespaces.filter-*.contention_seconds=60"
13023 lctl set_param -n osc.*.contention_seconds=60
13025 $DIRECTIO write $DIR/$tfile 0 10 4096
13026 $CHECKSTAT -s 40960 $DIR/$tfile
13028 # disable lockless i/o
13029 do_nodes $(comma_list $(osts_nodes)) \
13030 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13031 ldlm.namespaces.filter-*.contended_locks=32 \
13032 ldlm.namespaces.filter-*.contention_seconds=0"
13033 lctl set_param -n osc.*.contention_seconds=0
13034 clear_stats osc.*.osc_stats
13036 dd if=/dev/zero of=$DIR/$tfile count=0
13037 $CHECKSTAT -s 0 $DIR/$tfile
13039 restore_lustre_params <$p
13043 run_test 216 "check lockless direct write updates file size and kms correctly"
13045 test_217() { # bug 22430
13046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13050 for node in $(nodes_list); do
13051 nid=$(host_nids_address $node $NETTYPE)
13052 if [[ $nid = *-* ]] ; then
13053 echo "lctl ping $(h2nettype $nid)"
13054 lctl ping $(h2nettype $nid)
13056 echo "skipping $node (no hyphen detected)"
13060 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13063 # do directio so as not to populate the page cache
13064 log "creating a 10 Mb file"
13065 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13066 log "starting reads"
13067 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13068 log "truncating the file"
13069 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13071 kill %+ || true # reads might have finished
13072 echo "wait until dd is finished"
13074 log "removing the temporary file"
13075 rm -rf $DIR/$tfile || error "tmp file removal failed"
13077 run_test 218 "parallel read and truncate should not deadlock ======================="
13080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13081 # write one partial page
13082 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13083 # set no grant so vvp_io_commit_write will do sync write
13084 $LCTL set_param fail_loc=0x411
13085 # write a full page at the end of file
13086 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13088 $LCTL set_param fail_loc=0
13089 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13090 $LCTL set_param fail_loc=0x411
13091 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13094 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13095 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13097 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13099 test_220() { #LU-325
13100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13101 remote_ost_nodsh && skip "remote OST with nodsh" && return
13102 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13103 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13106 # create on MDT0000 so the last_id and next_id are correct
13108 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13112 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13113 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13114 osc.$mdtosc_proc1.prealloc_last_id)
13115 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13116 osc.$mdtosc_proc1.prealloc_next_id)
13120 if ! combined_mgs_mds ; then
13124 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13125 #define OBD_FAIL_OST_ENOINO 0x229
13126 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13127 create_pool $FSNAME.$TESTNAME || return 1
13128 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13130 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13132 MDSOBJS=$((last_id - next_id))
13133 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13135 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13136 echo "OST still has $count kbytes free"
13138 echo "create $MDSOBJS files @next_id..."
13139 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13141 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13142 osc.$mdtosc_proc1.prealloc_last_id)
13143 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13144 osc.$mdtosc_proc1.prealloc_next_id)
13146 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13151 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13152 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13154 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
13155 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
13156 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
13157 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
13158 echo "unlink $MDSOBJS files @$next_id..."
13159 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
13161 if ! combined_mgs_mds ; then
13165 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13169 dd if=`which date` of=$MOUNT/date oflag=sync
13170 chmod +x $MOUNT/date
13172 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13173 $LCTL set_param fail_loc=0x80001401
13175 $MOUNT/date > /dev/null
13178 run_test 221 "make sure fault and truncate race to not cause OOM"
13181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13183 test_mkdir -p $DIR/$tdir
13184 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13185 createmany -o $DIR/$tdir/$tfile 10
13186 cancel_lru_locks mdc
13187 cancel_lru_locks osc
13188 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13189 $LCTL set_param fail_loc=0x31a
13190 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13191 $LCTL set_param fail_loc=0
13194 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
13197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13199 test_mkdir -p $DIR/$tdir
13200 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13201 createmany -o $DIR/$tdir/$tfile 10
13202 cancel_lru_locks mdc
13203 cancel_lru_locks osc
13204 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13205 $LCTL set_param fail_loc=0x31a
13206 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13207 $LCTL set_param fail_loc=0
13209 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
13212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13214 test_mkdir -p $DIR/$tdir
13215 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
13216 createmany -o $DIR/$tdir/$tfile 10
13217 cancel_lru_locks mdc
13218 cancel_lru_locks osc
13219 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13220 $LCTL set_param fail_loc=0x31b
13221 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13222 $LCTL set_param fail_loc=0
13225 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13227 test_224a() { # LU-1039, MRP-303
13228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13229 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13230 $LCTL set_param fail_loc=0x508
13231 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13232 $LCTL set_param fail_loc=0
13235 run_test 224a "Don't panic on bulk IO failure"
13237 test_224b() { # LU-1039, MRP-303
13238 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13239 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13240 cancel_lru_locks osc
13241 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13242 $LCTL set_param fail_loc=0x515
13243 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13244 $LCTL set_param fail_loc=0
13247 run_test 224b "Don't panic on bulk IO failure"
13249 test_224c() { # LU-6441
13250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13251 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13253 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13254 save_writethrough $p
13255 set_cache writethrough on
13257 local pages_per_rpc=$($LCTL get_param \
13258 osc.*.max_pages_per_rpc)
13259 local at_max=$($LCTL get_param -n at_max)
13260 local timeout=$($LCTL get_param -n timeout)
13261 local test_at="$LCTL get_param -n at_max"
13262 local param_at="$FSNAME.sys.at_max"
13263 local test_timeout="$LCTL get_param -n timeout"
13264 local param_timeout="$FSNAME.sys.timeout"
13266 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13268 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13269 error "conf_param at_max=0 failed"
13270 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13271 error "conf_param timeout=5 failed"
13273 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13274 do_facet ost1 $LCTL set_param fail_loc=0x520
13275 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13276 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13278 do_facet ost1 $LCTL set_param fail_loc=0
13280 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13281 error "conf_param at_max=$at_max failed"
13282 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13283 $timeout || error "conf_param timeout=$timeout failed"
13285 $LCTL set_param -n $pages_per_rpc
13286 restore_lustre_params < $p
13289 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13291 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13294 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13295 if [ -z ${MDSSURVEY} ]; then
13296 skip_env "mds-survey not found" && return
13299 [ $MDSCOUNT -ge 2 ] &&
13300 skip "skipping now for more than one MDT" && return
13302 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13303 { skip "Need MDS version at least 2.2.51"; return; }
13305 local mds=$(facet_host $SINGLEMDS)
13306 local target=$(do_nodes $mds 'lctl dl' | \
13307 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13309 local cmd1="file_count=1000 thrhi=4"
13310 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13311 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13312 local cmd="$cmd1 $cmd2 $cmd3"
13314 rm -f ${TMP}/mds_survey*
13316 eval $cmd || error "mds-survey with zero-stripe failed"
13317 cat ${TMP}/mds_survey*
13318 rm -f ${TMP}/mds_survey*
13320 run_test 225a "Metadata survey sanity with zero-stripe"
13323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13324 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13325 if [ -z ${MDSSURVEY} ]; then
13326 skip_env "mds-survey not found" && return
13328 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13329 { skip "Need MDS version at least 2.2.51"; return; }
13331 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13332 skip_env "Need to mount OST to test" && return
13335 local mds=$(facet_host $SINGLEMDS)
13336 local target=$(do_nodes $mds 'lctl dl' | \
13337 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13339 local cmd1="file_count=1000 thrhi=4"
13340 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13341 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13342 local cmd="$cmd1 $cmd2 $cmd3"
13344 rm -f ${TMP}/mds_survey*
13346 eval $cmd || error "mds-survey with stripe_count failed"
13347 cat ${TMP}/mds_survey*
13348 rm -f ${TMP}/mds_survey*
13350 run_test 225b "Metadata survey sanity with stripe_count = 1"
13352 mcreate_path2fid () {
13358 local path=$DIR/$tdir/$name
13363 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13364 error "cannot create $desc"
13366 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13368 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13370 fid_path=$($LFS fid2path $MOUNT $fid)
13372 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13374 [ "$path" == "$fid_path" ] ||
13375 error "fid2path returned $fid_path, expected $path"
13377 echo "pass with $path and $fid"
13382 mkdir -p $DIR/$tdir
13384 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13385 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13386 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13387 mcreate_path2fid 0040666 0 0 dir "directory"
13388 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13389 mcreate_path2fid 0100666 0 0 file "regular file"
13390 mcreate_path2fid 0120666 0 0 link "symbolic link"
13391 mcreate_path2fid 0140666 0 0 sock "socket"
13393 run_test 226a "call path2fid and fid2path on files of all type"
13396 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13400 mkdir -p $DIR/$tdir
13401 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13402 error "create remote directory failed"
13403 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13404 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13405 "character special file (null)"
13406 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13407 "character special file (no device)"
13408 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13409 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13410 "block special file (loop)"
13411 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13412 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13413 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13415 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13417 # LU-1299 Executing or running ldd on a truncated executable does not
13418 # cause an out-of-memory condition.
13420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13421 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13422 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13423 chmod +x $MOUNT/date
13425 $MOUNT/date > /dev/null
13426 ldd $MOUNT/date > /dev/null
13429 run_test 227 "running truncated executable does not cause OOM"
13431 # LU-1512 try to reuse idle OI blocks
13433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13434 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13435 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13436 skip "ldiskfs only test" && return
13438 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13439 local myDIR=$DIR/$tdir
13442 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13443 $LCTL set_param fail_loc=0x80001002
13444 createmany -o $myDIR/t- 10000
13445 $LCTL set_param fail_loc=0
13446 # The guard is current the largest FID holder
13448 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13450 local IDX=$(($SEQ % 64))
13452 do_facet $SINGLEMDS sync
13453 # Make sure journal flushed.
13455 local blk1=$(do_facet $SINGLEMDS \
13456 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13457 grep Blockcount | awk '{print $4}')
13459 # Remove old files, some OI blocks will become idle.
13460 unlinkmany $myDIR/t- 10000
13461 # Create new files, idle OI blocks should be reused.
13462 createmany -o $myDIR/t- 2000
13463 do_facet $SINGLEMDS sync
13464 # Make sure journal flushed.
13466 local blk2=$(do_facet $SINGLEMDS \
13467 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13468 grep Blockcount | awk '{print $4}')
13470 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13472 run_test 228a "try to reuse idle OI blocks"
13475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13476 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13477 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13478 skip "ldiskfs only test" && return
13480 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13481 local myDIR=$DIR/$tdir
13484 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13485 $LCTL set_param fail_loc=0x80001002
13486 createmany -o $myDIR/t- 10000
13487 $LCTL set_param fail_loc=0
13488 # The guard is current the largest FID holder
13490 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13492 local IDX=$(($SEQ % 64))
13494 do_facet $SINGLEMDS sync
13495 # Make sure journal flushed.
13497 local blk1=$(do_facet $SINGLEMDS \
13498 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13499 grep Blockcount | awk '{print $4}')
13501 # Remove old files, some OI blocks will become idle.
13502 unlinkmany $myDIR/t- 10000
13505 stop $SINGLEMDS || error "Fail to stop MDT."
13507 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13509 df $MOUNT || error "Fail to df."
13510 # Create new files, idle OI blocks should be reused.
13511 createmany -o $myDIR/t- 2000
13512 do_facet $SINGLEMDS sync
13513 # Make sure journal flushed.
13515 local blk2=$(do_facet $SINGLEMDS \
13516 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13517 grep Blockcount | awk '{print $4}')
13519 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13521 run_test 228b "idle OI blocks can be reused after MDT restart"
13525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13526 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13527 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13528 skip "ldiskfs only test" && return
13530 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13531 local myDIR=$DIR/$tdir
13534 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13535 $LCTL set_param fail_loc=0x80001002
13536 # 20000 files can guarantee there are index nodes in the OI file
13537 createmany -o $myDIR/t- 20000
13538 $LCTL set_param fail_loc=0
13539 # The guard is current the largest FID holder
13541 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13543 local IDX=$(($SEQ % 64))
13545 do_facet $SINGLEMDS sync
13546 # Make sure journal flushed.
13548 local blk1=$(do_facet $SINGLEMDS \
13549 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13550 grep Blockcount | awk '{print $4}')
13552 # Remove old files, some OI blocks will become idle.
13553 unlinkmany $myDIR/t- 20000
13555 # The OI file should become empty now
13557 # Create new files, idle OI blocks should be reused.
13558 createmany -o $myDIR/t- 2000
13559 do_facet $SINGLEMDS sync
13560 # Make sure journal flushed.
13562 local blk2=$(do_facet $SINGLEMDS \
13563 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13564 grep Blockcount | awk '{print $4}')
13566 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13568 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13570 test_229() { # LU-2482, LU-3448
13571 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13572 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13575 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13579 # Create a file with a released layout and stripe count 2.
13580 $MULTIOP $DIR/$tfile H2c ||
13581 error "failed to create file with released layout"
13583 $GETSTRIPE -v $DIR/$tfile
13585 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13586 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
13588 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13589 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13590 stat $DIR/$tfile || error "failed to stat released file"
13592 chown $RUNAS_ID $DIR/$tfile ||
13593 error "chown $RUNAS_ID $DIR/$tfile failed"
13595 chgrp $RUNAS_ID $DIR/$tfile ||
13596 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13598 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13599 rm $DIR/$tfile || error "failed to remove released file"
13601 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13605 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13608 test_mkdir $DIR/$tdir
13609 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13610 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13611 [ $mdt_idx -ne 0 ] &&
13612 error "create local directory on wrong MDT $mdt_idx"
13614 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13615 error "create remote directory failed"
13616 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13617 [ $mdt_idx -ne $MDTIDX ] &&
13618 error "create remote directory on wrong MDT $mdt_idx"
13620 createmany -o $DIR/$tdir/test_230/t- 10 ||
13621 error "create files on remote directory failed"
13622 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13623 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13624 rm -r $DIR/$tdir || error "unlink remote directory failed"
13626 run_test 230a "Create remote directory and files under the remote directory"
13629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13630 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13637 local migrate_dir=$DIR/$tdir/migrate_dir
13638 local other_dir=$DIR/$tdir/other_dir
13640 test_mkdir $DIR/$tdir
13641 test_mkdir -i0 -c1 $migrate_dir
13642 test_mkdir -i0 -c1 $other_dir
13643 for ((i=0; i<10; i++)); do
13644 mkdir -p $migrate_dir/dir_${i}
13645 createmany -o $migrate_dir/dir_${i}/f 10 ||
13646 error "create files under remote dir failed $i"
13649 cp /etc/passwd $migrate_dir/$tfile
13650 cp /etc/passwd $other_dir/$tfile
13651 chattr +SAD $migrate_dir
13652 chattr +SAD $migrate_dir/$tfile
13654 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13655 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13656 local old_dir_mode=$(stat -c%f $migrate_dir)
13657 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13659 mkdir -p $migrate_dir/dir_default_stripe2
13660 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13661 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13663 mkdir -p $other_dir
13664 ln $migrate_dir/$tfile $other_dir/luna
13665 ln $migrate_dir/$tfile $migrate_dir/sofia
13666 ln $other_dir/$tfile $migrate_dir/david
13667 ln -s $migrate_dir/$tfile $other_dir/zachary
13668 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13669 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13671 $LFS migrate -m $MDTIDX $migrate_dir ||
13672 error "fails on migrating remote dir to MDT1"
13674 echo "migratate to MDT1, then checking.."
13675 for ((i = 0; i < 10; i++)); do
13676 for file in $(find $migrate_dir/dir_${i}); do
13677 mdt_index=$($LFS getstripe -M $file)
13678 [ $mdt_index == $MDTIDX ] ||
13679 error "$file is not on MDT${MDTIDX}"
13683 # the multiple link file should still in MDT0
13684 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13685 [ $mdt_index == 0 ] ||
13686 error "$file is not on MDT${MDTIDX}"
13688 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13689 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13690 error " expect $old_dir_flag get $new_dir_flag"
13692 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13693 [ "$old_file_flag" = "$new_file_flag" ] ||
13694 error " expect $old_file_flag get $new_file_flag"
13696 local new_dir_mode=$(stat -c%f $migrate_dir)
13697 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13698 error "expect mode $old_dir_mode get $new_dir_mode"
13700 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13701 [ "$old_file_mode" = "$new_file_mode" ] ||
13702 error "expect mode $old_file_mode get $new_file_mode"
13704 diff /etc/passwd $migrate_dir/$tfile ||
13705 error "$tfile different after migration"
13707 diff /etc/passwd $other_dir/luna ||
13708 error "luna different after migration"
13710 diff /etc/passwd $migrate_dir/sofia ||
13711 error "sofia different after migration"
13713 diff /etc/passwd $migrate_dir/david ||
13714 error "david different after migration"
13716 diff /etc/passwd $other_dir/zachary ||
13717 error "zachary different after migration"
13719 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13720 error "${tfile}_ln different after migration"
13722 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13723 error "${tfile}_ln_other different after migration"
13725 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13726 [ $stripe_count = 2 ] ||
13727 error "dir strpe_count $d != 2 after migration."
13729 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13730 [ $stripe_count = 2 ] ||
13731 error "file strpe_count $d != 2 after migration."
13733 #migrate back to MDT0
13736 $LFS migrate -m $MDTIDX $migrate_dir ||
13737 error "fails on migrating remote dir to MDT0"
13739 echo "migrate back to MDT0, checking.."
13740 for file in $(find $migrate_dir); do
13741 mdt_index=$($LFS getstripe -M $file)
13742 [ $mdt_index == $MDTIDX ] ||
13743 error "$file is not on MDT${MDTIDX}"
13746 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13747 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13748 error " expect $old_dir_flag get $new_dir_flag"
13750 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13751 [ "$old_file_flag" = "$new_file_flag" ] ||
13752 error " expect $old_file_flag get $new_file_flag"
13754 local new_dir_mode=$(stat -c%f $migrate_dir)
13755 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13756 error "expect mode $old_dir_mode get $new_dir_mode"
13758 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13759 [ "$old_file_mode" = "$new_file_mode" ] ||
13760 error "expect mode $old_file_mode get $new_file_mode"
13762 diff /etc/passwd ${migrate_dir}/$tfile ||
13763 error "$tfile different after migration"
13765 diff /etc/passwd ${other_dir}/luna ||
13766 error "luna different after migration"
13768 diff /etc/passwd ${migrate_dir}/sofia ||
13769 error "sofia different after migration"
13771 diff /etc/passwd ${other_dir}/zachary ||
13772 error "zachary different after migration"
13774 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13775 error "${tfile}_ln different after migration"
13777 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13778 error "${tfile}_ln_other different after migration"
13780 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13781 [ $stripe_count = 2 ] ||
13782 error "dir strpe_count $d != 2 after migration."
13784 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13785 [ $stripe_count = 2 ] ||
13786 error "file strpe_count $d != 2 after migration."
13788 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13790 run_test 230b "migrate directory"
13793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13794 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13795 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13799 local migrate_dir=$DIR/$tdir/migrate_dir
13801 #If migrating directory fails in the middle, all entries of
13802 #the directory is still accessiable.
13803 test_mkdir $DIR/$tdir
13804 test_mkdir -i0 -c1 $migrate_dir
13806 createmany -o $migrate_dir/f 10 ||
13807 error "create files under ${migrate_dir} failed"
13809 #failed after migrating 5 entries
13810 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13811 do_facet mds1 lctl set_param fail_loc=0x20001801
13812 do_facet mds1 lctl set_param fail_val=5
13813 local t=$(ls $migrate_dir | wc -l)
13814 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13815 error "migrate should fail after 5 entries"
13817 mkdir $migrate_dir/dir &&
13818 error "mkdir succeeds under migrating directory"
13819 touch $migrate_dir/file &&
13820 error "touch file succeeds under migrating directory"
13822 local u=$(ls $migrate_dir | wc -l)
13823 [ "$u" == "$t" ] || error "$u != $t during migration"
13825 for file in $(find $migrate_dir); do
13826 stat $file || error "stat $file failed"
13829 do_facet mds1 lctl set_param fail_loc=0
13830 do_facet mds1 lctl set_param fail_val=0
13832 $LFS migrate -m $MDTIDX $migrate_dir ||
13833 error "migrate open files should failed with open files"
13835 echo "Finish migration, then checking.."
13836 for file in $(find $migrate_dir); do
13837 mdt_index=$($LFS getstripe -M $file)
13838 [ $mdt_index == $MDTIDX ] ||
13839 error "$file is not on MDT${MDTIDX}"
13842 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13844 run_test 230c "check directory accessiblity if migration is failed"
13847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13848 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13851 local migrate_dir=$DIR/$tdir/migrate_dir
13855 test_mkdir $DIR/$tdir
13856 test_mkdir -i0 -c1 $migrate_dir
13858 for ((i=0; i<100; i++)); do
13859 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13860 createmany -o $migrate_dir/dir_${i}/f 100 ||
13861 error "create files under remote dir failed $i"
13864 $LFS migrate -m $MDTIDX $migrate_dir ||
13865 error "migrate remote dir error"
13867 echo "Finish migration, then checking.."
13868 for file in $(find $migrate_dir); do
13869 mdt_index=$($LFS getstripe -M $file)
13870 [ $mdt_index == $MDTIDX ] ||
13871 error "$file is not on MDT${MDTIDX}"
13874 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13876 run_test 230d "check migrate big directory"
13879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13880 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13886 mkdir -p $DIR/$tdir
13887 mkdir $DIR/$tdir/migrate_dir
13888 mkdir $DIR/$tdir/other_dir
13889 touch $DIR/$tdir/migrate_dir/a
13890 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13891 ls $DIR/$tdir/other_dir
13893 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13894 error "migrate dir fails"
13896 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13897 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13899 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13900 [ $mdt_index == 0 ] || error "a is not on MDT0"
13902 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13903 error "migrate dir fails"
13905 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13906 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13908 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13909 [ $mdt_index == 1 ] || error "a is not on MDT1"
13911 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13912 [ $mdt_index == 1 ] || error "b is not on MDT1"
13914 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13915 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13917 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13919 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13921 run_test 230e "migrate mulitple local link files"
13924 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13925 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13929 mkdir -p $DIR/$tdir
13930 mkdir $DIR/$tdir/migrate_dir
13931 $LFS mkdir -i1 $DIR/$tdir/other_dir
13932 touch $DIR/$tdir/migrate_dir/a
13933 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13934 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13935 ls $DIR/$tdir/other_dir
13937 # a should be migrated to MDT1, since no other links on MDT0
13938 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13939 error "#1 migrate dir fails"
13940 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13941 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13942 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13943 [ $mdt_index == 1 ] || error "a is not on MDT1"
13945 # a should stay on MDT1, because it is a mulitple link file
13946 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13947 error "#2 migrate dir fails"
13948 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13949 [ $mdt_index == 1 ] || error "a is not on MDT1"
13951 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13952 error "#3 migrate dir fails"
13954 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13955 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13956 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13958 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13959 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13961 # a should be migrated to MDT0, since no other links on MDT1
13962 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13963 error "#4 migrate dir fails"
13964 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13965 [ $mdt_index == 0 ] || error "a is not on MDT0"
13967 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13969 run_test 230f "migrate mulitple remote link files"
13972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13973 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13975 mkdir -p $DIR/$tdir/migrate_dir
13977 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13978 error "migrating dir to non-exist MDT succeeds"
13981 run_test 230g "migrate dir to non-exist MDT"
13984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13985 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13986 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13987 skip "Need MDS version at least 2.7.64" && return
13990 mkdir -p $DIR/$tdir/migrate_dir
13992 $LFS migrate -m1 $DIR &&
13993 error "migrating mountpoint1 should fail"
13995 $LFS migrate -m1 $DIR/$tdir/.. &&
13996 error "migrating mountpoint2 should fail"
13998 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13999 error "migrating $tdir fail"
14001 mdt_index=$($LFS getstripe -M $DIR/$tdir)
14002 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14004 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14005 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14008 run_test 230h "migrate .. and root"
14011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14012 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14014 mkdir -p $DIR/$tdir/migrate_dir
14016 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
14017 error "migration fails with a tailing slash"
14019 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14020 error "migration fails with two tailing slashes"
14022 run_test 230i "lfs migrate -m tolerates trailing slashes"
14026 # For simplicity this test assumes that max_pages_per_rpc
14027 # is the same across all OSCs
14028 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14029 local bulk_size=$((max_pages * 4096))
14030 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14033 mkdir -p $DIR/$tdir
14034 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14035 error "failed to set stripe with -S ${brw_size}M option"
14037 # clear the OSC stats
14038 $LCTL set_param osc.*.stats=0 &>/dev/null
14041 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14042 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14043 oflag=direct &>/dev/null || error "dd failed"
14045 sync; sleep 1; sync # just to be safe
14046 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14047 if [ x$nrpcs != "x1" ]; then
14048 $LCTL get_param osc.*.stats
14049 error "found $nrpcs ost_write RPCs, not 1 as expected"
14053 # Drop the OSC cache, otherwise we will read from it
14054 cancel_lru_locks osc
14056 # clear the OSC stats
14057 $LCTL set_param osc.*.stats=0 &>/dev/null
14059 # Client reads $bulk_size.
14060 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14061 iflag=direct &>/dev/null || error "dd failed"
14063 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14064 if [ x$nrpcs != "x1" ]; then
14065 $LCTL get_param osc.*.stats
14066 error "found $nrpcs ost_read RPCs, not 1 as expected"
14069 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14072 mkdir -p $DIR/$tdir
14074 for i in {0..1023}; do
14075 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14076 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14077 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14081 run_test 231b "must not assert on fully utilized OST request buffer"
14084 mkdir -p $DIR/$tdir
14085 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14086 $LCTL set_param fail_loc=0x31c
14088 # ignore dd failure
14089 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
14091 $LCTL set_param fail_loc=0
14092 umount_client $MOUNT || error "umount failed"
14093 mount_client $MOUNT || error "mount failed"
14095 run_test 232 "failed lock should not block umount"
14098 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14099 { skip "Need MDS version at least 2.3.64"; return; }
14100 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14102 local fid=$($LFS path2fid $MOUNT)
14103 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14104 error "cannot access $MOUNT using its FID '$fid'"
14106 run_test 233a "checking that OBF of the FS root succeeds"
14109 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14110 { skip "Need MDS version at least 2.5.90"; return; }
14111 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14113 local fid=$($LFS path2fid $MOUNT/.lustre)
14114 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14115 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14117 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14118 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14119 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14121 run_test 233b "checking that OBF of the FS .lustre succeeds"
14124 local p="$TMP/sanityN-$TESTNAME.parameters"
14125 save_lustre_params client "llite.*.xattr_cache" > $p
14126 lctl set_param llite.*.xattr_cache 1 ||
14127 { skip "xattr cache is not supported"; return 0; }
14129 mkdir -p $DIR/$tdir || error "mkdir failed"
14130 touch $DIR/$tdir/$tfile || error "touch failed"
14131 # OBD_FAIL_LLITE_XATTR_ENOMEM
14132 $LCTL set_param fail_loc=0x1405
14133 # output of the form: attr 2 4 44 3 fc13 x86_64
14134 V=($(IFS=".-" rpm -q attr))
14135 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
14136 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
14137 # attr pre-2.4.44-7 had a bug with rc
14138 # LU-3703 - SLES 11 and FC13 clients have older attr
14139 getfattr -n user.attr $DIR/$tdir/$tfile &&
14140 error "getfattr should have failed with ENOMEM"
14142 skip "LU-3703: attr version $(getfattr --version) too old"
14144 $LCTL set_param fail_loc=0x0
14147 restore_lustre_params < $p
14150 run_test 234 "xattr cache should not crash on ENOMEM"
14153 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14154 skip "Need MDS version at least 2.4.52" && return
14155 flock_deadlock $DIR/$tfile
14160 124) error "process hangs on a deadlock"
14162 *) error "error executing flock_deadlock $DIR/$tfile"
14166 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14170 check_swap_layouts_support && return 0
14171 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
14173 local ref1=/etc/passwd
14174 local ref2=/etc/group
14175 local file1=$DIR/$tdir/f1
14176 local file2=$DIR/$tdir/f2
14178 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14179 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14180 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14181 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14182 local fd=$(free_fd)
14183 local cmd="exec $fd<>$file2"
14186 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14187 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14190 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14195 run_test 236 "Layout swap on open unlinked file"
14197 # test to verify file handle related system calls
14198 # (name_to_handle_at/open_by_handle_at)
14199 # The new system calls are supported in glibc >= 2.14.
14202 echo "Test file_handle syscalls" > $DIR/$tfile ||
14203 error "write failed"
14204 check_fhandle_syscalls $DIR/$tfile ||
14205 error "check_fhandle_syscalls failed"
14207 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14209 # LU-4659 linkea consistency
14211 local server_version=$(lustre_version_code $SINGLEMDS)
14213 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14214 [[ $server_version -gt $(version_code 2.5.1) &&
14215 $server_version -lt $(version_code 2.5.50) ]] ||
14216 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14219 ln $DIR/$tfile $DIR/$tfile.lnk
14220 touch $DIR/$tfile.new
14221 mv $DIR/$tfile.new $DIR/$tfile
14222 local fid1=$($LFS path2fid $DIR/$tfile)
14223 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14224 local path1=$($LFS fid2path $FSNAME "$fid1")
14225 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14226 local path2=$($LFS fid2path $FSNAME "$fid2")
14227 [ $tfile.lnk == $path2 ] ||
14228 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14231 run_test 238 "Verify linkea consistency"
14234 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14235 skip "Need MDS version at least 2.5.60" && return
14236 local list=$(comma_list $(mdts_nodes))
14238 mkdir -p $DIR/$tdir
14239 createmany -o $DIR/$tdir/f- 5000
14240 unlinkmany $DIR/$tdir/f- 5000
14241 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.1) ] &&
14242 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14243 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14244 osp.*MDT*.sync_in_flight" | calc_sum)
14245 [ "$changes" -eq 0 ] || error "$changes not synced"
14247 run_test 239 "osp_sync test"
14249 test_239a() { #LU-5297
14250 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14252 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14253 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14254 chgrp $RUNAS_GID $DIR/$tfile
14255 wait_delete_completed
14257 run_test 239a "process invalid osp sync record correctly"
14259 test_239b() { #LU-5297
14260 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14262 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14263 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14264 chgrp $RUNAS_GID $DIR/$tfile1
14265 wait_delete_completed
14266 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14268 chgrp $RUNAS_GID $DIR/$tfile2
14269 wait_delete_completed
14271 run_test 239b "process osp sync record with ENOMEM error correctly"
14274 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14275 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14277 mkdir -p $DIR/$tdir
14279 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14280 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14281 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14282 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14284 umount_client $MOUNT || error "umount failed"
14285 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14286 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14287 mount_client $MOUNT || error "failed to mount client"
14289 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14290 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14292 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14295 for LOOP in $(seq $1); do
14296 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14297 cancel_lru_locks osc || true
14302 for LOOP in $(seq $1); do
14303 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14304 iflag=direct 2>/dev/null
14308 test_241a() { # was test_241
14309 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14311 cancel_lru_locks osc
14312 test_241_bio 1000 &
14317 run_test 241a "bio vs dio"
14320 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14322 test_241_dio 1000 &
14327 run_test 241b "dio vs dio"
14330 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14331 mkdir -p $DIR/$tdir
14332 touch $DIR/$tdir/$tfile
14334 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14335 do_facet mds1 lctl set_param fail_loc=0x105
14336 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14338 do_facet mds1 lctl set_param fail_loc=0
14339 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14341 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14345 test_mkdir -p $DIR/$tdir
14346 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14348 run_test 243 "various group lock tests"
14352 test_mkdir -p $DIR/$tdir
14353 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14354 sendfile_grouplock $DIR/$tdir/$tfile || \
14355 error "sendfile+grouplock failed"
14358 run_test 244 "sendfile with group lock tests"
14361 local flagname="multi_mod_rpcs"
14362 local connect_data_name="max_mod_rpcs"
14365 # check if multiple modify RPCs flag is set
14366 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14367 grep "connect_flags:")
14370 echo "$out" | grep -qw $flagname
14371 if [ $? -ne 0 ]; then
14372 echo "connect flag $flagname is not set"
14376 # check if multiple modify RPCs data is set
14377 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14380 echo "$out" | grep -qw $connect_data_name ||
14381 error "import should have connect data $connect_data_name"
14383 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14385 test_246() { # LU-7371
14386 remote_ost_nodsh && skip "remote OST with nodsh" && return
14387 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14388 skip "Need OST version >= 2.7.62" && return 0
14389 do_facet ost1 $LCTL set_param fail_val=4095
14390 #define OBD_FAIL_OST_READ_SIZE 0x234
14391 do_facet ost1 $LCTL set_param fail_loc=0x234
14392 $LFS setstripe $DIR/$tfile -i 0 -c 1
14393 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14394 cancel_lru_locks $FSNAME-OST0000
14395 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14397 run_test 246 "Read file of size 4095 should return right length"
14400 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14402 { skip "Fileset feature is not supported"; return; }
14404 local submount=${MOUNT}_$tdir
14407 mkdir -p $submount || error "mkdir $submount failed"
14408 FILESET="$FILESET/$tdir" mount_client $submount ||
14409 error "mount $submount failed"
14410 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14411 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14412 error "read $MOUNT/$tdir/$tfile failed"
14413 umount_client $submount || error "umount $submount failed"
14416 run_test 247a "mount subdir as fileset"
14419 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14420 { skip "Fileset feature is not supported"; return; }
14422 local submount=${MOUNT}_$tdir
14424 rm -rf $MOUNT/$tdir
14425 mkdir -p $submount || error "mkdir $submount failed"
14427 FILESET="$FILESET/$tdir" mount_client $submount &&
14428 error "mount $submount should fail"
14431 run_test 247b "mount subdir that dose not exist"
14434 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14435 { skip "Fileset feature is not supported"; return; }
14437 local submount=${MOUNT}_$tdir
14439 mkdir -p $MOUNT/$tdir/dir1
14440 mkdir -p $submount || error "mkdir $submount failed"
14441 FILESET="$FILESET/$tdir" mount_client $submount ||
14442 error "mount $submount failed"
14443 local fid=$($LFS path2fid $MOUNT/)
14444 $LFS fid2path $submount $fid && error "fid2path should fail"
14445 umount_client $submount || error "umount $submount failed"
14448 run_test 247c "running fid2path outside root"
14451 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14452 { skip "Fileset feature is not supported"; return; }
14454 local submount=${MOUNT}_$tdir
14456 mkdir -p $MOUNT/$tdir/dir1
14457 mkdir -p $submount || error "mkdir $submount failed"
14458 FILESET="$FILESET/$tdir" mount_client $submount ||
14459 error "mount $submount failed"
14460 local fid=$($LFS path2fid $submount/dir1)
14461 $LFS fid2path $submount $fid || error "fid2path should succeed"
14462 umount_client $submount || error "umount $submount failed"
14465 run_test 247d "running fid2path inside root"
14469 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14471 { skip "Fileset feature is not supported"; return; }
14473 local submount=${MOUNT}_$tdir
14476 mkdir -p $submount || error "mkdir $submount failed"
14477 FILESET="$FILESET/.." mount_client $submount &&
14478 error "mount $submount should fail"
14481 run_test 247e "mount .. as fileset"
14484 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14485 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14487 # create a large file for fast read verification
14488 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14490 # make sure the file is created correctly
14491 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14492 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14494 echo "Test 1: verify that fast read is 4 times faster on cache read"
14496 # small read with fast read enabled
14497 $LCTL set_param -n llite.*.fast_read=1
14498 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14499 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14500 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14501 # small read with fast read disabled
14502 $LCTL set_param -n llite.*.fast_read=0
14503 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14504 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14505 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14507 # verify that fast read is 4 times faster for cache read
14508 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14509 error_not_in_vm "fast read was not 4 times faster: " \
14510 "$t_fast vs $t_slow"
14512 echo "Test 2: verify the performance between big and small read"
14513 $LCTL set_param -n llite.*.fast_read=1
14515 # 1k non-cache read
14516 cancel_lru_locks osc
14517 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14518 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14519 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14521 # 1M non-cache read
14522 cancel_lru_locks osc
14523 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14524 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14525 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14527 # verify that big IO is not 4 times faster than small IO
14528 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14529 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14531 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14534 run_test 248 "fast read verification"
14536 test_249() { # LU-7890
14538 $SETSTRIPE -c 1 $DIR/$tfile
14540 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14541 skip "Need at least version 2.8.54"
14543 # Offset 2T == 4k * 512M
14544 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14545 error "dd to 2T offset failed"
14547 run_test 249 "Write above 2T file size"
14550 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14551 && skip "no 16TB file size limit on ZFS" && return
14553 $SETSTRIPE -c 1 $DIR/$tfile
14554 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14555 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14556 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14557 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14558 conv=notrunc,fsync && error "append succeeded"
14561 run_test 250 "Write above 16T limit"
14564 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14566 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14567 #Skip once - writing the first stripe will succeed
14568 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14569 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14570 error "short write happened"
14572 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14573 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14574 error "short read happened"
14578 run_test 251 "Handling short read and write correctly"
14588 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14589 remote_ost_nodsh && skip "remote OST with nodsh" && return
14590 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14591 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14592 skip "ldiskfs only test"
14596 # check lr_reader on OST0000
14598 dev=$(facet_device $tgt)
14599 out=$(do_facet $tgt $LR_READER $dev)
14600 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14602 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14603 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14604 error "Invalid uuid returned by $LR_READER on target $tgt"
14605 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14607 # check lr_reader -c on MDT0000
14609 dev=$(facet_device $tgt)
14610 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14611 echo "$LR_READER does not support additional options"
14614 out=$(do_facet $tgt $LR_READER -c $dev)
14615 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14617 num=$(echo "$out" | grep -c "mdtlov")
14618 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14619 error "Invalid number of mdtlov clients returned by $LR_READER"
14620 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14622 # check lr_reader -cr on MDT0000
14623 out=$(do_facet $tgt $LR_READER -cr $dev)
14624 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14626 echo "$out" | grep -q "^reply_data:$" ||
14627 error "$LR_READER should have returned 'reply_data' section"
14628 num=$(echo "$out" | grep -c "client_generation")
14629 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14631 run_test 252 "check lr_reader tool"
14633 test_253_fill_ost() {
14634 local size_mb #how many MB should we write to pass watermark
14635 local lwm=$3 #low watermark
14636 local free_10mb #10% of free space
14638 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14639 size_mb=$((free_kb / 1024 - lwm))
14640 free_10mb=$((free_kb / 10240))
14641 #If 10% of free space cross low watermark use it
14642 if (( free_10mb > size_mb )); then
14645 #At least we need to store 1.1 of difference between
14646 #free space and low watermark
14647 size_mb=$((size_mb + size_mb / 10))
14649 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14650 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14651 oflag=append conv=notrunc
14656 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14657 echo "OST still has $((free_kb / 1024)) mbytes free"
14664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14665 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14666 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14668 local ost_name=$($LFS osts |
14669 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14671 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14672 do_facet $SINGLEMDS $LCTL get_param -n \
14673 osp.$mdtosc_proc1.reserved_mb_high ||
14674 { skip "remote MDS does not support reserved_mb_high" &&
14679 wait_delete_completed
14682 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14683 osp.$mdtosc_proc1.reserved_mb_high)
14684 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14685 osp.$mdtosc_proc1.reserved_mb_low)
14686 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14688 if ! combined_mgs_mds ; then
14691 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14692 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14693 error "Adding $ost_name to pool failed"
14695 # Wait for client to see a OST at pool
14696 wait_update $HOSTNAME "$LCTL get_param -n
14697 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14698 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14699 error "Client can not see the pool"
14700 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14701 error "Setstripe failed"
14703 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14704 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14705 echo "OST still has $((blocks/1024)) mbytes free"
14707 local new_lwm=$((blocks/1024-10))
14708 do_facet $SINGLEMDS $LCTL set_param \
14709 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14710 do_facet $SINGLEMDS $LCTL set_param \
14711 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14713 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14715 #First enospc could execute orphan deletion so repeat.
14716 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14718 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14719 osp.$mdtosc_proc1.prealloc_status)
14720 echo "prealloc_status $oa_status"
14722 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14723 error "File creation should fail"
14724 #object allocation was stopped, but we still able to append files
14725 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14726 error "Append failed"
14727 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14729 wait_delete_completed
14733 for i in $(seq 10 12); do
14734 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14735 error "File creation failed after rm";
14738 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14739 osp.$mdtosc_proc1.prealloc_status)
14740 echo "prealloc_status $oa_status"
14742 if (( oa_status != 0 )); then
14743 error "Object allocation still disable after rm"
14745 do_facet $SINGLEMDS $LCTL set_param \
14746 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14747 do_facet $SINGLEMDS $LCTL set_param \
14748 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14751 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14752 error "Remove $ost_name from pool failed"
14753 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14754 error "Pool destroy fialed"
14756 if ! combined_mgs_mds ; then
14760 run_test 253 "Check object allocation limit"
14765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14766 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14767 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14768 { skip "MDS does not support changelog_size" && return; }
14770 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14771 echo "Registered as changelog user $cl_user"
14773 $LFS changelog_clear $MDT0 $cl_user 0
14775 local size1=$(do_facet mds1 \
14776 $LCTL get_param -n mdd.$MDT0.changelog_size)
14777 echo "Changelog size $size1"
14780 $LFS mkdir -i 0 $DIR/$tdir
14782 mkdir -p $DIR/$tdir/pics/2008/zachy
14783 touch $DIR/$tdir/pics/2008/zachy/timestamp
14784 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
14785 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14786 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14787 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14788 rm $DIR/$tdir/pics/desktop.jpg
14790 local size2=$(do_facet mds1 \
14791 $LCTL get_param -n mdd.$MDT0.changelog_size)
14792 echo "Changelog size after work $size2"
14794 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14796 if (( size2 <= size1 )); then
14797 error "Changelog size after work should be greater than original"
14801 run_test 254 "Check changelog size"
14808 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
14809 awk -F: '{print $2}' | grep $type > /dev/null
14810 if [ $? -ne 0 ]; then
14820 lfs ladvise -a willread $file > /dev/null 2>&1
14821 if [ $? -eq 0 ]; then
14825 lfs ladvise -a willread $file 2>&1 |
14826 grep "Inappropriate ioctl for device" > /dev/null
14827 if [ $? -eq 0 ]; then
14834 bc <<<"scale=2; ($1 - $2) * 100 / $2"
14837 # run a random read IO workload
14838 # usage: random_read_iops <filename> <filesize> <iosize>
14839 random_read_iops() {
14842 local iosize=${3:-4096}
14844 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
14845 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
14848 drop_file_oss_cache() {
14852 $LFS ladvise -a dontneed $file 2>/dev/null ||
14853 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
14856 ladvise_willread_performance()
14859 local average_origin=0
14860 local average_cache=0
14861 local average_ladvise=0
14863 for ((i = 1; i <= $repeat; i++)); do
14864 echo "Iter $i/$repeat: reading without willread hint"
14865 cancel_lru_locks osc
14866 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14867 local speed_origin=$(random_read_iops $DIR/$tfile $size)
14868 echo "Iter $i/$repeat: uncached speed: $speed_origin"
14869 average_origin=$(bc <<<"$average_origin + $speed_origin")
14871 cancel_lru_locks osc
14872 local speed_cache=$(random_read_iops $DIR/$tfile $size)
14873 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
14874 average_cache=$(bc <<<"$average_cache + $speed_cache")
14876 cancel_lru_locks osc
14877 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14878 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
14879 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
14880 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
14881 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
14883 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
14884 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
14885 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
14887 speedup_cache=$(percent $average_cache $average_origin)
14888 speedup_ladvise=$(percent $average_ladvise $average_origin)
14890 echo "Average uncached read: $average_origin"
14891 echo "Average speedup with OSS cached read: " \
14892 "$average_cache = +$speedup_cache%"
14893 echo "Average speedup with ladvise willread: " \
14894 "$average_ladvise = +$speedup_ladvise%"
14896 local lowest_speedup=20
14897 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
14898 echo "Speedup with OSS cached read less than $lowest_speedup%, " \
14899 "got $average_cache%. Skipping ladvise willread check."
14903 # the test won't work on ZFS until it supports 'ladvise dontneed', but
14904 # it is still good to run until then to exercise 'ladvise willread'
14905 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14906 [ "$(facet_fstype ost1)" = "zfs" ] &&
14907 echo "osd-zfs does not support dontneed or drop_caches" &&
14910 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
14911 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
14912 error_not_in_vm "Speedup with willread is less than " \
14913 "$lowest_speedup%, got $average_ladvise%"
14917 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14918 skip "lustre < 2.8.54 does not support ladvise " && return
14919 remote_ost_nodsh && skip "remote OST with nodsh" && return
14921 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
14923 ladvise_no_type willread $DIR/$tfile &&
14924 skip "willread ladvise is not supported" && return
14926 ladvise_no_ioctl $DIR/$tfile &&
14927 skip "ladvise ioctl is not supported" && return
14930 local size=$((size_mb * 1048576))
14931 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14932 error "dd to $DIR/$tfile failed"
14934 lfs ladvise -a willread $DIR/$tfile ||
14935 error "Ladvise failed with no range argument"
14937 lfs ladvise -a willread -s 0 $DIR/$tfile ||
14938 error "Ladvise failed with no -l or -e argument"
14940 lfs ladvise -a willread -e 1 $DIR/$tfile ||
14941 error "Ladvise failed with only -e argument"
14943 lfs ladvise -a willread -l 1 $DIR/$tfile ||
14944 error "Ladvise failed with only -l argument"
14946 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
14947 error "End offset should not be smaller than start offset"
14949 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
14950 error "End offset should not be equal to start offset"
14952 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
14953 error "Ladvise failed with overflowing -s argument"
14955 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
14956 error "Ladvise failed with overflowing -e argument"
14958 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
14959 error "Ladvise failed with overflowing -l argument"
14961 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
14962 error "Ladvise succeeded with conflicting -l and -e arguments"
14964 echo "Synchronous ladvise should wait"
14966 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
14967 do_nodes $(comma_list $(osts_nodes)) \
14968 $LCTL set_param fail_val=$delay fail_loc=0x237
14970 local start_ts=$SECONDS
14971 lfs ladvise -a willread $DIR/$tfile ||
14972 error "Ladvise failed with no range argument"
14973 local end_ts=$SECONDS
14974 local inteval_ts=$((end_ts - start_ts))
14976 if [ $inteval_ts -lt $(($delay - 1)) ]; then
14977 error "Synchronous advice didn't wait reply"
14980 echo "Asynchronous ladvise shouldn't wait"
14981 local start_ts=$SECONDS
14982 lfs ladvise -a willread -b $DIR/$tfile ||
14983 error "Ladvise failed with no range argument"
14984 local end_ts=$SECONDS
14985 local inteval_ts=$((end_ts - start_ts))
14987 if [ $inteval_ts -gt $(($delay / 2)) ]; then
14988 error "Asynchronous advice blocked"
14991 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
14992 ladvise_willread_performance
14994 run_test 255a "check 'lfs ladvise -a willread'"
15000 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
15004 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15005 skip "lustre < 2.8.54 does not support ladvise " && return
15006 remote_ost_nodsh && skip "remote OST with nodsh" && return
15008 lfs setstripe -c 1 -i 0 $DIR/$tfile
15010 ladvise_no_type dontneed $DIR/$tfile &&
15011 skip "dontneed ladvise is not supported" && return
15013 ladvise_no_ioctl $DIR/$tfile &&
15014 skip "ladvise ioctl is not supported" && return
15016 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15017 skip "lustre < 2.8.54 does not support ladvise" && return
15019 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15020 [ "$(facet_fstype ost1)" = "zfs" ] &&
15021 skip "zfs-osd does not support 'ladvise dontneed'" && return
15024 local size=$((size_mb * 1048576))
15025 # In order to prevent disturbance of other processes, only check 3/4
15026 # of the memory usage
15027 local kibibytes=$((size_mb * 1024 * 3 / 4))
15029 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15030 error "dd to $DIR/$tfile failed"
15032 local total=$(facet_meminfo ost1 MemTotal)
15033 echo "Total memory: $total KiB"
15035 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15036 local before_read=$(facet_meminfo ost1 Cached)
15037 echo "Cache used before read: $before_read KiB"
15039 lfs ladvise -a willread $DIR/$tfile ||
15040 error "Ladvise willread failed"
15041 local after_read=$(facet_meminfo ost1 Cached)
15042 echo "Cache used after read: $after_read KiB"
15044 lfs ladvise -a dontneed $DIR/$tfile ||
15045 error "Ladvise dontneed again failed"
15046 local no_read=$(facet_meminfo ost1 Cached)
15047 echo "Cache used after dontneed ladvise: $no_read KiB"
15049 if [ $total -lt $((before_read + kibibytes)) ]; then
15050 echo "Memory is too small, abort checking"
15054 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15055 error "Ladvise willread should use more memory" \
15056 "than $kibibytes KiB"
15059 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15060 error "Ladvise dontneed should release more memory" \
15061 "than $kibibytes KiB"
15064 run_test 255b "check 'lfs ladvise -a dontneed'"
15071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15072 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15073 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
15074 skip "ldiskfs only test" && return
15076 mdt_dev=$(mdsdevname 1)
15078 cl_user=$(do_facet mds1 \
15079 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
15080 if [[ -n $cl_user ]]; then
15081 skip "active changelog user"
15085 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15086 echo "Registered as changelog user $cl_user"
15089 mkdir -p $DIR/$tdir
15091 $LFS changelog_clear $MDT0 $cl_user 0
15094 touch $DIR/$tdir/{1..10}
15097 stop mds1 || error "Fail to stop MDT."
15100 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
15102 #after mount new plainllog is used
15103 touch $DIR/$tdir/{11..19}
15104 local TEMP256FILE=$(mktemp TEMP256XXXXXX)
15105 cat_sl=$(do_facet mds1 \
15106 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15107 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15110 if (( cat_sl != 2 )); then
15111 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15112 error "Changelog catalog has wrong number of slots $cat_sl"
15115 $LFS changelog_clear $MDT0 $cl_user 0
15117 TEMP256FILE=$(mktemp TEMP256XXXXXX)
15118 cat_sl=$(do_facet mds1 \
15119 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15120 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15123 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15125 if (( cat_sl == 2 )); then
15126 error "Empty plain llog was not deleted from changelog catalog"
15128 if (( cat_sl != 1 )); then
15129 error "Active plain llog shouldn\`t be deleted from catalog"
15132 run_test 256 "Check llog delete for empty and not full state"
15135 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15136 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15137 skip "Need MDS version at least 2.8.55" && return
15139 test_mkdir -p $DIR/$tdir
15141 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15142 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15145 #define OBD_FAIL_MDS_XATTR_REP 0x161
15146 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15147 local facet=mds$((mdtidx + 1))
15148 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15149 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15151 stop $facet || error "stop MDS failed"
15152 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15153 error "start MDS fail"
15155 run_test 257 "xattr locks are not lost"
15157 # Verify we take the i_mutex when security requires it
15159 #define OBD_FAIL_IMUTEX_SEC 0x141c
15160 $LCTL set_param fail_loc=0x141c
15162 chmod u+s $DIR/$tfile
15163 chmod a+rwx $DIR/$tfile
15164 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15166 if [ $RC -ne 0 ]; then
15167 error "error, failed to take i_mutex, rc=$?"
15173 # Verify we do NOT take the i_mutex in the normal case
15175 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15176 $LCTL set_param fail_loc=0x141d
15179 chmod a+rw $DIR/$tfile
15180 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15182 if [ $RC -ne 0 ]; then
15183 error "error, took i_mutex unnecessarily, rc=$?"
15188 run_test 258b "verify i_mutex security behavior"
15191 #define OBD_FAIL_MDC_CLOSE 0x806
15192 $LCTL set_param fail_loc=0x80000806
15196 run_test 260 "Check mdc_close fail"
15199 remote_ost_nodsh && skip "remote OST with nodsh" && return
15200 [ $(lustre_version_code ost1) -lt $(version_code 2.10.1) ] &&
15201 skip "Need OST version >= 2.10.1" && return 0
15203 local file=$DIR/$tfile
15206 oss=$(comma_list $(osts_nodes))
15208 dd if=/dev/urandom of=$file bs=1M count=2 ||
15209 error "failed to create a file"
15210 cancel_lru_locks osc
15213 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
15214 error "failed to read a file"
15216 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
15217 $LCTL set_param fail_loc=0x8000031f
15219 cancel_lru_locks osc &
15222 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
15223 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
15224 #IO takes another lock, but matches the PENDING one
15225 #and places it to the IO RPC
15226 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
15227 error "failed to read a file with PENDING lock"
15229 run_test 275 "Read on a canceled duplicate lock"
15232 remote_ost_nodsh && skip "remote OST with nodsh" && return
15235 do_facet ost1 "(while true; do \
15236 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
15237 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
15240 for LOOP in $(seq 20); do
15242 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
15245 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
15246 rm $TMP/sanity_276_pid"
15248 run_test 276 "Race between mount and obd_statfs"
15250 cleanup_test_300() {
15254 test_striped_dir() {
15259 mkdir -p $DIR/$tdir
15261 SAVE_UMASK=$(umask)
15262 trap cleanup_test_300 RETURN EXIT
15264 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
15265 $DIR/$tdir/striped_dir ||
15266 error "set striped dir error"
15268 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
15269 [ "$mode" = "755" ] || error "expect 755 got $mode"
15271 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
15272 error "getdirstripe failed"
15273 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
15274 if [ "$stripe_count" != "2" ]; then
15275 error "1:stripe_count is $stripe_count, expect 2"
15277 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
15278 if [ "$stripe_count" != "2" ]; then
15279 error "2:stripe_count is $stripe_count, expect 2"
15282 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
15283 if [ "$stripe_index" != "$mdt_index" ]; then
15284 error "stripe_index is $stripe_index, expect $mdt_index"
15287 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15288 error "nlink error after create striped dir"
15290 mkdir $DIR/$tdir/striped_dir/a
15291 mkdir $DIR/$tdir/striped_dir/b
15293 stat $DIR/$tdir/striped_dir/a ||
15294 error "create dir under striped dir failed"
15295 stat $DIR/$tdir/striped_dir/b ||
15296 error "create dir under striped dir failed"
15298 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
15299 error "nlink error after mkdir"
15301 rmdir $DIR/$tdir/striped_dir/a
15302 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
15303 error "nlink error after rmdir"
15305 rmdir $DIR/$tdir/striped_dir/b
15306 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15307 error "nlink error after rmdir"
15309 chattr +i $DIR/$tdir/striped_dir
15310 createmany -o $DIR/$tdir/striped_dir/f 10 &&
15311 error "immutable flags not working under striped dir!"
15312 chattr -i $DIR/$tdir/striped_dir
15314 rmdir $DIR/$tdir/striped_dir ||
15315 error "rmdir striped dir error"
15323 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15324 skip "skipped for lustre < 2.7.0" && return
15325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15326 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15328 test_striped_dir 0 || error "failed on striped dir on MDT0"
15329 test_striped_dir 1 || error "failed on striped dir on MDT0"
15331 run_test 300a "basic striped dir sanity test"
15334 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15335 skip "skipped for lustre < 2.7.0" && return
15336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15337 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15343 test_mkdir $DIR/$tdir || error "mkdir fail"
15344 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15345 error "set striped dir error"
15346 for ((i=0; i<10; i++)); do
15347 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
15349 touch $DIR/$tdir/striped_dir/file_$i ||
15350 error "touch error $i"
15351 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
15352 [ $mtime1 -eq $mtime2 ] &&
15353 error "mtime not change after create"
15355 rm -f $DIR/$tdir/striped_dir/file_$i ||
15356 error "unlink error $i"
15357 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
15358 [ $mtime2 -eq $mtime3 ] &&
15359 error "mtime did not change after unlink"
15363 run_test 300b "check ctime/mtime for striped dir"
15366 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15367 skip "skipped for lustre < 2.7.0" && return
15368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15369 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15372 mkdir -p $DIR/$tdir
15373 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
15374 error "set striped dir error"
15376 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
15377 error "chown striped dir failed"
15379 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
15380 error "create 5k files failed"
15382 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
15384 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
15388 run_test 300c "chown && check ls under striped directory"
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
15398 mkdir -p $DIR/$tdir
15399 $SETSTRIPE -c 2 $DIR/$tdir
15401 #local striped directory
15402 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15403 error "set striped dir error"
15404 createmany -o $DIR/$tdir/striped_dir/f 10 ||
15405 error "create 10 files failed"
15407 #remote striped directory
15408 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
15409 error "set striped dir error"
15410 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
15411 error "create 10 files failed"
15413 for file in $(find $DIR/$tdir); do
15414 stripe_count=$($GETSTRIPE -c $file)
15415 [ $stripe_count -eq 2 ] ||
15416 error "wrong stripe $stripe_count for $file"
15421 run_test 300d "check default stripe under striped directory"
15424 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15425 skip "Need MDS version at least 2.7.55" && return
15426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15427 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15431 mkdir -p $DIR/$tdir
15433 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15434 error "set striped dir error"
15436 touch $DIR/$tdir/striped_dir/a
15437 touch $DIR/$tdir/striped_dir/b
15438 touch $DIR/$tdir/striped_dir/c
15440 mkdir $DIR/$tdir/striped_dir/dir_a
15441 mkdir $DIR/$tdir/striped_dir/dir_b
15442 mkdir $DIR/$tdir/striped_dir/dir_c
15444 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
15445 error "set striped adir under striped dir error"
15447 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
15448 error "set striped bdir under striped dir error"
15450 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
15451 error "set striped cdir under striped dir error"
15453 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
15454 error "rename dir under striped dir fails"
15456 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
15457 error "rename dir under different stripes fails"
15459 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
15460 error "rename file under striped dir should succeed"
15462 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
15463 error "rename dir under striped dir should succeed"
15467 run_test 300e "check rename under striped directory"
15470 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15471 skip "Need MDS version at least 2.7.55" && return
15472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15473 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15478 mkdir -p $DIR/$tdir
15480 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15481 error "set striped dir error"
15483 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
15484 error "set striped dir error"
15486 touch $DIR/$tdir/striped_dir/a
15487 mkdir $DIR/$tdir/striped_dir/dir_a
15488 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
15489 error "create striped dir under striped dir fails"
15491 touch $DIR/$tdir/striped_dir1/b
15492 mkdir $DIR/$tdir/striped_dir1/dir_b
15493 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
15494 error "create striped dir under striped dir fails"
15496 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
15497 error "rename dir under different striped dir should fail"
15499 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
15500 error "rename striped dir under diff striped dir should fail"
15502 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
15503 error "rename file under diff striped dirs fails"
15507 run_test 300f "check rename cross striped directory"
15509 test_300_check_default_striped_dir()
15512 local default_count=$2
15513 local default_index=$3
15516 local dir_stripe_index
15519 echo "checking $dirname $default_count $default_index"
15520 $LFS setdirstripe -D -c $default_count -i $default_index \
15521 -t all_char $DIR/$tdir/$dirname ||
15522 error "set default stripe on striped dir error"
15523 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
15524 [ $stripe_count -eq $default_count ] ||
15525 error "expect $default_count get $stripe_count for $dirname"
15527 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
15528 [ $stripe_index -eq $default_index ] ||
15529 error "expect $default_index get $stripe_index for $dirname"
15531 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
15532 error "create dirs failed"
15534 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
15535 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
15536 for dir in $(find $DIR/$tdir/$dirname/*); do
15537 stripe_count=$($LFS getdirstripe -c $dir)
15538 [ $stripe_count -eq $default_count ] ||
15539 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
15540 error "stripe count $default_count != $stripe_count for $dir"
15542 stripe_index=$($LFS getdirstripe -i $dir)
15543 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
15544 error "$stripe_index != $default_index for $dir"
15546 #check default stripe
15547 stripe_count=$($LFS getdirstripe -D -c $dir)
15548 [ $stripe_count -eq $default_count ] ||
15549 error "default count $default_count != $stripe_count for $dir"
15551 stripe_index=$($LFS getdirstripe -D -i $dir)
15552 [ $stripe_index -eq $default_index ] ||
15553 error "default index $default_index != $stripe_index for $dir"
15555 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
15559 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15560 skip "Need MDS version at least 2.7.55" && return
15561 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15567 mkdir $DIR/$tdir/normal_dir
15569 #Checking when client cache stripe index
15570 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
15571 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
15572 error "create striped_dir failed"
15574 mkdir $DIR/$tdir/striped_dir/dir1 ||
15575 error "create dir1 fails"
15576 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
15577 [ $stripe_index -eq 1 ] ||
15578 error "dir1 expect 1 got $stripe_index"
15580 $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
15581 error "create dir2 fails"
15582 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
15583 [ $stripe_index -eq 2 ] ||
15584 error "dir2 expect 2 got $stripe_index"
15586 #check default stripe count/stripe index
15587 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
15588 test_300_check_default_striped_dir normal_dir 1 0
15589 test_300_check_default_striped_dir normal_dir 2 1
15590 test_300_check_default_striped_dir normal_dir 2 -1
15592 #delete default stripe information
15593 echo "delete default stripeEA"
15594 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
15595 error "set default stripe on striped dir error"
15597 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
15598 for dir in $(find $DIR/$tdir/normal_dir/*); do
15599 stripe_count=$($LFS getdirstripe -c $dir)
15600 [ $stripe_count -eq 0 ] ||
15601 error "expect 1 get $stripe_count for $dir"
15602 stripe_index=$($LFS getdirstripe -i $dir)
15603 [ $stripe_index -eq 0 ] ||
15604 error "expect 0 get $stripe_index for $dir"
15607 run_test 300g "check default striped directory for normal directory"
15610 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15611 skip "Need MDS version at least 2.7.55" && return
15612 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15617 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
15618 $DIR/$tdir/striped_dir ||
15619 error "set striped dir error"
15621 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
15622 test_300_check_default_striped_dir striped_dir 1 0
15623 test_300_check_default_striped_dir striped_dir 2 1
15624 test_300_check_default_striped_dir striped_dir 2 -1
15626 #delete default stripe information
15627 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
15628 error "set default stripe on striped dir error"
15630 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
15631 for dir in $(find $DIR/$tdir/striped_dir/*); do
15632 stripe_count=$($LFS getdirstripe -c $dir)
15633 [ $stripe_count -eq 0 ] ||
15634 error "expect 1 get $stripe_count for $dir"
15637 run_test 300h "check default striped directory for striped directory"
15640 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15641 skip "Need MDS version at least 2.7.55" && return
15642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15643 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15649 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15650 error "set striped dir error"
15652 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15653 error "create files under striped dir failed"
15655 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
15656 error "set striped hashdir error"
15658 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
15659 error "create dir0 under hash dir failed"
15660 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
15661 error "create dir1 under hash dir failed"
15663 # unfortunately, we need to umount to clear dir layout cache for now
15664 # once we fully implement dir layout, we can drop this
15665 umount_client $MOUNT || error "umount failed"
15666 mount_client $MOUNT || error "mount failed"
15668 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
15669 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
15670 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
15672 #set the stripe to be unknown hash type
15673 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
15674 $LCTL set_param fail_loc=0x1901
15675 for ((i = 0; i < 10; i++)); do
15676 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
15677 error "stat f-$i failed"
15678 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
15681 touch $DIR/$tdir/striped_dir/f0 &&
15682 error "create under striped dir with unknown hash should fail"
15684 $LCTL set_param fail_loc=0
15686 umount_client $MOUNT || error "umount failed"
15687 mount_client $MOUNT || error "mount failed"
15691 run_test 300i "client handle unknown hash type striped directory"
15694 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15695 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15696 skip "Need MDS version at least 2.7.55" && return
15697 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15703 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
15704 $LCTL set_param fail_loc=0x1702
15705 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15706 error "set striped dir error"
15708 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15709 error "create files under striped dir failed"
15711 $LCTL set_param fail_loc=0
15713 rm -rf $DIR/$tdir || error "unlink striped dir fails"
15717 run_test 300j "test large update record"
15720 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15721 skip "Need MDS version at least 2.7.55" && return
15722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15723 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15729 #define OBD_FAIL_LARGE_STRIPE 0x1703
15730 $LCTL set_param fail_loc=0x1703
15731 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
15732 error "set striped dir error"
15733 $LCTL set_param fail_loc=0
15735 $LFS getdirstripe $DIR/$tdir/striped_dir ||
15736 error "getstripeddir fails"
15737 rm -rf $DIR/$tdir/striped_dir ||
15738 error "unlink striped dir fails"
15742 run_test 300k "test large striped directory"
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
15751 test_mkdir -p $DIR/$tdir/striped_dir
15752 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
15753 error "chown $RUNAS_ID failed"
15754 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
15755 error "set default striped dir failed"
15757 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
15758 $LCTL set_param fail_loc=0x80000158
15759 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
15761 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
15762 [ $stripe_index -eq 1 ] ||
15763 error "expect 1 get $stripe_index for $dir"
15765 run_test 300l "non-root user to create dir under striped dir with stale layout"
15768 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15769 skip "Need MDS version at least 2.7.55" && return
15770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15771 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
15773 mkdir -p $DIR/$tdir/striped_dir
15774 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
15775 error "set default stripes dir error"
15777 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
15779 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
15780 [ $stripe_count -eq 0 ] ||
15781 error "expect 0 get $stripe_count for a"
15783 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
15784 error "set default stripes dir error"
15786 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
15788 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
15789 [ $stripe_count -eq 0 ] ||
15790 error "expect 0 get $stripe_count for b"
15792 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
15793 error "set default stripes dir error"
15795 mkdir $DIR/$tdir/striped_dir/c &&
15796 error "default stripe_index is invalid, mkdir c should fails"
15798 rm -rf $DIR/$tdir || error "rmdir fails"
15800 run_test 300m "setstriped directory on single MDT FS"
15803 local list=$(comma_list $(mdts_nodes))
15806 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15810 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15811 skip "Need MDS version at least 2.7.55" && return
15812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15813 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15814 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15817 local list=$(comma_list $(mdts_nodes))
15819 trap cleanup_300n RETURN EXIT
15820 mkdir -p $DIR/$tdir
15821 chmod 777 $DIR/$tdir
15822 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
15823 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15824 error "create striped dir succeeds with gid=0"
15826 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15827 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
15828 error "create striped dir fails with gid=-1"
15830 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15831 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
15832 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15833 error "set default striped dir succeeds with gid=0"
15836 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15837 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
15838 error "set default striped dir fails with gid=-1"
15841 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15842 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
15843 error "create test_dir fails"
15844 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
15845 error "create test_dir1 fails"
15846 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
15847 error "create test_dir2 fails"
15850 run_test 300n "non-root user to create dir under striped dir with default EA"
15853 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15854 skip "Need MDS version at least 2.7.55" && return
15855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15856 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15860 mkdir -p $DIR/$tdir
15862 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
15863 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
15864 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
15865 skip "not enough free inodes $numfree1 $numfree2"
15869 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
15870 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
15871 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
15872 skip "not enough free space $numfree1 $numfree2"
15876 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
15877 error "setdirstripe fails"
15879 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
15880 error "create dirs fails"
15882 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
15883 ls $DIR/$tdir/striped_dir > /dev/null ||
15884 error "ls striped dir fails"
15885 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
15886 error "unlink big striped dir fails"
15888 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
15891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15892 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15893 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15895 mkdir -p $DIR/$tdir
15897 #define OBD_FAIL_OUT_ENOSPC 0x1704
15898 do_facet mds2 lctl set_param fail_loc=0x80001704
15899 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
15900 error "create striped directory should fail"
15902 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
15904 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
15907 run_test 300p "create striped directory without space"
15910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15911 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15913 local fd=$(free_fd)
15914 local cmd="exec $fd<$tdir"
15916 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
15919 trap "eval $cmd" EXIT
15920 cd $tdir || error "cd $tdir fails"
15921 rmdir ../$tdir || error "rmdir $tdir fails"
15922 mkdir local_dir && error "create dir succeeds"
15923 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
15927 run_test 300q "create remote directory under orphan directory"
15929 prepare_remote_file() {
15930 mkdir $DIR/$tdir/src_dir ||
15931 error "create remote source failed"
15933 cp /etc/hosts $DIR/$tdir/src_dir/a || error
15934 touch $DIR/$tdir/src_dir/a
15936 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
15937 error "create remote target dir failed"
15939 touch $DIR/$tdir/tgt_dir/b
15941 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
15942 error "rename dir cross MDT failed!"
15944 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
15945 error "src_child still exists after rename"
15947 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
15948 error "missing file(a) after rename"
15950 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
15951 error "diff after rename"
15955 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15957 local remote_file=$DIR/$tdir/tgt_dir/b
15959 mkdir -p $DIR/$tdir
15961 prepare_remote_file || error "prepare remote file failed"
15964 $OPENUNLINK $remote_file $remote_file || error
15965 $CHECKSTAT -a $remote_file || error
15967 run_test 310a "open unlink remote file"
15970 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15972 local remote_file=$DIR/$tdir/tgt_dir/b
15974 mkdir -p $DIR/$tdir
15976 prepare_remote_file || error "prepare remote file failed"
15978 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15979 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
15980 $CHECKSTAT -t file $remote_file || error "check file failed"
15982 run_test 310b "unlink remote file with multiple links while open"
15985 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
15986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15987 local remote_file=$DIR/$tdir/tgt_dir/b
15989 mkdir -p $DIR/$tdir
15991 prepare_remote_file || error "prepare remote file failed"
15993 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15994 multiop_bg_pause $remote_file O_uc ||
15995 error "mulitop failed for remote file"
15997 $MULTIOP $DIR/$tfile Ouc
15998 kill -USR1 $MULTIPID
16001 run_test 310c "open-unlink remote file with multiple links"
16005 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16006 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
16007 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
16008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16009 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16011 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16013 mkdir -p $DIR/$tdir
16014 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
16015 createmany -o $DIR/$tdir/$tfile. 1000
16017 # statfs data is not real time, let's just calculate it
16018 old_iused=$((old_iused + 1000))
16020 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
16021 osp.*OST0000*MDT0000.create_count")
16022 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
16023 osp.*OST0000*MDT0000.max_create_count")
16024 for idx in $(seq $MDSCOUNT); do
16025 do_facet mds$idx "lctl set_param -n \
16026 osp.*OST0000*MDT000?.max_create_count=0"
16029 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
16030 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
16031 [ $index -ne 0 ] || error "$tfile stripe index is 0"
16033 unlinkmany $DIR/$tdir/$tfile. 1000
16035 for idx in $(seq $MDSCOUNT); do
16036 do_facet mds$idx "lctl set_param -n \
16037 osp.*OST0000*MDT000?.max_create_count=$max_count"
16038 do_facet mds$idx "lctl set_param -n \
16039 osp.*OST0000*MDT000?.create_count=$count"
16043 for i in $(seq 120); do
16044 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16045 # system may be too busy to destroy all objs in time, use
16046 # a somewhat small value to not fail autotest
16047 [ $((old_iused - new_iused)) -gt 400 ] && break
16051 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
16052 [ $((old_iused - new_iused)) -gt 400 ] ||
16053 error "objs not destroyed after unlink"
16055 run_test 311 "disable OSP precreate, and unlink should destroy objs"
16062 local vdevdir=$(dirname $(facet_vdevice $ost))
16063 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
16064 local zfs_zapid=$(do_facet $ost $cmd |
16065 grep -w "/O/0/d$((objid%32))" -C 5 |
16066 awk '/Object/{getline; print $1}')
16067 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
16068 awk "/$objid = /"'{printf $3}')
16073 zfs_object_blksz() {
16077 local vdevdir=$(dirname $(facet_vdevice $ost))
16078 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
16079 local blksz=$(do_facet $ost $cmd $objid |
16080 awk '/dblk/{getline; printf $4}')
16082 case "${blksz: -1}" in
16083 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
16084 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
16091 test_312() { # LU-4856
16092 remote_ost_nodsh && skip "remote OST with nodsh" && return
16094 [ $(facet_fstype ost1) = "zfs" ] ||
16095 { skip "the test only applies to zfs" && return; }
16097 local max_blksz=$(do_facet ost1 \
16098 $ZFS get -p recordsize $(facet_device ost1) |
16099 awk '!/VALUE/{print $3}')
16100 local min_blksz=$(getconf PAGE_SIZE)
16102 # to make life a little bit easier
16103 $LFS mkdir -c 1 -i 0 $DIR/$tdir
16104 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16106 local tf=$DIR/$tdir/$tfile
16108 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16110 # Get ZFS object id
16111 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16113 # block size change by sequential over write
16115 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
16116 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
16118 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16119 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
16123 # block size change by sequential append write
16124 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
16125 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16126 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16128 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
16129 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
16130 oflag=sync conv=notrunc
16132 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16133 [ $blksz -eq $((2 * count * min_blksz)) ] ||
16134 error "blksz error, actual $blksz, " \
16135 "expected: 2 * $count * $min_blksz"
16141 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
16142 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
16144 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
16145 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16146 [ $blksz -eq $min_blksz ] ||
16147 error "blksz error: $blksz, expected: $min_blksz"
16149 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
16150 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16151 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
16153 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
16154 blksz=$(zfs_object_blksz ost1 $zfs_objid)
16155 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
16157 run_test 312 "make sure ZFS adjusts its block size by write pattern"
16160 remote_ost_nodsh && skip "remote OST with nodsh" && return
16162 local file=$DIR/$tfile
16164 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
16166 # define OBD_FAIL_TGT_RCVD_EIO 0x720
16167 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16168 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
16169 error "write should failed"
16170 do_facet ost1 "$LCTL set_param fail_loc=0"
16173 run_test 313 "io should fail after last_rcvd update fail"
16176 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16178 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
16179 do_facet ost1 "$LCTL set_param fail_loc=0x720"
16181 wait_delete_completed
16182 do_facet ost1 "$LCTL set_param fail_loc=0"
16184 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
16186 test_315() { # LU-618
16187 local file=$DIR/$tfile
16190 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
16191 $MULTIOP $file oO_RDONLY:r4096000_c &
16196 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
16199 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
16202 run_test 315 "read should be accounted"
16205 local read_write=$1
16206 if [ "$read_write" = "write" ]; then
16207 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
16208 elif [ "$read_write" = "read" ]; then
16209 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
16211 error "argument error"
16214 # turn off debug for performance testing
16215 local saved_debug=$($LCTL get_param -n debug)
16216 $LCTL set_param debug=0
16218 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
16220 # get ost1 size - lustre-OST0000
16221 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
16222 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
16223 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
16225 if [ "$read_write" = "read" ]; then
16226 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
16229 local start_time=$(date +%s.%N)
16230 $dd_cmd bs=1M count=$blocks oflag=sync ||
16231 error "real dd $read_write error"
16232 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
16234 if [ "$read_write" = "write" ]; then
16238 # define OBD_FAIL_OST_FAKE_RW 0x238
16239 do_facet ost1 $LCTL set_param fail_loc=0x238
16241 local start_time=$(date +%s.%N)
16242 $dd_cmd bs=1M count=$blocks oflag=sync ||
16243 error "fake dd $read_write error"
16244 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
16246 if [ "$read_write" = "write" ]; then
16248 cancel_lru_locks osc
16249 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
16250 error "$tfile size not $blocks MB"
16252 do_facet ost1 $LCTL set_param fail_loc=0
16254 echo "fake $read_write $duration_fake vs. normal $read_write" \
16255 "$duration in seconds"
16256 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
16257 error_not_in_vm "fake write is slower"
16259 $LCTL set_param -n debug="$saved_debug"
16262 test_399a() { # LU-7655 for OST fake write
16263 remote_ost_nodsh && skip "remote OST with nodsh" && return
16267 run_test 399a "fake write should not be slower than normal write"
16269 test_399b() { # LU-8726 for OST fake read
16270 remote_ost_nodsh && skip "remote OST with nodsh" && return
16272 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
16273 skip "ldiskfs only test" && return 0
16277 run_test 399b "fake read should not be slower than normal read"
16279 test_400a() { # LU-1606, was conf-sanity test_74
16280 local extra_flags=''
16281 local out=$TMP/$tfile
16282 local prefix=/usr/include/lustre
16285 if ! which $CC > /dev/null 2>&1; then
16286 skip_env "$CC is not installed"
16290 if ! [[ -d $prefix ]]; then
16291 # Assume we're running in tree and fixup the include path.
16292 extra_flags+=" -I$LUSTRE/../libcfs/include"
16293 extra_flags+=" -I$LUSTRE/include"
16294 extra_flags+=" -L$LUSTRE/utils"
16297 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
16298 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
16299 error "client api broken"
16303 run_test 400a "Lustre client api program can compile and link"
16305 test_400b() { # LU-1606, LU-5011
16307 local out=$TMP/$tfile
16308 local prefix=/usr/include/lustre
16310 # We use a hard coded prefix so that this test will not fail
16311 # when run in tree. There are headers in lustre/include/lustre/
16312 # that are not packaged (like lustre_idl.h) and have more
16313 # complicated include dependencies (like config.h and lnet/types.h).
16314 # Since this test about correct packaging we just skip them when
16315 # they don't exist (see below) rather than try to fixup cppflags.
16317 if ! which $CC > /dev/null 2>&1; then
16318 skip_env "$CC is not installed"
16322 for header in $prefix/*.h; do
16323 if ! [[ -f "$header" ]]; then
16327 if [[ "$(basename $header)" == liblustreapi.h ]]; then
16328 continue # liblustreapi.h is deprecated.
16331 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
16332 error "cannot compile '$header'"
16336 run_test 400b "packaged headers can be compiled"
16338 test_401a() { #LU-7437
16339 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
16340 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
16342 #count the number of parameters by "list_param -R"
16343 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
16344 #count the number of parameters by listing proc files
16345 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
16346 echo "proc_dirs='$proc_dirs'"
16347 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
16348 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
16351 [ $params -eq $procs ] ||
16352 error "found $params parameters vs. $procs proc files"
16354 # test the list_param -D option only returns directories
16355 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
16356 #count the number of parameters by listing proc directories
16357 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
16360 [ $params -eq $procs ] ||
16361 error "found $params parameters vs. $procs proc files"
16363 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
16366 local save=$($LCTL get_param -n jobid_var)
16369 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
16370 error "no error returned when setting bad parameters"
16372 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
16373 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
16375 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
16376 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
16377 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
16379 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
16382 local jobid_var_old=$($LCTL get_param -n jobid_var)
16383 local jobid_var_new
16385 $LCTL set_param jobid_var= &&
16386 error "no error returned for 'set_param a='"
16388 jobid_var_new=$($LCTL get_param -n jobid_var)
16389 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16390 error "jobid_var was changed by setting without value"
16392 $LCTL set_param jobid_var &&
16393 error "no error returned for 'set_param a'"
16395 jobid_var_new=$($LCTL get_param -n jobid_var)
16396 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16397 error "jobid_var was changed by setting without value"
16399 run_test 401c "Verify 'lctl set_param' without value fails in either format."
16402 local jobid_var_old=$($LCTL get_param -n jobid_var)
16403 local jobid_var_new
16404 local new_value="foo=bar"
16406 $LCTL set_param jobid_var=$new_value ||
16407 error "'set_param a=b' did not accept a value containing '='"
16409 jobid_var_new=$($LCTL get_param -n jobid_var)
16410 [[ "$jobid_var_new" == "$new_value" ]] ||
16411 error "'set_param a=b' failed on a value containing '='"
16413 # Reset the jobid_var to test the other format
16414 $LCTL set_param jobid_var=$jobid_var_old
16415 jobid_var_new=$($LCTL get_param -n jobid_var)
16416 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16417 error "failed to reset jobid_var"
16419 $LCTL set_param jobid_var $new_value ||
16420 error "'set_param a b' did not accept a value containing '='"
16422 jobid_var_new=$($LCTL get_param -n jobid_var)
16423 [[ "$jobid_var_new" == "$new_value" ]] ||
16424 error "'set_param a b' failed on a value containing '='"
16426 $LCTL set_param jobid_var $jobid_var_old
16427 jobid_var_new=$($LCTL get_param -n jobid_var)
16428 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16429 error "failed to reset jobid_var"
16431 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
16434 local server_version=$(lustre_version_code $SINGLEMDS)
16435 [[ $server_version -ge $(version_code 2.7.66) ]] ||
16436 [[ $server_version -ge $(version_code 2.7.18.4) &&
16437 $server_version -lt $(version_code 2.7.50) ]] ||
16438 [[ $server_version -ge $(version_code 2.7.2) &&
16439 $server_version -lt $(version_code 2.7.11) ]] ||
16440 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
16442 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16443 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
16444 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
16445 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
16446 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
16447 echo "Touch failed - OK"
16449 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
16452 local file1=$DIR/$tfile.1
16453 local file2=$DIR/$tfile.2
16454 local tfile=$TMP/$tfile
16456 rm -f $file1 $file2 $tfile
16461 # 30 sec OBD_TIMEOUT in ll_getattr()
16462 # right before populating st_nlink
16463 $LCTL set_param fail_loc=0x80001409
16464 stat -c %h $file1 > $tfile &
16466 # create an alias, drop all locks and reclaim the dentry
16468 cancel_lru_locks mdc
16469 cancel_lru_locks osc
16470 sysctl -w vm.drop_caches=2
16474 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
16476 rm -f $tfile $file1 $file2
16478 run_test 403 "i_nlink should not drop to zero due to aliasing"
16480 test_404() { # LU-6601
16481 local server_version=$(lustre_version_code $SINGLEMDS)
16482 [[ $server_version -ge $(version_code 2.8.53) ]] ||
16483 { skip "Need server version newer than 2.8.52"; return 0; }
16485 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16486 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
16487 awk '/osp .*-osc-MDT/ { print $4}')
16490 for osp in $mosps; do
16491 echo "Deactivate: " $osp
16492 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
16493 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16494 awk -vp=$osp '$4 == p { print $2 }')
16495 [ $stat = IN ] || {
16496 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16497 error "deactivate error"
16499 echo "Activate: " $osp
16500 do_facet $SINGLEMDS $LCTL --device %$osp activate
16501 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16502 awk -vp=$osp '$4 == p { print $2 }')
16503 [ $stat = UP ] || {
16504 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16505 error "activate error"
16509 run_test 404 "validate manual {de}activated works properly for OSPs"
16512 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
16513 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
16514 skip "Layout swap lock is not supported" && return
16516 check_swap_layouts_support && return 0
16518 test_mkdir -p $DIR/$tdir
16519 swap_lock_test -d $DIR/$tdir ||
16520 error "One layout swap locked test failed"
16522 run_test 405 "Various layout swap lock tests"
16525 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16526 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16527 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
16528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16529 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
16530 skip "Need MDS version at least 2.8.50" && return
16532 local def_stripe_count=$($GETSTRIPE -c $MOUNT)
16533 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
16534 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
16535 local def_pool=$($GETSTRIPE -p $MOUNT)
16536 local test_pool=$TESTNAME
16538 if ! combined_mgs_mds ; then
16541 pool_add $test_pool || error "pool_add failed"
16542 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
16543 error "pool_add_targets failed"
16545 # parent set default stripe count only, child will stripe from both
16546 # parent and fs default
16547 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
16548 error "setstripe $MOUNT failed"
16549 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
16550 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
16551 for i in $(seq 10); do
16552 local f=$DIR/$tdir/$tfile.$i
16553 touch $f || error "touch failed"
16554 local count=$($GETSTRIPE -c $f)
16555 [ $count -eq $OSTCOUNT ] ||
16556 error "$f stripe count $count != $OSTCOUNT"
16557 local offset=$($GETSTRIPE -i $f)
16558 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
16559 local size=$($GETSTRIPE -S $f)
16560 [ $size -eq $((def_stripe_size * 2)) ] ||
16561 error "$f stripe size $size != $((def_stripe_size * 2))"
16562 local pool=$($GETSTRIPE -p $f)
16563 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
16566 # change fs default striping, delete parent default striping, now child
16567 # will stripe from new fs default striping only
16568 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
16569 error "change $MOUNT default stripe failed"
16570 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
16571 for i in $(seq 11 20); do
16572 local f=$DIR/$tdir/$tfile.$i
16573 touch $f || error "touch $f failed"
16574 local count=$($GETSTRIPE -c $f)
16575 [ $count -eq 1 ] || error "$f stripe count $count != 1"
16576 local offset=$($GETSTRIPE -i $f)
16577 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
16578 local size=$($GETSTRIPE -S $f)
16579 [ $size -eq $def_stripe_size ] ||
16580 error "$f stripe size $size != $def_stripe_size"
16581 local pool=$($GETSTRIPE -p $f)
16582 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
16586 unlinkmany $DIR/$tdir/$tfile. 1 20
16588 # restore FS default striping
16589 if [ -z $def_pool ]; then
16590 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16591 -i $def_stripe_offset $MOUNT ||
16592 error "restore default striping failed"
16594 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16595 -i $def_stripe_offset -p $def_pool $MOUNT ||
16596 error "restore default striping with $def_pool failed"
16599 local f=$DIR/$tdir/$tfile
16600 pool_remove_all_targets $test_pool $f
16601 pool_remove $test_pool $f
16603 if ! combined_mgs_mds ; then
16607 run_test 406 "DNE support fs default striping"
16610 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16611 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16612 skip "Need MDS version at least 2.8.55" && return
16613 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16615 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
16616 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
16617 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
16618 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
16619 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
16621 #define OBD_FAIL_DT_TXN_STOP 0x2019
16622 for idx in $(seq $MDSCOUNT); do
16623 do_facet mds$idx "lctl set_param fail_loc=0x2019"
16625 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
16626 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
16627 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
16630 run_test 407 "transaction fail should cause operation fail"
16633 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
16635 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
16636 lctl set_param fail_loc=0x8000040a
16637 # let ll_prepare_partial_page() fail
16638 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
16642 # create at least 100 unused inodes so that
16643 # shrink_icache_memory(0) should not return 0
16644 touch $DIR/$tfile-{0..100}
16645 rm -f $DIR/$tfile-{0..100}
16648 echo 2 > /proc/sys/vm/drop_caches
16650 run_test 408 "drop_caches should not hang due to page leaks"
16654 [ $MDSCOUNT -lt 2 ] &&
16655 skip "We need at least 2 MDTs for this test" && return
16657 check_mount_and_prep
16659 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
16660 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
16661 touch $DIR/$tdir/guard || error "(2) Fail to create"
16663 local PREFIX=$(str_repeat 'A' 128)
16664 echo "Create 1K hard links start at $(date)"
16665 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16666 error "(3) Fail to hard link"
16668 echo "Links count should be right although linkEA overflow"
16669 stat $DIR/$tdir/guard || error "(4) Fail to stat"
16670 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
16671 [ $linkcount -eq 1001 ] ||
16672 error "(5) Unexpected hard links count: $linkcount"
16674 echo "List all links start at $(date)"
16675 ls -l $DIR/$tdir/foo > /dev/null ||
16676 error "(6) Fail to list $DIR/$tdir/foo"
16678 echo "Unlink hard links start at $(date)"
16679 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16680 error "(7) Fail to unlink"
16682 run_test 409 "Large amount of cross-MDTs hard links on the same file"
16686 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
16687 skip "Need client version at least 2.9.59" && return
16689 # Create a file, and stat it from the kernel
16690 local testfile=$DIR/$tfile
16693 local run_id=$RANDOM
16694 local my_ino=$(stat --format "%i" $testfile)
16696 # Try to insert the module. This will always fail as the
16697 # module is designed to not be inserted.
16698 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
16701 # Anything but success is a test failure
16703 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
16704 error "no inode match"
16706 run_test 410 "Test inode number returned from kernel thread"
16709 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16710 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16711 skip "Need server version at least 2.9.55" & exit 0
16712 start_full_debug_logging
16716 stop_full_debug_logging
16720 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16721 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16722 awk '/The barrier for/ { print $7 }')
16725 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
16730 barrier_expired() {
16733 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16734 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16735 awk '/will be expired/ { print $7 }')
16737 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
16746 echo "Start barrier_freeze at: $(date)"
16747 #define OBD_FAIL_BARRIER_DELAY 0x2202
16748 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16749 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
16752 local b_status=$(barrier_stat)
16753 echo "Got barrier status at: $(date)"
16754 [ "$b_status" = "'freezing_p1'" ] ||
16755 error "(1) unexpected barrier status $b_status"
16757 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16759 b_status=$(barrier_stat)
16760 [ "$b_status" = "'frozen'" ] ||
16761 error "(2) unexpected barrier status $b_status"
16763 local expired=$(barrier_expired)
16764 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
16765 sleep $((expired + 3))
16767 b_status=$(barrier_stat)
16768 [ "$b_status" = "'expired'" ] ||
16769 error "(3) unexpected barrier status $b_status"
16771 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
16772 error "(4) fail to freeze barrier"
16774 b_status=$(barrier_stat)
16775 [ "$b_status" = "'frozen'" ] ||
16776 error "(5) unexpected barrier status $b_status"
16778 echo "Start barrier_thaw at: $(date)"
16779 #define OBD_FAIL_BARRIER_DELAY 0x2202
16780 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16781 do_facet mgs $LCTL barrier_thaw $FSNAME &
16784 b_status=$(barrier_stat)
16785 echo "Got barrier status at: $(date)"
16786 [ "$b_status" = "'thawing'" ] ||
16787 error "(6) unexpected barrier status $b_status"
16789 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16791 b_status=$(barrier_stat)
16792 [ "$b_status" = "'thawed'" ] ||
16793 error "(7) unexpected barrier status $b_status"
16795 #define OBD_FAIL_BARRIER_FAILURE 0x2203
16796 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
16797 do_facet mgs $LCTL barrier_freeze $FSNAME
16799 b_status=$(barrier_stat)
16800 [ "$b_status" = "'failed'" ] ||
16801 error "(8) unexpected barrier status $b_status"
16803 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16804 do_facet mgs $LCTL barrier_thaw $FSNAME
16808 run_test 801a "write barrier user interfaces and stat machine"
16813 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16814 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
16815 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
16816 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
16817 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
16819 cancel_lru_locks mdc
16821 # 180 seconds should be long enough
16822 do_facet mgs $LCTL barrier_freeze $FSNAME 180
16824 local b_status=$(barrier_stat)
16825 [ "$b_status" = "'frozen'" ] ||
16826 error "(6) unexpected barrier status $b_status"
16828 mkdir $DIR/$tdir/d0/d10 &
16831 touch $DIR/$tdir/d1/f13 &
16834 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
16837 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
16840 rm -f $DIR/$tdir/d4/f12 &
16843 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
16845 # To guarantee taht the 'stat' is not blocked
16846 b_status=$(barrier_stat)
16847 [ "$b_status" = "'frozen'" ] ||
16848 error "(8) unexpected barrier status $b_status"
16850 # let above commands to run at background
16853 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
16854 ps -p $touch_pid || error "(10) touch should be blocked"
16855 ps -p $ln_pid || error "(11) link should be blocked"
16856 ps -p $mv_pid || error "(12) rename should be blocked"
16857 ps -p $rm_pid || error "(13) unlink should be blocked"
16859 b_status=$(barrier_stat)
16860 [ "$b_status" = "'frozen'" ] ||
16861 error "(14) unexpected barrier status $b_status"
16863 do_facet mgs $LCTL barrier_thaw $FSNAME
16864 b_status=$(barrier_stat)
16865 [ "$b_status" = "'thawed'" ] ||
16866 error "(15) unexpected barrier status $b_status"
16868 wait $mkdir_pid || error "(16) mkdir should succeed"
16869 wait $touch_pid || error "(17) touch should succeed"
16870 wait $ln_pid || error "(18) link should succeed"
16871 wait $mv_pid || error "(19) rename should succeed"
16872 wait $rm_pid || error "(20) unlink should succeed"
16876 run_test 801b "modification will be blocked by write barrier"
16879 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
16883 stop mds2 || error "(1) Fail to stop mds2"
16885 do_facet mgs $LCTL barrier_freeze $FSNAME 30
16887 local b_status=$(barrier_stat)
16888 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
16889 do_facet mgs $LCTL barrier_thaw $FSNAME
16890 error "(2) unexpected barrier status $b_status"
16893 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16894 error "(3) Fail to rescan barrier bitmap"
16896 do_facet mgs $LCTL barrier_freeze $FSNAME 10
16898 b_status=$(barrier_stat)
16899 [ "$b_status" = "'frozen'" ] ||
16900 error "(4) unexpected barrier status $b_status"
16902 do_facet mgs $LCTL barrier_thaw $FSNAME
16903 b_status=$(barrier_stat)
16904 [ "$b_status" = "'thawed'" ] ||
16905 error "(5) unexpected barrier status $b_status"
16907 local devname=$(mdsdevname 2)
16909 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
16911 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16912 error "(7) Fail to rescan barrier bitmap"
16916 run_test 801c "rescan barrier bitmap"
16918 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
16919 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
16920 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
16926 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
16927 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
16928 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
16934 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16935 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16936 skip "Need server version at least 2.9.55" & exit 0
16938 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16940 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
16941 error "(2) Fail to copy"
16943 trap cleanup_802 EXIT
16945 # sync by force before remount as readonly
16946 sync; sync_all_data; sleep 3; sync_all_data
16950 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
16951 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
16952 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
16954 echo "Mount the server as read only"
16955 setupall server_only || error "(3) Fail to start servers"
16957 echo "Mount client without ro should fail"
16958 mount_client $MOUNT &&
16959 error "(4) Mount client without 'ro' should fail"
16961 echo "Mount client with ro should succeed"
16962 mount_client $MOUNT ro ||
16963 error "(5) Mount client with 'ro' should succeed"
16965 echo "Modify should be refused"
16966 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
16968 echo "Read should be allowed"
16969 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
16970 error "(7) Read should succeed under ro mode"
16974 run_test 802 "simulate readonly device"
16977 do_facet $SINGLEMDS zfs set quota=$old $fsset
16978 unlinkmany $DIR/$tdir/f- 1000000
16983 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
16984 [ "$(facet_fstype mds1)" != "zfs" ] &&
16985 skip "ZFS specific test" && return
16986 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
16987 skip "netfree not implemented before 0.7" && return
16988 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
16989 { skip "Need MDS version at least 2.10.57" && return 0; }
16996 local pref="osd-zfs.lustre-MDT0000."
16998 # limit available space on MDS dataset to meet nospace issue
16999 # quickly. then ZFS 0.7.2 can use reserved space if asked
17000 # properly (using netfree flag in osd_declare_destroy()
17001 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
17002 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
17004 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
17005 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
17006 let "usedkb=usedkb-freekb"
17007 let "freekb=freekb/2"
17008 if let "freekb > 5000"; then
17011 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
17012 trap cleanup_805 EXIT
17014 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
17015 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
17016 rm -rf $DIR/$tdir || error "not able to remove"
17017 do_facet $SINGLEMDS zfs set quota=$old $fsset
17020 run_test 805 "ZFS can remove from full fs"
17023 # tests that do cleanup/setup should be run at the end
17027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17029 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
17030 $LCTL set_param fail_loc=0x903
17032 cancel_lru_locks MGC
17034 FAIL_ON_ERROR=true cleanup
17035 FAIL_ON_ERROR=true setup
17037 run_test 900 "umount should not race with any mgc requeue thread"
17040 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
17041 check_and_cleanup_lustre
17042 if [ "$I_MOUNTED" != "yes" ]; then
17043 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true