2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: LU-9693 LU-6493 LU-9693 3561 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 45 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-2036 LU-8411 LU-9096 LU-9054
16 ALWAYS_EXCEPT=" 76 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"
23 if [ -r /etc/SuSE-release ]
25 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
26 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
28 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
35 if is_sles11; then # LU-4341
36 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
39 SRCDIR=$(cd $(dirname $0); echo $PWD)
40 export PATH=$PATH:/sbin
45 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
46 CREATETEST=${CREATETEST:-createtest}
48 LFIND=${LFIND:-"$LFS find"}
49 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
51 OPENFILE=${OPENFILE:-openfile}
52 OPENUNLINK=${OPENUNLINK:-openunlink}
53 export MULTIOP=${MULTIOP:-multiop}
54 READS=${READS:-"reads"}
55 MUNLINK=${MUNLINK:-munlink}
56 SOCKETSERVER=${SOCKETSERVER:-socketserver}
57 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
58 MEMHOG=${MEMHOG:-memhog}
59 DIRECTIO=${DIRECTIO:-directio}
60 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
62 CHECK_GRANT=${CHECK_GRANT:-"yes"}
63 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
64 export PARALLEL=${PARALLEL:-"no"}
66 export NAME=${NAME:-local}
73 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
74 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
75 . $LUSTRE/tests/test-framework.sh
77 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
81 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
83 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
84 # bug number for skipped test: LU-1957
85 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
87 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
94 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
95 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
104 check_swap_layouts_support()
106 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
107 { skip "Does not support layout lock."; return 0; }
111 check_and_setup_lustre
115 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
116 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
117 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
119 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
120 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
121 rm -rf $DIR/[Rdfs][0-9]*
123 # $RUNAS_ID may get set incorrectly somewhere else
124 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
126 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
130 if [ "${ONLY}" = "MOUNT" ] ; then
131 echo "Lustre is up, please go on"
135 echo "preparing for tests involving mounts"
136 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
138 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
139 echo # add a newline after mke2fs.
143 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
144 lctl set_param debug=-1 2> /dev/null || true
147 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
149 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
151 run_test 0a "touch; rm ====================="
154 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
155 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
157 run_test 0b "chmod 0755 $DIR ============================="
160 $LCTL get_param mdc.*.import | grep "state: FULL" ||
161 error "import not FULL"
162 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
165 run_test 0c "check import proc"
168 test_mkdir $DIR/$tdir
169 test_mkdir $DIR/$tdir/d2
170 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
171 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
174 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
176 run_test 1 "mkdir; remkdir; rmdir"
179 test_mkdir $DIR/$tdir
180 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
181 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
183 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
185 run_test 2 "mkdir; touch; rmdir; check file"
188 test_mkdir $DIR/$tdir
189 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
190 touch $DIR/$tdir/$tfile
191 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
193 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
195 run_test 3 "mkdir; touch; rmdir; check dir"
197 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
199 test_mkdir -i 1 $DIR/$tdir
201 touch $DIR/$tdir/$tfile ||
202 error "Create file under remote directory failed"
205 error "Expect error removing in-use dir $DIR/$tdir"
207 test -d $DIR/$tdir || error "Remote directory disappeared"
209 rm -rf $DIR/$tdir || error "remove remote dir error"
211 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
214 test_mkdir $DIR/$tdir
215 test_mkdir $DIR/$tdir/d2
216 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
217 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
218 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
220 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
223 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
224 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
225 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
226 error "$tfile does not have perm 0666 or UID $UID"
227 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
228 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
229 error "$tfile should be 0666 and owned by UID $UID"
231 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
234 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
236 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
237 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
238 error "$tfile should be owned by UID $RUNAS_ID"
239 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
240 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
241 error "$tfile should be owned by UID $RUNAS_ID"
243 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
246 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
248 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
249 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
250 error "$tfile should be owned by GID $UID"
251 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
252 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
253 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
255 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
258 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
259 test_mkdir $DIR/$tdir
260 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
261 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
262 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
263 test_mkdir $DIR/$tdir/d/subdir
264 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
265 error "$tdir/d/subdir should be GID $RUNAS_GID"
266 if [[ $MDSCOUNT -gt 1 ]]; then
267 # check remote dir sgid inherite
268 $LFS mkdir -i 0 $DIR/$tdir.local ||
269 error "mkdir $tdir.local failed"
270 chmod g+s $DIR/$tdir.local ||
271 error "chmod $tdir.local failed"
272 chgrp $RUNAS_GID $DIR/$tdir.local ||
273 error "chgrp $tdir.local failed"
274 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
275 error "mkdir $tdir.remote failed"
276 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
277 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
278 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
279 error "$tdir.remote should be mode 02755"
282 run_test 6g "verify new dir in sgid dir inherits group"
284 test_6h() { # bug 7331
285 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
286 touch $DIR/$tfile || error "touch failed"
287 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
288 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
289 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
290 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
291 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
293 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
296 test_mkdir $DIR/$tdir
297 $MCREATE $DIR/$tdir/$tfile
298 chmod 0666 $DIR/$tdir/$tfile
299 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
300 error "$tdir/$tfile should be mode 0666"
302 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
305 if [ ! -d $DIR/$tdir ]; then
306 test_mkdir $DIR/$tdir
308 $MCREATE $DIR/$tdir/$tfile
309 echo -n foo > $DIR/$tdir/$tfile
310 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
311 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
313 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
316 test_mkdir $DIR/$tdir
317 touch $DIR/$tdir/$tfile
318 chmod 0666 $DIR/$tdir/$tfile
319 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
320 error "$tfile mode not 0666"
322 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
325 test_mkdir $DIR/$tdir
326 test_mkdir $DIR/$tdir/d2
327 test_mkdir $DIR/$tdir/d2/d3
328 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
330 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
333 test_mkdir $DIR/$tdir
334 test_mkdir $DIR/$tdir/d2
335 touch $DIR/$tdir/d2/$tfile
336 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
337 error "$tdir/d2/$tfile not a file"
339 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
342 test_mkdir $DIR/$tdir
343 test_mkdir $DIR/$tdir/d2
344 chmod 0666 $DIR/$tdir/d2
345 chmod 0705 $DIR/$tdir/d2
346 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
347 error "$tdir/d2 mode not 0705"
349 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
352 test_mkdir $DIR/$tdir
353 touch $DIR/$tdir/$tfile
354 chmod 0666 $DIR/$tdir/$tfile
355 chmod 0654 $DIR/$tdir/$tfile
356 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
357 error "$tdir/d2 mode not 0654"
359 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
362 test_mkdir $DIR/$tdir
363 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
365 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
366 error "$tdir/$tfile size not 0 after truncate"
368 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
371 test_mkdir $DIR/$tdir
372 touch $DIR/$tdir/$tfile
374 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
376 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
379 test_mkdir $DIR/$tdir
380 touch $DIR/$tdir/$tfile
381 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
382 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
383 error "$tdir/${tfile_2} not a file after rename"
384 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
386 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
389 test_mkdir $DIR/$tdir
390 touch $DIR/$tdir/$tfile
391 rm -rf $DIR/$tdir/$tfile
392 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
394 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
397 test_mkdir $DIR/$tdir
398 touch $DIR/$tdir/$tfile
399 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
401 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
402 error "$tdir/l-exist not a symlink"
403 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
404 error "$tdir/l-exist not referencing a file"
405 rm -f $DIR/$tdir/l-exist
406 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
408 run_test 17a "symlinks: create, remove (real)"
411 test_mkdir $DIR/$tdir
412 ln -s no-such-file $DIR/$tdir/l-dangle
414 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
415 error "$tdir/l-dangle not referencing no-such-file"
416 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
417 error "$tdir/l-dangle not referencing non-existent file"
418 rm -f $DIR/$tdir/l-dangle
419 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
421 run_test 17b "symlinks: create, remove (dangling)"
423 test_17c() { # bug 3440 - don't save failed open RPC for replay
424 test_mkdir $DIR/$tdir
425 ln -s foo $DIR/$tdir/$tfile
426 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
428 run_test 17c "symlinks: open dangling (should return error)"
431 test_mkdir $DIR/$tdir
432 ln -s foo $DIR/$tdir/$tfile
433 touch $DIR/$tdir/$tfile || error "creating to new symlink"
435 run_test 17d "symlinks: create dangling"
438 test_mkdir $DIR/$tdir
439 local foo=$DIR/$tdir/$tfile
440 ln -s $foo $foo || error "create symlink failed"
441 ls -l $foo || error "ls -l failed"
442 ls $foo && error "ls not failed" || true
444 run_test 17e "symlinks: create recursive symlink (should return error)"
447 test_mkdir $DIR/$tdir
448 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
453 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
456 run_test 17f "symlinks: long and very long symlink name"
458 # str_repeat(S, N) generate a string that is string S repeated N times
463 while [ $((n -= 1)) -ge 0 ]; do
469 # Long symlinks and LU-2241
471 test_mkdir $DIR/$tdir
472 local TESTS="59 60 61 4094 4095"
474 # Fix for inode size boundary in 2.1.4
475 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
478 # Patch not applied to 2.2 or 2.3 branches
479 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
480 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
483 # skip long symlink name for rhel6.5.
484 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
485 grep -q '6.5' /etc/redhat-release &>/dev/null &&
486 TESTS="59 60 61 4062 4063"
489 local SYMNAME=$(str_repeat 'x' $i)
490 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
491 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
494 run_test 17g "symlinks: really long symlink name and inode boundaries"
496 test_17h() { #bug 17378
497 remote_mds_nodsh && skip "remote MDS with nodsh" && return
498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
500 test_mkdir $DIR/$tdir
501 if [[ $MDSCOUNT -gt 1 ]]; then
502 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
506 $LFS setstripe -c -1 $DIR/$tdir
507 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
508 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
509 touch $DIR/$tdir/$tfile || true
511 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
513 test_17i() { #bug 20018
514 remote_mds_nodsh && skip "remote MDS with nodsh" && return
515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
516 test_mkdir -c1 $DIR/$tdir
517 local foo=$DIR/$tdir/$tfile
519 if [[ $MDSCOUNT -gt 1 ]]; then
520 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
524 ln -s $foo $foo || error "create symlink failed"
525 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
526 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
527 ls -l $foo && error "error not detected"
530 run_test 17i "don't panic on short symlink"
532 test_17k() { #bug 22301
533 [[ -z "$(which rsync 2>/dev/null)" ]] &&
534 skip "no rsync command" && return 0
535 rsync --help | grep -q xattr ||
536 skip_env "$(rsync --version | head -n1) does not support xattrs"
537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
538 test_mkdir $DIR/$tdir
539 test_mkdir $DIR/$tdir.new
540 touch $DIR/$tdir/$tfile
541 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
542 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
543 error "rsync failed with xattrs enabled"
545 run_test 17k "symlinks: rsync with xattrs enabled"
547 test_17l() { # LU-279
548 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
549 skip "no getfattr command" && return 0
550 test_mkdir $DIR/$tdir
551 touch $DIR/$tdir/$tfile
552 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
553 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
554 # -h to not follow symlinks. -m '' to list all the xattrs.
555 # grep to remove first line: '# file: $path'.
556 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
558 lgetxattr_size_check $path $xattr ||
559 error "lgetxattr_size_check $path $xattr failed"
563 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
567 local short_sym="0123456789"
568 local wdir=$DIR/$tdir
571 remote_mds_nodsh && skip "remote MDS with nodsh" && return
572 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
573 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
574 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
576 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
577 skip "ldiskfs only test" && return 0
579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
583 # create a long symlink file
584 for ((i = 0; i < 4; ++i)); do
585 long_sym=${long_sym}${long_sym}
588 echo "create 512 short and long symlink files under $wdir"
589 for ((i = 0; i < 256; ++i)); do
590 ln -sf ${long_sym}"a5a5" $wdir/long-$i
591 ln -sf ${short_sym}"a5a5" $wdir/short-$i
597 wait_delete_completed
599 echo "recreate the 512 symlink files with a shorter string"
600 for ((i = 0; i < 512; ++i)); do
601 # rewrite the symlink file with a shorter string
602 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
603 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
606 local mds_index=$(($($LFS getstripe -M $wdir) + 1))
607 local devname=$(mdsdevname $mds_index)
609 echo "stop and checking mds${mds_index}:"
610 # e2fsck should not return error
612 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
615 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
616 error "start mds${mds_index} failed"
617 df $MOUNT > /dev/null 2>&1
619 error "e2fsck detected error for short/long symlink: rc=$rc"
621 run_test 17m "run e2fsck against MDT which contains short/long symlink"
623 check_fs_consistency_17n() {
627 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
628 # so it only check MDT1/MDT2 instead of all of MDTs.
629 for mdt_index in 1 2; do
630 local devname=$(mdsdevname $mdt_index)
631 # e2fsck should not return error
633 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
636 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
637 error "mount mds$mdt_index failed"
638 df $MOUNT > /dev/null 2>&1
646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
647 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
648 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
649 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
651 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
652 skip "ldiskfs only test" && return 0
654 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
658 test_mkdir $DIR/$tdir
659 for ((i=0; i<10; i++)); do
660 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
661 error "create remote dir error $i"
662 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
663 error "create files under remote dir failed $i"
666 check_fs_consistency_17n ||
667 error "e2fsck report error after create files under remote dir"
669 for ((i = 0; i < 10; i++)); do
670 rm -rf $DIR/$tdir/remote_dir_${i} ||
671 error "destroy remote dir error $i"
674 check_fs_consistency_17n ||
675 error "e2fsck report error after unlink files under remote dir"
677 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
678 skip "lustre < 2.4.50 does not support migrate mv " && return
680 for ((i = 0; i < 10; i++)); do
681 mkdir -p $DIR/$tdir/remote_dir_${i}
682 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
683 error "create files under remote dir failed $i"
684 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
685 error "migrate remote dir error $i"
687 check_fs_consistency_17n || error "e2fsck report error after migration"
689 for ((i = 0; i < 10; i++)); do
690 rm -rf $DIR/$tdir/remote_dir_${i} ||
691 error "destroy remote dir error $i"
694 check_fs_consistency_17n || error "e2fsck report error after unlink"
696 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
700 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
701 skip "Need MDS version at least 2.3.64" && return
703 local wdir=$DIR/${tdir}o
709 mdt_index=$($LFS getstripe -M $wdir/$tfile)
710 mdt_index=$((mdt_index + 1))
713 #fail mds will wait the failover finish then set
714 #following fail_loc to avoid interfer the recovery process.
717 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
718 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
719 ls -l $wdir/$tfile && rc=1
720 do_facet mds${mdt_index} lctl set_param fail_loc=0
721 [[ $rc -eq 0 ]] || error "stat file should fail"
723 run_test 17o "stat file with incompat LMA feature"
726 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
727 ls $DIR || error "Failed to ls $DIR: $?"
729 run_test 18 "touch .../f ; ls ... =============================="
735 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
737 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
740 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
742 run_test 19b "ls -l .../f19 (should return error) =============="
745 [ $RUNAS_ID -eq $UID ] &&
746 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
747 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
749 run_test 19c "$RUNAS touch .../f19 (should return error) =="
752 cat $DIR/f19 && error || true
754 run_test 19d "cat .../f19 (should return error) =============="
763 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
765 run_test 20 "touch .../f ; ls -l ..."
768 test_mkdir $DIR/$tdir
769 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
770 ln -s dangle $DIR/$tdir/link
771 echo foo >> $DIR/$tdir/link
772 cat $DIR/$tdir/dangle
773 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
774 $CHECKSTAT -f -t file $DIR/$tdir/link ||
775 error "$tdir/link not linked to a file"
777 run_test 21 "write to dangling link"
780 local wdir=$DIR/$tdir
782 chown $RUNAS_ID:$RUNAS_GID $wdir
783 (cd $wdir || error "cd $wdir failed";
784 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
786 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
787 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
788 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
789 error "checkstat -u failed"
791 run_test 22 "unpack tar archive as non-root user"
795 test_mkdir $DIR/$tdir
796 local file=$DIR/$tdir/$tfile
798 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
799 openfile -f O_CREAT:O_EXCL $file &&
800 error "$file recreate succeeded" || true
802 run_test 23a "O_CREAT|O_EXCL in subdir"
804 test_23b() { # bug 18988
805 test_mkdir $DIR/$tdir
806 local file=$DIR/$tdir/$tfile
809 echo foo > $file || error "write filed"
810 echo bar >> $file || error "append filed"
811 $CHECKSTAT -s 8 $file || error "wrong size"
814 run_test 23b "O_APPEND check"
818 echo '-- same directory rename'
819 test_mkdir $DIR/$tdir
820 touch $DIR/$tdir/$tfile.1
821 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
822 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
824 run_test 24a "rename file to non-existent target"
827 test_mkdir $DIR/$tdir
828 touch $DIR/$tdir/$tfile.{1,2}
829 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
830 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
831 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
833 run_test 24b "rename file to existing target"
836 test_mkdir $DIR/$tdir
837 test_mkdir $DIR/$tdir/d$testnum.1
838 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
839 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
840 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
842 run_test 24c "rename directory to non-existent target"
845 test_mkdir -c1 $DIR/$tdir
846 test_mkdir -c1 $DIR/$tdir/d$testnum.1
847 test_mkdir -c1 $DIR/$tdir/d$testnum.2
848 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
849 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
850 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
852 run_test 24d "rename directory to existing target"
855 echo '-- cross directory renames --'
859 mv $DIR/R5a/f $DIR/R5b/g
860 $CHECKSTAT -a $DIR/R5a/f || error
861 $CHECKSTAT -t file $DIR/R5b/g || error
863 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
868 touch $DIR/R6a/f $DIR/R6b/g
869 mv $DIR/R6a/f $DIR/R6b/g
870 $CHECKSTAT -a $DIR/R6a/f || error
871 $CHECKSTAT -t file $DIR/R6b/g || error
873 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
878 test_mkdir $DIR/R7a/d
879 mv $DIR/R7a/d $DIR/R7b/e
880 $CHECKSTAT -a $DIR/R7a/d || error
881 $CHECKSTAT -t dir $DIR/R7b/e || error
883 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
886 test_mkdir -c1 $DIR/R8a
887 test_mkdir -c1 $DIR/R8b
888 test_mkdir -c1 $DIR/R8a/d
889 test_mkdir -c1 $DIR/R8b/e
890 mrename $DIR/R8a/d $DIR/R8b/e
891 $CHECKSTAT -a $DIR/R8a/d || error
892 $CHECKSTAT -t dir $DIR/R8b/e || error
894 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
897 echo "-- rename error cases"
901 mrename $DIR/R9/f $DIR/R9/a
902 $CHECKSTAT -t file $DIR/R9/f || error
903 $CHECKSTAT -t dir $DIR/R9/a || error
904 $CHECKSTAT -a $DIR/R9/a/f || error
906 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
910 mrename $DIR/R10/f $DIR/R10/g
911 $CHECKSTAT -t dir $DIR/R10 || error
912 $CHECKSTAT -a $DIR/R10/f || error
913 $CHECKSTAT -a $DIR/R10/g || error
915 run_test 24j "source does not exist ============================"
919 test_mkdir $DIR/R11a/d
921 mv $DIR/R11a/f $DIR/R11a/d
922 $CHECKSTAT -a $DIR/R11a/f || error
923 $CHECKSTAT -t file $DIR/R11a/d/f || error
925 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
927 # bug 2429 - rename foo foo foo creates invalid file
930 $MULTIOP $f OcNs || error
932 run_test 24l "Renaming a file to itself ========================"
936 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
937 # on ext3 this does not remove either the source or target files
938 # though the "expected" operation would be to remove the source
939 $CHECKSTAT -t file ${f} || error "${f} missing"
940 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
942 run_test 24m "Renaming a file to a hard link to itself ========="
946 # this stats the old file after it was renamed, so it should fail
950 $CHECKSTAT ${f}.rename
953 run_test 24n "Statting the old file after renaming (Posix rename 2)"
956 test_mkdir $DIR/$tdir
957 rename_many -s random -v -n 10 $DIR/$tdir
959 run_test 24o "rename of files during htree split"
964 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
965 mrename $DIR/R12a $DIR/R12b
966 $CHECKSTAT -a $DIR/R12a || error
967 $CHECKSTAT -t dir $DIR/R12b || error
968 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
969 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
971 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
973 cleanup_multiop_pause() {
979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
982 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
983 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
986 trap cleanup_multiop_pause EXIT
987 mrename $DIR/R13a $DIR/R13b
988 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
989 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
990 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
991 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
992 cleanup_multiop_pause
993 wait $MULTIPID || error "multiop close failed"
995 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
997 test_24r() { #bug 3789
999 test_mkdir $DIR/R14a/b
1000 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1001 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1002 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1004 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1007 test_mkdir $DIR/R15a
1008 test_mkdir $DIR/R15a/b
1009 test_mkdir $DIR/R15a/b/c
1010 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1011 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1012 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1014 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1016 test_mkdir $DIR/R16a
1017 test_mkdir $DIR/R16a/b
1018 test_mkdir $DIR/R16a/b/c
1019 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1020 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1021 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1023 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1025 test_24u() { # bug12192
1026 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1027 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1029 run_test 24u "create stripe file"
1033 size=$(getconf PAGE_SIZE 2>/dev/null)
1034 echo -n ${size:-4096}
1037 simple_cleanup_common() {
1040 [ -z "$DIR" -o -z "$tdir" ] && return 0
1042 local start=$SECONDS
1045 wait_delete_completed
1046 echo "cleanup time $((SECONDS - start))"
1050 max_pages_per_rpc() {
1051 local mdtname="$(printf "MDT%04x" ${1:-0})"
1052 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1057 local nrfiles=${COUNT:-100000}
1058 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1059 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1061 local fname="$DIR/$tdir/$tfile"
1062 test_mkdir "$(dirname $fname)"
1063 # assume MDT0000 has the fewest inodes
1064 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1065 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1066 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1068 trap simple_cleanup_common EXIT
1070 createmany -m "$fname" $nrfiles
1072 cancel_lru_locks mdc
1073 lctl set_param mdc.*.stats clear
1075 # was previously test_24D: LU-6101
1076 # readdir() returns correct number of entries after cursor reload
1077 local num_ls=$(ls $DIR/$tdir | wc -l)
1078 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1079 local num_all=$(ls -a $DIR/$tdir | wc -l)
1080 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1081 $num_all -ne $((nrfiles + 2)) ]; then
1082 error "Expected $nrfiles files, got $num_ls " \
1083 "($num_uniq unique $num_all .&..)"
1085 # LU-5 large readdir
1086 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1087 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1088 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1089 # take into account of overhead in lu_dirpage header and end mark in
1090 # each page, plus one in rpc_num calculation.
1091 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1092 local page_entries=$((($(page_size) - 24) / dirent_size))
1093 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1094 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1095 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1096 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1097 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1098 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1099 error "large readdir doesn't take effect: " \
1100 "$mds_readpage should be about $rpc_max"
1102 simple_cleanup_common
1104 run_test 24v "list large directory (test hash collision, b=17560)"
1106 test_24w() { # bug21506
1108 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1109 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1110 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1111 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1112 [[ "$SZ1" -eq "$SZ2" ]] ||
1113 error "Error reading at the end of the file $tfile"
1115 run_test 24w "Reading a file larger than 4Gb"
1118 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1120 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1121 skip "Need MDS version at least 2.7.56" && return
1123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1125 local remote_dir=$DIR/$tdir/remote_dir
1127 test_mkdir $DIR/$tdir
1128 $LFS mkdir -i $MDTIDX $remote_dir ||
1129 error "create remote directory failed"
1131 test_mkdir $DIR/$tdir/src_dir
1132 touch $DIR/$tdir/src_file
1133 test_mkdir $remote_dir/tgt_dir
1134 touch $remote_dir/tgt_file
1136 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1137 error "rename dir cross MDT failed!"
1139 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1140 error "rename file cross MDT failed!"
1142 touch $DIR/$tdir/ln_file
1143 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1144 error "ln file cross MDT failed"
1146 rm -rf $DIR/$tdir || error "Can not delete directories"
1148 run_test 24x "cross MDT rename/link"
1151 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1152 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1153 local remote_dir=$DIR/$tdir/remote_dir
1156 test_mkdir $DIR/$tdir
1157 $LFS mkdir -i $mdtidx $remote_dir ||
1158 error "create remote directory failed"
1160 test_mkdir $remote_dir/src_dir
1161 touch $remote_dir/src_file
1162 test_mkdir $remote_dir/tgt_dir
1163 touch $remote_dir/tgt_file
1165 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1166 error "rename subdir in the same remote dir failed!"
1168 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1169 error "rename files in the same remote dir failed!"
1171 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1172 error "link files in the same remote dir failed!"
1174 rm -rf $DIR/$tdir || error "Can not delete directories"
1176 run_test 24y "rename/link on the same dir should succeed"
1178 test_24A() { # LU-3182
1182 test_mkdir $DIR/$tdir
1183 trap simple_cleanup_common EXIT
1184 createmany -m $DIR/$tdir/$tfile $NFILES
1185 local t=$(ls $DIR/$tdir | wc -l)
1186 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1187 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1188 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1189 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1192 simple_cleanup_common || error "Can not delete directories"
1194 run_test 24A "readdir() returns correct number of entries."
1196 test_24B() { # LU-4805
1197 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1200 test_mkdir $DIR/$tdir
1201 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1202 error "create striped dir failed"
1204 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1205 [ $count -eq 2 ] || error "Expected 2, got $count"
1207 touch $DIR/$tdir/striped_dir/a
1209 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1210 [ $count -eq 3 ] || error "Expected 3, got $count"
1212 touch $DIR/$tdir/striped_dir/.f
1214 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1215 [ $count -eq 4 ] || error "Expected 4, got $count"
1217 rm -rf $DIR/$tdir || error "Can not delete directories"
1219 run_test 24B "readdir for striped dir return correct number of entries"
1222 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1228 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1229 error "create striped dir failed"
1231 cd $DIR/$tdir/d0/striped_dir
1233 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1234 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1235 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1237 [ "$d0_ino" = "$parent_ino" ] ||
1238 error ".. wrong, expect $d0_ino, get $parent_ino"
1240 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1241 error "mv striped dir failed"
1243 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1245 [ "$d1_ino" = "$parent_ino" ] ||
1246 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1248 run_test 24C "check .. in striped dir"
1251 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1255 mkdir $DIR/$tdir/src_dir
1256 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1257 error "create remote source failed"
1259 touch $DIR/$tdir/src_dir/src_child/a
1261 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1262 error "create remote target dir failed"
1264 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1265 error "create remote target child failed"
1267 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1268 error "rename dir cross MDT failed!"
1272 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1273 error "src_child still exists after rename"
1275 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1276 error "missing file(a) after rename"
1278 rm -rf $DIR/$tdir || error "Can not delete directories"
1280 run_test 24E "cross MDT rename/link"
1283 echo '== symlink sanity ============================================='
1287 touch $DIR/s25/foo || error
1289 run_test 25a "create file in symlinked directory ==============="
1292 [ ! -d $DIR/d25 ] && test_25a
1293 $CHECKSTAT -t file $DIR/s25/foo || error
1295 run_test 25b "lookup file in symlinked directory ==============="
1299 test_mkdir $DIR/d26/d26-2
1300 ln -s d26/d26-2 $DIR/s26
1301 touch $DIR/s26/foo || error
1303 run_test 26a "multiple component symlink ======================="
1306 test_mkdir -p $DIR/$tdir/d26-2
1307 ln -s $tdir/d26-2/foo $DIR/s26-2
1308 touch $DIR/s26-2 || error
1310 run_test 26b "multiple component symlink at end of lookup ======"
1313 test_mkdir $DIR/d26.2
1314 touch $DIR/d26.2/foo
1315 ln -s d26.2 $DIR/s26.2-1
1316 ln -s s26.2-1 $DIR/s26.2-2
1317 ln -s s26.2-2 $DIR/s26.2-3
1318 chmod 0666 $DIR/s26.2-3/foo
1320 run_test 26c "chain of symlinks"
1322 # recursive symlinks (bug 439)
1324 ln -s d26-3/foo $DIR/d26-3
1326 run_test 26d "create multiple component recursive symlink"
1329 [ ! -h $DIR/d26-3 ] && test_26d
1332 run_test 26e "unlink multiple component recursive symlink"
1334 # recursive symlinks (bug 7022)
1336 test_mkdir $DIR/$tdir
1337 test_mkdir $DIR/$tdir/$tfile
1338 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1339 test_mkdir -p lndir/bar1
1340 test_mkdir $DIR/$tdir/$tfile/$tfile
1341 cd $tfile || error "cd $tfile failed"
1342 ln -s .. dotdot || error "ln dotdot failed"
1343 ln -s dotdot/lndir lndir || error "ln lndir failed"
1344 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1345 output=`ls $tfile/$tfile/lndir/bar1`
1346 [ "$output" = bar1 ] && error "unexpected output"
1347 rm -r $tfile || error "rm $tfile failed"
1348 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1350 run_test 26f "rm -r of a directory which has recursive symlink"
1353 test_mkdir $DIR/$tdir
1354 $LFS getstripe $DIR/$tdir
1355 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1356 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1357 cp /etc/hosts $DIR/$tdir/$tfile || error
1359 run_test 27a "one stripe file"
1362 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1363 test_mkdir $DIR/$tdir
1364 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1365 $LFS getstripe -c $DIR/$tdir/$tfile
1366 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1367 error "two-stripe file doesn't have two stripes"
1369 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1371 run_test 27b "create and write to two stripe file"
1374 test_mkdir $DIR/$tdir
1375 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1376 error "setstripe failed"
1377 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1378 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1380 run_test 27d "create file with default settings"
1383 # LU-5839 adds check for existed layout before setting it
1384 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1385 skip "Need MDS version at least 2.7.56" && return
1386 test_mkdir $DIR/$tdir
1387 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1388 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1389 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1391 run_test 27e "setstripe existing file (should return error)"
1394 test_mkdir $DIR/$tdir
1395 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1396 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1397 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1398 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1399 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1400 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1402 run_test 27f "setstripe with bad stripe size (should return error)"
1405 test_mkdir $DIR/$tdir
1406 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1407 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1408 error "$DIR/$tdir/$tfile has object"
1410 run_test 27g "$LFS getstripe with no objects"
1413 test_mkdir $DIR/$tdir
1414 touch $DIR/$tdir/$tfile || error "touch failed"
1415 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1416 error "missing objects"
1418 run_test 27i "$LFS getstripe with some objects"
1421 test_mkdir $DIR/$tdir
1422 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1423 error "setstripe failed" || true
1425 run_test 27j "setstripe with bad stripe offset (should return error)"
1427 test_27k() { # bug 2844
1428 test_mkdir $DIR/$tdir
1429 local file=$DIR/$tdir/$tfile
1430 local ll_max_blksize=$((4 * 1024 * 1024))
1431 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1432 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1433 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1434 dd if=/dev/zero of=$file bs=4k count=1
1435 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1436 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1438 run_test 27k "limit i_blksize for broken user apps"
1441 mcreate $DIR/$tfile || error "creating file"
1442 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1443 error "setstripe should have failed" || true
1445 run_test 27l "check setstripe permissions (should return error)"
1448 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1450 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1452 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1453 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1456 trap simple_cleanup_common EXIT
1457 test_mkdir $DIR/$tdir
1458 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1459 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1460 error "dd should fill OST0"
1462 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1464 [ $i -gt 256 ] && break
1467 touch $DIR/$tdir/$tfile.$i
1468 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1469 awk '{print $1}'| grep -w "0") ] &&
1470 error "OST0 was full but new created file still use it"
1472 touch $DIR/$tdir/$tfile.$i
1473 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1474 awk '{print $1}'| grep -w "0") ] &&
1475 error "OST0 was full but new created file still use it"
1476 simple_cleanup_common
1478 run_test 27m "create file while OST0 was full"
1481 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1482 head -n 1 | awk '{ print $1 * 2 }')
1486 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1487 # if the OST isn't full anymore.
1489 local OSTIDX=${1:-""}
1491 local list=$(comma_list $(osts_nodes))
1492 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1494 do_nodes $list lctl set_param fail_loc=0
1495 sync # initiate all OST_DESTROYs from MDS to OST
1499 exhaust_precreations() {
1502 local FAILIDX=${3:-$OSTIDX}
1503 local ofacet=ost$((OSTIDX + 1))
1505 test_mkdir -p -c1 $DIR/$tdir
1506 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1507 local mfacet=mds$((mdtidx + 1))
1508 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1510 local OST=$(ostname_from_index $OSTIDX)
1513 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1514 local last_id=$(do_facet $mfacet lctl get_param -n \
1515 osc.$mdtosc_proc1.prealloc_last_id)
1516 local next_id=$(do_facet $mfacet lctl get_param -n \
1517 osc.$mdtosc_proc1.prealloc_next_id)
1519 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1520 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1522 test_mkdir -p $DIR/$tdir/${OST}
1523 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1524 #define OBD_FAIL_OST_ENOSPC 0x215
1525 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1526 echo "Creating to objid $last_id on ost $OST..."
1527 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1528 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1529 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1533 exhaust_all_precreations() {
1535 for (( i=0; i < OSTCOUNT; i++ )) ; do
1536 exhaust_precreations $i $1 -1
1541 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1543 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1544 remote_ost_nodsh && skip "remote OST with nodsh" && return
1547 rm -f $DIR/$tdir/$tfile
1548 exhaust_precreations 0 0x80000215
1549 $LFS setstripe -c -1 $DIR/$tdir
1550 touch $DIR/$tdir/$tfile || error
1551 $LFS getstripe $DIR/$tdir/$tfile
1554 run_test 27n "create file with some full OSTs"
1557 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1559 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1560 remote_ost_nodsh && skip "remote OST with nodsh" && return
1563 rm -f $DIR/$tdir/$tfile
1564 exhaust_all_precreations 0x215
1566 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1571 run_test 27o "create file with all full OSTs (should error)"
1574 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1576 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1577 remote_ost_nodsh && skip "remote OST with nodsh" && return
1580 rm -f $DIR/$tdir/$tfile
1581 test_mkdir $DIR/$tdir
1583 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1584 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1585 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1587 exhaust_precreations 0 0x80000215
1588 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1589 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1590 $LFS getstripe $DIR/$tdir/$tfile
1594 run_test 27p "append to a truncated file with some full OSTs"
1597 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1599 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1600 remote_ost_nodsh && skip "remote OST with nodsh" && return
1603 rm -f $DIR/$tdir/$tfile
1605 test_mkdir $DIR/$tdir
1606 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1607 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1608 error "truncate $DIR/$tdir/$tfile failed"
1609 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1611 exhaust_all_precreations 0x215
1613 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1614 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1618 run_test 27q "append to truncated file with all OSTs full (should error)"
1621 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1623 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1624 remote_ost_nodsh && skip "remote OST with nodsh" && return
1627 rm -f $DIR/$tdir/$tfile
1628 exhaust_precreations 0 0x80000215
1630 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error
1634 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1636 test_27s() { # bug 10725
1637 test_mkdir $DIR/$tdir
1638 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1639 local stripe_count=0
1640 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1641 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1642 error "stripe width >= 2^32 succeeded" || true
1645 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1647 test_27t() { # bug 10864
1652 $WLFS getstripe $tfile
1655 run_test 27t "check that utils parse path correctly"
1657 test_27u() { # bug 4900
1658 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1659 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1661 local list=$(comma_list $(mdts_nodes))
1663 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1664 do_nodes $list $LCTL set_param fail_loc=0x139
1665 test_mkdir -p $DIR/$tdir
1666 trap simple_cleanup_common EXIT
1667 createmany -o $DIR/$tdir/t- 1000
1668 do_nodes $list $LCTL set_param fail_loc=0
1670 TLOG=$TMP/$tfile.getstripe
1671 $LFS getstripe $DIR/$tdir > $TLOG
1672 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1673 unlinkmany $DIR/$tdir/t- 1000
1675 [[ $OBJS -gt 0 ]] &&
1676 error "$OBJS objects created on OST-0. See $TLOG" || pass
1678 run_test 27u "skip object creation on OSC w/o objects"
1680 test_27v() { # bug 4900
1681 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1683 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1684 remote_ost_nodsh && skip "remote OST with nodsh" && return
1686 exhaust_all_precreations 0x215
1689 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1691 touch $DIR/$tdir/$tfile
1692 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1694 for (( i=1; i < OSTCOUNT; i++ )); do
1695 do_facet ost$i lctl set_param fail_loc=0x705
1697 local START=`date +%s`
1698 createmany -o $DIR/$tdir/$tfile 32
1700 local FINISH=`date +%s`
1701 local TIMEOUT=`lctl get_param -n timeout`
1702 local PROCESS=$((FINISH - START))
1703 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1704 error "$FINISH - $START >= $TIMEOUT / 2"
1705 sleep $((TIMEOUT / 2 - PROCESS))
1708 run_test 27v "skip object creation on slow OST"
1710 test_27w() { # bug 10997
1711 test_mkdir $DIR/$tdir
1712 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1713 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1714 error "stripe size $size != 65536" || true
1715 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1716 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1718 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1721 [[ $OSTCOUNT -lt 2 ]] &&
1722 skip_env "skipping multiple stripe count/offset test" && return
1724 test_mkdir $DIR/$tdir
1725 for i in $(seq 1 $OSTCOUNT); do
1727 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1728 error "setstripe -c $i -i $offset failed"
1729 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1730 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1731 [ $count -ne $i ] && error "stripe count $count != $i" || true
1732 [ $index -ne $offset ] &&
1733 error "stripe offset $index != $offset" || true
1736 run_test 27wa "check $LFS setstripe -c -i options"
1739 remote_ost_nodsh && skip "remote OST with nodsh" && return
1740 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1741 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1742 OFFSET=$(($OSTCOUNT - 1))
1744 local OST=$(ostname_from_index $OSTIDX)
1746 test_mkdir $DIR/$tdir
1747 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1748 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1750 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1751 for i in $(seq 0 $OFFSET); do
1752 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1753 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1754 error "OST0 was degraded but new created file still use it"
1756 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1758 run_test 27x "create files while OST0 is degraded"
1761 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1762 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1763 remote_ost_nodsh && skip "remote OST with nodsh" && return
1764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1766 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1767 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1768 osc.$mdtosc.prealloc_last_id)
1769 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1770 osc.$mdtosc.prealloc_next_id)
1771 local fcount=$((last_id - next_id))
1772 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1773 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1775 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1776 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1777 local OST_DEACTIVE_IDX=-1
1782 for OSC in $MDS_OSCS; do
1783 OST=$(osc_to_ost $OSC)
1784 OSTIDX=$(index_from_ostuuid $OST)
1785 if [ $OST_DEACTIVE_IDX == -1 ]; then
1786 OST_DEACTIVE_IDX=$OSTIDX
1788 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1789 echo $OSC "is Deactivated:"
1790 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1794 OSTIDX=$(index_from_ostuuid $OST)
1795 test_mkdir $DIR/$tdir
1796 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1798 for OSC in $MDS_OSCS; do
1799 OST=$(osc_to_ost $OSC)
1800 OSTIDX=$(index_from_ostuuid $OST)
1801 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1802 echo $OST "is degraded:"
1803 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1804 obdfilter.$OST.degraded=1
1809 createmany -o $DIR/$tdir/$tfile $fcount
1811 for OSC in $MDS_OSCS; do
1812 OST=$(osc_to_ost $OSC)
1813 OSTIDX=$(index_from_ostuuid $OST)
1814 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1815 echo $OST "is recovered from degraded:"
1816 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1817 obdfilter.$OST.degraded=0
1819 do_facet $SINGLEMDS lctl --device %$OSC activate
1823 # all osp devices get activated, hence -1 stripe count restored
1824 local stripe_count=0
1826 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1827 # devices get activated.
1829 $LFS setstripe -c -1 $DIR/$tfile
1830 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1832 [ $stripe_count -ne $OSTCOUNT ] &&
1833 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1836 run_test 27y "create files while OST0 is degraded and the rest inactive"
1842 lmm_count=$($GETSTRIPE -c $1)
1843 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1844 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1846 local old_ifs="$IFS"
1848 fid=($($LFS path2fid $1))
1851 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1852 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1854 # compare lmm_seq and lu_fid->f_seq
1855 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1856 # compare lmm_object_id and lu_fid->oid
1857 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1859 # check the trusted.fid attribute of the OST objects of the file
1860 local have_obdidx=false
1862 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1863 # skip lines up to and including "obdidx"
1864 [ -z "$obdidx" ] && break
1865 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1866 $have_obdidx || continue
1868 local ost=$((obdidx + 1))
1869 local dev=$(ostdevname $ost)
1872 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1874 seq=$(echo $seq | sed -e "s/^0x//g")
1875 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1876 oid_hex=$(echo $oid)
1878 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1880 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1884 # Don't unmount/remount the OSTs if we don't need to do that.
1885 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1886 # update too, until that use mount/ll_decode_filter_fid/mount.
1887 # Re-enable when debugfs will understand new filter_fid.
1889 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
1890 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1891 $dev 2>/dev/null" | grep "parent=")
1893 if [ -z "$ff" ]; then
1895 mount_fstype ost$ost
1896 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1897 $(facet_mntpt ost$ost)/$obj_file)
1898 unmount_fstype ost$ost
1899 start ost$ost $dev $OST_MOUNT_OPTS
1903 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1905 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1907 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1908 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1910 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
1911 # stripe_size=1048576 component_id=1 component_start=0 \
1912 # component_end=33554432
1913 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
1914 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
1915 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
1917 if grep -q 'stripe=' <<<$ff; then
1918 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
1920 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1921 # into f_ver in this case. See comment on ff_parent.
1922 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
1925 # compare lmm_seq and filter_fid->ff_parent.f_seq
1926 [ $ff_pseq = $lmm_seq ] ||
1927 error "FF parent SEQ $ff_pseq != $lmm_seq"
1928 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1929 [ $ff_poid = $lmm_oid ] ||
1930 error "FF parent OID $ff_poid != $lmm_oid"
1931 (($ff_pstripe == $stripe_nr)) ||
1932 error "FF stripe $ff_pstripe != $stripe_nr"
1934 stripe_nr=$((stripe_nr + 1))
1935 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
1937 if grep -q 'stripe_count=' <<<$ff; then
1938 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
1939 -e 's/ .*//' <<<$ff)
1940 [ $lmm_count = $ff_scnt ] ||
1941 error "FF stripe count $lmm_count != $ff_scnt"
1947 remote_ost_nodsh && skip "remote OST with nodsh" && return
1948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1949 test_mkdir $DIR/$tdir
1951 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1952 { error "setstripe -c -1 failed"; return 1; }
1953 # We need to send a write to every object to get parent FID info set.
1954 # This _should_ also work for setattr, but does not currently.
1955 # touch $DIR/$tdir/$tfile-1 ||
1956 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1957 { error "dd $tfile-1 failed"; return 2; }
1958 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1959 { error "setstripe -c -1 failed"; return 3; }
1960 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1961 { error "dd $tfile-2 failed"; return 4; }
1963 # make sure write RPCs have been sent to OSTs
1966 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1967 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1969 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1971 test_27A() { # b=19102
1972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1973 local restore_size=$($GETSTRIPE -S $MOUNT)
1974 local restore_count=$($GETSTRIPE -c $MOUNT)
1975 local restore_offset=$($GETSTRIPE -i $MOUNT)
1976 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1977 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1978 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1979 local default_size=$($GETSTRIPE -S $MOUNT)
1980 local default_offset=$($GETSTRIPE -i $MOUNT)
1981 local dsize=$((1024 * 1024))
1982 [ $default_size -eq $dsize ] ||
1983 error "stripe size $default_size != $dsize"
1984 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1985 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1987 run_test 27A "check filesystem-wide default LOV EA values"
1989 test_27B() { # LU-2523
1990 test_mkdir $DIR/$tdir
1991 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1993 # open f1 with O_LOV_DELAY_CREATE
1995 # call setstripe ioctl on open file descriptor for f1
1997 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2001 # open f1 with O_LOV_DELAY_CREATE
2003 # call setstripe ioctl on open file descriptor for f1
2005 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2007 # Allow multiop to fail in imitation of NFS's busted semantics.
2010 run_test 27B "call setstripe on open unlinked file/rename victim"
2012 test_27C() { #LU-2871
2013 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2021 test_mkdir $DIR/$tdir
2023 for i in $(seq 0 $((OSTCOUNT - 1))); do
2024 # set stripe across all OSTs starting from OST$i
2025 $SETSTRIPE -i $i -c -1 $tfile$i
2026 # get striping information
2027 ost_idx=($($GETSTRIPE $tfile$i |
2028 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2032 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2033 error "${#ost_idx[@]} != $OSTCOUNT"
2035 for index in $(seq 0 $((OSTCOUNT - 1))); do
2037 for j in $(echo ${ost_idx[@]}); do
2038 if [ $index -eq $j ]; then
2044 error "Can not find $index in ${ost_idx[@]}"
2048 run_test 27C "check full striping across all OSTs"
2051 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2052 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2053 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2054 local POOL=${POOL:-testpool}
2056 local last_ost=$(($OSTCOUNT - 1))
2058 local ost_list=$(seq $first_ost $ost_step $last_ost)
2059 local ost_range="$first_ost $last_ost $ost_step"
2061 test_mkdir $DIR/$tdir
2062 pool_add $POOL || error "pool_add failed"
2063 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2066 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2068 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2069 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2070 skip27D += "-s 30,31"
2071 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2072 error "llapi_layout_test failed"
2074 destroy_test_pools || error "destroy test pools failed"
2076 run_test 27D "validate llapi_layout API"
2078 # Verify that default_easize is increased from its initial value after
2079 # accessing a widely striped file.
2081 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2082 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2083 skip "client does not have LU-3338 fix" && return
2085 # 72 bytes is the minimum space required to store striping
2086 # information for a file striped across one OST:
2087 # (sizeof(struct lov_user_md_v3) +
2088 # sizeof(struct lov_user_ost_data_v1))
2090 $LCTL set_param -n llite.*.default_easize $min_easize ||
2091 error "lctl set_param failed"
2092 local easize=$($LCTL get_param -n llite.*.default_easize)
2094 [ $easize -eq $min_easize ] ||
2095 error "failed to set default_easize"
2097 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2098 error "setstripe failed"
2102 easize=$($LCTL get_param -n llite.*.default_easize)
2104 [ $easize -gt $min_easize ] ||
2105 error "default_easize not updated"
2107 run_test 27E "check that default extended attribute size properly increases"
2109 test_27F() { # LU-5346/LU-7975
2110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2111 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2112 skip "Need MDS version at least 2.8.51" && return
2113 remote_ost_nodsh && skip "remote OST with nodsh" && return
2115 test_mkdir $DIR/$tdir
2117 $SETSTRIPE -c 2 $DIR/$tdir
2119 # stop all OSTs to reproduce situation for LU-7975 ticket
2120 for num in $(seq $OSTCOUNT); do
2124 # open/create f0 with O_LOV_DELAY_CREATE
2125 # truncate f0 to a non-0 size
2127 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2129 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2130 # open/write it again to force delayed layout creation
2131 cat /etc/hosts > $DIR/$tdir/f0 &
2135 for num in $(seq $OSTCOUNT); do
2136 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2137 error "ost$num failed to start"
2140 wait $catpid || error "cat failed"
2142 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2143 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2146 run_test 27F "Client resend delayed layout creation with non-zero size"
2148 # createtest also checks that device nodes are created and
2149 # then visible correctly (#2091)
2150 test_28() { # bug 2091
2152 $CREATETEST $DIR/d28/ct || error
2154 run_test 28 "create/mknod/mkdir with bad file types ============"
2157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2158 sync; sleep 1; sync # flush out any dirty pages from previous tests
2165 declare -i LOCKCOUNTORIG=0
2166 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2167 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2169 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2171 declare -i LOCKUNUSEDCOUNTORIG=0
2172 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2173 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2180 declare -i LOCKCOUNTCURRENT=0
2181 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2182 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2185 declare -i LOCKUNUSEDCOUNTCURRENT=0
2186 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2187 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2190 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2191 $LCTL set_param -n ldlm.dump_namespaces ""
2192 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2193 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2194 log "dumped log to $TMP/test_29.dk (bug 5793)"
2197 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2198 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2199 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2200 log "dumped log to $TMP/test_29.dk (bug 5793)"
2204 run_test 29 "IT_GETATTR regression ============================"
2206 test_30a() { # was test_30
2207 cp $(which ls) $DIR || cp /bin/ls $DIR
2211 run_test 30a "execute binary from Lustre (execve) =============="
2214 cp `which ls` $DIR || cp /bin/ls $DIR
2216 $RUNAS $DIR/ls / || error
2219 run_test 30b "execute binary from Lustre as non-root ==========="
2221 test_30c() { # b=22376
2222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2223 cp `which ls` $DIR || cp /bin/ls $DIR
2225 cancel_lru_locks mdc
2226 cancel_lru_locks osc
2227 $RUNAS $DIR/ls / || error
2230 run_test 30c "execute binary from Lustre without read perms ===="
2233 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2234 $CHECKSTAT -a $DIR/f31 || error
2236 run_test 31a "open-unlink file =================================="
2239 touch $DIR/f31 || error
2240 ln $DIR/f31 $DIR/f31b || error
2241 $MULTIOP $DIR/f31b Ouc || error
2242 $CHECKSTAT -t file $DIR/f31 || error
2244 run_test 31b "unlink file with multiple links while open ======="
2247 touch $DIR/f31 || error
2248 ln $DIR/f31 $DIR/f31c || error
2249 multiop_bg_pause $DIR/f31 O_uc || return 1
2251 $MULTIOP $DIR/f31c Ouc
2252 kill -USR1 $MULTIPID
2255 run_test 31c "open-unlink file with multiple links ============="
2258 opendirunlink $DIR/d31d $DIR/d31d || error
2259 $CHECKSTAT -a $DIR/d31d || error
2261 run_test 31d "remove of open directory ========================="
2263 test_31e() { # bug 2904
2264 openfilleddirunlink $DIR/d31e || error
2266 run_test 31e "remove of open non-empty directory ==============="
2268 test_31f() { # bug 4554
2269 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2271 test_mkdir $DIR/d31f
2272 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2273 cp /etc/hosts $DIR/d31f
2275 $GETSTRIPE $DIR/d31f/hosts
2276 multiop_bg_pause $DIR/d31f D_c || return 1
2279 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2280 test_mkdir $DIR/d31f
2281 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2282 cp /etc/hosts $DIR/d31f
2284 $GETSTRIPE $DIR/d31f/hosts
2285 multiop_bg_pause $DIR/d31f D_c || return 1
2288 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2289 wait $MULTIPID || error "first opendir $MULTIPID failed"
2293 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2294 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2297 run_test 31f "remove of open directory with open-unlink file ==="
2300 echo "-- cross directory link --"
2301 test_mkdir -c1 $DIR/${tdir}ga
2302 test_mkdir -c1 $DIR/${tdir}gb
2303 touch $DIR/${tdir}ga/f
2304 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2305 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2306 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2307 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2308 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2310 run_test 31g "cross directory link==============="
2313 echo "-- cross directory link --"
2314 test_mkdir -c1 $DIR/${tdir}
2315 test_mkdir -c1 $DIR/${tdir}/dir
2316 touch $DIR/${tdir}/f
2317 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2318 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2319 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2320 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2321 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2323 run_test 31h "cross directory link under child==============="
2326 echo "-- cross directory link --"
2327 test_mkdir -c1 $DIR/$tdir
2328 test_mkdir -c1 $DIR/$tdir/dir
2329 touch $DIR/$tdir/dir/f
2330 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2331 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2332 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2333 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2334 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2336 run_test 31i "cross directory link under parent==============="
2339 test_mkdir -c1 -p $DIR/$tdir
2340 test_mkdir -c1 -p $DIR/$tdir/dir1
2341 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2342 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2343 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2344 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2347 run_test 31j "link for directory==============="
2350 test_mkdir -c1 -p $DIR/$tdir
2352 touch $DIR/$tdir/exist
2353 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2354 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2355 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2356 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2357 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2358 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2359 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2362 run_test 31k "link to file: the same, non-existing, dir==============="
2368 touch $DIR/d31m2/exist
2369 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2370 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2371 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2372 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2373 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2374 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2377 run_test 31m "link to file: the same, non-existing, dir==============="
2380 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2381 nlink=$(stat --format=%h $DIR/$tfile)
2382 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2384 local cmd="exec $fd<$DIR/$tfile"
2387 trap "eval $cmd" EXIT
2388 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2389 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2390 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2391 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2392 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2395 run_test 31n "check link count of unlinked file"
2398 local TEMPNAME=$(mktemp $1_XXXXXX)
2399 mlink $TEMPNAME $1 2> /dev/null &&
2400 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2404 test_31o() { # LU-2901
2405 test_mkdir $DIR/$tdir
2406 for LOOP in $(seq 100); do
2407 rm -f $DIR/$tdir/$tfile*
2408 for THREAD in $(seq 8); do
2409 link_one $DIR/$tdir/$tfile.$LOOP &
2412 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2413 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2414 error "$LINKS duplicate links to $tfile.$LOOP" &&
2418 run_test 31o "duplicate hard links with same filename"
2421 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2423 test_mkdir $DIR/$tdir
2424 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2425 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2427 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2428 error "open unlink test1 failed"
2429 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2430 error "open unlink test2 failed"
2432 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2433 error "test1 still exists"
2434 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2435 error "test2 still exists"
2437 run_test 31p "remove of open striped directory"
2439 cleanup_test32_mount() {
2442 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2443 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2444 losetup -d $loopdev || true
2450 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2451 echo "== more mountpoints and symlinks ================="
2452 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2453 trap cleanup_test32_mount EXIT
2454 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2455 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2456 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2457 cleanup_test32_mount
2459 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2463 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2464 trap cleanup_test32_mount EXIT
2465 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2466 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2467 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2468 cleanup_test32_mount
2470 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2474 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2475 trap cleanup_test32_mount EXIT
2476 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2477 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2478 test_mkdir -p $DIR/$tdir/d2/test_dir
2479 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2480 cleanup_test32_mount
2482 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2486 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2487 trap cleanup_test32_mount EXIT
2488 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2489 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2490 test_mkdir -p $DIR/$tdir/d2/test_dir
2491 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2492 cleanup_test32_mount
2494 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2498 test_mkdir -p $DIR/$tdir/tmp
2499 local tmp_dir=$DIR/$tdir/tmp
2500 ln -s $DIR/$tdir $tmp_dir/symlink11
2501 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2502 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2503 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2505 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2509 test_mkdir -p $DIR/$tdir/tmp
2510 local tmp_dir=$DIR/$tdir/tmp
2511 ln -s $DIR/$tdir $tmp_dir/symlink11
2512 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2513 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2514 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2516 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2519 local tmp_dir=$DIR/$tdir/tmp
2520 test_mkdir -p $tmp_dir
2521 test_mkdir $DIR/${tdir}2
2522 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2523 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2524 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2525 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2526 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2527 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2529 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2532 rm -fr $DIR/$tdir $DIR/${tdir}2
2533 tmp_dir=$DIR/$tdir/tmp
2534 test_mkdir -p $tmp_dir
2535 test_mkdir $DIR/${tdir}2
2536 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2537 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2538 ls $tmp_dir/symlink12 || error "listing symlink12"
2539 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2541 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2545 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2546 trap cleanup_test32_mount EXIT
2547 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2548 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2549 touch $DIR/$tdir/test_file
2550 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2551 cleanup_test32_mount
2553 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2557 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2558 trap cleanup_test32_mount EXIT
2559 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2560 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2561 touch $DIR/$tdir/test_file
2562 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2563 cleanup_test32_mount
2565 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2570 trap cleanup_test32_mount EXIT
2571 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2572 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2573 test_mkdir -p $DIR/$tdir/d2
2574 touch $DIR/$tdir/d2/test_file || error
2575 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2576 cleanup_test32_mount
2578 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2583 trap cleanup_test32_mount EXIT
2584 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2585 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2586 test_mkdir -p $DIR/$tdir/d2
2587 touch $DIR/$tdir/d2/test_file
2588 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2589 cleanup_test32_mount
2591 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2595 test_mkdir -p $DIR/d32m/tmp
2596 TMP_DIR=$DIR/d32m/tmp
2597 ln -s $DIR $TMP_DIR/symlink11
2598 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2599 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2600 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2602 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2606 test_mkdir -p $DIR/d32n/tmp
2607 TMP_DIR=$DIR/d32n/tmp
2608 ln -s $DIR $TMP_DIR/symlink11
2609 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2610 ls -l $DIR/d32n/tmp/symlink11 || error
2611 ls -l $DIR/d32n/symlink01 || error
2613 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2617 test_mkdir -p $DIR/d32o/tmp
2618 TMP_DIR=$DIR/d32o/tmp
2619 ln -s $DIR/$tfile $TMP_DIR/symlink12
2620 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2621 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2622 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2623 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2624 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2626 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2636 test_mkdir -p $DIR/d32p/tmp
2638 TMP_DIR=$DIR/d32p/tmp
2640 ln -s $DIR/$tfile $TMP_DIR/symlink12
2642 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2644 cat $DIR/d32p/tmp/symlink12 || error
2646 cat $DIR/d32p/symlink02 || error
2649 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2653 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2654 trap cleanup_test32_mount EXIT
2655 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2656 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2657 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2658 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2659 cleanup_test32_mount
2661 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2665 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2666 trap cleanup_test32_mount EXIT
2667 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2668 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2669 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2670 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2671 cleanup_test32_mount
2673 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2678 chmod 444 $DIR/$tfile
2679 chown $RUNAS_ID $DIR/$tfile
2681 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2684 run_test 33aa "write file with mode 444 (should return error)"
2688 test_mkdir $DIR/$tdir
2689 chown $RUNAS_ID $DIR/$tdir
2690 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2691 error "$RUNAS create $tdir/$tfile failed"
2692 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2693 error "open RDWR" || true
2695 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2699 test_mkdir $DIR/$tdir
2700 chown $RUNAS_ID $DIR/$tdir
2701 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2703 run_test 33b "test open file with malformed flags (No panic)"
2706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2712 remote_ost_nodsh && skip "remote OST with nodsh" && return
2715 test_mkdir $DIR/$tdir
2716 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2719 for ostnum in $(seq $OSTCOUNT); do
2720 # test-framework's OST numbering is one-based, while Lustre's
2722 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2723 # Parsing llobdstat's output sucks; we could grep the /proc
2724 # path, but that's likely to not be as portable as using the
2725 # llobdstat utility. So we parse lctl output instead.
2726 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2727 obdfilter/$ostname/stats |
2728 awk '/^write_bytes/ {print $7}' )
2729 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2730 if (( ${write_bytes:-0} > 0 ))
2737 $all_zeros || return 0
2740 echo foo > $DIR/$tdir/bar
2744 # Total up write_bytes after writing. We'd better find non-zeros.
2745 for ostnum in $(seq $OSTCOUNT); do
2746 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2747 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2748 obdfilter/$ostname/stats |
2749 awk '/^write_bytes/ {print $7}' )
2750 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2751 if (( ${write_bytes:-0} > 0 ))
2760 for ostnum in $(seq $OSTCOUNT); do
2761 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2762 echo "Check that write_bytes is present in obdfilter/*/stats:"
2763 do_facet ost$ostnum lctl get_param -n \
2764 obdfilter/$ostname/stats
2766 error "OST not keeping write_bytes stats (b22312)"
2769 run_test 33c "test llobdstat and write_bytes"
2772 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2775 local remote_dir=$DIR/$tdir/remote_dir
2777 test_mkdir $DIR/$tdir
2778 $LFS mkdir -i $MDTIDX $remote_dir ||
2779 error "create remote directory failed"
2781 touch $remote_dir/$tfile
2782 chmod 444 $remote_dir/$tfile
2783 chown $RUNAS_ID $remote_dir/$tfile
2785 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2787 chown $RUNAS_ID $remote_dir
2788 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2789 error "create" || true
2790 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2791 error "open RDWR" || true
2792 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2794 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2797 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2801 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2802 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2803 mkdir $DIR/$tdir/local_dir
2805 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2806 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2807 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2809 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2810 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2812 rmdir $DIR/$tdir/* || error "rmdir failed"
2815 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2816 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2817 mkdir $DIR/$tdir/local_dir
2819 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2820 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2821 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2823 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2824 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2826 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2829 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2830 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2831 mkdir $DIR/$tdir/local_dir
2833 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2834 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2835 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2837 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2838 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2840 run_test 33e "mkdir and striped directory should have same mode"
2844 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2848 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2849 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2852 chmod go+rwx $DIR/$tdir
2853 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2854 trap cleanup_33f EXIT
2856 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2857 error "cannot create striped directory"
2859 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2860 error "cannot create files in striped directory"
2862 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2863 error "cannot remove files in striped directory"
2865 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2866 error "cannot remove striped directory"
2870 run_test 33f "nonroot user can create, access, and remove a striped directory"
2873 mkdir -p $DIR/$tdir/dir2
2875 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2877 [[ $err =~ "exists" ]] || error "Not exists error"
2879 run_test 33g "nonroot user create already existing root created file"
2881 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2884 $MCREATE $DIR/f34 || error
2885 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2886 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2887 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2888 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2890 run_test 34a "truncate file that has not been opened ==========="
2893 [ ! -f $DIR/f34 ] && test_34a
2894 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2895 $OPENFILE -f O_RDONLY $DIR/f34
2896 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2897 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2899 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2902 [ ! -f $DIR/f34 ] && test_34a
2903 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2904 $OPENFILE -f O_RDWR $DIR/f34
2905 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2906 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2908 run_test 34c "O_RDWR opening file-with-size works =============="
2911 [ ! -f $DIR/f34 ] && test_34a
2912 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2913 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2916 run_test 34d "write to sparse file ============================="
2920 $MCREATE $DIR/f34e || error
2921 $TRUNCATE $DIR/f34e 1000 || error
2922 $CHECKSTAT -s 1000 $DIR/f34e || error
2923 $OPENFILE -f O_RDWR $DIR/f34e
2924 $CHECKSTAT -s 1000 $DIR/f34e || error
2926 run_test 34e "create objects, some with size and some without =="
2928 test_34f() { # bug 6242, 6243
2929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2932 $MCREATE $DIR/f34f || error
2933 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2934 dd if=$DIR/f34f of=$TMP/f34f
2935 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2936 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2937 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2938 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2939 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2941 run_test 34f "read from a file with no objects until EOF ======="
2944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2945 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2946 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2947 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2948 cancel_lru_locks osc
2949 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2950 error "wrong size after lock cancel"
2952 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2953 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2954 error "expanding truncate failed"
2955 cancel_lru_locks osc
2956 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2957 error "wrong expanded size after lock cancel"
2959 run_test 34g "truncate long file ==============================="
2962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2966 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2967 sync # Flush the cache so that multiop below does not block on cache
2968 # flush when getting the group lock
2969 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2972 # Since just timed wait is not good enough, let's do a sync write
2973 # that way we are sure enough time for a roundtrip + processing
2974 # passed + 2 seconds of extra margin.
2975 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2979 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2980 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2984 local nsz=`stat -c %s $DIR/$tfile`
2985 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2987 run_test 34h "ftruncate file under grouplock should not block"
2990 cp /bin/sh $DIR/f35a
2992 chown $RUNAS_ID $DIR/f35a
2993 $RUNAS $DIR/f35a && error || true
2996 run_test 35a "exec file with mode 444 (should return and not leak)"
3000 utime $DIR/f36 || error
3002 run_test 36a "MDS utime check (mknod, utime)"
3006 utime $DIR/f36 || error
3008 run_test 36b "OST utime check (open, utime)"
3013 chown $RUNAS_ID $DIR/d36
3014 $RUNAS utime $DIR/d36/f36 || error
3016 run_test 36c "non-root MDS utime check (mknod, utime)"
3019 [ ! -d $DIR/d36 ] && test_36c
3020 echo "" > $DIR/d36/f36
3021 $RUNAS utime $DIR/d36/f36 || error
3023 run_test 36d "non-root OST utime check (open, utime)"
3026 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3027 test_mkdir $DIR/$tdir
3028 touch $DIR/$tdir/$tfile
3029 $RUNAS utime $DIR/$tdir/$tfile &&
3030 error "utime worked, expected failure" || true
3032 run_test 36e "utime on non-owned file (should return error)"
3036 local LANG_SAVE=$LANG
3037 local LC_LANG_SAVE=$LC_LANG
3038 export LANG=C LC_LANG=C # for date language
3040 DATESTR="Dec 20 2000"
3041 test_mkdir $DIR/$tdir
3042 lctl set_param fail_loc=$fl
3044 cp /etc/hosts $DIR/$tdir/$tfile
3045 sync & # write RPC generated with "current" inode timestamp, but delayed
3047 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3048 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3049 cancel_lru_locks osc
3050 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3052 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3053 echo "BEFORE: $LS_BEFORE" && \
3054 echo "AFTER : $LS_AFTER" && \
3055 echo "WANT : $DATESTR" && \
3056 error "$DIR/$tdir/$tfile timestamps changed" || true
3058 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3063 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3064 subr_36fh "0x80000214"
3066 run_test 36f "utime on file racing with OST BRW write =========="
3069 remote_ost_nodsh && skip "remote OST with nodsh" && return
3070 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3075 test_mkdir $DIR/$tdir
3076 fmd_max_age=$(do_facet ost1 \
3077 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3080 fmd_before=$(do_facet ost1 \
3081 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3082 touch $DIR/$tdir/$tfile
3083 sleep $((fmd_max_age + 12))
3084 fmd_after=$(do_facet ost1 \
3085 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3087 echo "fmd_before: $fmd_before"
3088 echo "fmd_after: $fmd_after"
3089 [[ $fmd_after -gt $fmd_before ]] &&
3090 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3091 error "fmd didn't expire after ping" || true
3093 run_test 36g "filter mod data cache expiry ====================="
3096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3097 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3098 subr_36fh "0x80000227"
3100 run_test 36h "utime on file racing with OST BRW write =========="
3103 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3105 test_mkdir $DIR/$tdir
3106 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3108 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3109 local new_mtime=$((mtime + 200))
3111 #change Modify time of striped dir
3112 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3113 error "change mtime failed"
3115 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3117 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3119 run_test 36i "change mtime on striped directory"
3121 # test_37 - duplicate with tests 32q 32r
3124 local file=$DIR/$tfile
3126 openfile -f O_DIRECTORY $file
3129 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3130 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3132 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3134 test_39a() { # was test_39
3136 touch $DIR/${tfile}2
3137 # ls -l $DIR/$tfile $DIR/${tfile}2
3138 # ls -lu $DIR/$tfile $DIR/${tfile}2
3139 # ls -lc $DIR/$tfile $DIR/${tfile}2
3141 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3142 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3144 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3146 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3148 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3149 error "O_TRUNC didn't change timestamps"
3152 run_test 39a "mtime changed on create"
3155 test_mkdir -c1 $DIR/$tdir
3156 cp -p /etc/passwd $DIR/$tdir/fopen
3157 cp -p /etc/passwd $DIR/$tdir/flink
3158 cp -p /etc/passwd $DIR/$tdir/funlink
3159 cp -p /etc/passwd $DIR/$tdir/frename
3160 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3163 echo "aaaaaa" >> $DIR/$tdir/fopen
3164 echo "aaaaaa" >> $DIR/$tdir/flink
3165 echo "aaaaaa" >> $DIR/$tdir/funlink
3166 echo "aaaaaa" >> $DIR/$tdir/frename
3168 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3169 local link_new=`stat -c %Y $DIR/$tdir/flink`
3170 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3171 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3173 cat $DIR/$tdir/fopen > /dev/null
3174 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3175 rm -f $DIR/$tdir/funlink2
3176 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3178 for (( i=0; i < 2; i++ )) ; do
3179 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3180 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3181 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3182 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3184 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3185 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3186 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3187 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3189 cancel_lru_locks osc
3190 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3193 run_test 39b "mtime change on open, link, unlink, rename ======"
3195 # this should be set to past
3196 TEST_39_MTIME=`date -d "1 year ago" +%s`
3202 local mtime0=`stat -c %Y $DIR1/$tfile`
3204 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3205 local mtime1=`stat -c %Y $DIR1/$tfile`
3206 [ "$mtime1" = $TEST_39_MTIME ] || \
3207 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3210 echo hello >> $DIR1/$tfile
3212 local mtime2=`stat -c %Y $DIR1/$tfile`
3213 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3214 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3216 mv $DIR1/$tfile $DIR1/$tfile-1
3218 for (( i=0; i < 2; i++ )) ; do
3219 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3220 [ "$mtime2" = "$mtime3" ] || \
3221 error "mtime ($mtime2) changed (to $mtime3) on rename"
3223 cancel_lru_locks osc
3224 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3227 run_test 39c "mtime change on rename ==========================="
3231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3234 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3236 for (( i=0; i < 2; i++ )) ; do
3237 local mtime=`stat -c %Y $DIR1/$tfile`
3238 [ $mtime = $TEST_39_MTIME ] || \
3239 error "mtime($mtime) is not set to $TEST_39_MTIME"
3241 cancel_lru_locks osc
3242 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3245 run_test 39d "create, utime, stat =============================="
3249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3251 local mtime1=`stat -c %Y $DIR1/$tfile`
3253 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3255 for (( i=0; i < 2; i++ )) ; do
3256 local mtime2=`stat -c %Y $DIR1/$tfile`
3257 [ $mtime2 = $TEST_39_MTIME ] || \
3258 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3260 cancel_lru_locks osc
3261 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3264 run_test 39e "create, stat, utime, stat ========================"
3268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3270 mtime1=`stat -c %Y $DIR1/$tfile`
3273 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3275 for (( i=0; i < 2; i++ )) ; do
3276 local mtime2=`stat -c %Y $DIR1/$tfile`
3277 [ $mtime2 = $TEST_39_MTIME ] || \
3278 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3280 cancel_lru_locks osc
3281 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3284 run_test 39f "create, stat, sleep, utime, stat ================="
3288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3289 echo hello >> $DIR1/$tfile
3290 local mtime1=`stat -c %Y $DIR1/$tfile`
3293 chmod o+r $DIR1/$tfile
3295 for (( i=0; i < 2; i++ )) ; do
3296 local mtime2=`stat -c %Y $DIR1/$tfile`
3297 [ "$mtime1" = "$mtime2" ] || \
3298 error "lost mtime: $mtime2, should be $mtime1"
3300 cancel_lru_locks osc
3301 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3304 run_test 39g "write, chmod, stat ==============================="
3308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3313 echo hello >> $DIR1/$tfile
3314 local mtime1=`stat -c %Y $DIR1/$tfile`
3316 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3318 if [ "$d1" != "$d2" ]; then
3319 echo "write and touch not within one second"
3321 for (( i=0; i < 2; i++ )) ; do
3322 local mtime2=`stat -c %Y $DIR1/$tfile`
3323 [ "$mtime2" = $TEST_39_MTIME ] || \
3324 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3326 cancel_lru_locks osc
3327 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3331 run_test 39h "write, utime within one second, stat ============="
3334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3338 echo hello >> $DIR1/$tfile
3339 local mtime1=`stat -c %Y $DIR1/$tfile`
3341 mv $DIR1/$tfile $DIR1/$tfile-1
3343 for (( i=0; i < 2; i++ )) ; do
3344 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3346 [ "$mtime1" = "$mtime2" ] || \
3347 error "lost mtime: $mtime2, should be $mtime1"
3349 cancel_lru_locks osc
3350 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3353 run_test 39i "write, rename, stat =============================="
3356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3357 start_full_debug_logging
3361 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3362 lctl set_param fail_loc=0x80000412
3363 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3364 error "multiop failed"
3366 local mtime1=`stat -c %Y $DIR1/$tfile`
3368 mv $DIR1/$tfile $DIR1/$tfile-1
3370 kill -USR1 $multipid
3371 wait $multipid || error "multiop close failed"
3373 for (( i=0; i < 2; i++ )) ; do
3374 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3375 [ "$mtime1" = "$mtime2" ] ||
3376 error "mtime is lost on close: $mtime2, " \
3379 cancel_lru_locks osc
3380 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3382 lctl set_param fail_loc=0
3383 stop_full_debug_logging
3385 run_test 39j "write, rename, close, stat ======================="
3388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3392 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3394 local mtime1=`stat -c %Y $DIR1/$tfile`
3396 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3398 kill -USR1 $multipid
3399 wait $multipid || error "multiop close failed"
3401 for (( i=0; i < 2; i++ )) ; do
3402 local mtime2=`stat -c %Y $DIR1/$tfile`
3404 [ "$mtime2" = $TEST_39_MTIME ] || \
3405 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3407 cancel_lru_locks osc
3408 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3411 run_test 39k "write, utime, close, stat ========================"
3413 # this should be set to future
3414 TEST_39_ATIME=`date -d "1 year" +%s`
3417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3418 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3419 local atime_diff=$(do_facet $SINGLEMDS \
3420 lctl get_param -n mdd.*MDT0000*.atime_diff)
3424 # test setting directory atime to future
3425 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3426 local atime=$(stat -c %X $DIR/$tdir)
3427 [ "$atime" = $TEST_39_ATIME ] ||
3428 error "atime is not set to future: $atime, $TEST_39_ATIME"
3430 # test setting directory atime from future to now
3431 local now=$(date +%s)
3432 touch -a -d @$now $DIR/$tdir
3434 atime=$(stat -c %X $DIR/$tdir)
3435 [ "$atime" -eq "$now" ] ||
3436 error "atime is not updated from future: $atime, $now"
3438 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3441 # test setting directory atime when now > dir atime + atime_diff
3442 local d1=$(date +%s)
3444 local d2=$(date +%s)
3445 cancel_lru_locks mdc
3446 atime=$(stat -c %X $DIR/$tdir)
3447 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3448 error "atime is not updated : $atime, should be $d2"
3450 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3453 # test not setting directory atime when now < dir atime + atime_diff
3455 cancel_lru_locks mdc
3456 atime=$(stat -c %X $DIR/$tdir)
3457 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3458 error "atime is updated to $atime, should remain $d1<atime<$d2"
3460 do_facet $SINGLEMDS \
3461 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3463 run_test 39l "directory atime update ==========================="
3466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3469 local far_past_mtime=$(date -d "May 29 1953" +%s)
3470 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3472 touch -m -d @$far_past_mtime $DIR1/$tfile
3473 touch -a -d @$far_past_atime $DIR1/$tfile
3475 for (( i=0; i < 2; i++ )) ; do
3476 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3477 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3478 error "atime or mtime set incorrectly"
3480 cancel_lru_locks osc
3481 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3484 run_test 39m "test atime and mtime before 1970"
3486 test_39n() { # LU-3832
3487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3488 local atime_diff=$(do_facet $SINGLEMDS \
3489 lctl get_param -n mdd.*MDT0000*.atime_diff)
3494 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3497 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3498 atime0=$(stat -c %X $DIR/$tfile)
3501 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3502 atime1=$(stat -c %X $DIR/$tfile)
3505 cancel_lru_locks mdc
3506 cancel_lru_locks osc
3507 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3508 atime2=$(stat -c %X $DIR/$tfile)
3510 do_facet $SINGLEMDS \
3511 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3513 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3514 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3516 run_test 39n "check that O_NOATIME is honored"
3519 TESTDIR=$DIR/$tdir/$tfile
3520 [ -e $TESTDIR ] && rm -rf $TESTDIR
3527 links2=$(stat -c %h .)
3528 [ $(($links1 + 2)) != $links2 ] &&
3529 error "wrong links count $(($links1 + 2)) != $links2"
3531 links3=$(stat -c %h .)
3532 [ $(($links1 + 1)) != $links3 ] &&
3533 error "wrong links count $links1 != $links3"
3536 run_test 39o "directory cached attributes updated after create"
3539 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3541 TESTDIR=$DIR/$tdir/$tdir
3542 [ -e $TESTDIR ] && rm -rf $TESTDIR
3543 test_mkdir -p $TESTDIR
3547 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3548 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3550 links2=$(stat -c %h .)
3551 [ $(($links1 + 2)) != $links2 ] &&
3552 error "wrong links count $(($links1 + 2)) != $links2"
3554 links3=$(stat -c %h .)
3555 [ $(($links1 + 1)) != $links3 ] &&
3556 error "wrong links count $links1 != $links3"
3559 run_test 39p "remote directory cached attributes updated after create ========"
3562 test_39q() { # LU-8041
3563 local testdir=$DIR/$tdir
3565 multiop_bg_pause $testdir D_c || error "multiop failed"
3567 cancel_lru_locks mdc
3568 kill -USR1 $multipid
3569 local atime=$(stat -c %X $testdir)
3570 [ "$atime" -ne 0 ] || error "atime is zero"
3572 run_test 39q "close won't zero out atime"
3575 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3576 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3577 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3578 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3579 error "$tfile is not 4096 bytes in size"
3581 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3585 small_write $DIR/f41 18
3587 run_test 41 "test small file write + fstat ====================="
3589 count_ost_writes() {
3590 lctl get_param -n osc.*.stats |
3591 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3592 END { printf("%0.0f", writes) }'
3599 BG_DIRTY_RATIO_SAVE=10
3600 MAX_BG_DIRTY_RATIO=25
3604 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3605 # dirty_ratio, dirty_background_ratio
3606 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3607 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3608 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3609 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3611 # if file not here, we are a 2.4 kernel
3612 kill -CONT `pidof kupdated`
3617 # setup the trap first, so someone cannot exit the test at the
3618 # exact wrong time and mess up a machine
3619 trap start_writeback EXIT
3620 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3621 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3622 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3623 sysctl -w vm.dirty_writeback_centisecs=0
3624 sysctl -w vm.dirty_writeback_centisecs=0
3625 # save and increase /proc/sys/vm/dirty_ratio
3626 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3627 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3628 # save and increase /proc/sys/vm/dirty_background_ratio
3629 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3630 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3632 # if file not here, we are a 2.4 kernel
3633 kill -STOP `pidof kupdated`
3637 # ensure that all stripes have some grant before we test client-side cache
3639 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3640 dd if=/dev/zero of=$i bs=4k count=1
3645 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3646 # file truncation, and file removal.
3648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3650 cancel_lru_locks osc
3652 sync; sleep 1; sync # just to be safe
3653 BEFOREWRITES=`count_ost_writes`
3654 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3655 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3656 AFTERWRITES=`count_ost_writes`
3657 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3658 error "$BEFOREWRITES < $AFTERWRITES"
3661 run_test 42a "ensure that we don't flush on close"
3664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3666 cancel_lru_locks osc
3669 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3670 BEFOREWRITES=$(count_ost_writes)
3671 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3672 AFTERWRITES=$(count_ost_writes)
3673 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3674 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3676 BEFOREWRITES=$(count_ost_writes)
3677 sync || error "sync: $?"
3678 AFTERWRITES=$(count_ost_writes)
3679 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3680 error "$BEFOREWRITES < $AFTERWRITES on sync"
3682 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3686 run_test 42b "test destroy of file with cached dirty data ======"
3688 # if these tests just want to test the effect of truncation,
3689 # they have to be very careful. consider:
3690 # - the first open gets a {0,EOF}PR lock
3691 # - the first write conflicts and gets a {0, count-1}PW
3692 # - the rest of the writes are under {count,EOF}PW
3693 # - the open for truncate tries to match a {0,EOF}PR
3694 # for the filesize and cancels the PWs.
3695 # any number of fixes (don't get {0,EOF} on open, match
3696 # composite locks, do smarter file size management) fix
3697 # this, but for now we want these tests to verify that
3698 # the cancellation with truncate intent works, so we
3699 # start the file with a full-file pw lock to match against
3700 # until the truncate.
3705 cancel_lru_locks osc
3707 # prime the file with 0,EOF PW to match
3711 # now the real test..
3712 dd if=/dev/zero of=$file bs=1024 count=100
3713 BEFOREWRITES=`count_ost_writes`
3714 $TRUNCATE $file $offset
3715 cancel_lru_locks osc
3716 AFTERWRITES=`count_ost_writes`
3721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3723 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3724 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3727 run_test 42c "test partial truncate of file with cached dirty data"
3730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3732 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3733 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3736 run_test 42d "test complete truncate of file with cached dirty data"
3738 test_42e() { # bug22074
3739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3740 local TDIR=$DIR/${tdir}e
3741 local pagesz=$(page_size)
3742 local pages=16 # hardcoded 16 pages, don't change it.
3743 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3744 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3748 test_mkdir $DIR/${tdir}e
3749 $SETSTRIPE -c 1 $TDIR
3750 createmany -o $TDIR/f $files
3752 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3754 # we assume that with $OSTCOUNT files, at least one of them will
3755 # be allocated on OST0.
3756 warmup_files=$((OSTCOUNT * max_dirty_mb))
3757 createmany -o $TDIR/w $warmup_files
3759 # write a large amount of data into one file and sync, to get good
3760 # avail_grant number from OST.
3761 for ((i=0; i<$warmup_files; i++)); do
3762 idx=$($GETSTRIPE -i $TDIR/w$i)
3763 [ $idx -ne 0 ] && continue
3764 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3767 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3769 $LCTL get_param $proc_osc0/cur_dirty_bytes
3770 $LCTL get_param $proc_osc0/cur_grant_bytes
3772 # create as much dirty pages as we can while not to trigger the actual
3773 # RPCs directly. but depends on the env, VFS may trigger flush during this
3774 # period, hopefully we are good.
3775 for ((i=0; i<$warmup_files; i++)); do
3776 idx=$($GETSTRIPE -i $TDIR/w$i)
3777 [ $idx -ne 0 ] && continue
3778 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3780 $LCTL get_param $proc_osc0/cur_dirty_bytes
3781 $LCTL get_param $proc_osc0/cur_grant_bytes
3783 # perform the real test
3784 $LCTL set_param $proc_osc0/rpc_stats 0
3785 for ((;i<$files; i++)); do
3786 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3787 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3790 $LCTL get_param $proc_osc0/rpc_stats
3793 local have_ppr=false
3794 $LCTL get_param $proc_osc0/rpc_stats |
3795 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3796 # skip lines until we are at the RPC histogram data
3797 [ "$PPR" == "pages" ] && have_ppr=true && continue
3798 $have_ppr || continue
3800 # we only want the percent stat for < 16 pages
3801 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3803 percent=$((percent + WPCT))
3804 if [[ $percent -gt 15 ]]; then
3805 error "less than 16-pages write RPCs" \
3812 run_test 42e "verify sub-RPC writes are not done synchronously"
3814 test_43A() { # was test_43
3815 test_mkdir $DIR/$tdir
3816 cp -p /bin/ls $DIR/$tdir/$tfile
3817 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3819 # give multiop a chance to open
3822 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3825 run_test 43A "execution of file opened for write should return -ETXTBSY"
3828 test_mkdir $DIR/$tdir
3829 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3830 cp -p multiop $DIR/$tdir/multiop
3831 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3832 error "multiop open $TMP/$tfile.junk failed"
3834 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3835 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3836 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3838 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3841 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3842 test_mkdir $DIR/$tdir
3843 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3844 cp -p multiop $DIR/$tdir/multiop
3845 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3846 error "multiop open $TMP/$tfile.junk failed"
3848 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3849 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3850 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3852 run_test 43b "truncate of file being executed should return -ETXTBSY"
3855 local testdir="$DIR/$tdir"
3858 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3859 ( cd $testdir && md5sum -c )
3861 run_test 43c "md5sum of copy into lustre"
3863 test_44A() { # was test_44
3864 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3865 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3866 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3868 run_test 44A "zero length read from a sparse stripe"
3871 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3873 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3874 [[ $nstripe -gt $OSTCOUNT ]] &&
3875 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3877 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3879 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3880 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3884 OFFSETS="0 $((stride/2)) $((stride-1))"
3885 for offset in $OFFSETS; do
3886 for i in $(seq 0 $((nstripe-1))); do
3887 local GLOBALOFFSETS=""
3889 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3890 local myfn=$DIR/d44a-$size
3891 echo "--------writing $myfn at $size"
3892 ll_sparseness_write $myfn $size ||
3893 error "ll_sparseness_write"
3894 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3895 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3896 error "ll_sparseness_verify $GLOBALOFFSETS"
3898 for j in $(seq 0 $((nstripe-1))); do
3900 size=$((((j + $nstripe )*$stride + $offset)))
3901 ll_sparseness_write $myfn $size ||
3902 error "ll_sparseness_write"
3903 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3905 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3906 error "ll_sparseness_verify $GLOBALOFFSETS"
3911 run_test 44a "test sparse pwrite ==============================="
3915 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3921 before=`dirty_osc_total`
3922 echo executing "\"$*\""
3924 after=`dirty_osc_total`
3925 echo before $before, after $after
3928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3930 # Obtain grants from OST if it supports it
3931 echo blah > ${f}_grant
3934 do_dirty_record "echo blah > $f"
3935 [[ $before -eq $after ]] && error "write wasn't cached"
3936 do_dirty_record "> $f"
3937 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3938 do_dirty_record "echo blah > $f"
3939 [[ $before -eq $after ]] && error "write wasn't cached"
3940 do_dirty_record "sync"
3941 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3942 do_dirty_record "echo blah > $f"
3943 [[ $before -eq $after ]] && error "write wasn't cached"
3944 do_dirty_record "cancel_lru_locks osc"
3945 [[ $before -gt $after ]] ||
3946 error "lock cancellation didn't lower dirty count"
3949 run_test 45 "osc io page accounting ============================"
3951 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3952 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3953 # objects offset and an assert hit when an rpc was built with 1023's mapped
3954 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3960 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3962 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3963 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3967 run_test 46 "dirtying a previously written page ================"
3969 # test_47 is removed "Device nodes check" is moved to test_28
3971 test_48a() { # bug 2399
3972 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3973 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3974 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3976 test_mkdir $DIR/$tdir
3978 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3979 test_mkdir $DIR/$tdir
3980 touch foo || error "'touch foo' failed after recreating cwd"
3982 touch .foo || error "'touch .foo' failed after recreating cwd"
3984 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3985 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3986 cd . || error "'cd .' failed after recreating cwd"
3987 mkdir . && error "'mkdir .' worked after recreating cwd"
3988 rmdir . && error "'rmdir .' worked after recreating cwd"
3989 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3990 cd .. || error "'cd ..' failed after recreating cwd"
3992 run_test 48a "Access renamed working dir (should return errors)="
3994 test_48b() { # bug 2399
3996 test_mkdir $DIR/$tdir
3998 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3999 touch foo && error "'touch foo' worked after removing cwd"
4000 mkdir foo && error "'mkdir foo' worked after removing cwd"
4001 touch .foo && error "'touch .foo' worked after removing cwd"
4002 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4003 ls . > /dev/null && error "'ls .' worked after removing cwd"
4004 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4005 mkdir . && error "'mkdir .' worked after removing cwd"
4006 rmdir . && error "'rmdir .' worked after removing cwd"
4007 ln -s . foo && error "'ln -s .' worked after removing cwd"
4008 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4010 run_test 48b "Access removed working dir (should return errors)="
4012 test_48c() { # bug 2350
4013 #lctl set_param debug=-1
4016 test_mkdir -p $DIR/$tdir/dir
4018 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4019 $TRACE touch foo && error "touch foo worked after removing cwd"
4020 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4021 touch .foo && error "touch .foo worked after removing cwd"
4022 mkdir .foo && error "mkdir .foo worked after removing cwd"
4023 $TRACE ls . && error "'ls .' worked after removing cwd"
4024 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4025 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4026 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4027 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4028 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4030 run_test 48c "Access removed working subdir (should return errors)"
4032 test_48d() { # bug 2350
4033 #lctl set_param debug=-1
4036 test_mkdir -p $DIR/$tdir/dir
4038 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4039 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4040 $TRACE touch foo && error "'touch foo' worked after removing parent"
4041 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4042 touch .foo && error "'touch .foo' worked after removing parent"
4043 mkdir .foo && error "mkdir .foo worked after removing parent"
4044 $TRACE ls . && error "'ls .' worked after removing parent"
4045 $TRACE ls .. && error "'ls ..' worked after removing parent"
4046 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4047 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4048 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4051 run_test 48d "Access removed parent subdir (should return errors)"
4053 test_48e() { # bug 4134
4054 #lctl set_param debug=-1
4057 test_mkdir -p $DIR/$tdir/dir
4059 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4060 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4061 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4062 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4063 # On a buggy kernel addition of "touch foo" after cd .. will
4064 # produce kernel oops in lookup_hash_it
4065 touch ../foo && error "'cd ..' worked after recreate parent"
4067 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4069 run_test 48e "Access to recreated parent subdir (should return errors)"
4071 test_49() { # LU-1030
4072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4073 remote_ost_nodsh && skip "remote OST with nodsh" && return
4074 # get ost1 size - lustre-OST0000
4075 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4077 # write 800M at maximum
4078 [[ $ost1_size -lt 2 ]] && ost1_size=2
4079 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4081 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4082 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4085 # change max_pages_per_rpc while writing the file
4086 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4087 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4088 # loop until dd process exits
4089 while ps ax -opid | grep -wq $dd_pid; do
4090 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4091 sleep $((RANDOM % 5 + 1))
4093 # restore original max_pages_per_rpc
4094 $LCTL set_param $osc1_mppc=$orig_mppc
4095 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4097 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4101 test_mkdir $DIR/$tdir
4103 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4105 run_test 50 "special situations: /proc symlinks ==============="
4107 test_51a() { # was test_51
4108 # bug 1516 - create an empty entry right after ".." then split dir
4109 test_mkdir -c1 $DIR/$tdir
4110 touch $DIR/$tdir/foo
4111 $MCREATE $DIR/$tdir/bar
4113 createmany -m $DIR/$tdir/longfile 201
4115 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4116 $MCREATE $DIR/$tdir/longfile$FNUM
4121 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4123 run_test 51a "special situations: split htree with empty entry =="
4125 cleanup_print_lfs_df () {
4132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4133 local dir=$DIR/$tdir
4135 local nrdirs=$((65536 + 100))
4137 # cleanup the directory
4144 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4145 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4146 [[ $numfree -lt $nrdirs ]] &&
4147 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4150 # need to check free space for the directories as well
4151 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4152 numfree=$(( blkfree / $(fs_inode_ksize) ))
4153 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4156 trap cleanup_print_lfsdf EXIT
4159 createmany -d $dir/d $nrdirs ||
4160 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4163 nrdirs=$(ls -U $dir | wc -l)
4165 # unlink all but 100 subdirectories, then check it still works
4167 local delete=$((nrdirs - left))
4172 # for ldiskfs the nlink count should be 1, but this is OSD specific
4173 # and so this is listed for informational purposes only
4174 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4175 unlinkmany -d $dir/d $delete ||
4176 error "unlink of first $delete subdirs failed"
4178 echo "nlink between: $(stat -c %h $dir)"
4179 local found=$(ls -U $dir | wc -l)
4180 [ $found -ne $left ] &&
4181 error "can't find subdirs: found only $found, expected $left"
4183 unlinkmany -d $dir/d $delete $left ||
4184 error "unlink of second $left subdirs failed"
4185 # regardless of whether the backing filesystem tracks nlink accurately
4186 # or not, the nlink count shouldn't be more than "." and ".." here
4187 local after=$(stat -c %h $dir)
4188 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4189 echo "nlink after: $after"
4191 cleanup_print_lfs_df
4193 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4197 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4198 test_mkdir $DIR/$tdir
4199 createmany -o $DIR/$tdir/t- 1000
4200 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4201 for N in $(seq 0 $((OSTCOUNT - 1))); do
4202 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4203 END { printf("%0.0f", objs) }' $TMP/$tfile)
4204 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4205 '($1 == '$N') { objs += 1 } \
4206 END { printf("%0.0f", objs) }')
4207 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4209 unlinkmany $DIR/$tdir/t- 1000
4212 for N in $(seq 1 $((OSTCOUNT - 1))); do
4213 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4214 error "OST $N has less objects vs OST $NLAST" \
4215 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4216 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4217 error "OST $N has less objects vs OST $NLAST" \
4218 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4220 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4221 error "OST $N has less #0 objects vs OST $NLAST" \
4222 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4223 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4224 error "OST $N has less #0 objects vs OST $NLAST" \
4225 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4230 run_test 51d "check object distribution"
4233 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4234 skip "ldiskfs only test"
4238 test_mkdir -c1 $DIR/$tdir
4239 test_mkdir -c1 $DIR/$tdir/d0
4241 touch $DIR/$tdir/d0/foo
4242 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4243 error "file exceed 65000 nlink limit!"
4244 unlinkmany $DIR/$tdir/d0/f- 65001
4247 run_test 51e "check file nlink limit"
4250 test_mkdir $DIR/$tdir
4253 local ulimit_old=$(ulimit -n)
4254 local spare=20 # number of spare fd's for scripts/libraries, etc.
4255 local mdt=$(lfs getstripe -M $DIR/$tdir)
4256 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4258 echo "MDT$mdt numfree=$numfree, max=$max"
4259 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4260 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4261 while ! ulimit -n $((numfree + spare)); do
4262 numfree=$((numfree * 3 / 4))
4264 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4266 echo "left ulimit at $ulimit_old"
4269 createmany -o -k -t 120 $DIR/$tdir/f $numfree ||
4270 error "create+open $numfree files in $DIR/$tdir failed"
4271 ulimit -n $ulimit_old
4273 # if createmany exits at 120s there will be fewer than $numfree files
4274 unlinkmany $DIR/$tdir/f $numfree || true
4276 run_test 51f "check many open files limit"
4279 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4280 test_mkdir $DIR/$tdir
4281 touch $DIR/$tdir/foo
4282 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4283 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4284 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4285 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4286 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4288 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4289 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4290 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4292 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4293 cp -r $DIR/$tdir $TMP/
4294 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4296 run_test 52a "append-only flag test (should return errors)"
4299 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4300 test_mkdir $DIR/$tdir
4301 touch $DIR/$tdir/foo
4302 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4303 cat test > $DIR/$tdir/foo && error "cat test worked"
4304 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4305 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4306 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4308 echo foo >> $DIR/$tdir/foo && error "echo worked"
4309 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4310 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4311 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4312 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4314 chattr -i $DIR/$tdir/foo || error "chattr failed"
4316 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4318 run_test 52b "immutable flag test (should return errors) ======="
4321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4322 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4323 remote_ost_nodsh && skip "remote OST with nodsh" && return
4336 local support_last_seq=true
4338 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4339 support_last_seq=false
4342 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4344 for value in $(do_facet $SINGLEMDS \
4345 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4346 param=$(echo ${value[0]} | cut -d "=" -f1)
4347 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4349 if $support_last_seq; then
4350 param_seq=$(echo $param |
4351 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4352 mds_last_seq=$(do_facet $SINGLEMDS \
4353 $LCTL get_param -n $param_seq)
4355 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4357 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4358 node=$(facet_active_host ost$((ostnum+1)))
4359 param="obdfilter.$ostname.last_id"
4360 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4361 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4362 ost_last_id=$ost_last
4364 if $support_last_seq; then
4365 ost_last_id=$(echo $ost_last |
4366 awk -F':' '{print $2}' |
4368 ost_last_seq=$(echo $ost_last |
4369 awk -F':' '{print $1}')
4370 [[ $ost_last_seq = $mds_last_seq ]] || continue
4373 if [[ $ost_last_id != $mds_last ]]; then
4374 error "$ost_last_id != $mds_last"
4381 $found || error "can not match last_seq/last_id for $mdtosc"
4384 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4387 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4389 $SOCKETSERVER $DIR/socket ||
4390 error "$SOCKETSERVER $DIR/socket failed: $?"
4391 $SOCKETCLIENT $DIR/socket ||
4392 error "$SOCKETCLIENT $DIR/socket failed: $?"
4393 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4395 run_test 54a "unix domain socket test =========================="
4401 dd if=/dev/zero of=$f bs=$(page_size) count=1
4403 run_test 54b "char device works in lustre ======================"
4406 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4407 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4408 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4410 for i in $(seq 3 7); do
4411 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4420 loopdev="$DIR/loop54c"
4423 $UMOUNT $DIR/$tdir || rc=$?
4424 losetup -d $loopdev || true
4425 losetup -d $LOOPDEV || true
4426 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4432 loopdev="$DIR/loop54c"
4435 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4436 trap cleanup_54c EXIT
4437 mknod $loopdev b 7 $LOOPNUM
4438 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4439 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4440 losetup $loopdev $DIR/$tfile ||
4441 error "can't set up $loopdev for $DIR/$tfile"
4442 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4443 test_mkdir $DIR/$tdir
4444 mount -t ext2 $loopdev $DIR/$tdir ||
4445 error "error mounting $loopdev on $DIR/$tdir"
4446 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4449 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4453 run_test 54c "block device works in lustre ====================="
4459 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4461 run_test 54d "fifo device works in lustre ======================"
4466 cp -aL /dev/console $f
4467 echo $string > $f || error "echo $string to $f failed"
4469 run_test 54e "console/tty device works in lustre ======================"
4471 #The test_55 used to be iopen test and it was removed by bz#24037.
4472 #run_test 55 "check iopen_connect_dentry() ======================"
4474 test_56a() { # was test_56
4477 test_mkdir -p $DIR/$tdir/dir
4479 NUMFILESx2=$(($NUMFILES * 2))
4480 for i in $(seq 1 $NUMFILES); do
4481 touch $DIR/$tdir/file$i
4482 touch $DIR/$tdir/dir/file$i
4485 # test lfs getstripe with --recursive
4486 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4487 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4488 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4489 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4490 [[ $FILENUM -eq $NUMFILES ]] ||
4491 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4492 echo "$GETSTRIPE --recursive passed."
4494 # test lfs getstripe with file instead of dir
4495 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4496 [[ $FILENUM -eq 1 ]] ||
4497 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4498 echo "$GETSTRIPE file1 passed."
4500 #test lfs getstripe with --verbose
4501 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4502 grep -c lmm_magic) -eq $NUMFILES ]] ||
4503 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4504 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4505 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4507 #test lfs getstripe with -v prints lmm_fid
4508 [[ $($GETSTRIPE -v $DIR/$tdir | grep -c lmm_fid) -eq $NUMFILES ]] ||
4509 error "$GETSTRIPE -v $DIR/$tdir: want $NUMFILES lmm_fid: lines"
4510 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_fid) -eq 0 ]] ||
4511 error "$GETSTRIPE $DIR/$tdir: showed lmm_fid"
4512 echo "$GETSTRIPE --verbose passed."
4514 #check for FID information
4515 local fid1=$($GETSTRIPE --fid $DIR/$tdir/file1)
4516 local fid2=$($GETSTRIPE --verbose $DIR/$tdir/file1 |
4517 awk '/lmm_fid: / { print $2 }')
4518 local fid3=$($LFS path2fid $DIR/$tdir/file1)
4519 [ "$fid1" != "$fid2" ] &&
4520 error "getstripe --fid $fid1 != getstripe --verbose $fid2"
4521 [ "$fid1" != "$fid3" ] &&
4522 error "getstripe --fid $fid1 != lfs path2fid $fid3"
4523 echo "$GETSTRIPE --fid passed."
4525 #test lfs getstripe with --obd
4526 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4527 grep -q "unknown obduuid" ||
4528 error "$GETSTRIPE --obd wrong_uuid should return error message"
4530 [[ $OSTCOUNT -lt 2 ]] &&
4531 skip_env "skipping other $GETSTRIPE --obd test" && return
4534 OBDUUID=$(ostuuid_from_index $OSTIDX)
4535 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4536 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4537 [[ $FOUND -eq $FILENUM ]] ||
4538 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4539 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4540 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4541 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4542 error "$GETSTRIPE --obd: should not show file on other obd"
4543 echo "$GETSTRIPE --obd passed"
4545 run_test 56a "check $GETSTRIPE"
4548 test_mkdir $DIR/$tdir
4550 for i in $(seq 1 $NUMDIRS); do
4551 test_mkdir $DIR/$tdir/dir$i
4554 # test lfs getdirstripe default mode is non-recursion, which is
4555 # different from lfs getstripe
4556 dircnt=$($LFS getdirstripe $DIR/$tdir | grep -c lmv_stripe_count)
4557 [[ $dircnt -eq 1 ]] ||
4558 error "$LFS getdirstripe: found $dircnt, not 1"
4559 dircnt=$($LFS getdirstripe --recursive $DIR/$tdir |
4560 grep -c lmv_stripe_count)
4561 [[ $dircnt -eq $((NUMDIRS + 1)) ]] ||
4562 error "$LFS getdirstripe --recursive: found $dircnt, \
4563 not $((NUMDIRS + 1))"
4565 run_test 56b "check $LFS getdirstripe"
4569 local ost_name=$(ostname_from_index $ost_idx)
4571 local old_status=$(ost_dev_status $ost_idx)
4572 [[ -z "$old_status" ]] ||
4573 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4575 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4578 local new_status=$(ost_dev_status $ost_idx)
4579 [[ "$new_status" = "D" ]] ||
4580 error "OST $ost_name is in status of '$new_status', not 'D'"
4582 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4585 new_status=$(ost_dev_status $ost_idx)
4586 [[ -z "$new_status" ]] ||
4587 error "OST $ost_name is in status of '$new_status', not ''"
4589 run_test 56c "check 'lfs df' showing device status"
4594 local LOCAL_NUMFILES="$1"
4595 local LOCAL_NUMDIRS="$2"
4596 local MKDIR_PARAMS="$3"
4597 local DIR_STRIPE_PARAMS="$4"
4599 if [ ! -d "$TDIR" ] ; then
4600 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4601 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4602 for i in `seq 1 $LOCAL_NUMFILES` ; do
4605 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4606 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4607 for j in `seq 1 $LOCAL_NUMFILES` ; do
4608 touch $TDIR/dir$i/file$j
4614 setup_56_special() {
4618 if [ ! -e "$TDIR/loop1b" ] ; then
4619 for i in `seq 1 $LOCAL_NUMFILES` ; do
4620 mknod $TDIR/loop${i}b b 7 $i
4621 mknod $TDIR/null${i}c c 1 3
4622 ln -s $TDIR/file1 $TDIR/link${i}l
4624 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4625 mknod $TDIR/dir$i/loop${i}b b 7 $i
4626 mknod $TDIR/dir$i/null${i}c c 1 3
4627 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4636 setup_56 $NUMFILES $NUMDIRS
4638 EXPECTED=$(($NUMDIRS + 2))
4639 # test lfs find with -name
4640 for i in $(seq 1 $NUMFILES) ; do
4641 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4642 [ $NUMS -eq $EXPECTED ] ||
4643 error "lfs find -name \"*$i\" $TDIR wrong: "\
4644 "found $NUMS, expected $EXPECTED"
4647 run_test 56g "check lfs find -name ============================="
4653 setup_56 $NUMFILES $NUMDIRS
4655 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4656 # test lfs find with ! -name
4657 for i in $(seq 1 $NUMFILES) ; do
4658 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4659 [ $NUMS -eq $EXPECTED ] ||
4660 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4661 "found $NUMS, expected $EXPECTED"
4664 run_test 56h "check lfs find ! -name"
4668 test_mkdir $DIR/$tdir
4669 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4670 CMD="$LFIND -ost $UUID $DIR/$tdir"
4672 [ -z "$OUT" ] || error "'$CMD' returned directory '$OUT'"
4674 run_test 56i "check 'lfs find -ost UUID' skips directories"
4678 setup_56_special $NUMFILES $NUMDIRS
4680 EXPECTED=$((NUMDIRS + 1))
4681 CMD="$LFIND -type d $TDIR"
4682 NUMS=$($CMD | wc -l)
4683 [ $NUMS -eq $EXPECTED ] ||
4684 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4686 run_test 56j "check lfs find -type d ============================="
4690 setup_56_special $NUMFILES $NUMDIRS
4692 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4693 CMD="$LFIND -type f $TDIR"
4694 NUMS=$($CMD | wc -l)
4695 [ $NUMS -eq $EXPECTED ] ||
4696 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4698 run_test 56k "check lfs find -type f ============================="
4702 setup_56_special $NUMFILES $NUMDIRS
4704 EXPECTED=$((NUMDIRS + NUMFILES))
4705 CMD="$LFIND -type b $TDIR"
4706 NUMS=$($CMD | wc -l)
4707 [ $NUMS -eq $EXPECTED ] ||
4708 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4710 run_test 56l "check lfs find -type b ============================="
4714 setup_56_special $NUMFILES $NUMDIRS
4716 EXPECTED=$((NUMDIRS + NUMFILES))
4717 CMD="$LFIND -type c $TDIR"
4718 NUMS=$($CMD | wc -l)
4719 [ $NUMS -eq $EXPECTED ] ||
4720 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4722 run_test 56m "check lfs find -type c ============================="
4726 setup_56_special $NUMFILES $NUMDIRS
4728 EXPECTED=$((NUMDIRS + NUMFILES))
4729 CMD="$LFIND -type l $TDIR"
4730 NUMS=$($CMD | wc -l)
4731 [ $NUMS -eq $EXPECTED ] ||
4732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4734 run_test 56n "check lfs find -type l ============================="
4738 setup_56 $NUMFILES $NUMDIRS
4739 utime $TDIR/file1 > /dev/null || error "utime (1)"
4740 utime $TDIR/file2 > /dev/null || error "utime (2)"
4741 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4742 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4743 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4744 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4747 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4748 [ $NUMS -eq $EXPECTED ] || \
4749 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4752 CMD="$LFIND -mtime 0 $TDIR"
4753 NUMS=$($CMD | wc -l)
4754 [ $NUMS -eq $EXPECTED ] ||
4755 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4757 run_test 56o "check lfs find -mtime for old files =========================="
4760 [ $RUNAS_ID -eq $UID ] &&
4761 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4764 setup_56 $NUMFILES $NUMDIRS
4766 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4768 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4769 NUMS=$($CMD | wc -l)
4770 [ $NUMS -eq $EXPECTED ] || \
4771 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4773 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4774 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4775 NUMS=$($CMD | wc -l)
4776 [ $NUMS -eq $EXPECTED ] || \
4777 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4779 run_test 56p "check lfs find -uid and ! -uid ==============================="
4782 [ $RUNAS_ID -eq $UID ] &&
4783 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4786 setup_56 $NUMFILES $NUMDIRS
4788 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4791 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4792 NUMS=$($CMD | wc -l)
4793 [ $NUMS -eq $EXPECTED ] ||
4794 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4796 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4797 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4798 NUMS=$($CMD | wc -l)
4799 [ $NUMS -eq $EXPECTED ] ||
4800 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4802 run_test 56q "check lfs find -gid and ! -gid ==============================="
4806 setup_56 $NUMFILES $NUMDIRS
4809 CMD="$LFIND -size 0 -type f $TDIR"
4810 NUMS=$($CMD | wc -l)
4811 [ $NUMS -eq $EXPECTED ] ||
4812 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4814 CMD="$LFIND ! -size 0 -type f $TDIR"
4815 NUMS=$($CMD | wc -l)
4816 [ $NUMS -eq $EXPECTED ] ||
4817 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4818 echo "test" > $TDIR/$tfile
4819 echo "test2" > $TDIR/$tfile.2 && sync
4821 CMD="$LFIND -size 5 -type f $TDIR"
4822 NUMS=$($CMD | wc -l)
4823 [ $NUMS -eq $EXPECTED ] ||
4824 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4826 CMD="$LFIND -size +5 -type f $TDIR"
4827 NUMS=$($CMD | wc -l)
4828 [ $NUMS -eq $EXPECTED ] ||
4829 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4831 CMD="$LFIND -size +0 -type f $TDIR"
4832 NUMS=$($CMD | wc -l)
4833 [ $NUMS -eq $EXPECTED ] ||
4834 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4836 CMD="$LFIND ! -size -5 -type f $TDIR"
4837 NUMS=$($CMD | wc -l)
4838 [ $NUMS -eq $EXPECTED ] ||
4839 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4841 CMD="$LFIND -size -5 -type f $TDIR"
4842 NUMS=$($CMD | wc -l)
4843 [ $NUMS -eq $EXPECTED ] ||
4844 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4846 run_test 56r "check lfs find -size works =========================="
4848 test_56s() { # LU-611
4853 for i in $(seq 1 $NUMDIRS); do
4854 $SETSTRIPE -c $((OSTCOUNT + 1)) $TDIR/dir$i/$tfile
4857 CMD="$LFIND -c $OSTCOUNT $TDIR"
4858 NUMS=$($CMD | wc -l)
4859 [ $NUMS -eq $EXPECTED ] || {
4861 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4865 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4866 if [[ $OSTCOUNT -gt 1 ]]; then
4867 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4871 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4875 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4876 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4877 NUMS=$($CMD | wc -l)
4878 [ $NUMS -eq $EXPECTED ] || {
4880 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4883 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4884 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4885 NUMS=$($CMD | wc -l)
4886 [ $NUMS -eq $EXPECTED ] || {
4888 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4892 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4893 NUMS=$($CMD | wc -l)
4894 [ $NUMS -eq $EXPECTED ] || {
4896 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4899 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4900 NUMS=$($CMD | wc -l)
4901 [ $NUMS -eq $EXPECTED ] || {
4903 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4907 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4908 NUMS=$($CMD | wc -l)
4909 [ $NUMS -eq $EXPECTED ] || {
4911 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4914 run_test 56s "check lfs find -stripe-count works"
4916 test_56t() { # LU-611
4921 for i in $(seq 1 $NUMDIRS); do
4922 $SETSTRIPE -S 4M $TDIR/dir$i/$tfile
4925 CMD="$LFIND -S 4M $TDIR"
4926 NUMS=$($CMD | wc -l)
4927 [ $NUMS -eq $EXPECTED ] || {
4929 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4933 setup_56 $NUMFILES $NUMDIRS "--stripe-size 512k"
4935 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4937 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4938 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4939 NUMS=$($CMD | wc -l)
4940 [ $NUMS -eq $EXPECTED ] ||
4941 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4943 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4944 NUMS=$($CMD | wc -l)
4945 [ $NUMS -eq $EXPECTED ] ||
4946 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4948 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4949 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4950 NUMS=$($CMD | wc -l)
4951 [ $NUMS -eq $EXPECTED ] ||
4952 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4954 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4955 NUMS=$($CMD | wc -l)
4956 [ $NUMS -eq $EXPECTED ] ||
4957 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4960 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4961 NUMS=$($CMD | wc -l)
4962 [ $NUMS -eq $EXPECTED ] ||
4963 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4965 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4966 NUMS=$($CMD | wc -l)
4967 [ $NUMS -eq $EXPECTED ] ||
4968 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4971 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4972 NUMS=$($CMD | wc -l)
4973 [ $NUMS -eq $EXPECTED ] ||
4974 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4976 run_test 56t "check lfs find -stripe-size works"
4978 test_56u() { # LU-611
4980 setup_56 $NUMFILES $NUMDIRS "-i 0"
4982 if [[ $OSTCOUNT -gt 1 ]]; then
4983 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4989 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4990 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4991 NUMS=$($CMD | wc -l)
4992 [ $NUMS -eq $EXPECTED ] ||
4993 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4996 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4997 NUMS=$($CMD | wc -l)
4998 [ $NUMS -eq $EXPECTED ] ||
4999 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5001 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
5002 NUMS=$($CMD | wc -l)
5003 [ $NUMS -eq $EXPECTED ] ||
5004 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5007 # This should produce an error and not return any files
5008 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
5009 NUMS=$($CMD 2>/dev/null | wc -l)
5010 [ $NUMS -eq $EXPECTED ] ||
5011 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5013 if [[ $OSTCOUNT -gt 1 ]]; then
5014 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
5015 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
5016 NUMS=$($CMD | wc -l)
5017 [ $NUMS -eq $EXPECTED ] ||
5018 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
5021 run_test 56u "check lfs find -stripe-index works"
5028 setup_56 $NUMFILES $NUMDIRS
5030 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
5031 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
5033 for file in $($LFIND -mdt $UUID $TDIR); do
5034 file_mdt_idx=$($GETSTRIPE -M $file)
5035 [ $file_mdt_idx -eq $MDT_IDX ] ||
5036 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
5039 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5042 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5046 rm -rf $TDIR || error "remove $TDIR failed"
5047 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5050 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
5051 error "$GETSTRIPE -S -d $TDIR failed"
5052 stripe_size=${stripe_size%% *}
5054 local file_size=$((stripe_size * OSTCOUNT))
5055 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5056 local required_space=$((file_num * file_size))
5058 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5060 [[ $free_space -le $((required_space / 1024)) ]] &&
5061 skip_env "need $required_space bytes, have $free_space KB" &&
5065 local dd_count=$((file_size / dd_bs))
5067 # write data into the files
5071 for i in $(seq 1 $NUMFILES); do
5073 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5074 error "write data into $file failed"
5076 for i in $(seq 1 $NUMDIRS); do
5077 for j in $(seq 1 $NUMFILES); do
5078 file=$TDIR/dir$i/file$j
5079 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5080 error "write data into $file failed"
5084 # $LFS_MIGRATE will fail if hard link migration is unsupported
5085 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5086 createmany -l$TDIR/dir1/file1 $TDIR/dir1/link 200 ||
5087 error "creating links to $TDIR/dir1/file1 failed"
5091 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5094 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
5096 eval $cmd || error "$cmd failed"
5098 check_stripe_count $TDIR/file1 $expected
5100 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5102 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5103 # OST 1 if it is on OST 0. This file is small enough to
5104 # be on only one stripe.
5105 file=$TDIR/migr_1_ost
5106 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5107 error "write data into $file failed"
5108 local obdidx=$($LFS getstripe -i $file)
5109 local oldmd5=$(md5sum $file)
5111 [[ $obdidx -eq 0 ]] && newobdidx=1
5112 cmd="$LFS migrate -i $newobdidx $file"
5114 eval $cmd || error "$cmd failed"
5115 local realobdix=$($LFS getstripe -i $file)
5116 local newmd5=$(md5sum $file)
5117 [[ $newobdidx -ne $realobdix ]] &&
5118 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
5119 [[ "$oldmd5" != "$newmd5" ]] &&
5120 error "md5sum differ: $oldmd5, $newmd5"
5124 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
5126 eval $cmd || error "$cmd failed"
5128 for j in $(seq 1 $NUMFILES); do
5129 check_stripe_count $TDIR/dir1/file$j $expected
5132 # lfs_migrate works with lfs find
5133 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
5134 $LFS_MIGRATE -y -c $expected"
5136 eval $cmd || error "$cmd failed"
5138 for i in $(seq 2 $NUMFILES); do
5139 check_stripe_count $TDIR/file$i $expected
5141 for i in $(seq 2 $NUMDIRS); do
5142 for j in $(seq 1 $NUMFILES); do
5143 check_stripe_count $TDIR/dir$i/file$j $expected
5147 run_test 56w "check lfs_migrate -c stripe_count works"
5150 check_swap_layouts_support && return 0
5151 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5153 local dir0=$DIR/$tdir/$testnum
5156 local ref1=/etc/passwd
5157 local file1=$dir0/file1
5159 $SETSTRIPE -c 2 $file1
5161 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5162 stripe=$($GETSTRIPE -c $file1)
5163 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5164 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5169 run_test 56x "lfs migration support"
5172 check_swap_layouts_support && return 0
5173 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5175 local dir0=$DIR/$tdir/$testnum
5178 local ref1=/etc/passwd
5179 local file1=$dir0/file1
5181 $SETSTRIPE -c 2 $file1
5183 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5184 local stripe=$($GETSTRIPE -c $file1)
5185 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5186 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5191 run_test 56xa "lfs migration --block support"
5194 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5195 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5199 local dir0=$DIR/$tdir/$testnum
5201 local f1=$dir0/file1
5202 local f2=$dir0/file2
5204 touch $f1 || error "creating std file $f1"
5205 $MULTIOP $f2 H2c || error "creating released file $f2"
5207 # a directory can be raid0, so ask only for files
5208 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5209 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5211 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5212 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5214 # only files can be released, so no need to force file search
5215 res=$($LFIND $dir0 -L released)
5216 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5218 res=$($LFIND $dir0 \! -L released)
5219 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5222 run_test 56y "lfs find -L raid0|released"
5224 test_56z() { # LU-4824
5225 # This checks to make sure 'lfs find' continues after errors
5226 # There are two classes of errors that should be caught:
5227 # - If multiple paths are provided, all should be searched even if one
5229 # - If errors are encountered during the search, it should not terminate
5232 test_mkdir $DIR/$tdir
5233 for i in d{0..9}; do
5234 test_mkdir $DIR/$tdir/$i
5236 touch $DIR/$tdir/d{0..9}/$tfile
5237 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5238 error "$LFS find did not return an error"
5239 # Make a directory unsearchable. This should NOT be the last entry in
5240 # directory order. Arbitrarily pick the 6th entry
5241 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5242 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5243 # The user should be able to see 10 directories and 9 files
5244 [ $count == 19 ] || error "$LFS find did not continue after error"
5246 run_test 56z "lfs find should continue after an error"
5248 test_56aa() { # LU-5937
5249 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5252 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5254 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5255 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5257 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5259 run_test 56aa "lfs find --size under striped dir"
5262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5263 # note test will not do anything if MDS is not local
5264 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5265 skip "ldiskfs only test"
5269 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5270 local MNTDEV="osd*.*MDT*.mntdev"
5271 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5272 [ -z "$DEV" ] && error "can't access $MNTDEV"
5273 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5274 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5275 error "can't access $DEV"
5276 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5277 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5281 run_test 57a "verify MDS filesystem created with large inodes =="
5284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5285 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5286 skip "ldiskfs only test"
5290 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5291 local dir=$DIR/$tdir
5295 local FILEN=$dir/f$FILECOUNT
5297 rm -rf $dir || error "removing $dir"
5299 local mdtidx=$($LFS getstripe -M $dir)
5300 local mdtname=MDT$(printf %04x $mdtidx)
5301 local facet=mds$((mdtidx + 1))
5303 echo "mcreating $FILECOUNT files"
5304 createmany -m $dir/f 1 $FILECOUNT || \
5305 error "creating files in $dir"
5307 # verify that files do not have EAs yet
5308 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5309 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5313 df $dir #make sure we get new statfs data
5314 local MDSFREE=$(do_facet $facet \
5315 lctl get_param -n osd*.*$mdtname.kbytesfree)
5316 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5317 echo "opening files to create objects/EAs"
5319 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5320 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5323 # verify that files have EAs now
5324 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5325 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5327 sleep 1 #make sure we get new statfs data
5329 local MDSFREE2=$(do_facet $facet \
5330 lctl get_param -n osd*.*$mdtname.kbytesfree)
5331 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5332 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5333 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5334 error "MDC before $MDCFREE != after $MDCFREE2"
5336 echo "MDC before $MDCFREE != after $MDCFREE2"
5337 echo "unable to confirm if MDS has large inodes"
5342 run_test 57b "default LOV EAs are stored inside large inodes ==="
5345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5346 [ -z "$(which wiretest 2>/dev/null)" ] &&
5347 skip_env "could not find wiretest" && return
5350 run_test 58 "verify cross-platform wire constants =============="
5353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5354 echo "touch 130 files"
5355 createmany -o $DIR/f59- 130
5357 unlinkmany $DIR/f59- 130
5359 # wait for commitment of removal
5360 wait_delete_completed
5362 run_test 59 "verify cancellation of llog records async ========="
5364 TEST60_HEAD="test_60 run $RANDOM"
5366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5367 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5368 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5369 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5370 skip_env "missing subtest run-llog.sh" && return
5372 log "$TEST60_HEAD - from kernel mode"
5373 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5374 do_facet mgs "sh run-llog.sh" || error "run-llog.sh failed"
5375 do_facet mgs $LCTL dk > $TMP/$tfile
5377 # LU-6388: test llog_reader
5378 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5379 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5380 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5381 skip_env "missing llog_reader" && return
5382 local fstype=$(facet_fstype mgs)
5383 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5384 skip_env "Only for ldiskfs or zfs type mgs" && return
5386 local mntpt=$(facet_mntpt mgs)
5387 local mgsdev=$(mgsdevname 1)
5399 #get fid and record list
5400 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5402 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5404 #remount mgs as ldiskfs or zfs type
5405 stop mgs || error "stop mgs failed"
5406 mount_fstype mgs || error "remount mgs failed"
5407 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5410 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5411 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5416 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5418 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5420 echo "obj_file is $obj_file"
5421 do_facet mgs $llog_reader $obj_file
5423 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5424 awk '{ print $3 }' | sed -e "s/^type=//g")
5425 if [ $rec_type != $rec ]; then
5426 echo "FAILED test_60a wrong record type $rec_type," \
5432 #check obj path if record type is LLOG_LOGID_MAGIC
5433 if [ "$rec" == "1064553b" ]; then
5434 path=$(do_facet mgs $llog_reader $obj_file |
5435 grep "path=" | awk '{ print $NF }' |
5436 sed -e "s/^path=//g")
5437 if [ $obj_file != $mntpt/$path ]; then
5438 echo "FAILED test_60a wrong obj path" \
5439 "$montpt/$path, should be $obj_file"
5446 #restart mgs before "error", otherwise it will block the next test
5447 stop mgs || error "stop mgs failed"
5448 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5449 $pass || error "test failed, see FAILED test_60a messages for specifics"
5451 run_test 60a "llog_test run from kernel module and test llog_reader"
5454 # test old logid format
5455 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5456 do_facet mgs $LCTL dl | grep MGS
5457 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5458 error "old llog_print failed"
5461 # test new logid format
5462 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5463 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5464 error "new llog_print failed"
5467 run_test 60aa "llog_print works with FIDs and simple names"
5469 test_60b() { # bug 6411
5470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5472 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5484 [[ $LLOG_COUNT -gt 100 ]] &&
5485 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5487 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5491 echo "create 5000 files"
5492 createmany -o $DIR/f60c- 5000
5493 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5494 lctl set_param fail_loc=0x80000137
5495 unlinkmany $DIR/f60c- 5000
5496 lctl set_param fail_loc=0
5498 run_test 60c "unlink file when mds full"
5501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5502 SAVEPRINTK=$(lctl get_param -n printk)
5504 # verify "lctl mark" is even working"
5505 MESSAGE="test message ID $RANDOM $$"
5506 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5507 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5509 lctl set_param printk=0 || error "set lnet.printk failed"
5510 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5511 MESSAGE="new test message ID $RANDOM $$"
5512 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5513 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5514 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5516 lctl set_param -n printk="$SAVEPRINTK"
5518 run_test 60d "test printk console message masking"
5521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5524 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5525 do_facet mds1 lctl set_param fail_loc=0x15b
5528 run_test 60e "no space while new llog is being created"
5531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5533 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5534 cancel_lru_locks osc
5535 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5538 run_test 61 "mmap() writes don't make sync hang ================"
5540 # bug 2330 - insufficient obd_match error checking causes LBUG
5542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5545 cancel_lru_locks osc
5546 lctl set_param fail_loc=0x405
5547 cat $f && error "cat succeeded, expect -EIO"
5548 lctl set_param fail_loc=0
5550 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5551 # match every page all of the time.
5552 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5554 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5555 # Though this test is irrelevant anymore, it helped to reveal some
5556 # other grant bugs (LU-4482), let's keep it.
5557 test_63a() { # was test_63
5558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5559 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5560 for i in `seq 10` ; do
5561 dd if=/dev/zero of=$DIR/f63 bs=8k &
5567 rm -f $DIR/f63 || true
5569 run_test 63a "Verify oig_wait interruption does not crash ======="
5571 # bug 2248 - async write errors didn't return to application on sync
5572 # bug 3677 - async write errors left page locked
5574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5576 lctl set_param debug=-1
5578 # ensure we have a grant to do async writes
5579 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5582 sync # sync lest earlier test intercept the fail_loc
5584 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5585 lctl set_param fail_loc=0x80000406
5586 $MULTIOP $DIR/$tfile Owy && \
5587 error "sync didn't return ENOMEM"
5588 sync; sleep 2; sync # do a real sync this time to flush page
5589 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5590 error "locked page left in cache after async error" || true
5593 run_test 63b "async write errors should be returned to fsync ==="
5596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5598 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5600 run_test 64a "verify filter grant calculations (in kernel) ====="
5603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5604 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5606 run_test 64b "check out-of-space detection on client"
5609 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5611 run_test 64c "verify grant shrink"
5613 # bug 1414 - set/get directories' stripe info
5615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5616 test_mkdir $DIR/$tdir
5618 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5620 run_test 65a "directory with no stripe info"
5623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5624 test_mkdir $DIR/$tdir
5625 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5627 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5630 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5632 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5636 [ $OSTCOUNT -lt 2 ] && skip "need at least 2 OSTs" && return
5637 test_mkdir $DIR/$tdir
5638 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
5640 $LFS setstripe -S $((stripesize * 4)) -i 1 \
5641 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5643 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5645 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5649 test_mkdir $DIR/$tdir
5650 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5651 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5653 if [[ $STRIPECOUNT -le 0 ]]; then
5655 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5656 #LOV_MAX_STRIPE_COUNT is 2000
5657 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5659 sc=$(($STRIPECOUNT - 1))
5661 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5662 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5663 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5664 error "lverify failed"
5666 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5670 test_mkdir $DIR/$tdir
5672 $SETSTRIPE $DIR/$tdir || error "setstripe"
5673 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5674 error "no stripe info failed"
5676 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5678 run_test 65e "directory setstripe defaults"
5681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5682 test_mkdir $DIR/${tdir}f
5683 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5685 run_test 65f "dir setstripe permission (should return error) ==="
5688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5689 test_mkdir $DIR/$tdir
5690 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5692 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5693 error "setstripe -S failed"
5694 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
5695 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
5696 error "delete default stripe failed"
5698 run_test 65g "directory setstripe -d"
5701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5702 test_mkdir $DIR/$tdir
5703 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5705 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5706 error "setstripe -S failed"
5707 test_mkdir $DIR/$tdir/dd1
5708 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5709 error "stripe info inherit failed"
5711 run_test 65h "directory stripe info inherit ===================="
5713 test_65i() { # bug6367
5714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5715 $SETSTRIPE -S 65536 -c -1 $MOUNT
5717 run_test 65i "set non-default striping on root directory (bug 6367)="
5719 test_65ia() { # bug12836
5720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5721 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5723 run_test 65ia "getstripe on -1 default directory striping"
5725 test_65ib() { # bug12836
5726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5727 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5729 run_test 65ib "getstripe -v on -1 default directory striping"
5731 test_65ic() { # bug12836
5732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5733 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5735 run_test 65ic "new find on -1 default directory striping"
5737 test_65j() { # bug6367
5738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5740 # if we aren't already remounting for each test, do so for this test
5741 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5742 cleanup || error "failed to unmount"
5745 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5747 run_test 65j "set default striping on root directory (bug 6367)="
5749 test_65k() { # bug11679
5750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5751 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5752 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5754 local disable_precreate=true
5755 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
5756 disable_precreate=false
5758 echo "Check OST status: "
5759 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
5760 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
5762 for OSC in $MDS_OSCS; do
5763 echo $OSC "is active"
5764 do_facet $SINGLEMDS lctl --device %$OSC activate
5767 for INACTIVE_OSC in $MDS_OSCS; do
5768 local ost=$(osc_to_ost $INACTIVE_OSC)
5769 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
5770 lov.*md*.target_obd |
5771 awk -F: /$ost/'{ print $1 }' | head -n 1)
5774 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
5775 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
5777 echo "Deactivate: " $INACTIVE_OSC
5778 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5780 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
5781 osp.$ost*MDT0000.create_count")
5782 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
5783 osp.$ost*MDT0000.max_create_count")
5784 $disable_precreate &&
5785 do_facet $SINGLEMDS "lctl set_param -n \
5786 osp.$ost*MDT0000.max_create_count=0"
5788 for idx in $(seq 0 $((OSTCOUNT - 1))); do
5789 [ -f $DIR/$tdir/$idx ] && continue
5790 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
5791 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
5792 error "setstripe $idx should succeed"
5793 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
5795 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
5798 do_facet $SINGLEMDS "lctl set_param -n \
5799 osp.$ost*MDT0000.max_create_count=$max_count"
5800 do_facet $SINGLEMDS "lctl set_param -n \
5801 osp.$ost*MDT0000.create_count=$count"
5802 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5803 echo $INACTIVE_OSC "is Activate"
5805 wait_osc_import_state mds ost$ostnum FULL
5808 run_test 65k "validate manual striping works properly with deactivated OSCs"
5810 test_65l() { # bug 12836
5811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5812 test_mkdir -p $DIR/$tdir/test_dir
5813 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5814 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5816 run_test 65l "lfs find on -1 stripe dir ========================"
5819 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
5822 run_test 65m "normal user can't set filesystem default stripe"
5824 # bug 2543 - update blocks count on client
5826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5828 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5829 sync; sync_all_data; sync; sync_all_data
5830 cancel_lru_locks osc
5831 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5832 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5834 run_test 66 "update inode blocks count on client ==============="
5837 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5841 swapon -s | awk '($1 == "'$1'") { print $4 }'
5844 # bug5265, obdfilter oa2dentry return -ENOENT
5845 # #define OBD_FAIL_SRV_ENOENT 0x217
5847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5848 remote_ost_nodsh && skip "remote OST with nodsh" && return
5851 $SETSTRIPE -c 1 -i 0 $f
5853 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5855 do_facet ost1 lctl set_param fail_loc=0x217
5856 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5857 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5859 do_facet ost1 lctl set_param fail_loc=0
5860 $DIRECTIO write $f 0 2 || error "write error"
5862 cancel_lru_locks osc
5863 $DIRECTIO read $f 0 1 || error "read error"
5865 do_facet ost1 lctl set_param fail_loc=0x217
5866 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5868 do_facet ost1 lctl set_param fail_loc=0
5871 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5874 test_mkdir $DIR/$tdir
5875 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5876 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5878 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5880 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5882 [ "$RUNAS_ID" = "$UID" ] &&
5883 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5885 # Check that testing environment is properly set up. Skip if not
5886 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5887 skip_env "User $RUNAS_ID does not exist - skipping"
5891 chmod 777 $DIR/$tfile
5892 chmod ug+s $DIR/$tfile
5893 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5894 error "$RUNAS dd $DIR/$tfile failed"
5895 # See if we are still setuid/sgid
5896 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5897 error "S/gid is not dropped on write"
5898 # Now test that MDS is updated too
5899 cancel_lru_locks mdc
5900 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5901 error "S/gid is not dropped on MDS"
5904 run_test 72a "Test that remove suid works properly (bug5695) ===="
5906 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5909 [ "$RUNAS_ID" = "$UID" ] && \
5910 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5911 [ "$RUNAS_ID" -eq 0 ] && \
5912 skip_env "RUNAS_ID = 0 -- skipping" && return
5914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5915 # Check that testing environment is properly set up. Skip if not
5916 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5917 skip_env "User $RUNAS_ID does not exist - skipping"
5920 touch $DIR/${tfile}-f{g,u}
5921 test_mkdir $DIR/${tfile}-dg
5922 test_mkdir $DIR/${tfile}-du
5923 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5924 chmod g+s $DIR/${tfile}-{f,d}g
5925 chmod u+s $DIR/${tfile}-{f,d}u
5926 for perm in 777 2777 4777; do
5927 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5928 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5929 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5930 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5934 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5936 # bug 3462 - multiple simultaneous MDC requests
5938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5939 test_mkdir $DIR/d73-1
5940 test_mkdir $DIR/d73-2
5941 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5944 lctl set_param fail_loc=0x80000129
5945 $MULTIOP $DIR/d73-1/f73-2 Oc &
5947 lctl set_param fail_loc=0
5949 $MULTIOP $DIR/d73-2/f73-3 Oc &
5953 wait $pid1 || return 1
5957 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5958 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5959 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5963 run_test 73 "multiple MDC requests (should not deadlock)"
5965 test_74a() { # bug 6149, 6184
5966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5967 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5969 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5970 # will spin in a tight reconnection loop
5972 $LCTL set_param fail_loc=0x8000030e
5973 # get any lock that won't be difficult - lookup works.
5975 $LCTL set_param fail_loc=0
5979 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5981 test_74b() { # bug 13310
5982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5983 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5985 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5986 # will spin in a tight reconnection loop
5987 $LCTL set_param fail_loc=0x8000030e
5988 # get a "difficult" lock
5990 $LCTL set_param fail_loc=0
5994 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5998 #define OBD_FAIL_LDLM_NEW_LOCK
5999 $LCTL set_param fail_loc=0x319
6000 touch $DIR/$tfile && error "touch successful"
6001 $LCTL set_param fail_loc=0
6004 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6007 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6010 get_inode_slab_tunables() {
6011 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
6014 set_inode_slab_tunables() {
6015 echo "lustre_inode_cache $1" > /proc/slabinfo
6018 test_76() { # Now for bug 20433, added originally in bug 1443
6019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6020 local SLAB_SETTINGS=$(get_inode_slab_tunables)
6021 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6022 # we cannot set limit below 1 which means 1 inode in each
6023 # per-cpu cache is still allowed
6024 set_inode_slab_tunables "1 1 0"
6025 cancel_lru_locks osc
6026 BEFORE_INODES=$(num_inodes)
6027 echo "before inodes: $BEFORE_INODES"
6029 [ "$SLOW" = "no" ] && COUNT=100
6030 for i in $(seq $COUNT); do
6034 cancel_lru_locks osc
6035 AFTER_INODES=$(num_inodes)
6036 echo "after inodes: $AFTER_INODES"
6038 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6040 AFTER_INODES=$(num_inodes)
6042 echo "wait $wait seconds inodes: $AFTER_INODES"
6043 if [ $wait -gt 30 ]; then
6044 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6047 set_inode_slab_tunables "$SLAB_SETTINGS"
6049 run_test 76 "confirm clients recycle inodes properly ===="
6055 # Note: in sptlrpc modes which enable its own bulk checksum, the
6056 # original crc32_le bulk checksum will be automatically disabled,
6057 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6058 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6059 # In this case set_checksums() will not be no-op, because sptlrpc
6060 # bulk checksum will be enabled all through the test.
6062 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6063 lctl set_param -n osc.*.checksums $1
6067 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6068 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6069 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6070 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6073 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6074 log "set checksum type to $1"
6077 F77_TMP=$TMP/f77-temp
6080 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6081 error "error writing to $F77_TMP"
6084 test_77a() { # bug 10889
6085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6086 $GSS && skip "could not run with gss" && return
6087 [ ! -f $F77_TMP ] && setup_f77
6089 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6093 run_test 77a "normal checksum read/write operation"
6095 test_77b() { # bug 10889
6096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6097 $GSS && skip "could not run with gss" && return
6098 [ ! -f $F77_TMP ] && setup_f77
6099 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6100 $LCTL set_param fail_loc=0x80000409
6103 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6104 error "dd error: $?"
6105 $LCTL set_param fail_loc=0
6107 for algo in $CKSUM_TYPES; do
6108 cancel_lru_locks osc
6109 set_checksum_type $algo
6110 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6111 $LCTL set_param fail_loc=0x80000408
6112 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6113 $LCTL set_param fail_loc=0
6116 set_checksum_type $ORIG_CSUM_TYPE
6119 run_test 77b "checksum error on client write, read"
6124 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6126 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6127 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6128 $check_ost && [ -n $ost_file_prefix ] &&
6129 do_facet ost1 rm -f ${ost_file_prefix}\*
6133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6134 $GSS && skip "could not run with gss" && return
6137 local osc_file_prefix
6139 local check_ost=false
6140 local ost_file_prefix
6146 # ensure corruption will occur on first OSS/OST
6147 $LFS setstripe -i 0 $DIR/$tfile
6149 [ ! -f $F77_TMP ] && setup_f77
6150 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6151 error "dd write error: $?"
6152 fid=$($LFS path2fid $DIR/$tfile)
6154 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6157 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6158 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6160 echo "OSS do not support bulk pages dump upon error"
6163 osc_file_prefix=$($LCTL get_param -n debug_path)
6164 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6166 trap cleanup_77c EXIT
6169 # enable bulk pages dump upon error on Client
6170 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6171 # enable bulk pages dump upon error on OSS
6173 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6175 # flush Client cache to allow next read to reach OSS
6176 cancel_lru_locks osc
6178 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6179 $LCTL set_param fail_loc=0x80000408
6180 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6181 $LCTL set_param fail_loc=0
6185 # check cksum dump on Client
6186 osc_file=$(ls ${osc_file_prefix}*)
6187 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6188 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6189 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6190 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6191 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6193 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6194 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6195 error "dump content does not match on Client"
6197 $check_ost || skip "No need to check cksum dump on OSS"
6199 # check cksum dump on OSS
6200 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6201 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6202 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6203 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6204 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6205 error "dump content does not match on OSS"
6209 run_test 77c "checksum error on client read with debug"
6211 test_77d() { # bug 10889
6212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6213 $GSS && skip "could not run with gss" && return
6214 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6215 $LCTL set_param fail_loc=0x80000409
6217 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6218 error "direct write: rc=$?"
6219 $LCTL set_param fail_loc=0
6222 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6223 $LCTL set_param fail_loc=0x80000408
6225 cancel_lru_locks osc
6226 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6227 error "direct read: rc=$?"
6228 $LCTL set_param fail_loc=0
6231 run_test 77d "checksum error on OST direct write, read"
6233 test_77f() { # bug 10889
6234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6235 $GSS && skip "could not run with gss" && return
6237 for algo in $CKSUM_TYPES; do
6238 cancel_lru_locks osc
6239 set_checksum_type $algo
6240 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6241 $LCTL set_param fail_loc=0x409
6242 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6243 error "direct write succeeded"
6244 $LCTL set_param fail_loc=0
6246 set_checksum_type $ORIG_CSUM_TYPE
6249 run_test 77f "repeat checksum error on write (expect error)"
6251 test_77g() { # bug 10889
6252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6253 $GSS && skip "could not run with gss" && return
6254 remote_ost_nodsh && skip "remote OST with nodsh" && return
6256 [ ! -f $F77_TMP ] && setup_f77
6258 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6259 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6260 do_facet ost1 lctl set_param fail_loc=0x8000021a
6262 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6263 error "write error: rc=$?"
6264 do_facet ost1 lctl set_param fail_loc=0
6267 cancel_lru_locks osc
6268 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6269 do_facet ost1 lctl set_param fail_loc=0x8000021b
6271 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6272 do_facet ost1 lctl set_param fail_loc=0
6275 run_test 77g "checksum error on OST write, read"
6277 test_77j() { # bug 13805
6278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6279 $GSS && skip "could not run with gss" && return
6280 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6281 lctl set_param fail_loc=0x40c
6282 remount_client $MOUNT
6283 lctl set_param fail_loc=0
6284 # wait async osc connect to finish and reflect updated state value
6286 for (( i=0; i < OSTCOUNT; i++ )) ; do
6287 wait_osc_import_state client ost$((i+1)) FULL
6290 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6291 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6292 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6293 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6295 remount_client $MOUNT
6297 run_test 77j "client only supporting ADLER32"
6299 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6308 test_78() { # bug 10901
6309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6310 remote_ost || { skip_env "local OST" && return; }
6313 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6314 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6315 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6316 echo "MemTotal: $MEMTOTAL"
6318 # reserve 256MB of memory for the kernel and other running processes,
6319 # and then take 1/2 of the remaining memory for the read/write buffers.
6320 if [ $MEMTOTAL -gt 512 ] ;then
6321 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6323 # for those poor memory-starved high-end clusters...
6324 MEMTOTAL=$((MEMTOTAL / 2))
6326 echo "Mem to use for directio: $MEMTOTAL"
6328 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6329 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6330 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6331 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6333 echo "Smallest OST: $SMALLESTOST"
6334 [[ $SMALLESTOST -lt 10240 ]] &&
6335 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6337 trap cleanup_test_78 EXIT
6339 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6340 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6342 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6343 echo "File size: $F78SIZE"
6344 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6345 for i in $(seq 1 $NSEQ); do
6346 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6347 echo directIO rdwr round $i of $NSEQ
6348 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6353 run_test 78 "handle large O_DIRECT writes correctly ============"
6355 test_79() { # bug 12743
6356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6357 wait_delete_completed
6359 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6360 BKFREE=$(calc_osc_kbytes kbytesfree)
6361 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6363 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6364 DFTOTAL=`echo $STRING | cut -d, -f1`
6365 DFUSED=`echo $STRING | cut -d, -f2`
6366 DFAVAIL=`echo $STRING | cut -d, -f3`
6367 DFFREE=$(($DFTOTAL - $DFUSED))
6369 ALLOWANCE=$((64 * $OSTCOUNT))
6371 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6372 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6373 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6375 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6376 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6377 error "df free($DFFREE) mismatch OST free($BKFREE)"
6379 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6380 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6381 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6384 run_test 79 "df report consistency check ======================="
6386 test_80() { # bug 10718
6387 remote_ost_nodsh && skip "remote OST with nodsh" && return
6388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6389 # relax strong synchronous semantics for slow backends like ZFS
6390 local soc="obdfilter.*.sync_on_lock_cancel"
6391 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6393 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6394 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6395 facet_active_host $host; done | sort -u)
6396 do_nodes $hosts lctl set_param $soc=never
6399 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6401 local BEFORE=`date +%s`
6402 cancel_lru_locks osc
6403 local AFTER=`date +%s`
6404 local DIFF=$((AFTER-BEFORE))
6405 if [ $DIFF -gt 1 ] ; then
6406 error "elapsed for 1M@1T = $DIFF"
6409 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6413 run_test 80 "Page eviction is equally fast at high offsets too ===="
6415 test_81a() { # LU-456
6416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6417 remote_ost_nodsh && skip "remote OST with nodsh" && return
6418 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6419 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6420 do_facet ost1 lctl set_param fail_loc=0x80000228
6422 # write should trigger a retry and success
6423 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6424 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6426 if [ $RC -ne 0 ] ; then
6427 error "write should success, but failed for $RC"
6430 run_test 81a "OST should retry write when get -ENOSPC ==============="
6432 test_81b() { # LU-456
6433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6434 remote_ost_nodsh && skip "remote OST with nodsh" && return
6435 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6436 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6437 do_facet ost1 lctl set_param fail_loc=0x228
6439 # write should retry several times and return -ENOSPC finally
6440 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6441 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6444 if [ $RC -ne $ENOSPC ] ; then
6445 error "dd should fail for -ENOSPC, but succeed."
6448 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6450 test_82() { # LU-1031
6451 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6455 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6457 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6459 kill -USR1 $MULTIPID2
6461 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6462 error "First grouplock does not block second one"
6464 echo "Second grouplock blocks first one"
6466 kill -USR1 $MULTIPID1
6470 run_test 82 "Basic grouplock test"
6473 local sfile="/boot/System.map-$(uname -r)"
6474 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6475 $LCTL set_param fail_loc=0x140d
6476 cp $sfile $DIR/$tfile || error "write failed"
6477 diff -c $sfile $DIR/$tfile || error "files are different"
6478 $LCTL set_param fail_loc=0
6481 run_test 83 "Short write in ptask ==============================="
6484 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6486 test_mkdir $DIR/$tdir.cvsroot
6487 chown $RUNAS_ID $DIR/$tdir.cvsroot
6490 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
6493 # some versions of cvs import exit(1) when asked to import links or
6494 # files they can't read. ignore those files.
6495 local toignore=$(find . -type l -printf '-I %f\n' -o \
6496 ! -perm /4 -printf '-I %f\n')
6497 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
6498 $tdir.reposname vtag rtag
6501 test_mkdir $DIR/$tdir.reposname
6502 chown $RUNAS_ID $DIR/$tdir.reposname
6503 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
6505 cd $DIR/$tdir.reposname
6507 $RUNAS cvs add -m 'addmsg' foo99
6509 $RUNAS cvs commit -m 'nomsg' foo99
6510 rm -fr $DIR/$tdir.cvsroot
6512 run_test 99 "cvs strange file/directory operations"
6515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6516 [[ "$NETTYPE" =~ tcp ]] ||
6517 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
6520 remote_ost_nodsh && skip "remote OST with nodsh" && return
6521 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6523 { skip "useless for local single node setup" && return; }
6525 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6526 [ "$PROT" != "tcp" ] && continue
6527 RPORT=$(echo $REMOTE | cut -d: -f2)
6528 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6531 LPORT=`echo $LOCAL | cut -d: -f2`
6532 if [ $LPORT -ge 1024 ]; then
6533 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6535 error_exit "local: $LPORT > 1024, remote: $RPORT"
6538 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6540 run_test 100 "check local port using privileged port ==========="
6542 function get_named_value()
6551 echo $line | sed "s/^$tag[ ]*//"
6558 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6559 awk '/^max_cached_mb/ { print $2 }')
6562 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6568 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
6572 local cache_limit=32
6574 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6575 trap cleanup_101a EXIT
6576 $LCTL set_param -n llite.*.read_ahead_stats 0
6577 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6580 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6582 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6583 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6586 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6587 get_named_value 'read but discarded' | cut -d" " -f1); do
6588 discard=$(($discard + $s))
6592 if [[ $(($discard * 10)) -gt $nreads ]]; then
6593 $LCTL get_param osc.*-osc*.rpc_stats
6594 $LCTL get_param llite.*.read_ahead_stats
6595 error "too many ($discard) discarded pages"
6597 rm -f $DIR/$tfile || true
6599 run_test 101a "check read-ahead for random reads"
6602 test_mkdir $DIR/$tdir
6603 local STRIPE_SIZE=$1
6604 local FILE_LENGTH=$2
6607 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6609 local list=$(comma_list $(osts_nodes))
6610 set_osd_param $list '' read_cache_enable 0
6611 set_osd_param $list '' writethrough_cache_enable 0
6613 trap cleanup_test101bc EXIT
6614 # prepare the read-ahead file
6615 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6617 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6618 count=$FILE_SIZE_MB 2> /dev/null
6622 cleanup_test101bc() {
6627 local list=$(comma_list $(osts_nodes))
6628 set_osd_param $list '' read_cache_enable 1
6629 set_osd_param $list '' writethrough_cache_enable 1
6633 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6638 local STRIPE_SIZE=$2
6639 local FILE_LENGTH=$3
6640 local RA_INC=1048576
6641 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6642 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6643 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6644 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6645 get_named_value 'read but discarded' |
6646 cut -d" " -f1 | calc_total)
6647 if [[ $DISCARD -gt $discard_limit ]]; then
6648 $LCTL get_param llite.*.read_ahead_stats
6649 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6651 echo "Read-ahead success for size ${READ_SIZE}"
6656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6657 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6658 local STRIPE_SIZE=1048576
6659 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6660 if [ $SLOW == "yes" ]; then
6661 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6663 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6666 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6668 # prepare the read-ahead file
6669 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6670 cancel_lru_locks osc
6671 for BIDX in 2 4 8 16 32 64 128 256
6673 local BSIZE=$((BIDX*4096))
6674 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6675 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6676 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6677 $LCTL set_param -n llite.*.read_ahead_stats 0
6678 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6679 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6680 cancel_lru_locks osc
6681 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6686 run_test 101b "check stride-io mode read-ahead ================="
6689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6690 local STRIPE_SIZE=1048576
6691 local FILE_LENGTH=$((STRIPE_SIZE*100))
6695 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6697 cancel_lru_locks osc
6698 $LCTL set_param osc.*.rpc_stats 0
6699 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6700 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6701 local stats=$($LCTL get_param -n $osc_rpc_stats)
6702 local lines=$(echo "$stats" | awk 'END {print NR;}')
6705 if [ $lines -le 20 ]; then
6708 for size in 1 2 4 8; do
6709 local rpc=$(echo "$stats" |
6710 awk '($1 == "'$size':") {print $2; exit; }')
6712 error "Small $((size*4))k read IO $rpc !"
6714 echo "$osc_rpc_stats check passed!"
6719 run_test 101c "check stripe_size aligned read-ahead ================="
6722 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6723 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6728 local file=$DIR/$tfile
6729 local sz_MB=${FILESIZE_101d:-500}
6730 local ra_MB=${READAHEAD_MB:-40}
6732 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6733 [ $free_MB -lt $sz_MB ] &&
6734 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6736 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6737 $SETSTRIPE -c -1 $file || error "setstripe failed"
6739 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6740 echo Cancel LRU locks on lustre client to flush the client cache
6741 cancel_lru_locks osc
6743 echo Disable read-ahead
6744 local old_READAHEAD=$(set_read_ahead 0)
6746 echo Reading the test file $file with read-ahead disabled
6747 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6749 echo Cancel LRU locks on lustre client to flush the client cache
6750 cancel_lru_locks osc
6751 echo Enable read-ahead with ${ra_MB}MB
6752 set_read_ahead $ra_MB
6754 echo Reading the test file $file with read-ahead enabled
6755 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6757 echo "read-ahead disabled time read $raOFF"
6758 echo "read-ahead enabled time read $raON"
6760 set_read_ahead $old_READAHEAD
6762 wait_delete_completed
6764 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6765 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6767 run_test 101d "file read with and without read-ahead enabled"
6770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6771 local file=$DIR/$tfile
6772 local size_KB=500 #KB
6776 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6777 local need_KB=$((count * size_KB))
6778 [[ $free_KB -le $need_KB ]] &&
6779 skip_env "Need free space $need_KB, have $free_KB" && return
6781 echo "Creating $count ${size_KB}K test files"
6782 for ((i = 0; i < $count; i++)); do
6783 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6786 echo "Cancel LRU locks on lustre client to flush the client cache"
6787 cancel_lru_locks osc
6789 echo "Reset readahead stats"
6790 $LCTL set_param -n llite.*.read_ahead_stats 0
6792 for ((i = 0; i < $count; i++)); do
6793 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6796 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6797 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6799 for ((i = 0; i < $count; i++)); do
6800 rm -rf $file.$i 2>/dev/null
6803 #10000 means 20% reads are missing in readahead
6804 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6806 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6809 which iozone || { skip "no iozone installed" && return; }
6811 local old_debug=$($LCTL get_param debug)
6812 old_debug=${old_debug#*=}
6813 $LCTL set_param debug="reada mmap"
6815 # create a test file
6816 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
6818 echo Cancel LRU locks on lustre client to flush the client cache
6819 cancel_lru_locks osc
6821 echo Reset readahead stats
6822 $LCTL set_param -n llite.*.read_ahead_stats 0
6824 echo mmap read the file with small block size
6825 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
6828 echo checking missing pages
6829 $LCTL get_param llite.*.read_ahead_stats
6830 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6831 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6833 $LCTL set_param debug="$old_debug"
6834 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
6837 run_test 101f "check mmap read performance"
6839 test_101g_brw_size_test() {
6841 local pages=$((mb * 1048576 / $(page_size)))
6843 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
6844 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
6845 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
6846 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
6850 $LCTL set_param -n osc.*.rpc_stats=0
6852 # 10 RPCs should be enough for the test
6854 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
6855 { error "dd write ${mb} MB blocks failed"; return 3; }
6856 cancel_lru_locks osc
6857 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
6858 { error "dd write ${mb} MB blocks failed"; return 4; }
6860 # calculate number of full-sized read and write RPCs
6861 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
6862 sed -n '/pages per rpc/,/^$/p' |
6863 awk '/'$pages':/ { reads += $2; writes += $6 }; \
6864 END { print reads,writes }'))
6865 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
6867 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
6875 local osts=$(get_facets OST)
6876 local list=$(comma_list $(osts_nodes))
6877 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
6878 local brw_size="obdfilter.*.brw_size"
6880 $LFS setstripe -i 0 -c 1 $DIR/$tfile
6882 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
6883 if [ $(lustre_version_code ost1) -ge $(version_code 2.8.52) -a \
6884 $(lustre_version_code client) -ge $(version_code 2.8.52) ]; then
6885 [ $(lustre_version_code ost1) -ge $(version_code 2.9.52) ] &&
6887 if [[ $orig_mb -lt 16 ]]; then
6888 save_lustre_params $osts "$brw_size" > $p
6889 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
6890 error "set 16MB RPC size failed"
6892 echo "remount client to enable new RPC size"
6893 remount_client $MOUNT || error "remount_client failed"
6896 test_101g_brw_size_test 16 || error "16MB RPC test failed"
6897 # should be able to set brw_size=12, but no rpc_stats for that
6898 test_101g_brw_size_test 8 || error "8MB RPC test failed"
6901 test_101g_brw_size_test 4 || error "4MB RPC test failed"
6903 if [[ $orig_mb -lt 16 ]]; then
6904 restore_lustre_params < $p
6905 remount_client $MOUNT || error "remount_client restore failed"
6908 rm -f $p $DIR/$tfile
6910 run_test 101g "Big bulk(4/16 MiB) readahead"
6913 test_mkdir $DIR/$tdir
6914 chown $RUNAS_ID $DIR/$tdir
6917 STRIPE_COUNT=$OSTCOUNT
6918 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6920 trap cleanup_test102 EXIT
6922 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6924 for num in 1 2 3 4; do
6925 for count in $(seq 1 $STRIPE_COUNT); do
6926 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6927 local size=`expr $STRIPE_SIZE \* $num`
6928 local file=file"$num-$idx-$count"
6929 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6935 $1 tar cf $TMP/f102.tar $tdir --xattrs
6941 rm -rf $DIR/d0.sanity/d102
6945 local testfile=$DIR/$tfile
6949 [ "$UID" != 0 ] && skip_env "must run as root" && return
6950 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6951 skip_env "must have user_xattr" && return
6953 [ -z "$(which setfattr 2>/dev/null)" ] &&
6954 skip_env "could not find setfattr" && return
6956 echo "set/get xattr..."
6957 setfattr -n trusted.name1 -v value1 $testfile ||
6958 error "setfattr -n trusted.name1=value1 $testfile failed"
6959 getfattr -n trusted.name1 $testfile 2> /dev/null |
6960 grep "trusted.name1=.value1" ||
6961 error "$testfile missing trusted.name1=value1"
6963 setfattr -n user.author1 -v author1 $testfile ||
6964 error "setfattr -n user.author1=author1 $testfile failed"
6965 getfattr -n user.author1 $testfile 2> /dev/null |
6966 grep "user.author1=.author1" ||
6967 error "$testfile missing trusted.author1=author1"
6970 setfattr -n trusted.name2 -v value2 $testfile ||
6971 error "$testfile unable to set trusted.name2"
6972 setfattr -n trusted.name3 -v value3 $testfile ||
6973 error "$testfile unable to set trusted.name3"
6974 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6975 grep "trusted.name" | wc -l) -eq 3 ] ||
6976 error "$testfile missing 3 trusted.name xattrs"
6978 setfattr -n user.author2 -v author2 $testfile ||
6979 error "$testfile unable to set user.author2"
6980 setfattr -n user.author3 -v author3 $testfile ||
6981 error "$testfile unable to set user.author3"
6982 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6983 grep "user.author" | wc -l) -eq 3 ] ||
6984 error "$testfile missing 3 user.author xattrs"
6986 echo "remove xattr..."
6987 setfattr -x trusted.name1 $testfile ||
6988 error "$testfile error deleting trusted.name1"
6989 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6990 error "$testfile did not delete trusted.name1 xattr"
6992 setfattr -x user.author1 $testfile ||
6993 error "$testfile error deleting user.author1"
6994 echo "set lustre special xattr ..."
6995 $LFS setstripe -c1 $testfile
6996 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
6997 awk -F "=" '/trusted.lov/ { print $2 }' )
6998 setfattr -n "trusted.lov" -v $lovea $testfile ||
6999 error "$testfile doesn't ignore setting trusted.lov again"
7000 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7001 error "$testfile allow setting invalid trusted.lov"
7004 run_test 102a "user xattr test =================================="
7007 [ -z "$(which setfattr 2>/dev/null)" ] &&
7008 skip_env "could not find setfattr" && return
7010 # b10930: get/set/list trusted.lov xattr
7011 echo "get/set/list trusted.lov xattr ..."
7012 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7013 local testfile=$DIR/$tfile
7014 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7015 error "setstripe failed"
7016 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7017 error "getstripe failed"
7018 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7019 error "can't get trusted.lov from $testfile"
7021 local testfile2=${testfile}2
7022 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7023 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7026 setfattr -n trusted.lov -v $value $testfile2
7027 local stripe_size=$($GETSTRIPE -S $testfile2)
7028 local stripe_count=$($GETSTRIPE -c $testfile2)
7029 [[ $stripe_size -eq 65536 ]] ||
7030 error "stripe size $stripe_size != 65536"
7031 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7032 error "stripe count $stripe_count != $STRIPECOUNT"
7035 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7038 [ -z "$(which setfattr 2>/dev/null)" ] &&
7039 skip_env "could not find setfattr" && return
7041 # b10930: get/set/list lustre.lov xattr
7042 echo "get/set/list lustre.lov xattr ..."
7043 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7044 test_mkdir $DIR/$tdir
7045 chown $RUNAS_ID $DIR/$tdir
7046 local testfile=$DIR/$tdir/$tfile
7047 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7048 error "setstripe failed"
7049 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7050 error "getstripe failed"
7051 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7052 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7054 local testfile2=${testfile}2
7055 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7056 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7058 $RUNAS $MCREATE $testfile2
7059 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7060 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7061 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7062 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7063 [ $stripe_count -eq $STRIPECOUNT ] ||
7064 error "stripe count $stripe_count != $STRIPECOUNT"
7066 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7068 compare_stripe_info1() {
7069 local stripe_index_all_zero=true
7071 for num in 1 2 3 4; do
7072 for count in $(seq 1 $STRIPE_COUNT); do
7073 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7074 local size=$((STRIPE_SIZE * num))
7075 local file=file"$num-$offset-$count"
7076 stripe_size=$($LFS getstripe -S $PWD/$file)
7077 [[ $stripe_size -ne $size ]] &&
7078 error "$file: size $stripe_size != $size"
7079 stripe_count=$($LFS getstripe -c $PWD/$file)
7080 # allow fewer stripes to be created, ORI-601
7081 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7082 error "$file: count $stripe_count != $count"
7083 stripe_index=$($LFS getstripe -i $PWD/$file)
7084 [[ $stripe_index -ne 0 ]] &&
7085 stripe_index_all_zero=false
7089 $stripe_index_all_zero &&
7090 error "all files are being extracted starting from OST index 0"
7094 have_xattrs_include() {
7095 tar --help | grep -q xattrs-include &&
7096 echo --xattrs-include="lustre.*"
7100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7101 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7102 XINC=$(have_xattrs_include)
7104 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7106 compare_stripe_info1
7108 run_test 102d "tar restore stripe info from tarfile,not keep osts"
7111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7112 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7113 XINC=$(have_xattrs_include)
7115 test_mkdir $DIR/$tdir.restore
7117 tar cf - --xattrs $tdir | tar xf - \
7118 -C $DIR/$tdir.restore --xattrs $XINC
7119 cd $DIR/$tdir.restore/$tdir
7120 compare_stripe_info1
7122 run_test 102f "tar copy files, not keep osts"
7125 local xsize=${1:-1024} # in bytes
7126 local file=$DIR/$tfile
7128 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7129 skip "must have user_xattr" && return 0
7130 [ -z "$(which setfattr 2>/dev/null)" ] &&
7131 skip_env "could not find setfattr" && return 0
7132 [ -z "$(which getfattr 2>/dev/null)" ] &&
7133 skip_env "could not find getfattr" && return 0
7137 local value="$(generate_string $xsize)"
7139 local xbig=trusted.big
7140 log "save $xbig on $file"
7141 setfattr -n $xbig -v $value $file ||
7142 error "saving $xbig on $file failed"
7144 local orig=$(get_xattr_value $xbig $file)
7145 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7147 local xsml=trusted.sml
7148 log "save $xsml on $file"
7149 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7151 local new=$(get_xattr_value $xbig $file)
7152 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7154 log "grow $xsml on $file"
7155 setfattr -n $xsml -v "$value" $file ||
7156 error "growing $xsml on $file failed"
7158 new=$(get_xattr_value $xbig $file)
7159 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7160 log "$xbig still valid after growing $xsml"
7165 test_102h() { # bug 15777
7168 run_test 102h "grow xattr from inside inode to external block"
7171 large_xattr_enabled || { skip "large_xattr disabled" && return; }
7172 grow_xattr $(max_xattr_size)
7174 run_test 102ha "grow xattr from inside inode to external inode"
7176 test_102i() { # bug 17038
7177 [ -z "$(which getfattr 2>/dev/null)" ] &&
7178 skip "could not find getfattr" && return
7180 ln -s $DIR/$tfile $DIR/${tfile}link
7181 getfattr -n trusted.lov $DIR/$tfile ||
7182 error "lgetxattr on $DIR/$tfile failed"
7183 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7184 grep -i "no such attr" ||
7185 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7186 rm -f $DIR/$tfile $DIR/${tfile}link
7188 run_test 102i "lgetxattr test on symbolic link ============"
7191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7192 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7193 XINC=$(have_xattrs_include)
7194 setup_test102 "$RUNAS"
7195 chown $RUNAS_ID $DIR/$tdir
7196 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7198 compare_stripe_info1 "$RUNAS"
7200 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7203 [ -z "$(which setfattr 2>/dev/null)" ] &&
7204 skip "could not find setfattr" && return
7206 # b22187 just check that does not crash for regular file.
7207 setfattr -n trusted.lov $DIR/$tfile
7208 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
7209 local test_kdir=$DIR/$tdir
7210 test_mkdir $test_kdir
7211 local default_size=$($LFS getstripe -S $test_kdir)
7212 local default_count=$($LFS getstripe -c $test_kdir)
7213 local default_offset=$($LFS getstripe -i $test_kdir)
7214 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7215 error 'dir setstripe failed'
7216 setfattr -n trusted.lov $test_kdir
7217 local stripe_size=$($LFS getstripe -S $test_kdir)
7218 local stripe_count=$($LFS getstripe -c $test_kdir)
7219 local stripe_offset=$($LFS getstripe -i $test_kdir)
7220 [ $stripe_size -eq $default_size ] ||
7221 error "stripe size $stripe_size != $default_size"
7222 [ $stripe_count -eq $default_count ] ||
7223 error "stripe count $stripe_count != $default_count"
7224 [ $stripe_offset -eq $default_offset ] ||
7225 error "stripe offset $stripe_offset != $default_offset"
7226 rm -rf $DIR/$tfile $test_kdir
7228 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7231 [ -z "$(which getfattr 2>/dev/null)" ] &&
7232 skip "could not find getfattr" && return
7234 # LU-532 trusted. xattr is invisible to non-root
7235 local testfile=$DIR/$tfile
7239 echo "listxattr as user..."
7240 chown $RUNAS_ID $testfile
7241 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7242 grep -q "trusted" &&
7243 error "$testfile trusted xattrs are user visible"
7247 run_test 102l "listxattr size test =================================="
7249 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7250 local path=$DIR/$tfile
7253 listxattr_size_check $path || error "listattr_size_check $path failed"
7255 run_test 102m "Ensure listxattr fails on small bufffer ========"
7259 getxattr() { # getxattr path name
7260 # Return the base64 encoding of the value of xattr name on path.
7264 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7266 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7268 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7270 getfattr --absolute-names --encoding=base64 --name=$name $path |
7271 awk -F= -v name=$name '$1 == name {
7272 print substr($0, index($0, "=") + 1);
7276 test_102n() { # LU-4101 mdt: protect internal xattrs
7277 [ -z "$(which setfattr 2>/dev/null)" ] &&
7278 skip "could not find setfattr" && return
7279 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7281 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7285 local file0=$DIR/$tfile.0
7286 local file1=$DIR/$tfile.1
7287 local xattr0=$TMP/$tfile.0
7288 local xattr1=$TMP/$tfile.1
7289 local namelist="lov lma lmv link fid version som hsm"
7293 rm -rf $file0 $file1 $xattr0 $xattr1
7296 # Get 'before' xattrs of $file1.
7297 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7299 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7300 namelist+=" lfsck_namespace"
7301 for name in $namelist; do
7302 # Try to copy xattr from $file0 to $file1.
7303 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7305 setfattr --name=trusted.$name --value="$value" $file1 ||
7306 error "setxattr 'trusted.$name' failed"
7308 # Try to set a garbage xattr.
7309 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7311 if [[ x$name == "xlov" ]]; then
7312 setfattr --name=trusted.lov --value="$value" $file1 &&
7313 error "setxattr invalid 'trusted.lov' success"
7315 setfattr --name=trusted.$name --value="$value" $file1 ||
7316 error "setxattr invalid 'trusted.$name' failed"
7319 # Try to remove the xattr from $file1. We don't care if this
7320 # appears to succeed or fail, we just don't want there to be
7321 # any changes or crashes.
7322 setfattr --remove=$trusted.$name $file1 2> /dev/null
7325 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7328 # Try to copy xattr from $file0 to $file1.
7329 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7331 setfattr --name=trusted.$name --value="$value" $file1 ||
7332 error "setxattr 'trusted.$name' failed"
7334 # Try to set a garbage xattr.
7335 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7337 setfattr --name=trusted.$name --value="$value" $file1 ||
7338 error "setxattr 'trusted.$name' failed"
7340 # Try to remove the xattr from $file1. We don't care if this
7341 # appears to succeed or fail, we just don't want there to be
7342 # any changes or crashes.
7343 setfattr --remove=$trusted.$name $file1 2> /dev/null
7346 # Get 'after' xattrs of file1.
7347 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7349 if ! diff $xattr0 $xattr1; then
7350 error "before and after xattrs of '$file1' differ"
7353 rm -rf $file0 $file1 $xattr0 $xattr1
7357 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7359 test_102p() { # LU-4703 setxattr did not check ownership
7360 local testfile=$DIR/$tfile
7362 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7363 skip "MDS needs to be at least 2.5.56" && return
7367 echo "setfacl as user..."
7368 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7369 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7371 echo "setfattr as user..."
7372 setfacl -m "u:$RUNAS_ID:---" $testfile
7373 $RUNAS setfattr -x system.posix_acl_access $testfile
7374 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7376 run_test 102p "check setxattr(2) correctly fails without permission"
7379 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7380 skip "MDS needs to be at least 2.6.92" && return
7381 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7383 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7386 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7387 skip "MDS needs to be at least 2.6.93" && return
7388 touch $DIR/$tfile || error "touch"
7389 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7390 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7391 rm $DIR/$tfile || error "rm"
7394 mkdir -p $DIR/$tdir || error "mkdir"
7395 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7396 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7397 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7398 error "$testfile error deleting user.author1"
7399 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7400 grep "user.$(basename $tdir)" &&
7401 error "$tdir did not delete user.$(basename $tdir)"
7402 rmdir $DIR/$tdir || error "rmdir"
7405 test_mkdir $DIR/$tdir
7406 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7407 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7408 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7409 error "$testfile error deleting user.author1"
7410 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7411 grep "user.$(basename $tdir)" &&
7412 error "$tdir did not delete user.$(basename $tdir)"
7413 rmdir $DIR/$tdir || error "rm striped dir"
7415 run_test 102r "set EAs with empty values"
7419 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7424 [ "$UID" != 0 ] && skip_env "must run as root" && return
7425 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7426 skip "must have acl enabled" && return
7427 [ -z "$(which setfacl 2>/dev/null)" ] &&
7428 skip_env "could not find setfacl" && return
7429 $GSS && skip "could not run under gss" && return
7430 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7432 gpasswd -a daemon bin # LU-5641
7433 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7435 declare -a identity_old
7437 for num in $(seq $MDSCOUNT); do
7438 switch_identity $num true || identity_old[$num]=$?
7446 echo "performing cp ..."
7447 run_acl_subtest cp || error "run_acl_subtest cp failed"
7448 echo "performing getfacl-noacl..."
7449 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7450 echo "performing misc..."
7451 run_acl_subtest misc || error "misc test failed"
7452 echo "performing permissions..."
7453 run_acl_subtest permissions || error "permissions failed"
7454 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7455 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7456 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7457 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7459 echo "performing permissions xattr..."
7460 run_acl_subtest permissions_xattr ||
7461 error "permissions_xattr failed"
7463 echo "performing setfacl..."
7464 run_acl_subtest setfacl || error "setfacl test failed"
7466 # inheritance test got from HP
7467 echo "performing inheritance..."
7468 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7469 chmod +x make-tree || error "chmod +x failed"
7470 run_acl_subtest inheritance || error "inheritance test failed"
7473 echo "LU-974 ignore umask when acl is enabled..."
7474 run_acl_subtest 974 || error "LU-974 umask test failed"
7475 if [ $MDSCOUNT -ge 2 ]; then
7476 run_acl_subtest 974_remote ||
7477 error "LU-974 umask test failed under remote dir"
7480 echo "LU-2561 newly created file is same size as directory..."
7481 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7482 run_acl_subtest 2561 || error "LU-2561 test failed"
7484 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7487 run_acl_subtest 4924 || error "LU-4924 test failed"
7492 for num in $(seq $MDSCOUNT); do
7493 if [ "${identity_old[$num]}" = 1 ]; then
7494 switch_identity $num false || identity_old[$num]=$?
7498 run_test 103a "acl test ========================================="
7502 cp -rp $DIR/$tdir $DIR/$tdir.bak
7504 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7505 error "$DIR/$tdir shouldn't contain default ACL"
7506 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7507 error "$DIR/$tdir.bak shouldn't contain default ACL"
7510 run_test 103c "'cp -rp' won't set empty acl"
7513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7515 lfs df || error "lfs df failed"
7516 lfs df -ih || error "lfs df -ih failed"
7517 lfs df -h $DIR || error "lfs df -h $DIR failed"
7518 lfs df -i $DIR || error "lfs df -i $DIR failed"
7519 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7520 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7522 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7523 lctl --device %$OSC deactivate
7524 lfs df || error "lfs df with deactivated OSC failed"
7525 lctl --device %$OSC activate
7526 # wait the osc back to normal
7527 wait_osc_import_state client ost FULL
7529 lfs df || error "lfs df with reactivated OSC failed"
7532 run_test 104a "lfs df [-ih] [path] test ========================="
7535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7536 [ $RUNAS_ID -eq $UID ] &&
7537 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7539 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7540 grep "Permission denied" | wc -l)))
7541 if [ $denied_cnt -ne 0 ]; then
7542 error "lfs check servers test failed"
7545 run_test 104b "$RUNAS lfs check servers test ===================="
7548 # doesn't work on 2.4 kernels
7550 if $(flock_is_enabled); then
7551 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7553 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7557 run_test 105a "flock when mounted without -o flock test ========"
7561 if $(flock_is_enabled); then
7562 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7564 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7568 run_test 105b "fcntl when mounted without -o flock test ========"
7572 if $(flock_is_enabled); then
7573 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7575 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7579 run_test 105c "lockf when mounted without -o flock test"
7581 test_105d() { # bug 15924
7582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7583 test_mkdir $DIR/$tdir
7584 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7585 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7586 $LCTL set_param fail_loc=0x80000315
7587 flocks_test 2 $DIR/$tdir
7589 run_test 105d "flock race (should not freeze) ========"
7591 test_105e() { # bug 22660 && 22040
7592 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7594 flocks_test 3 $DIR/$tfile
7596 run_test 105e "Two conflicting flocks from same process"
7598 test_106() { #bug 10921
7599 test_mkdir $DIR/$tdir
7600 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7601 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7603 run_test 106 "attempt exec of dir followed by chown of that dir"
7606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7613 local save_pattern=$(sysctl -n kernel.core_pattern)
7614 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7615 sysctl -w kernel.core_pattern=$file
7616 sysctl -w kernel.core_uses_pid=0
7624 kill -s 11 $SLEEPPID
7626 if [ -e $file ]; then
7627 size=`stat -c%s $file`
7628 [ $size -eq 0 ] && error "Fail to create core file $file"
7630 error "Fail to create core file $file"
7633 sysctl -w kernel.core_pattern=$save_pattern
7634 sysctl -w kernel.core_uses_pid=$save_uses_pid
7637 run_test 107 "Coredump on SIG"
7640 test_mkdir $DIR/$tdir
7641 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
7642 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
7643 error "mkdir with 256 char should fail, but did not"
7644 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7645 error "create with 255 char failed"
7646 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7647 error "create with 256 char should fail, but did not"
7652 run_test 110 "filename length checking"
7655 # Purpose: To verify dynamic thread (OSS) creation.
7658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7659 remote_ost_nodsh && skip "remote OST with nodsh" && return
7661 # Lustre does not stop service threads once they are started.
7662 # Reset number of running threads to default.
7667 local save_params="$TMP/sanity-$TESTNAME.parameters"
7669 # Get ll_ost_io count before I/O
7670 OSTIO_pre=$(do_facet ost1 \
7671 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
7672 # Exit if lustre is not running (ll_ost_io not running).
7673 [ -z "$OSTIO_pre" ] && error "no OSS threads"
7675 echo "Starting with $OSTIO_pre threads"
7676 local thread_max=$((OSTIO_pre * 2))
7677 local rpc_in_flight=$((thread_max * 2))
7678 # Number of I/O Process proposed to be started.
7680 local facets=$(get_facets OST)
7682 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
7683 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
7685 # Set in_flight to $rpc_in_flight
7686 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
7687 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
7688 nfiles=${rpc_in_flight}
7689 # Set ost thread_max to $thread_max
7690 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
7692 # 5 Minutes should be sufficient for max number of OSS
7693 # threads(thread_max) to be created.
7697 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
7698 test_mkdir $DIR/$tdir
7699 for i in $(seq $nfiles); do
7700 local file=$DIR/$tdir/${tfile}-$i
7701 $LFS setstripe -c -1 -i 0 $file
7702 ($WTL $file $timeout)&
7705 # I/O Started - Wait for thread_started to reach thread_max or report
7706 # error if thread_started is more than thread_max.
7707 echo "Waiting for thread_started to reach thread_max"
7708 local thread_started=0
7709 local end_time=$((SECONDS + timeout))
7711 while [ $SECONDS -le $end_time ] ; do
7713 # Get ost i/o thread_started count.
7714 thread_started=$(do_facet ost1 \
7716 ost.OSS.ost_io.threads_started | cut -d= -f2")
7717 # Break out if thread_started is equal/greater than thread_max
7718 if [[ $thread_started -ge $thread_max ]]; then
7719 echo ll_ost_io thread_started $thread_started, \
7720 equal/greater than thread_max $thread_max
7726 # Cleanup - We have the numbers, Kill i/o jobs if running.
7727 jobcount=($(jobs -p))
7728 for i in $(seq 0 $((${#jobcount[@]}-1)))
7730 kill -9 ${jobcount[$i]}
7731 if [ $? -ne 0 ] ; then
7733 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
7737 # Cleanup files left by WTL binary.
7738 for i in $(seq $nfiles); do
7739 local file=$DIR/$tdir/${tfile}-$i
7741 if [ $? -ne 0 ] ; then
7742 echo "Warning: Failed to delete file $file"
7746 restore_lustre_params <$save_params
7747 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
7749 # Error out if no new thread has started or Thread started is greater
7751 if [[ $thread_started -le $OSTIO_pre ||
7752 $thread_started -gt $thread_max ]]; then
7753 error "ll_ost_io: thread_started $thread_started" \
7754 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
7755 "No new thread started or thread started greater " \
7759 run_test 115 "verify dynamic thread creation===================="
7762 wait_delete_completed
7763 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7764 echo "OST kbytes available: ${AVAIL[@]}"
7769 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7770 #echo OST $i: ${AVAIL[i]}kb
7771 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7775 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7780 echo "Min free space: OST $MINI: $MINV"
7781 echo "Max free space: OST $MAXI: $MAXV"
7784 test_116a() { # was previously test_116()
7785 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7786 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7788 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7790 echo -n "Free space priority "
7791 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7796 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7797 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7799 trap simple_cleanup_common EXIT
7802 # Check if we need to generate uneven OSTs
7803 test_mkdir -p $DIR/$tdir/OST${MINI}
7804 local FILL=$((MINV / 4))
7805 local DIFF=$((MAXV - MINV))
7806 local DIFF2=$((DIFF * 100 / MINV))
7808 local threshold=$(do_facet $SINGLEMDS \
7809 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7810 threshold=${threshold%%%}
7811 echo -n "Check for uneven OSTs: "
7812 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7814 if [[ $DIFF2 -gt $threshold ]]; then
7816 echo "Don't need to fill OST$MINI"
7818 # generate uneven OSTs. Write 2% over the QOS threshold value
7820 DIFF=$((threshold - DIFF2 + 2))
7821 DIFF2=$((MINV * DIFF / 100))
7822 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
7823 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7824 error "setstripe failed"
7825 DIFF=$((DIFF2 / 2048))
7827 while [ $i -lt $DIFF ]; do
7829 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7830 bs=2M count=1 2>/dev/null
7839 DIFF=$((MAXV - MINV))
7840 DIFF2=$((DIFF * 100 / MINV))
7841 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
7842 if [ $DIFF2 -gt $threshold ]; then
7845 echo "failed - QOS mode won't be used"
7846 skip "QOS imbalance criteria not met"
7847 simple_cleanup_common
7856 # now fill using QOS
7857 $SETSTRIPE -c 1 $DIR/$tdir
7858 FILL=$((FILL / 200))
7859 if [ $FILL -gt 600 ]; then
7862 echo "writing $FILL files to QOS-assigned OSTs"
7864 while [ $i -lt $FILL ]; do
7866 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7870 echo "wrote $i 200k files"
7874 echo "Note: free space may not be updated, so measurements might be off"
7876 DIFF2=$((MAXV - MINV))
7877 echo "free space delta: orig $DIFF final $DIFF2"
7878 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7879 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
7880 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7881 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
7882 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7883 if [[ $DIFF -gt 0 ]]; then
7884 FILL=$((DIFF2 * 100 / DIFF - 100))
7885 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7888 # Figure out which files were written where
7889 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7890 awk '/'$MINI1': / {print $2; exit}')
7892 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7893 echo "$MINC files created on smaller OST $MINI1"
7894 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7895 awk '/'$MAXI1': / {print $2; exit}')
7897 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7898 echo "$MAXC files created on larger OST $MAXI1"
7899 if [[ $MINC -gt 0 ]]; then
7900 FILL=$((MAXC * 100 / MINC - 100))
7901 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7903 [[ $MAXC -gt $MINC ]] ||
7904 error_ignore LU-9 "stripe QOS didn't balance free space"
7905 simple_cleanup_common
7907 run_test 116a "stripe QOS: free space balance ==================="
7909 test_116b() { # LU-2093
7910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7911 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7913 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7914 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7915 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7916 [ -z "$old_rr" ] && skip "no QOS" && return 0
7917 do_facet $SINGLEMDS lctl set_param \
7918 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7920 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7921 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7922 do_facet $SINGLEMDS lctl set_param fail_loc=0
7924 do_facet $SINGLEMDS lctl set_param \
7925 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7927 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7929 test_117() # bug 10891
7931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7932 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7933 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7934 lctl set_param fail_loc=0x21e
7935 > $DIR/$tfile || error "truncate failed"
7936 lctl set_param fail_loc=0
7937 echo "Truncate succeeded."
7940 run_test 117 "verify osd extend =========="
7942 NO_SLOW_RESENDCOUNT=4
7943 export OLD_RESENDCOUNT=""
7944 set_resend_count () {
7945 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7946 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7947 lctl set_param -n $PROC_RESENDCOUNT $1
7948 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7951 # for reduce test_118* time (b=14842)
7952 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7954 # Reset async IO behavior after error case
7956 FILE=$DIR/reset_async
7958 # Ensure all OSCs are cleared
7959 $SETSTRIPE -c -1 $FILE
7960 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7965 test_118a() #bug 11710
7967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7970 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7971 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7972 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7974 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7975 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7980 run_test 118a "verify O_SYNC works =========="
7984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7985 remote_ost_nodsh && skip "remote OST with nodsh" && return
7989 #define OBD_FAIL_SRV_ENOENT 0x217
7990 set_nodes_failloc "$(osts_nodes)" 0x217
7991 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7993 set_nodes_failloc "$(osts_nodes)" 0
7994 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7995 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7998 if [[ $RC -eq 0 ]]; then
7999 error "Must return error due to dropped pages, rc=$RC"
8003 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8004 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8008 echo "Dirty pages not leaked on ENOENT"
8010 # Due to the above error the OSC will issue all RPCs syncronously
8011 # until a subsequent RPC completes successfully without error.
8012 $MULTIOP $DIR/$tfile Ow4096yc
8017 run_test 118b "Reclaim dirty pages on fatal error =========="
8021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8023 # for 118c, restore the original resend count, LU-1940
8024 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8025 set_resend_count $OLD_RESENDCOUNT
8026 remote_ost_nodsh && skip "remote OST with nodsh" && return
8030 #define OBD_FAIL_OST_EROFS 0x216
8031 set_nodes_failloc "$(osts_nodes)" 0x216
8033 # multiop should block due to fsync until pages are written
8034 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8038 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8039 error "Multiop failed to block on fsync, pid=$MULTIPID"
8042 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8044 if [[ $WRITEBACK -eq 0 ]]; then
8045 error "No page in writeback, writeback=$WRITEBACK"
8048 set_nodes_failloc "$(osts_nodes)" 0
8051 if [[ $RC -ne 0 ]]; then
8052 error "Multiop fsync failed, rc=$RC"
8055 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8056 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8058 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8059 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8063 echo "Dirty pages flushed via fsync on EROFS"
8066 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8068 # continue to use small resend count to reduce test_118* time (b=14842)
8069 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8074 remote_ost_nodsh && skip "remote OST with nodsh" && return
8078 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8079 set_nodes_failloc "$(osts_nodes)" 0x214
8080 # multiop should block due to fsync until pages are written
8081 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8085 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8086 error "Multiop failed to block on fsync, pid=$MULTIPID"
8089 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8091 if [[ $WRITEBACK -eq 0 ]]; then
8092 error "No page in writeback, writeback=$WRITEBACK"
8095 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8096 set_nodes_failloc "$(osts_nodes)" 0
8098 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8099 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8101 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8102 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8106 echo "Dirty pages gaurenteed flushed via fsync"
8109 run_test 118d "Fsync validation inject a delay of the bulk =========="
8112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8115 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8116 lctl set_param fail_loc=0x8000040a
8118 # Should simulate EINVAL error which is fatal
8119 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8121 if [[ $RC -eq 0 ]]; then
8122 error "Must return error due to dropped pages, rc=$RC"
8125 lctl set_param fail_loc=0x0
8127 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8128 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8129 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8131 if [[ $LOCKED -ne 0 ]]; then
8132 error "Locked pages remain in cache, locked=$LOCKED"
8135 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8136 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8140 echo "No pages locked after fsync"
8145 run_test 118f "Simulate unrecoverable OSC side error =========="
8148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8151 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8152 lctl set_param fail_loc=0x406
8154 # simulate local -ENOMEM
8155 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8158 lctl set_param fail_loc=0
8159 if [[ $RC -eq 0 ]]; then
8160 error "Must return error due to dropped pages, rc=$RC"
8163 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8164 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8165 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8167 if [[ $LOCKED -ne 0 ]]; then
8168 error "Locked pages remain in cache, locked=$LOCKED"
8171 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8172 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8176 echo "No pages locked after fsync"
8181 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8185 remote_ost_nodsh && skip "remote OST with nodsh" && return
8189 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8190 set_nodes_failloc "$(osts_nodes)" 0x20e
8191 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8192 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8195 set_nodes_failloc "$(osts_nodes)" 0
8196 if [[ $RC -eq 0 ]]; then
8197 error "Must return error due to dropped pages, rc=$RC"
8200 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8201 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8202 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8204 if [[ $LOCKED -ne 0 ]]; then
8205 error "Locked pages remain in cache, locked=$LOCKED"
8208 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8209 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8213 echo "No pages locked after fsync"
8217 run_test 118h "Verify timeout in handling recoverables errors =========="
8219 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8223 remote_ost_nodsh && skip "remote OST with nodsh" && return
8227 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8228 set_nodes_failloc "$(osts_nodes)" 0x20e
8230 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8231 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8234 set_nodes_failloc "$(osts_nodes)" 0
8238 if [[ $RC -ne 0 ]]; then
8239 error "got error, but should be not, rc=$RC"
8242 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8243 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8244 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8245 if [[ $LOCKED -ne 0 ]]; then
8246 error "Locked pages remain in cache, locked=$LOCKED"
8249 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8250 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8254 echo "No pages locked after fsync"
8258 run_test 118i "Fix error before timeout in recoverable error =========="
8260 [ "$SLOW" = "no" ] && set_resend_count 4
8263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8264 remote_ost_nodsh && skip "remote OST with nodsh" && return
8268 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8269 set_nodes_failloc "$(osts_nodes)" 0x220
8271 # return -EIO from OST
8272 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8274 set_nodes_failloc "$(osts_nodes)" 0x0
8275 if [[ $RC -eq 0 ]]; then
8276 error "Must return error due to dropped pages, rc=$RC"
8279 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8280 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8281 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8282 if [[ $LOCKED -ne 0 ]]; then
8283 error "Locked pages remain in cache, locked=$LOCKED"
8286 # in recoverable error on OST we want resend and stay until it finished
8287 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8288 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8292 echo "No pages locked after fsync"
8296 run_test 118j "Simulate unrecoverable OST side error =========="
8300 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8301 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8303 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8304 set_nodes_failloc "$(osts_nodes)" 0x20e
8305 test_mkdir $DIR/$tdir
8307 for ((i=0;i<10;i++)); do
8308 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8309 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8316 set_nodes_failloc "$(osts_nodes)" 0
8319 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8325 test_mkdir $DIR/$tdir
8326 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8329 run_test 118l "fsync dir"
8331 test_118m() # LU-3066
8333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8334 test_mkdir $DIR/$tdir
8335 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8338 run_test 118m "fdatasync dir ========="
8340 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8342 test_119a() # bug 11737
8344 BSIZE=$((512 * 1024))
8345 directio write $DIR/$tfile 0 1 $BSIZE
8346 # We ask to read two blocks, which is more than a file size.
8347 # directio will indicate an error when requested and actual
8348 # sizes aren't equeal (a normal situation in this case) and
8349 # print actual read amount.
8350 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8351 if [ "$NOB" != "$BSIZE" ]; then
8352 error "read $NOB bytes instead of $BSIZE"
8356 run_test 119a "Short directIO read must return actual read amount"
8358 test_119b() # bug 11737
8360 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8362 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8363 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8365 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8366 error "direct read failed"
8369 run_test 119b "Sparse directIO read must return actual read amount"
8371 test_119c() # bug 13099
8374 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8375 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8378 run_test 119c "Testing for direct read hitting hole"
8380 test_119d() # bug 15950
8382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8383 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8384 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8386 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8387 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8388 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8389 lctl set_param fail_loc=0x40d
8390 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8393 cat $DIR/$tfile > /dev/null &
8394 lctl set_param fail_loc=0
8397 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8399 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8400 error "the read rpcs have not completed in 2s"
8402 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8404 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8408 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8409 test_mkdir $DIR/$tdir
8410 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8411 { skip "no early lock cancel on server"; return 0; }
8413 lru_resize_disable mdc
8414 lru_resize_disable osc
8415 cancel_lru_locks mdc
8416 # asynchronous object destroy at MDT could cause bl ast to client
8417 cancel_lru_locks osc
8419 stat $DIR/$tdir > /dev/null
8420 can1=$(do_facet $SINGLEMDS \
8421 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8422 awk '/ldlm_cancel/ {print $2}')
8423 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8424 awk '/ldlm_bl_callback/ {print $2}')
8425 test_mkdir -c1 $DIR/$tdir/d1
8426 can2=$(do_facet $SINGLEMDS \
8427 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8428 awk '/ldlm_cancel/ {print $2}')
8429 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8430 awk '/ldlm_bl_callback/ {print $2}')
8431 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8432 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8433 lru_resize_enable mdc
8434 lru_resize_enable osc
8436 run_test 120a "Early Lock Cancel: mkdir test"
8439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8440 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8441 test_mkdir $DIR/$tdir
8442 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8443 { skip "no early lock cancel on server"; return 0; }
8444 lru_resize_disable mdc
8445 lru_resize_disable osc
8446 cancel_lru_locks mdc
8447 stat $DIR/$tdir > /dev/null
8448 can1=$(do_facet $SINGLEMDS \
8449 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8450 awk '/ldlm_cancel/ {print $2}')
8451 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8452 awk '/ldlm_bl_callback/ {print $2}')
8454 can2=$(do_facet $SINGLEMDS \
8455 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8456 awk '/ldlm_cancel/ {print $2}')
8457 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8458 awk '/ldlm_bl_callback/ {print $2}')
8459 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8460 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8461 lru_resize_enable mdc
8462 lru_resize_enable osc
8464 run_test 120b "Early Lock Cancel: create test"
8467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8468 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8469 test_mkdir -c1 $DIR/$tdir
8470 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8471 { skip "no early lock cancel on server"; return 0; }
8472 lru_resize_disable mdc
8473 lru_resize_disable osc
8474 test_mkdir -c1 $DIR/$tdir/d1
8475 test_mkdir -c1 $DIR/$tdir/d2
8476 touch $DIR/$tdir/d1/f1
8477 cancel_lru_locks mdc
8478 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8479 can1=$(do_facet $SINGLEMDS \
8480 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8481 awk '/ldlm_cancel/ {print $2}')
8482 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8483 awk '/ldlm_bl_callback/ {print $2}')
8484 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8485 can2=$(do_facet $SINGLEMDS \
8486 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8487 awk '/ldlm_cancel/ {print $2}')
8488 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8489 awk '/ldlm_bl_callback/ {print $2}')
8490 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8491 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8492 lru_resize_enable mdc
8493 lru_resize_enable osc
8495 run_test 120c "Early Lock Cancel: link test"
8498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8499 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8500 test_mkdir -c1 $DIR/$tdir
8501 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8502 { skip "no early lock cancel on server"; return 0; }
8503 lru_resize_disable mdc
8504 lru_resize_disable osc
8506 cancel_lru_locks mdc
8507 stat $DIR/$tdir > /dev/null
8508 can1=$(do_facet $SINGLEMDS \
8509 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8510 awk '/ldlm_cancel/ {print $2}')
8511 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8512 awk '/ldlm_bl_callback/ {print $2}')
8513 chmod a+x $DIR/$tdir
8514 can2=$(do_facet $SINGLEMDS \
8515 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8516 awk '/ldlm_cancel/ {print $2}')
8517 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8518 awk '/ldlm_bl_callback/ {print $2}')
8519 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8520 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8521 lru_resize_enable mdc
8522 lru_resize_enable osc
8524 run_test 120d "Early Lock Cancel: setattr test"
8527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8528 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8529 { skip "no early lock cancel on server"; return 0; }
8530 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8531 local dlmtrace_set=false
8533 test_mkdir -c1 $DIR/$tdir
8534 lru_resize_disable mdc
8535 lru_resize_disable osc
8536 ! $LCTL get_param debug | grep -q dlmtrace &&
8537 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8538 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8539 cancel_lru_locks mdc
8540 cancel_lru_locks osc
8541 dd if=$DIR/$tdir/f1 of=/dev/null
8542 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8543 # XXX client can not do early lock cancel of OST lock
8544 # during unlink (LU-4206), so cancel osc lock now.
8546 cancel_lru_locks osc
8547 can1=$(do_facet $SINGLEMDS \
8548 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8549 awk '/ldlm_cancel/ {print $2}')
8550 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8551 awk '/ldlm_bl_callback/ {print $2}')
8552 unlink $DIR/$tdir/f1
8554 can2=$(do_facet $SINGLEMDS \
8555 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8556 awk '/ldlm_cancel/ {print $2}')
8557 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8558 awk '/ldlm_bl_callback/ {print $2}')
8559 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8560 $LCTL dk $TMP/cancel.debug.txt
8561 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8562 $LCTL dk $TMP/blocking.debug.txt
8563 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8564 lru_resize_enable mdc
8565 lru_resize_enable osc
8567 run_test 120e "Early Lock Cancel: unlink test"
8570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8571 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8572 { skip "no early lock cancel on server"; return 0; }
8573 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8574 test_mkdir -c1 $DIR/$tdir
8575 lru_resize_disable mdc
8576 lru_resize_disable osc
8577 test_mkdir -c1 $DIR/$tdir/d1
8578 test_mkdir -c1 $DIR/$tdir/d2
8579 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8580 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8581 cancel_lru_locks mdc
8582 cancel_lru_locks osc
8583 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8584 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8585 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8586 # XXX client can not do early lock cancel of OST lock
8587 # during rename (LU-4206), so cancel osc lock now.
8589 cancel_lru_locks osc
8590 can1=$(do_facet $SINGLEMDS \
8591 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8592 awk '/ldlm_cancel/ {print $2}')
8593 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8594 awk '/ldlm_bl_callback/ {print $2}')
8595 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8597 can2=$(do_facet $SINGLEMDS \
8598 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8599 awk '/ldlm_cancel/ {print $2}')
8600 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8601 awk '/ldlm_bl_callback/ {print $2}')
8602 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8603 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8604 lru_resize_enable mdc
8605 lru_resize_enable osc
8607 run_test 120f "Early Lock Cancel: rename test"
8610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8611 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8612 { skip "no early lock cancel on server"; return 0; }
8613 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8614 lru_resize_disable mdc
8615 lru_resize_disable osc
8617 echo create $count files
8618 test_mkdir $DIR/$tdir
8619 cancel_lru_locks mdc
8620 cancel_lru_locks osc
8623 can0=$(do_facet $SINGLEMDS \
8624 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8625 awk '/ldlm_cancel/ {print $2}')
8626 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8627 awk '/ldlm_bl_callback/ {print $2}')
8628 createmany -o $DIR/$tdir/f $count
8630 can1=$(do_facet $SINGLEMDS \
8631 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8632 awk '/ldlm_cancel/ {print $2}')
8633 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8634 awk '/ldlm_bl_callback/ {print $2}')
8636 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8637 echo rm $count files
8640 can2=$(do_facet $SINGLEMDS \
8641 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8642 awk '/ldlm_cancel/ {print $2}')
8643 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8644 awk '/ldlm_bl_callback/ {print $2}')
8646 echo total: $count removes in $((t2-t1))
8647 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8649 # wait for commitment of removal
8650 lru_resize_enable mdc
8651 lru_resize_enable osc
8653 run_test 120g "Early Lock Cancel: performance test"
8655 test_121() { #bug #10589
8656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8658 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8659 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8660 lctl set_param fail_loc=0x310
8661 cancel_lru_locks osc > /dev/null
8662 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8663 lctl set_param fail_loc=0
8664 [[ $reads -eq $writes ]] ||
8665 error "read $reads blocks, must be $writes blocks"
8667 run_test 121 "read cancel race ========="
8669 test_123a() { # was test 123, statahead(bug 11401)
8670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8672 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
8673 log "testing UP system. Performance may be lower than expected."
8678 test_mkdir $DIR/$tdir
8679 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8680 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8682 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8683 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8685 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8686 lctl set_param -n llite.*.statahead_max 0
8687 lctl get_param llite.*.statahead_max
8688 cancel_lru_locks mdc
8689 cancel_lru_locks osc
8691 time ls -l $DIR/$tdir | wc -l
8693 delta=$((etime - stime))
8694 log "ls $i files without statahead: $delta sec"
8695 lctl set_param llite.*.statahead_max=$max
8697 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8698 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8699 cancel_lru_locks mdc
8700 cancel_lru_locks osc
8702 time ls -l $DIR/$tdir | wc -l
8704 delta_sa=$((etime - stime))
8705 log "ls $i files with statahead: $delta_sa sec"
8706 lctl get_param -n llite.*.statahead_stats
8707 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8709 [[ $swrong -lt $ewrong ]] &&
8710 log "statahead was stopped, maybe too many locks held!"
8711 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8713 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8714 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8715 lctl set_param -n llite.*.statahead_max 0
8716 lctl get_param llite.*.statahead_max
8717 cancel_lru_locks mdc
8718 cancel_lru_locks osc
8720 time ls -l $DIR/$tdir | wc -l
8722 delta=$((etime - stime))
8723 log "ls $i files again without statahead: $delta sec"
8724 lctl set_param llite.*.statahead_max=$max
8725 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8726 if [ $SLOWOK -eq 0 ]; then
8727 error "ls $i files is slower with statahead!"
8729 log "ls $i files is slower with statahead!"
8735 [ $delta -gt 20 ] && break
8736 [ $delta -gt 8 ] && MULT=$((50 / delta))
8737 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8745 delta=$((etime - stime))
8746 log "rm -r $DIR/$tdir/: $delta seconds"
8748 lctl get_param -n llite.*.statahead_stats
8750 run_test 123a "verify statahead work"
8752 test_123b () { # statahead(bug 15027)
8753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8754 test_mkdir $DIR/$tdir
8755 createmany -o $DIR/$tdir/$tfile-%d 1000
8757 cancel_lru_locks mdc
8758 cancel_lru_locks osc
8760 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8761 lctl set_param fail_loc=0x80000803
8762 ls -lR $DIR/$tdir > /dev/null
8764 lctl set_param fail_loc=0x0
8765 lctl get_param -n llite.*.statahead_stats
8770 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8774 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
8775 { skip "no lru resize on server"; return 0; }
8777 test_mkdir $DIR/$tdir
8779 log "create $NR files at $DIR/$tdir"
8780 createmany -o $DIR/$tdir/f $NR ||
8781 error "failed to create $NR files in $DIR/$tdir"
8783 cancel_lru_locks mdc
8784 ls -l $DIR/$tdir > /dev/null
8788 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8789 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8790 LRU_SIZE=$($LCTL get_param -n $PARAM)
8791 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8792 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8794 log "NS=$(basename $NSDIR)"
8799 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8800 skip "Not enough cached locks created!"
8807 # We know that lru resize allows one client to hold $LIMIT locks
8808 # for 10h. After that locks begin to be killed by client.
8810 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8812 if [ $LIMIT -lt $LRU_SIZE ]; then
8813 skip "Limit is too small $LIMIT"
8817 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8818 # killing locks. Some time was spent for creating locks. This means
8819 # that up to the moment of sleep finish we must have killed some of
8820 # them (10-100 locks). This depends on how fast ther were created.
8821 # Many of them were touched in almost the same moment and thus will
8822 # be killed in groups.
8823 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8825 # Use $LRU_SIZE_B here to take into account real number of locks
8826 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8827 local LRU_SIZE_B=$LRU_SIZE
8829 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8830 log "OLD_LVF=$OLD_LVF"
8831 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8833 # Let's make sure that we really have some margin. Client checks
8834 # cached locks every 10 sec.
8836 log "Sleep ${SLEEP} sec"
8838 while ((SEC<$SLEEP)); do
8842 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8846 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8847 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8849 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8850 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8851 unlinkmany $DIR/$tdir/f $NR
8855 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8856 log "unlink $NR files at $DIR/$tdir"
8857 unlinkmany $DIR/$tdir/f $NR
8859 run_test 124a "lru resize ======================================="
8861 get_max_pool_limit()
8863 local limit=$($LCTL get_param \
8864 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8867 if [[ $l -gt $max ]]; then
8875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8876 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
8877 { skip "no lru resize on server"; return 0; }
8879 LIMIT=$(get_max_pool_limit)
8881 NR=$(($(default_lru_size)*20))
8882 if [[ $NR -gt $LIMIT ]]; then
8883 log "Limit lock number by $LIMIT locks"
8887 IFree=$(mdsrate_inodes_available)
8888 if [ $IFree -lt $NR ]; then
8889 log "Limit lock number by $IFree inodes"
8893 lru_resize_disable mdc
8894 test_mkdir -p $DIR/$tdir/disable_lru_resize
8896 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8897 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8898 cancel_lru_locks mdc
8901 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8904 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8907 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8911 nolruresize_delta=$((etime-stime))
8912 log "ls -la time: $nolruresize_delta seconds"
8913 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8914 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8916 lru_resize_enable mdc
8917 test_mkdir -p $DIR/$tdir/enable_lru_resize
8919 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8920 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8921 cancel_lru_locks mdc
8924 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8927 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8930 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8934 lruresize_delta=$((etime-stime))
8935 log "ls -la time: $lruresize_delta seconds"
8936 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8938 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8939 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8940 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8941 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8943 log "lru resize performs the same with no lru resize"
8945 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8947 run_test 124b "lru resize (performance test) ======================="
8950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8951 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
8952 { skip "no lru resize on server"; return 0; }
8954 # cache ununsed locks on client
8956 cancel_lru_locks mdc
8957 test_mkdir $DIR/$tdir
8958 createmany -o $DIR/$tdir/f $nr ||
8959 error "failed to create $nr files in $DIR/$tdir"
8960 ls -l $DIR/$tdir > /dev/null
8962 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8963 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8964 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8965 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8966 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8968 # set lru_max_age to 1 sec
8969 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
8970 echo "sleep $((recalc_p * 2)) seconds..."
8971 sleep $((recalc_p * 2))
8973 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8974 # restore lru_max_age
8975 $LCTL set_param -n $nsdir.lru_max_age $max_age
8976 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8977 unlinkmany $DIR/$tdir/f $nr
8979 run_test 124c "LRUR cancel very aged locks"
8981 test_125() { # 13358
8982 $LCTL get_param -n llite.*.client_type | grep -q local ||
8983 { skip "must run as local client"; return; }
8984 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
8985 { skip "must have acl enabled"; return; }
8986 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8987 test_mkdir $DIR/$tdir
8988 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
8989 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
8990 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
8992 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8994 test_126() { # bug 12829/13455
8995 $LCTL get_param -n llite.*.client_type | grep -q local ||
8996 { skip "must run as local client"; return; }
8997 [ "$UID" != 0 ] && skip_env "$TESTNAME (must run as root)" && return
8998 $GSS && skip "must run as gss disabled" && return
9000 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9001 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9003 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9005 run_test 126 "check that the fsgid provided by the client is taken into account"
9007 test_127a() { # bug 15521
9008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9009 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9010 $LCTL set_param osc.*.stats=0
9011 FSIZE=$((2048 * 1024))
9012 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9013 cancel_lru_locks osc
9014 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9016 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9017 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9018 echo "got $COUNT $NAME"
9019 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9020 eval $NAME=$COUNT || error "Wrong proc format"
9023 read_bytes|write_bytes)
9024 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9025 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9026 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9027 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9028 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9029 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9030 error "sumsquare is too small: $SUMSQ"
9031 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9032 error "sumsquare is too big: $SUMSQ"
9036 done < $DIR/${tfile}.tmp
9038 #check that we actually got some stats
9039 [ "$read_bytes" ] || error "Missing read_bytes stats"
9040 [ "$write_bytes" ] || error "Missing write_bytes stats"
9041 [ "$read_bytes" != 0 ] || error "no read done"
9042 [ "$write_bytes" != 0 ] || error "no write done"
9044 run_test 127a "verify the client stats are sane"
9046 test_127b() { # bug LU-333
9047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9048 $LCTL set_param llite.*.stats=0
9049 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9050 # perform 2 reads and writes so MAX is different from SUM.
9051 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9052 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9053 cancel_lru_locks osc
9054 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9055 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9057 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9058 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9059 echo "got $COUNT $NAME"
9060 eval $NAME=$COUNT || error "Wrong proc format"
9064 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9065 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9066 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9067 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9070 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9071 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9072 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9073 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9077 done < $TMP/${tfile}.tmp
9079 #check that we actually got some stats
9080 [ "$read_bytes" ] || error "Missing read_bytes stats"
9081 [ "$write_bytes" ] || error "Missing write_bytes stats"
9082 [ "$read_bytes" != 0 ] || error "no read done"
9083 [ "$write_bytes" != 0 ] || error "no write done"
9085 rm -f $TMP/${tfile}.tmp
9087 run_test 127b "verify the llite client stats are sane"
9089 test_128() { # bug 15212
9091 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9096 result=$(grep error $TMP/$tfile.log)
9097 rm -f $DIR/$tfile $TMP/$tfile.log
9099 error "consecutive find's under interactive lfs failed"
9101 run_test 128 "interactive lfs for 2 consecutive find's"
9108 local ldproc=/proc/fs/ldiskfs
9109 local facets=$(get_facets MDS)
9111 for facet in ${facets//,/ }; do
9112 canondev=$(ldiskfs_canon \
9113 *.$(convert_facet2label $facet).mntdev $facet)
9114 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9115 ldproc=/sys/fs/ldiskfs
9116 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9117 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9122 local facets=$(get_facets MDS)
9123 for facet in ${facets//,/ }; do
9124 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9130 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9131 { skip "Need MDS version with at least 2.5.56"; return 0; }
9133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9134 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9135 skip "ldiskfs only test"
9138 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9141 local has_warning=false
9146 # block size of mds1
9147 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9148 set_dir_limits $maxsize $maxsize
9149 local dirsize=$(stat -c%s "$DIR/$tdir")
9151 while [[ $dirsize -le $maxsize ]]; do
9152 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9154 if ! $has_warning; then
9155 check_mds_dmesg '"is approaching"' && has_warning=true
9158 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9159 # EFBIG for previous versions included in ldiskfs series
9160 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9162 echo "return code $rc received as expected"
9164 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9165 error_exit "create failed w/o dir size limit"
9167 check_mds_dmesg '"has reached"' ||
9168 error_exit "reached message should be output"
9170 [ $has_warning -eq 0 ] &&
9171 error_exit "warning message should be output"
9173 dirsize=$(stat -c%s "$DIR/$tdir")
9175 [[ $dirsize -ge $maxsize ]] && return 0
9176 error_exit "current dir size $dirsize, " \
9177 "previous limit $maxsize"
9178 elif [ $rc -ne 0 ]; then
9180 error_exit "return $rc received instead of expected " \
9181 "$EFBIG or $ENOSPC, files in dir $dirsize"
9183 nfiles=$((nfiles + 1))
9184 dirsize=$(stat -c%s "$DIR/$tdir")
9188 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9190 run_test 129 "test directory size limit ========================"
9199 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9200 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9203 trap cleanup_130 EXIT RETURN
9205 local fm_file=$DIR/$tfile
9206 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9207 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9208 error "dd failed for $fm_file"
9210 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9211 filefrag -ves $fm_file
9213 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9214 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9215 [ $RC != 0 ] && error "filefrag $fm_file failed"
9217 filefrag_op=$(filefrag -ve $fm_file |
9218 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9219 lun=$($GETSTRIPE -i $fm_file)
9221 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9224 for line in $filefrag_op
9226 frag_lun=`echo $line | cut -d: -f5`
9227 ext_len=`echo $line | cut -d: -f4`
9228 if (( $frag_lun != $lun )); then
9230 error "FIEMAP on 1-stripe file($fm_file) failed"
9233 (( tot_len += ext_len ))
9236 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9238 error "FIEMAP on 1-stripe file($fm_file) failed;"
9244 echo "FIEMAP on single striped file succeeded"
9246 run_test 130a "FIEMAP (1-stripe file)"
9249 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9251 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9252 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9255 trap cleanup_130 EXIT RETURN
9257 local fm_file=$DIR/$tfile
9258 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9259 error "setstripe on $fm_file"
9260 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9261 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9263 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9264 error "dd failed on $fm_file"
9266 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9267 filefrag_op=$(filefrag -ve $fm_file |
9268 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9270 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9271 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9276 for line in $filefrag_op
9278 frag_lun=$(echo $line | cut -d: -f5 |
9279 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9280 ext_len=$(echo $line | cut -d: -f4)
9281 if (( $frag_lun != $last_lun )); then
9282 if (( tot_len != 1024 )); then
9284 error "FIEMAP on $fm_file failed; returned " \
9285 "len $tot_len for OST $last_lun instead of 1024"
9292 (( tot_len += ext_len ))
9295 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9297 error "FIEMAP on $fm_file failed; returned wrong number of " \
9298 "luns or wrong len for OST $last_lun"
9304 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9306 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9309 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9311 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9312 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9315 trap cleanup_130 EXIT RETURN
9317 local fm_file=$DIR/$tfile
9318 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9319 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9320 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9322 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9323 error "dd failed on $fm_file"
9325 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9326 filefrag_op=$(filefrag -ve $fm_file |
9327 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9329 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9330 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9335 for line in $filefrag_op
9337 frag_lun=$(echo $line | cut -d: -f5 |
9338 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9339 ext_len=$(echo $line | cut -d: -f4)
9340 if (( $frag_lun != $last_lun )); then
9341 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9342 if (( logical != 512 )); then
9344 error "FIEMAP on $fm_file failed; returned " \
9345 "logical start for lun $logical instead of 512"
9348 if (( tot_len != 512 )); then
9350 error "FIEMAP on $fm_file failed; returned " \
9351 "len $tot_len for OST $last_lun instead of 1024"
9358 (( tot_len += ext_len ))
9361 if (( num_luns != 2 || tot_len != 512 )); then
9363 error "FIEMAP on $fm_file failed; returned wrong number of " \
9364 "luns or wrong len for OST $last_lun"
9370 echo "FIEMAP on 2-stripe file with hole succeeded"
9372 run_test 130c "FIEMAP (2-stripe file with hole)"
9375 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9377 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9378 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9381 trap cleanup_130 EXIT RETURN
9383 local fm_file=$DIR/$tfile
9384 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9385 error "setstripe on $fm_file"
9386 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9387 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9389 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
9390 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
9391 error "dd failed on $fm_file"
9393 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9394 filefrag_op=$(filefrag -ve $fm_file |
9395 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9397 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9398 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9403 for line in $filefrag_op
9405 frag_lun=$(echo $line | cut -d: -f5 |
9406 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9407 ext_len=$(echo $line | cut -d: -f4)
9408 if (( $frag_lun != $last_lun )); then
9409 if (( tot_len != 1024 )); then
9411 error "FIEMAP on $fm_file failed; returned " \
9412 "len $tot_len for OST $last_lun instead of 1024"
9419 (( tot_len += ext_len ))
9422 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
9424 error "FIEMAP on $fm_file failed; returned wrong number of " \
9425 "luns or wrong len for OST $last_lun"
9431 echo "FIEMAP on N-stripe file succeeded"
9433 run_test 130d "FIEMAP (N-stripe file)"
9436 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9438 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9439 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9441 trap cleanup_130 EXIT RETURN
9443 local fm_file=$DIR/$tfile
9444 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9445 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9446 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9449 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9450 for ((i = 0; i < $NUM_BLKS; i++))
9452 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9455 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9456 filefrag_op=$(filefrag -ve $fm_file |
9457 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9459 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9460 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9465 for line in $filefrag_op
9467 frag_lun=$(echo $line | cut -d: -f5 |
9468 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9469 ext_len=$(echo $line | cut -d: -f4)
9470 if (( $frag_lun != $last_lun )); then
9471 if (( tot_len != $EXPECTED_LEN )); then
9473 error "FIEMAP on $fm_file failed; returned " \
9474 "len $tot_len for OST $last_lun instead " \
9482 (( tot_len += ext_len ))
9485 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9487 error "FIEMAP on $fm_file failed; returned wrong number " \
9488 "of luns or wrong len for OST $last_lun"
9494 echo "FIEMAP with continuation calls succeeded"
9496 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9498 # Test for writev/readv
9500 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
9501 error "writev test failed"
9502 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
9503 error "readv failed"
9506 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9509 local fsize=$((524288 + 1048576 + 1572864))
9510 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
9511 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9512 error "append writev test failed"
9514 ((fsize += 1572864 + 1048576))
9515 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
9516 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
9517 error "append writev test failed"
9520 run_test 131b "test append writev"
9523 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9526 run_test 131c "test read/write on file w/o objects"
9529 rwv -f $DIR/$tfile -w -n 1 1572864
9530 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9531 if [ "$NOB" != 1572864 ]; then
9532 error "Short read filed: read $NOB bytes instead of 1572864"
9536 run_test 131d "test short read"
9539 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9540 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9541 error "read hitting hole failed"
9544 run_test 131e "test read hitting hole"
9553 mds*) res=$(do_facet $facet \
9554 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
9556 ost*) res=$(do_facet $facet \
9557 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
9559 *) error "Wrong facet '$facet'" ;;
9562 [ "$res" ] || error "The counter for $op on $facet was not incremented"
9563 # if the argument $3 is zero, it means any stat increment is ok.
9564 if [[ $want -gt 0 ]]; then
9565 local count=$(echo $res | awk '{ print $2 }')
9566 [[ $count -ne $want ]] &&
9567 error "The $op counter on $facet is $count, not $want"
9572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9573 remote_ost_nodsh && skip "remote OST with nodsh" && return
9574 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9576 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9577 { skip "MDS doesn't support rename stats"; return; }
9578 local testdir=$DIR/${tdir}/stats_testdir
9579 mkdir -p $DIR/${tdir}
9582 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9583 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9585 # verify mdt stats first.
9586 mkdir ${testdir} || error "mkdir failed"
9587 check_stats $SINGLEMDS "mkdir" 1
9588 touch ${testdir}/${tfile} || error "touch failed"
9589 check_stats $SINGLEMDS "open" 1
9590 check_stats $SINGLEMDS "close" 1
9591 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
9592 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
9593 check_stats $SINGLEMDS "mknod" 2
9595 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
9596 check_stats $SINGLEMDS "unlink" 1
9597 rm -f ${testdir}/${tfile} || error "file remove failed"
9598 check_stats $SINGLEMDS "unlink" 2
9600 # remove working dir and check mdt stats again.
9601 rmdir ${testdir} || error "rmdir failed"
9602 check_stats $SINGLEMDS "rmdir" 1
9604 local testdir1=$DIR/${tdir}/stats_testdir1
9606 mkdir -p ${testdir1}
9607 touch ${testdir1}/test1
9608 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9609 check_stats $SINGLEMDS "crossdir_rename" 1
9611 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9612 check_stats $SINGLEMDS "samedir_rename" 1
9616 run_test 133a "Verifying MDT stats ========================================"
9619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9620 remote_ost_nodsh && skip "remote OST with nodsh" && return
9621 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9622 local testdir=$DIR/${tdir}/stats_testdir
9623 mkdir -p ${testdir} || error "mkdir failed"
9624 touch ${testdir}/${tfile} || error "touch failed"
9625 cancel_lru_locks mdc
9628 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9629 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9631 # extra mdt stats verification.
9632 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9633 check_stats $SINGLEMDS "setattr" 1
9634 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9635 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9637 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9638 check_stats $SINGLEMDS "getattr" 1
9640 $LFS df || error "lfs failed"
9641 check_stats $SINGLEMDS "statfs" 1
9645 run_test 133b "Verifying extra MDT stats =================================="
9648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9649 remote_ost_nodsh && skip "remote OST with nodsh" && return
9650 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9651 local testdir=$DIR/$tdir/stats_testdir
9652 test_mkdir -p $testdir
9654 # verify obdfilter stats.
9655 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
9657 cancel_lru_locks osc
9658 wait_delete_completed
9661 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9662 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9664 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
9667 cancel_lru_locks osc
9668 check_stats ost1 "write" 1
9670 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
9671 check_stats ost1 "read" 1
9673 > $testdir/$tfile || error "truncate failed"
9674 check_stats ost1 "punch" 1
9676 rm -f $testdir/$tfile || error "file remove failed"
9677 wait_delete_completed
9678 check_stats ost1 "destroy" 1
9682 run_test 133c "Verifying OST stats ========================================"
9689 while [ $value -ge 2 ]; do
9694 if [ $orig -gt $order ]; then
9702 local size=('K' 'M' 'G' 'T');
9704 local size_string=$value
9706 while [ $value -ge 1024 ]; do
9707 if [ $i -gt 3 ]; then
9708 #T is the biggest unit we get here, if that is bigger,
9710 size_string=${value}T
9713 value=$((value >> 10))
9714 if [ $value -lt 1024 ]; then
9715 size_string=${value}${size[$i]}
9726 local context=${2:-.}
9727 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9729 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9734 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9735 remote_ost_nodsh && skip "remote OST with nodsh" && return
9736 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9737 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9738 { skip "MDS doesn't support rename stats"; return; }
9740 local testdir1=$DIR/${tdir}/stats_testdir1
9741 local testdir2=$DIR/${tdir}/stats_testdir2
9743 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9745 mkdir -p ${testdir1} || error "mkdir failed"
9746 mkdir -p ${testdir2} || error "mkdir failed"
9748 createmany -o $testdir1/test 512 || error "createmany failed"
9750 # check samedir rename size
9751 mv ${testdir1}/test0 ${testdir1}/test_0
9753 local testdir1_size=$(ls -l $DIR/${tdir} |
9754 awk '/stats_testdir1/ {print $5}')
9755 local testdir2_size=$(ls -l $DIR/${tdir} |
9756 awk '/stats_testdir2/ {print $5}')
9758 testdir1_size=$(order_2 $testdir1_size)
9759 testdir2_size=$(order_2 $testdir2_size)
9761 testdir1_size=$(size_in_KMGT $testdir1_size)
9762 testdir2_size=$(size_in_KMGT $testdir2_size)
9764 echo "source rename dir size: ${testdir1_size}"
9765 echo "target rename dir size: ${testdir2_size}"
9767 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9768 eval $cmd || error "$cmd failed"
9769 local samedir=$($cmd | grep 'same_dir')
9770 local same_sample=$(get_rename_size $testdir1_size)
9771 [ -z "$samedir" ] && error "samedir_rename_size count error"
9772 [[ $same_sample -eq 1 ]] ||
9773 error "samedir_rename_size error $same_sample"
9774 echo "Check same dir rename stats success"
9776 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9778 # check crossdir rename size
9779 mv ${testdir1}/test_0 ${testdir2}/test_0
9781 testdir1_size=$(ls -l $DIR/${tdir} |
9782 awk '/stats_testdir1/ {print $5}')
9783 testdir2_size=$(ls -l $DIR/${tdir} |
9784 awk '/stats_testdir2/ {print $5}')
9786 testdir1_size=$(order_2 $testdir1_size)
9787 testdir2_size=$(order_2 $testdir2_size)
9789 testdir1_size=$(size_in_KMGT $testdir1_size)
9790 testdir2_size=$(size_in_KMGT $testdir2_size)
9792 echo "source rename dir size: ${testdir1_size}"
9793 echo "target rename dir size: ${testdir2_size}"
9795 eval $cmd || error "$cmd failed"
9796 local crossdir=$($cmd | grep 'crossdir')
9797 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9798 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9799 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9800 [[ $src_sample -eq 1 ]] ||
9801 error "crossdir_rename_size error $src_sample"
9802 [[ $tgt_sample -eq 1 ]] ||
9803 error "crossdir_rename_size error $tgt_sample"
9804 echo "Check cross dir rename stats success"
9807 run_test 133d "Verifying rename_stats ========================================"
9810 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9811 remote_ost_nodsh && skip "remote OST with nodsh" && return
9812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9813 local testdir=$DIR/${tdir}/stats_testdir
9814 local ctr f0 f1 bs=32768 count=42 sum
9816 mkdir -p ${testdir} || error "mkdir failed"
9818 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9820 for ctr in {write,read}_bytes; do
9822 cancel_lru_locks osc
9824 do_facet ost1 $LCTL set_param -n \
9825 "obdfilter.*.exports.clear=clear"
9827 if [ $ctr = write_bytes ]; then
9829 f1=${testdir}/${tfile}
9831 f0=${testdir}/${tfile}
9835 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9838 cancel_lru_locks osc
9840 sum=$(do_facet ost1 $LCTL get_param \
9841 "obdfilter.*.exports.*.stats" |
9842 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9843 $1 == ctr { sum += $7 }
9844 END { printf("%0.0f", sum) }')
9846 if ((sum != bs * count)); then
9847 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9853 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9855 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
9858 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9859 remote_ost_nodsh && skip "remote OST with nodsh" && return
9860 # First without trusting modes.
9861 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9862 echo "proc_dirs='$proc_dirs'"
9863 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9864 find $proc_dirs -exec cat '{}' \; &> /dev/null
9866 # Second verifying readability.
9867 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
9869 # eventually, this can also be replaced with "lctl get_param -R",
9870 # but not until that option is always available on the server
9872 for facet in mds1 ost1; do
9873 local facet_proc_dirs=$(do_facet $facet \
9874 \\\ls -d $proc_regexp 2>/dev/null)
9875 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9876 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9877 do_facet $facet find $facet_proc_dirs \
9878 ! -name req_history \
9879 -exec cat '{}' \\\; &> /dev/null
9881 do_facet $facet find $facet_proc_dirs \
9882 ! -name req_history \
9884 -exec cat '{}' \\\; &> /dev/null ||
9885 error "proc file read failed"
9888 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9891 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9892 remote_ost_nodsh && skip "remote OST with nodsh" && return
9893 # Second verifying writability.
9894 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
9895 echo "proc_dirs='$proc_dirs'"
9896 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
9899 -not -name force_lbug \
9900 -not -name changelog_mask \
9901 -exec badarea_io '{}' \; &> /dev/null ||
9902 error "find $proc_dirs failed"
9905 for facet in mds1 ost1; do
9906 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
9907 skip "Too old lustre on $facet" && continue
9908 local facet_proc_dirs=$(do_facet $facet \
9909 \\\ls -d $proc_regexp 2> /dev/null)
9910 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9911 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9912 do_facet $facet find $facet_proc_dirs \
9914 -not -name force_lbug \
9915 -not -name changelog_mask \
9916 -exec badarea_io '{}' \\\; &> /dev/null ||
9917 error "$facet find $facet_proc_dirs failed"
9920 # remount the FS in case writes/reads /proc break the FS
9921 cleanup || error "failed to unmount"
9922 setup || error "failed to setup"
9925 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9928 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9929 remote_ost_nodsh && skip "remote OST with nodsh" && return
9930 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
9931 skip "Need MDS version at least 2.9.54" && return
9934 for facet in client mds1 ost1; do
9935 local facet_proc_dirs=$(do_facet $facet \
9936 \\\ls -d $proc_regexp 2> /dev/null)
9937 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
9938 echo "${facet}_proc_dirs='$facet_proc_dirs'"
9939 # Get the list of files that are missing the terminating newline
9940 local missing=($(do_facet $facet \
9941 find ${facet_proc_dirs} -type f \| \
9943 awk -v FS='\v' -v RS='\v\v' \
9944 "'END { if(NR>0 && \
9945 \\\$NF !~ /.*\\\n\$/) \
9949 [ ${#missing[*]} -eq 0 ] ||
9950 error "files do not end with newline: ${missing[*]}"
9953 run_test 133h "Proc files should end with newlines"
9956 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9957 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9958 skip "Need MDS version at least 2.7.54" && return
9960 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9961 cancel_lru_locks mdc
9963 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9964 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9965 [ $unused -eq 0 ] || error "$unused locks are not cleared"
9968 createmany -o $DIR/$tdir/f $nr ||
9969 error "failed to create $nr files in $DIR/$tdir"
9970 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9972 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9973 do_facet mds1 $LCTL set_param fail_loc=0x327
9974 do_facet mds1 $LCTL set_param fail_val=500
9977 echo "sleep 10 seconds ..."
9979 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9981 do_facet mds1 $LCTL set_param fail_loc=0
9982 do_facet mds1 $LCTL set_param fail_val=0
9983 [ $lck_cnt -lt $unused ] ||
9984 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9987 unlinkmany $DIR/$tdir/f $nr
9989 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9992 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9993 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9994 skip "Need MDS version at least 2.7.54" && return
9996 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9997 cancel_lru_locks mdc
9999 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10000 ldlm.lock_reclaim_threshold_mb)
10001 # disable reclaim temporarily
10002 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10004 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10005 do_facet mds1 $LCTL set_param fail_loc=0x328
10006 do_facet mds1 $LCTL set_param fail_val=500
10008 $LCTL set_param debug=+trace
10011 createmany -o $DIR/$tdir/f $nr &
10012 local create_pid=$!
10014 echo "Sleep $TIMEOUT seconds ..."
10016 if ! ps -p $create_pid > /dev/null 2>&1; then
10017 do_facet mds1 $LCTL set_param fail_loc=0
10018 do_facet mds1 $LCTL set_param fail_val=0
10019 do_facet mds1 $LCTL set_param \
10020 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10021 error "createmany finished incorrectly!"
10023 do_facet mds1 $LCTL set_param fail_loc=0
10024 do_facet mds1 $LCTL set_param fail_val=0
10025 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10026 wait $create_pid || return 1
10028 unlinkmany $DIR/$tdir/f $nr
10030 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10032 test_140() { #bug-17379
10033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10034 test_mkdir $DIR/$tdir
10035 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10036 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10038 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10039 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10041 while i=$((i + 1)); do
10043 cd $i || error "Changing to $i"
10044 ln -s ../stat stat || error "Creating stat symlink"
10045 # Read the symlink until ELOOP present,
10046 # not LBUGing the system is considered success,
10047 # we didn't overrun the stack.
10048 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10049 if [ $ret -ne 0 ]; then
10050 if [ $ret -eq 40 ]; then
10053 error "Open stat symlink"
10059 echo "The symlink depth = $i"
10060 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10061 error "Invalid symlink depth"
10063 # Test recursive symlink
10064 ln -s symlink_self symlink_self
10065 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10066 echo "open symlink_self returns $ret"
10067 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10069 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10073 local TF="$TMP/$tfile"
10075 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10077 cancel_lru_locks osc
10078 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10079 remount_client $MOUNT
10081 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10084 $TRUNCATE $DIR/$tfile 6000
10085 cancel_lru_locks osc
10086 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10089 echo "12345" >>$DIR/$tfile
10090 cancel_lru_locks osc
10091 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10094 echo "12345" >>$DIR/$tfile
10095 cancel_lru_locks osc
10096 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10101 run_test 150 "truncate/append tests"
10103 #LU-2902 roc_hit was not able to read all values from lproc
10104 function roc_hit_init() {
10105 local list=$(comma_list $(osts_nodes))
10106 local dir=$DIR/$tdir-check
10107 local file=$dir/$tfile
10113 #use setstripe to do a write to every ost
10114 for i in $(seq 0 $((OSTCOUNT-1))); do
10115 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10116 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10117 idx=$(printf %04x $i)
10118 BEFORE=$(get_osd_param $list *OST*$idx stats |
10119 awk '$1 == "cache_access" {sum += $7}
10120 END { printf("%0.0f", sum) }')
10122 cancel_lru_locks osc
10123 cat $file >/dev/null
10125 AFTER=$(get_osd_param $list *OST*$idx stats |
10126 awk '$1 == "cache_access" {sum += $7}
10127 END { printf("%0.0f", sum) }')
10129 echo BEFORE:$BEFORE AFTER:$AFTER
10130 if ! let "AFTER - BEFORE == 4"; then
10132 error "roc_hit is not safe to use"
10140 function roc_hit() {
10141 local list=$(comma_list $(osts_nodes))
10142 echo $(get_osd_param $list '' stats |
10143 awk '$1 == "cache_hit" {sum += $7}
10144 END { printf("%0.0f", sum) }')
10147 function set_cache() {
10150 if [ "$2" == "off" ]; then
10153 local list=$(comma_list $(osts_nodes))
10154 set_osd_param $list '' $1_cache_enable $on
10156 cancel_lru_locks osc
10160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10161 remote_ost_nodsh && skip "remote OST with nodsh" && return
10164 local list=$(comma_list $(osts_nodes))
10166 # check whether obdfilter is cache capable at all
10167 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10168 echo "not cache-capable obdfilter"
10172 # check cache is enabled on all obdfilters
10173 if get_osd_param $list '' read_cache_enable | grep 0; then
10174 echo "oss cache is disabled"
10178 set_osd_param $list '' writethrough_cache_enable 1
10180 # check write cache is enabled on all obdfilters
10181 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10182 echo "oss write cache is NOT enabled"
10188 #define OBD_FAIL_OBD_NO_LRU 0x609
10189 do_nodes $list $LCTL set_param fail_loc=0x609
10191 # pages should be in the case right after write
10192 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10195 local BEFORE=$(roc_hit)
10196 cancel_lru_locks osc
10197 cat $DIR/$tfile >/dev/null
10198 local AFTER=$(roc_hit)
10200 do_nodes $list $LCTL set_param fail_loc=0
10202 if ! let "AFTER - BEFORE == CPAGES"; then
10203 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10206 # the following read invalidates the cache
10207 cancel_lru_locks osc
10208 set_osd_param $list '' read_cache_enable 0
10209 cat $DIR/$tfile >/dev/null
10211 # now data shouldn't be found in the cache
10213 cancel_lru_locks osc
10214 cat $DIR/$tfile >/dev/null
10216 if let "AFTER - BEFORE != 0"; then
10217 error "IN CACHE: before: $BEFORE, after: $AFTER"
10220 set_osd_param $list '' read_cache_enable 1
10223 run_test 151 "test cache on oss and controls ==============================="
10226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10227 local TF="$TMP/$tfile"
10229 # simulate ENOMEM during write
10230 #define OBD_FAIL_OST_NOMEM 0x226
10231 lctl set_param fail_loc=0x80000226
10232 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10234 sync || error "sync failed"
10235 lctl set_param fail_loc=0
10237 # discard client's cache
10238 cancel_lru_locks osc
10240 # simulate ENOMEM during read
10241 lctl set_param fail_loc=0x80000226
10242 cmp $TF $DIR/$tfile || error "cmp failed"
10243 lctl set_param fail_loc=0
10247 run_test 152 "test read/write with enomem ============================"
10250 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10252 run_test 153 "test if fdatasync does not crash ======================="
10254 dot_lustre_fid_permission_check() {
10256 local ffid=$MOUNT/.lustre/fid/$fid
10259 echo "stat fid $fid"
10260 stat $ffid > /dev/null || error "stat $ffid failed."
10261 echo "touch fid $fid"
10262 touch $ffid || error "touch $ffid failed."
10263 echo "write to fid $fid"
10264 cat /etc/hosts > $ffid || error "write $ffid failed."
10265 echo "read fid $fid"
10266 diff /etc/hosts $ffid || error "read $ffid failed."
10267 echo "append write to fid $fid"
10268 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10269 echo "rename fid $fid"
10270 mv $ffid $test_dir/$tfile.1 &&
10271 error "rename $ffid to $tfile.1 should fail."
10272 touch $test_dir/$tfile.1
10273 mv $test_dir/$tfile.1 $ffid &&
10274 error "rename $tfile.1 to $ffid should fail."
10275 rm -f $test_dir/$tfile.1
10276 echo "truncate fid $fid"
10277 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10278 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10279 echo "link fid $fid"
10280 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10282 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10283 echo "setfacl fid $fid"
10284 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10285 echo "getfacl fid $fid"
10286 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10288 echo "unlink fid $fid"
10289 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10290 echo "mknod fid $fid"
10291 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10293 fid=[0xf00000400:0x1:0x0]
10294 ffid=$MOUNT/.lustre/fid/$fid
10296 echo "stat non-exist fid $fid"
10297 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10298 echo "write to non-exist fid $fid"
10299 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10300 echo "link new fid $fid"
10301 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10303 mkdir -p $test_dir/$tdir
10304 touch $test_dir/$tdir/$tfile
10305 fid=$($LFS path2fid $test_dir/$tdir)
10308 error "error: could not get fid for $test_dir/$dir/$tfile."
10310 ffid=$MOUNT/.lustre/fid/$fid
10313 ls $ffid > /dev/null || error "ls $ffid failed."
10314 echo "touch $fid/$tfile.1"
10315 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10317 echo "touch $MOUNT/.lustre/fid/$tfile"
10318 touch $MOUNT/.lustre/fid/$tfile && \
10319 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10321 echo "setxattr to $MOUNT/.lustre/fid"
10322 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10324 echo "listxattr for $MOUNT/.lustre/fid"
10325 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10327 echo "delxattr from $MOUNT/.lustre/fid"
10328 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10330 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10331 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10332 error "touch invalid fid should fail."
10334 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10335 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10336 error "touch non-normal fid should fail."
10338 echo "rename $tdir to $MOUNT/.lustre/fid"
10339 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10340 error "rename to $MOUNT/.lustre/fid should fail."
10342 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10344 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10345 local new_obf_mode=777
10347 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10348 chmod $new_obf_mode $DIR/.lustre/fid ||
10349 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10351 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10352 [ $obf_mode -eq $new_obf_mode ] ||
10353 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10355 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10356 chmod $old_obf_mode $DIR/.lustre/fid ||
10357 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10360 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10361 fid=$($LFS path2fid $test_dir/$tfile-2)
10363 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10365 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10366 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10367 error "create lov data thru .lustre failed"
10369 echo "cp /etc/passwd $test_dir/$tfile-2"
10370 cp /etc/passwd $test_dir/$tfile-2 ||
10371 error "copy to $test_dir/$tfile-2 failed."
10372 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10373 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10374 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10376 rm -rf $test_dir/tfile.lnk
10377 rm -rf $test_dir/$tfile-2
10381 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10382 skip "Need MDS version at least 2.4.1" && return
10384 local tf=$DIR/$tfile
10387 local fid=$($LFS path2fid $tf)
10388 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10390 # check that we get the same pathname back
10391 local found=$($LFS fid2path $MOUNT "$fid")
10392 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10393 [ "$found" == "$tf" ] ||
10394 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10396 run_test 154A "lfs path2fid and fid2path basic checks"
10399 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10400 skip "Need MDS version at least 2.4.1" && return
10402 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10403 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10404 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10405 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10407 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10408 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10410 # check that we get the same pathname
10411 echo "PFID: $PFID, name: $name"
10412 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10413 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10414 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10415 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10417 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10419 run_test 154B "verify the ll_decode_linkea tool"
10422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10423 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10424 { skip "Need MDS version at least 2.2.51"; return 0; }
10425 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10426 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10428 cp /etc/hosts $DIR/$tfile
10430 fid=$($LFS path2fid $DIR/$tfile)
10432 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10434 dot_lustre_fid_permission_check "$fid" $DIR ||
10435 error "dot lustre permission check $fid failed"
10437 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10439 touch $MOUNT/.lustre/file &&
10440 error "creation is not allowed under .lustre"
10442 mkdir $MOUNT/.lustre/dir &&
10443 error "mkdir is not allowed under .lustre"
10447 run_test 154a "Open-by-FID"
10450 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10451 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10452 { skip "Need MDS version at least 2.2.51"; return 0; }
10453 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10455 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10457 local remote_dir=$DIR/$tdir/remote_dir
10461 mkdir -p $DIR/$tdir
10462 $LFS mkdir -i $MDTIDX $remote_dir ||
10463 error "create remote directory failed"
10465 cp /etc/hosts $remote_dir/$tfile
10467 fid=$($LFS path2fid $remote_dir/$tfile)
10469 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10471 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10472 error "dot lustre permission check $fid failed"
10475 run_test 154b "Open-by-FID for remote directory"
10478 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10479 skip "Need MDS version at least 2.4.1" && return
10481 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10482 local FID1=$($LFS path2fid $DIR/$tfile.1)
10483 local FID2=$($LFS path2fid $DIR/$tfile.2)
10484 local FID3=$($LFS path2fid $DIR/$tfile.3)
10487 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10488 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10489 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10491 [ "$FID" = "${!want}" ] ||
10492 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10496 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10498 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10499 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10503 run_test 154c "lfs path2fid and fid2path multiple arguments"
10506 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10507 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10508 skip "Need MDS version at least 2.5.53" && return
10510 if remote_mds; then
10511 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10515 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10522 local fid=$($LFS path2fid $DIR/$tfile)
10525 cmd="exec $fd<$DIR/$tfile"
10527 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10528 echo "$fid_list" | grep "$fid"
10531 cmd="exec $fd>/dev/null"
10533 if [ $rc -ne 0 ]; then
10534 error "FID $fid not found in open files list $fid_list"
10537 run_test 154d "Verify open file fid"
10541 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10542 skip "Need MDS version at least 2.6.50" && return
10544 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10545 error ".lustre returned by readdir"
10548 run_test 154e ".lustre is not returned by readdir"
10551 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10552 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10553 test_mkdir -p -c1 $DIR/$tdir/d
10554 # test dirs inherit from its stripe
10555 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10556 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10557 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10558 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10561 # get fid of parents
10562 local FID0=$($LFS path2fid $DIR/$tdir/d)
10563 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10564 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10565 local FID3=$($LFS path2fid $DIR)
10567 # check that path2fid --parents returns expected <parent_fid>/name
10568 # 1) test for a directory (single parent)
10569 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10570 [ "$parent" == "$FID0/foo1" ] ||
10571 error "expected parent: $FID0/foo1, got: $parent"
10573 # 2) test for a file with nlink > 1 (multiple parents)
10574 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10575 echo "$parent" | grep -F "$FID1/$tfile" ||
10576 error "$FID1/$tfile not returned in parent list"
10577 echo "$parent" | grep -F "$FID2/link" ||
10578 error "$FID2/link not returned in parent list"
10580 # 3) get parent by fid
10581 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10582 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10583 echo "$parent" | grep -F "$FID1/$tfile" ||
10584 error "$FID1/$tfile not returned in parent list (by fid)"
10585 echo "$parent" | grep -F "$FID2/link" ||
10586 error "$FID2/link not returned in parent list (by fid)"
10588 # 4) test for entry in root directory
10589 parent=$($LFS path2fid --parents $DIR/f)
10590 echo "$parent" | grep -F "$FID3/f" ||
10591 error "$FID3/f not returned in parent list"
10593 # 5) test it on root directory
10594 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10595 error "$MOUNT should not have parents"
10597 # enable xattr caching and check that linkea is correctly updated
10598 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10599 save_lustre_params client "llite.*.xattr_cache" > $save
10600 lctl set_param llite.*.xattr_cache 1
10602 # 6.1) linkea update on rename
10603 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10605 # get parents by fid
10606 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10607 # foo1 should no longer be returned in parent list
10608 echo "$parent" | grep -F "$FID1" &&
10609 error "$FID1 should no longer be in parent list"
10610 # the new path should appear
10611 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10612 error "$FID2/$tfile.moved is not in parent list"
10614 # 6.2) linkea update on unlink
10615 rm -f $DIR/$tdir/d/foo2/link
10616 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10617 # foo2/link should no longer be returned in parent list
10618 echo "$parent" | grep -F "$FID2/link" &&
10619 error "$FID2/link should no longer be in parent list"
10623 restore_lustre_params < $save
10626 run_test 154f "get parent fids by reading link ea"
10630 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
10631 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
10632 { skip "Need MDS version at least 2.6.92"; return 0; }
10633 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10635 mkdir -p $DIR/$tdir
10636 llapi_fid_test -d $DIR/$tdir
10638 run_test 154g "various llapi FID tests"
10640 test_155_small_load() {
10641 local temp=$TMP/$tfile
10642 local file=$DIR/$tfile
10644 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10645 error "dd of=$temp bs=6096 count=1 failed"
10647 cancel_lru_locks osc
10648 cmp $temp $file || error "$temp $file differ"
10650 $TRUNCATE $temp 6000
10651 $TRUNCATE $file 6000
10652 cmp $temp $file || error "$temp $file differ (truncate1)"
10654 echo "12345" >>$temp
10655 echo "12345" >>$file
10656 cmp $temp $file || error "$temp $file differ (append1)"
10658 echo "12345" >>$temp
10659 echo "12345" >>$file
10660 cmp $temp $file || error "$temp $file differ (append2)"
10666 test_155_big_load() {
10667 remote_ost_nodsh && skip "remote OST with nodsh" && return
10668 local temp=$TMP/$tfile
10669 local file=$DIR/$tfile
10672 local cache_size=$(do_facet ost$((MAXI+1)) \
10673 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10674 local large_file_size=$((cache_size * 2))
10676 echo "OSS cache size: $cache_size KB"
10677 echo "Large file size: $large_file_size KB"
10679 [ $MAXV -le $large_file_size ] && \
10680 skip_env "max available OST size needs > $large_file_size KB" && \
10683 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10685 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10686 error "dd of=$temp bs=$large_file_size count=1k failed"
10689 cancel_lru_locks osc
10690 cmp $temp $file || error "$temp $file differ"
10696 save_writethrough() {
10697 local facets=$(get_facets OST)
10699 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
10700 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
10704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10705 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10706 save_writethrough $p
10709 set_cache writethrough on
10710 test_155_small_load
10711 restore_lustre_params < $p
10714 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10718 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10719 save_writethrough $p
10722 set_cache writethrough off
10723 test_155_small_load
10724 restore_lustre_params < $p
10727 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10731 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10732 save_writethrough $p
10735 set_cache writethrough on
10736 test_155_small_load
10737 restore_lustre_params < $p
10740 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10744 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10745 save_writethrough $p
10748 set_cache writethrough off
10749 test_155_small_load
10750 restore_lustre_params < $p
10753 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10757 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10758 save_writethrough $p
10761 set_cache writethrough on
10763 restore_lustre_params < $p
10766 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10770 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10771 save_writethrough $p
10774 set_cache writethrough off
10776 restore_lustre_params < $p
10779 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10783 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10784 save_writethrough $p
10787 set_cache writethrough on
10789 restore_lustre_params < $p
10792 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10796 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10797 save_writethrough $p
10800 set_cache writethrough off
10802 restore_lustre_params < $p
10805 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10808 remote_ost_nodsh && skip "remote OST with nodsh" && return
10809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10813 local file="$DIR/$tfile"
10814 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10816 [ "$(facet_fstype ost1)" = "zfs" -a \
10817 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10818 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10821 save_writethrough $p
10824 log "Turn on read and write cache"
10826 set_cache writethrough on
10828 log "Write data and read it back."
10829 log "Read should be satisfied from the cache."
10830 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10832 cancel_lru_locks osc
10833 cat $file >/dev/null
10835 if ! let "AFTER - BEFORE == CPAGES"; then
10836 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10838 log "cache hits:: before: $BEFORE, after: $AFTER"
10841 log "Read again; it should be satisfied from the cache."
10843 cancel_lru_locks osc
10844 cat $file >/dev/null
10846 if ! let "AFTER - BEFORE == CPAGES"; then
10847 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10849 log "cache hits:: before: $BEFORE, after: $AFTER"
10852 log "Turn off the read cache and turn on the write cache"
10854 set_cache writethrough on
10856 log "Read again; it should be satisfied from the cache."
10858 cancel_lru_locks osc
10859 cat $file >/dev/null
10861 if ! let "AFTER - BEFORE == CPAGES"; then
10862 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10864 log "cache hits:: before: $BEFORE, after: $AFTER"
10867 log "Read again; it should not be satisfied from the cache."
10869 cancel_lru_locks osc
10870 cat $file >/dev/null
10872 if ! let "AFTER - BEFORE == 0"; then
10873 error "IN CACHE: before: $BEFORE, after: $AFTER"
10875 log "cache hits:: before: $BEFORE, after: $AFTER"
10878 log "Write data and read it back."
10879 log "Read should be satisfied from the cache."
10880 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10882 cancel_lru_locks osc
10883 cat $file >/dev/null
10885 if ! let "AFTER - BEFORE == CPAGES"; then
10886 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10888 log "cache hits:: before: $BEFORE, after: $AFTER"
10891 log "Read again; it should not be satisfied from the cache."
10893 cancel_lru_locks osc
10894 cat $file >/dev/null
10896 if ! let "AFTER - BEFORE == 0"; then
10897 error "IN CACHE: before: $BEFORE, after: $AFTER"
10899 log "cache hits:: before: $BEFORE, after: $AFTER"
10902 log "Turn off read and write cache"
10904 set_cache writethrough off
10906 log "Write data and read it back"
10907 log "It should not be satisfied from the cache."
10909 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10910 cancel_lru_locks osc
10912 cat $file >/dev/null
10914 if ! let "AFTER - BEFORE == 0"; then
10915 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10917 log "cache hits:: before: $BEFORE, after: $AFTER"
10920 log "Turn on the read cache and turn off the write cache"
10922 set_cache writethrough off
10924 log "Write data and read it back"
10925 log "It should not be satisfied from the cache."
10927 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10929 cancel_lru_locks osc
10930 cat $file >/dev/null
10932 if ! let "AFTER - BEFORE == 0"; then
10933 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10935 log "cache hits:: before: $BEFORE, after: $AFTER"
10938 log "Read again; it should be satisfied from the cache."
10940 cancel_lru_locks osc
10941 cat $file >/dev/null
10943 if ! let "AFTER - BEFORE == CPAGES"; then
10944 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10946 log "cache hits:: before: $BEFORE, after: $AFTER"
10950 restore_lustre_params < $p
10953 run_test 156 "Verification of tunables"
10956 cleanup_changelog () {
10958 echo "Deregistering changelog client $CL_USER"
10959 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
10963 if [[ $MDSCOUNT -gt 1 ]]; then
10964 error_ignore bz17935 $*
10972 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10974 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10976 if [ $MASK -eq 1 ]; then
10977 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10979 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10983 changelog_extract_field() {
10987 local identifier=$4
10989 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10990 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10996 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10997 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10998 { skip "Need MDS version at least 2.2.0"; return; }
11000 local CL_USERS="mdd.$MDT0.changelog_users"
11001 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11002 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11003 changelog_register -n)
11004 echo "Registered as changelog user $CL_USER"
11005 trap cleanup_changelog EXIT
11006 $GET_CL_USERS | grep -q $CL_USER ||
11007 error "User $CL_USER not found in changelog_users"
11010 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11011 touch $DIR/$tdir/pics/2008/zachy/timestamp
11012 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11013 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11014 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11015 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11016 rm $DIR/$tdir/pics/desktop.jpg
11018 $LFS changelog $MDT0 | tail -5
11020 echo "verifying changelog mask"
11021 changelog_chmask "MKDIR"
11022 changelog_chmask "CLOSE"
11024 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11025 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11027 changelog_chmask "MKDIR"
11028 changelog_chmask "CLOSE"
11030 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11031 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11033 $LFS changelog $MDT0
11034 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11035 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11036 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11037 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11040 echo "verifying target fid"
11041 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11042 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11043 [ "$fidc" == "$fidf" ] ||
11044 err17935 "fid in changelog $fidc != file fid $fidf"
11045 echo "verifying parent fid"
11046 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11047 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11048 [ "$fidc" == "$fidf" ] ||
11049 err17935 "pfid in changelog $fidc != dir fid $fidf"
11051 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11052 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11053 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11054 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11055 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11056 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11058 MIN_REC=$($GET_CL_USERS |
11059 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11060 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11061 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11062 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11063 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11065 # LU-3446 changelog index reset on MDT restart
11066 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11067 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11068 $LFS changelog_clear $MDT0 $CL_USER 0
11069 stop $SINGLEMDS || error "Fail to stop MDT."
11070 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11071 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11072 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11073 [ $CUR_REC1 == $CUR_REC2 ] ||
11074 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11076 echo "verifying user deregister"
11078 $GET_CL_USERS | grep -q $CL_USER &&
11079 error "User $CL_USER still in changelog_users"
11081 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11082 if [ $CL_USER -eq 0 ]; then
11083 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11084 touch $DIR/$tdir/chloe
11085 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11086 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11087 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11089 echo "$CL_USER other changelog users; can't verify off"
11092 run_test 160a "changelog sanity"
11094 test_160b() { # LU-3587
11095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11096 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11097 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11098 { skip "Need MDS version at least 2.2.0"; return; }
11100 local CL_USERS="mdd.$MDT0.changelog_users"
11101 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11102 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11103 changelog_register -n)
11104 echo "Registered as changelog user $CL_USER"
11105 trap cleanup_changelog EXIT
11106 $GET_CL_USERS | grep -q $CL_USER ||
11107 error "User $CL_USER not found in changelog_users"
11109 local LONGNAME1=$(str_repeat a 255)
11110 local LONGNAME2=$(str_repeat b 255)
11113 echo "creating very long named file"
11114 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11115 echo "moving very long named file"
11116 mv $LONGNAME1 $LONGNAME2
11118 $LFS changelog $MDT0 | grep RENME
11122 run_test 160b "Verify that very long rename doesn't crash in changelog"
11125 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11128 local server_version=$(lustre_version_code $SINGLEMDS)
11130 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11131 [[ $server_version -gt $(version_code 2.5.1) &&
11132 $server_version -lt $(version_code 2.5.50) ]] ||
11133 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11136 # Registration step
11137 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11138 changelog_register -n)
11139 trap cleanup_changelog EXIT
11142 mkdir -p $DIR/$tdir
11143 $MCREATE $DIR/$tdir/foo_160c
11144 changelog_chmask "TRUNC"
11145 $TRUNCATE $DIR/$tdir/foo_160c 200
11146 changelog_chmask "TRUNC"
11147 $TRUNCATE $DIR/$tdir/foo_160c 199
11148 $LFS changelog $MDT0
11149 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11150 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11151 $LFS changelog_clear $MDT0 $CL_USER 0
11153 # Deregistration step
11156 run_test 160c "verify that changelog log catch the truncate event"
11159 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11160 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11162 local server_version=$(lustre_version_code mds1)
11163 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11165 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11166 { skip "Need MDS version at least 2.7.60+"; return; }
11167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11169 # Registration step
11170 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11171 changelog_register -n)
11173 trap cleanup_changelog EXIT
11174 mkdir -p $DIR/$tdir/migrate_dir
11175 $LFS changelog_clear $MDT0 $CL_USER 0
11177 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11178 $LFS changelog $MDT0
11179 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11180 $LFS changelog_clear $MDT0 $CL_USER 0
11181 [ $MIGRATES -eq 1 ] ||
11182 error "MIGRATE changelog mask count $MIGRATES != 1"
11184 # Deregistration step
11187 run_test 160d "verify that changelog log catch the migrate event"
11190 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11193 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11194 changelog_register -n)
11195 echo "Registered as changelog user $CL_USER"
11196 trap cleanup_changelog EXIT
11198 # Delete a future user (expect fail)
11199 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11202 if [ $rc -eq 0 ]; then
11203 error "Deleted non-existant user cl77"
11204 elif [ $rc -ne 2 ]; then
11205 error "changelog_deregister failed with $rc, " \
11206 "expected 2 (ENOENT)"
11209 # Clear to a bad index (1 billion should be safe)
11210 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11213 if [ $rc -eq 0 ]; then
11214 error "Successfully cleared to invalid CL index"
11215 elif [ $rc -ne 22 ]; then
11216 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11219 run_test 160e "changelog negative testing"
11222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11223 test_mkdir -c1 $DIR/$tdir
11224 cp /etc/hosts $DIR/$tdir/$tfile
11225 test_mkdir -c1 $DIR/$tdir/foo1
11226 test_mkdir -c1 $DIR/$tdir/foo2
11227 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11228 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11229 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11230 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11231 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11232 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11233 $LFS fid2path $DIR $FID
11234 err17935 "bad link ea"
11237 rm $DIR/$tdir/foo2/zachary
11239 rm $DIR/$tdir/foo2/thor
11241 rm $DIR/$tdir/$tfile
11243 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11244 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11246 $LFS fid2path $DIR $FID
11247 err17935 "bad link rename"
11249 rm $DIR/$tdir/foo2/maggie
11252 local longname=filename_avg_len_is_thirty_two_
11253 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11254 error "failed to hardlink many files"
11255 links=$($LFS fid2path $DIR $FID | wc -l)
11256 echo -n "${links}/1000 links in link EA"
11257 [[ $links -gt 60 ]] ||
11258 err17935 "expected at least 60 links in link EA"
11259 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11260 error "failed to unlink many hardlinks"
11262 run_test 161a "link ea sanity"
11265 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11266 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11268 local remote_dir=$DIR/$tdir/remote_dir
11270 mkdir -p $DIR/$tdir
11271 $LFS mkdir -i $MDTIDX $remote_dir ||
11272 error "create remote directory failed"
11274 cp /etc/hosts $remote_dir/$tfile
11275 mkdir -p $remote_dir/foo1
11276 mkdir -p $remote_dir/foo2
11277 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11278 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11279 ln $remote_dir/$tfile $remote_dir/foo1/luna
11280 ln $remote_dir/$tfile $remote_dir/foo2/thor
11282 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
11284 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11285 $LFS fid2path $DIR $FID
11286 err17935 "bad link ea"
11289 rm $remote_dir/foo2/zachary
11291 rm $remote_dir/foo2/thor
11293 rm $remote_dir/$tfile
11295 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
11296 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
11297 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
11298 $LFS fid2path $DIR $FID
11299 err17935 "bad link rename"
11301 rm $remote_dir/foo2/maggie
11304 local longname=filename_avg_len_is_thirty_two_
11305 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
11306 error "failed to hardlink many files"
11307 links=$($LFS fid2path $DIR $FID | wc -l)
11308 echo -n "${links}/1000 links in link EA"
11309 [[ ${links} -gt 60 ]] ||
11310 err17935 "expected at least 60 links in link EA"
11311 unlinkmany $remote_dir/foo2/$longname 1000 ||
11312 error "failed to unlink many hardlinks"
11314 run_test 161b "link ea sanity under remote directory"
11317 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11319 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
11320 skip "Need MDS version at least 2.1.5" && return
11322 # define CLF_RENAME_LAST 0x0001
11323 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
11324 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11325 changelog_register -n)
11327 trap cleanup_changelog EXIT
11329 mkdir -p $DIR/$tdir
11330 touch $DIR/$tdir/foo_161c
11331 touch $DIR/$tdir/bar_161c
11332 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11333 $LFS changelog $MDT0 | grep RENME
11334 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
11336 $LFS changelog_clear $MDT0 $CL_USER 0
11337 if [ x$flags != "x0x1" ]; then
11338 error "flag $flags is not 0x1"
11340 echo "rename overwrite a target having nlink = 1," \
11341 "changelog record has flags of $flags"
11343 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
11344 touch $DIR/$tdir/foo_161c
11345 touch $DIR/$tdir/bar_161c
11346 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11347 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
11348 $LFS changelog $MDT0 | grep RENME
11349 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11350 $LFS changelog_clear $MDT0 $CL_USER 0
11351 if [ x$flags != "x0x0" ]; then
11352 error "flag $flags is not 0x0"
11354 echo "rename overwrite a target having nlink > 1," \
11355 "changelog record has flags of $flags"
11357 # rename doesn't overwrite a target (changelog flag 0x0)
11358 touch $DIR/$tdir/foo_161c
11359 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
11360 $LFS changelog $MDT0 | grep RENME
11361 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
11362 $LFS changelog_clear $MDT0 $CL_USER 0
11363 if [ x$flags != "x0x0" ]; then
11364 error "flag $flags is not 0x0"
11366 echo "rename doesn't overwrite a target," \
11367 "changelog record has flags of $flags"
11369 # define CLF_UNLINK_LAST 0x0001
11370 # unlink a file having nlink = 1 (changelog flag 0x1)
11371 rm -f $DIR/$tdir/foo2_161c
11372 $LFS changelog $MDT0 | grep UNLNK
11373 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11374 $LFS changelog_clear $MDT0 $CL_USER 0
11375 if [ x$flags != "x0x1" ]; then
11376 error "flag $flags is not 0x1"
11378 echo "unlink a file having nlink = 1," \
11379 "changelog record has flags of $flags"
11381 # unlink a file having nlink > 1 (changelog flag 0x0)
11382 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
11383 rm -f $DIR/$tdir/foobar_161c
11384 $LFS changelog $MDT0 | grep UNLNK
11385 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
11386 $LFS changelog_clear $MDT0 $CL_USER 0
11387 if [ x$flags != "x0x0" ]; then
11388 error "flag $flags is not 0x0"
11390 echo "unlink a file having nlink > 1," \
11391 "changelog record has flags of $flags"
11394 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
11401 # cleanup previous run
11402 rm -rf $DIR/$tdir/$tfile
11404 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11405 changelog_register -n)
11406 [[ $? -eq 0 ]] || error "changelog_register failed"
11408 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
11409 # interfer with $MOUNT/.lustre/fid/ access
11411 [[ $? -eq 0 ]] || error "mkdir failed"
11413 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
11414 $LCTL set_param fail_loc=0x8000140c
11416 $LCTL set_param fail_val=5
11419 echo foofoo > $DIR/$tdir/$tfile &
11422 # wait for create to be delayed
11426 [[ $? -eq 0 ]] || error "create should be blocked"
11428 local tempfile=$(mktemp)
11429 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
11430 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
11431 # some delay may occur during ChangeLog publishing and file read just
11432 # above, that could allow file write to happen finally
11433 [[ -s $tempfile ]] && echo "file should be empty"
11435 $LCTL set_param fail_loc=0
11438 [[ $? -eq 0 ]] || error "create failed"
11440 $LFS changelog_clear $MDT0 $user 0
11441 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
11443 run_test 161d "create with concurrent .lustre/fid access"
11450 local path=$(${LFS} fid2path $*)
11451 # Remove the '//' indicating a remote directory
11452 path=$(echo $path | sed 's#//#/#g')
11455 if [ $RC -ne 0 ]; then
11456 err17935 "path looked up of $expected failed. Error $RC"
11458 elif [ "${path}" != "${expected}" ]; then
11459 err17935 "path looked up \"${path}\" instead of \"${expected}\""
11462 echo "fid $fid resolves to path $path (expected $expected)"
11465 test_162a() { # was test_162
11466 # Make changes to filesystem
11467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11468 test_mkdir -p -c1 $DIR/$tdir/d2
11469 touch $DIR/$tdir/d2/$tfile
11470 touch $DIR/$tdir/d2/x1
11471 touch $DIR/$tdir/d2/x2
11472 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
11473 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
11475 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
11476 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
11477 error "check path $tdir/d2/$tfile failed"
11480 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
11481 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
11482 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
11483 error "check path $tdir/d2/p/q/r/slink failed"
11485 # softlink to wrong file
11486 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
11487 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
11488 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
11489 error "check path $tdir/d2/p/q/r/slink.wrong failed"
11492 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
11493 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
11494 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
11495 # fid2path dir/fsname should both work
11496 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
11497 error "check path $tdir/d2/a/b/c/new_file failed"
11498 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
11499 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
11501 # hardlink count: check that there are 2 links
11502 # Doesnt work with CMD yet: 17935
11503 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
11504 err17935 "expected 2 links"
11506 # hardlink indexing: remove the first link
11507 rm $DIR/$tdir/d2/p/q/r/hlink
11508 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
11509 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
11513 run_test 162a "path lookup sanity"
11516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11517 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11520 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
11521 error "create striped dir failed"
11523 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
11524 tail -n 1 | awk '{print $2}')
11525 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
11527 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
11528 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
11531 for ((i=0;i<5;i++)); do
11532 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
11533 error "get fid for f$i failed"
11534 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
11535 error "check path $tdir/striped_dir/f$i failed"
11537 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
11538 error "get fid for d$i failed"
11539 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
11540 error "check path $tdir/striped_dir/d$i failed"
11545 run_test 162b "striped directory path lookup sanity"
11547 # LU-4239: Verify fid2path works with paths 100 or more directories deep
11549 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
11550 skip "Need MDS version at least 2.7.51" && return
11551 test_mkdir $DIR/$tdir.local
11552 test_mkdir $DIR/$tdir.remote
11553 local lpath=$tdir.local
11554 local rpath=$tdir.remote
11556 for ((i = 0; i <= 101; i++)); do
11559 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
11560 error "get fid for local directory $DIR/$lpath failed"
11561 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
11562 error "check path for local directory $DIR/$lpath failed"
11565 test_mkdir $DIR/$rpath
11566 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
11567 error "get fid for remote directory $DIR/$rpath failed"
11568 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
11569 error "check path for remote directory $DIR/$rpath failed"
11574 run_test 162c "fid2path works with paths 100 or more directories deep"
11577 # do directio so as not to populate the page cache
11578 log "creating a 10 Mb file"
11579 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11580 log "starting reads"
11581 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11582 log "truncating the file"
11583 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11585 kill %+ || true # reads might have finished
11586 echo "wait until dd is finished"
11588 log "removing the temporary file"
11589 rm -rf $DIR/$tfile || error "tmp file removal failed"
11591 run_test 169 "parallel read and truncate should not deadlock"
11594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11595 $LCTL clear # bug 18514
11596 $LCTL debug_daemon start $TMP/${tfile}_log_good
11598 $LCTL debug_daemon stop
11599 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11600 error "sed failed to read log_good"
11602 $LCTL debug_daemon start $TMP/${tfile}_log_good
11604 $LCTL debug_daemon stop
11606 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11607 error "lctl df log_bad failed"
11609 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11610 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11612 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11613 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11615 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11616 error "bad_line good_line1 good_line2 are empty"
11618 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11619 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11620 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11622 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11623 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11624 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11626 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11627 error "bad_line_new good_line_new are empty"
11629 local expected_good=$((good_line1 + good_line2*2))
11631 rm -f $TMP/${tfile}*
11632 # LU-231, short malformed line may not be counted into bad lines
11633 if [ $bad_line -ne $bad_line_new ] &&
11634 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11635 error "expected $bad_line bad lines, but got $bad_line_new"
11639 if [ $expected_good -ne $good_line_new ]; then
11640 error "expected $expected_good good lines, but got $good_line_new"
11645 run_test 170 "test lctl df to handle corrupted log ====================="
11647 test_171() { # bug20592
11648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11649 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11650 $LCTL set_param fail_loc=0x50e
11651 $LCTL set_param fail_val=3000
11652 multiop_bg_pause $DIR/$tfile O_s || true
11654 kill -USR1 $MULTIPID
11658 if dmesg | grep "recursive fault"; then
11659 error "caught a recursive fault"
11661 $LCTL set_param fail_loc=0
11664 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11666 # it would be good to share it with obdfilter-survey/iokit-libecho code
11667 setup_obdecho_osc () {
11670 local obdfilter_name=$2
11671 echo "Creating new osc for $obdfilter_name on $ost_nid"
11672 # make sure we can find loopback nid
11673 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11675 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11676 ${obdfilter_name}_osc_UUID || rc=2; }
11677 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11678 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11682 cleanup_obdecho_osc () {
11683 local obdfilter_name=$1
11684 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11685 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11692 local pages=${3:-64}
11697 local obd_size=$(get_obd_size $node $OBD)
11698 local page_size=$(get_page_size $node)
11699 if [[ -n "$obd_size" ]]; then
11700 local new_count=$((obd_size / (pages * page_size / 1024)))
11701 [[ $new_count -ge $count ]] || count=$new_count
11704 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11705 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11707 if [ $rc -eq 0 ]; then
11708 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11709 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11711 echo "New object id is $id"
11712 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11714 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11715 "test_brw $count w v $pages $id" || rc=4; }
11716 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11718 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11719 "cleanup" || rc=5; }
11720 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11721 "detach" || rc=6; }
11722 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11728 remote_ost_nodsh && skip "remote OST with nodsh" && return
11730 local rmmod_local=0
11732 if ! module_loaded obdecho; then
11733 load_module obdecho/obdecho
11737 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11738 local host=$(lctl get_param -n osc.$osc.import |
11739 awk '/current_connection:/ {print $2}' )
11740 local target=$(lctl get_param -n osc.$osc.import |
11741 awk '/target:/ {print $2}' )
11742 target=${target%_UUID}
11744 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11745 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11746 [[ -n $target ]] && cleanup_obdecho_osc $target
11747 [ $rmmod_local -eq 1 ] && rmmod obdecho
11750 run_test 180a "test obdecho on osc"
11753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11754 remote_ost_nodsh && skip "remote OST with nodsh" && return
11756 local rmmod_remote=0
11758 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11759 rmmod_remote=true || error "failed to load module obdecho"
11760 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11761 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11762 $rmmod_remote && do_facet ost1 "rmmod obdecho"
11765 run_test 180b "test obdecho directly on obdfilter"
11767 test_180c() { # LU-2598
11768 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11769 remote_ost_nodsh && skip "remote OST with nodsh" && return
11770 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11771 skip "Need MDS version at least 2.4.0" && return
11774 local rmmod_remote=false
11775 local pages=16384 # 64MB bulk I/O RPC size
11778 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11779 rmmod_remote=true || error "failed to load module obdecho"
11781 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11783 if [ -n "$target" ]; then
11784 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11786 echo "there is no obdfilter target on ost1"
11789 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11792 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11794 test_181() { # bug 22177
11795 test_mkdir $DIR/$tdir
11796 # create enough files to index the directory
11797 createmany -o $DIR/$tdir/foobar 4000
11798 # print attributes for debug purpose
11801 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11803 # remove the files & current working dir
11804 unlinkmany $DIR/$tdir/foobar 4000
11806 kill -USR1 $MULTIPID
11808 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11811 run_test 181 "Test open-unlinked dir ========================"
11817 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11819 $LCTL set_param mdc.*.rpc_stats=clear
11821 for (( i = 0; i < $tcount; i++ )) ; do
11822 mkdir $DIR/$tdir/$i
11825 for (( i = 0; i < $tcount; i++ )) ; do
11826 createmany -o $DIR/$tdir/$i/f- $fcount &
11830 for (( i = 0; i < $tcount; i++ )) ; do
11831 unlinkmany $DIR/$tdir/$i/f- $fcount &
11835 $LCTL get_param mdc.*.rpc_stats
11839 run_test 182 "Test parallel modify metadata operations ================"
11841 test_183() { # LU-2275
11842 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11843 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11844 skip "Need MDS version at least 2.3.56" && return
11846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11847 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11848 echo aaa > $DIR/$tdir/$tfile
11850 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11851 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11853 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11854 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11856 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11858 # Flush negative dentry cache
11859 touch $DIR/$tdir/$tfile
11861 # We are not checking for any leaked references here, they'll
11862 # become evident next time we do cleanup with module unload.
11865 run_test 183 "No crash or request leak in case of strange dispositions ========"
11867 # test suite 184 is for LU-2016, LU-2017
11869 check_swap_layouts_support && return 0
11871 dir0=$DIR/$tdir/$testnum
11872 test_mkdir -p -c1 $dir0
11877 $SETSTRIPE -c1 $file1
11879 $SETSTRIPE -c2 $file2
11881 gen1=$($GETSTRIPE -g $file1)
11882 gen2=$($GETSTRIPE -g $file2)
11884 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11885 gen=$($GETSTRIPE -g $file1)
11886 [[ $gen1 != $gen ]] ||
11887 "Layout generation on $file1 does not change"
11888 gen=$($GETSTRIPE -g $file2)
11889 [[ $gen2 != $gen ]] ||
11890 "Layout generation on $file2 does not change"
11892 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11893 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11895 run_test 184a "Basic layout swap"
11898 check_swap_layouts_support && return 0
11900 dir0=$DIR/$tdir/$testnum
11901 mkdir -p $dir0 || error "creating dir $dir0"
11908 $SETSTRIPE -c1 $file1
11909 $SETSTRIPE -c2 $file2
11910 $SETSTRIPE -c1 $file3
11911 chown $RUNAS_ID $file3
11912 gen1=$($GETSTRIPE -g $file1)
11913 gen2=$($GETSTRIPE -g $file2)
11915 $LFS swap_layouts $dir1 $dir2 &&
11916 error "swap of directories layouts should fail"
11917 $LFS swap_layouts $dir1 $file1 &&
11918 error "swap of directory and file layouts should fail"
11919 $RUNAS $LFS swap_layouts $file1 $file2 &&
11920 error "swap of file we cannot write should fail"
11921 $LFS swap_layouts $file1 $file3 &&
11922 error "swap of file with different owner should fail"
11923 /bin/true # to clear error code
11925 run_test 184b "Forbidden layout swap (will generate errors)"
11928 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
11929 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
11930 check_swap_layouts_support && return 0
11932 local dir0=$DIR/$tdir/$testnum
11933 mkdir -p $dir0 || error "creating dir $dir0"
11935 local ref1=$dir0/ref1
11936 local ref2=$dir0/ref2
11937 local file1=$dir0/file1
11938 local file2=$dir0/file2
11939 # create a file large enough for the concurrent test
11940 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11941 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11942 echo "ref file size: ref1($(stat -c %s $ref1))," \
11943 "ref2($(stat -c %s $ref2))"
11946 dd if=$ref1 of=$file1 bs=16k &
11949 # Make sure dd starts to copy file
11950 while [ ! -f $file1 ]; do sleep 0.1; done
11952 $LFS swap_layouts $file1 $file2
11955 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11956 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11958 # how many bytes copied before swapping layout
11959 local copied=$(stat -c %s $file2)
11960 local remaining=$(stat -c %s $ref1)
11961 remaining=$((remaining - copied))
11962 echo "Copied $copied bytes before swapping layout..."
11964 cmp -n $copied $file1 $ref2 | grep differ &&
11965 error "Content mismatch [0, $copied) of ref2 and file1"
11966 cmp -n $copied $file2 $ref1 ||
11967 error "Content mismatch [0, $copied) of ref1 and file2"
11968 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11969 error "Content mismatch [$copied, EOF) of ref1 and file1"
11972 rm -f $ref1 $ref2 $file1 $file2
11974 run_test 184c "Concurrent write and layout swap"
11977 check_swap_layouts_support && return 0
11978 [ -z "$(which getfattr 2>/dev/null)" ] &&
11979 skip "no getfattr command" && return 0
11981 local file1=$DIR/$tdir/$tfile-1
11982 local file2=$DIR/$tdir/$tfile-2
11983 local file3=$DIR/$tdir/$tfile-3
11987 mkdir -p $DIR/$tdir
11988 touch $file1 || error "create $file1 failed"
11989 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11990 error "create $file2 failed"
11991 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11992 error "create $file3 failed"
11993 lovea1=$(get_layout_param $file1)
11995 $LFS swap_layouts $file2 $file3 ||
11996 error "swap $file2 $file3 layouts failed"
11997 $LFS swap_layouts $file1 $file2 ||
11998 error "swap $file1 $file2 layouts failed"
12000 lovea2=$(get_layout_param $file2)
12003 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12005 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12006 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12008 run_test 184d "allow stripeless layouts swap"
12011 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12012 { skip "Need MDS version at least 2.6.94"; return 0; }
12013 check_swap_layouts_support && return 0
12014 [ -z "$(which getfattr 2>/dev/null)" ] &&
12015 skip "no getfattr command" && return 0
12017 local file1=$DIR/$tdir/$tfile-1
12018 local file2=$DIR/$tdir/$tfile-2
12019 local file3=$DIR/$tdir/$tfile-3
12022 mkdir -p $DIR/$tdir
12023 touch $file1 || error "create $file1 failed"
12024 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12025 error "create $file2 failed"
12026 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12027 error "create $file3 failed"
12029 $LFS swap_layouts $file1 $file2 ||
12030 error "swap $file1 $file2 layouts failed"
12032 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12033 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12035 echo 123 > $file1 || error "Should be able to write into $file1"
12037 $LFS swap_layouts $file1 $file3 ||
12038 error "swap $file1 $file3 layouts failed"
12040 echo 123 > $file1 || error "Should be able to write into $file1"
12042 rm -rf $file1 $file2 $file3
12044 run_test 184e "Recreate layout after stripeless layout swaps"
12046 test_185() { # LU-2441
12047 # LU-3553 - no volatile file support in old servers
12048 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12049 { skip "Need MDS version at least 2.3.60"; return 0; }
12051 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12052 touch $DIR/$tdir/spoo
12053 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12054 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12055 error "cannot create/write a volatile file"
12056 [ "$FILESET" == "" ] &&
12057 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12058 error "FID is still valid after close"
12060 multiop_bg_pause $DIR/$tdir vVw4096_c
12067 # assume that the next FID for this client is sequential, since stdout
12068 # is unfortunately eaten by multiop_bg_pause
12069 local n=$((${fidv[1]} + 1))
12070 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12071 if [ "$FILESET" == "" ]; then
12072 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12073 error "FID is missing before close"
12075 kill -USR1 $multi_pid
12076 # 1 second delay, so if mtime change we will see it
12078 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12079 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12081 run_test 185 "Volatile file support"
12084 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12085 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12086 skip "Need MDS version at least 2.3.0" && return
12088 local dir0=$DIR/$tdir/$testnum
12089 mkdir -p $dir0 || error "creating dir $dir0"
12091 local file=$dir0/file1
12092 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12093 local dv1=$($LFS data_version $file)
12094 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12095 local dv2=$($LFS data_version $file)
12096 [[ $dv1 != $dv2 ]] ||
12097 error "data version did not change on write $dv1 == $dv2"
12102 run_test 187a "Test data version change"
12105 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12106 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12107 skip "Need MDS version at least 2.3.0" && return
12109 local dir0=$DIR/$tdir/$testnum
12110 mkdir -p $dir0 || error "creating dir $dir0"
12112 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12113 [[ ${DV[0]} != ${DV[1]} ]] ||
12114 error "data version did not change on write"\
12115 " ${DV[0]} == ${DV[1]}"
12120 run_test 187b "Test data version change on volatile file"
12123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12124 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12125 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12127 local POOL=${POOL:-cea1}
12128 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12129 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12132 local last_ost=$(($OSTCOUNT - 1))
12134 local ost_list=$(seq $first_ost $ost_step $last_ost)
12135 local ost_range="$first_ost $last_ost $ost_step"
12136 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12137 local file_dir=$POOL_ROOT/file_tst
12138 local subdir=$test_path/subdir
12142 # former test_200a test_200b
12143 pool_add $POOL || { rc=$? ; break; }
12144 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12145 # former test_200c test_200d
12146 mkdir -p $test_path
12147 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12148 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12150 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12151 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12152 || { rc=$? ; break; }
12153 # former test_200e test_200f
12154 local files=$((OSTCOUNT*3))
12155 pool_alloc_files $POOL $test_path $files "$ost_list" \
12156 || { rc=$? ; break; }
12157 pool_create_files $POOL $file_dir $files "$ost_list" \
12158 || { rc=$? ; break; }
12159 # former test_200g test_200h
12160 pool_lfs_df $POOL || { rc=$? ; break; }
12161 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12163 # former test_201a test_201b test_201c
12164 pool_remove_first_target $POOL || { rc=$? ; break; }
12166 local f=$test_path/$tfile
12167 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12168 pool_remove $POOL $f || { rc=$? ; break; }
12175 run_test 200 "OST pools"
12177 # usage: default_attr <count | size | offset>
12179 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12182 # usage: check_default_stripe_attr
12183 check_default_stripe_attr() {
12184 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12187 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12189 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12193 error "unknown getstripe attr '$1'"
12196 [ $ACTUAL == $EXPECTED ] ||
12197 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12201 test_mkdir $DIR/$tdir
12202 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12204 check_default_stripe_attr --stripe-count
12205 check_default_stripe_attr --stripe-size
12206 check_default_stripe_attr --stripe-index
12208 run_test 204a "Print default stripe attributes"
12211 test_mkdir $DIR/$tdir
12212 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12214 check_default_stripe_attr --stripe-size
12215 check_default_stripe_attr --stripe-index
12217 run_test 204b "Print default stripe size and offset"
12220 test_mkdir $DIR/$tdir
12221 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12223 check_default_stripe_attr --stripe-count
12224 check_default_stripe_attr --stripe-index
12226 run_test 204c "Print default stripe count and offset"
12229 test_mkdir $DIR/$tdir
12230 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12232 check_default_stripe_attr --stripe-count
12233 check_default_stripe_attr --stripe-size
12235 run_test 204d "Print default stripe count and size"
12238 test_mkdir $DIR/$tdir
12239 $SETSTRIPE -d $DIR/$tdir
12241 check_default_stripe_attr --stripe-count --raw
12242 check_default_stripe_attr --stripe-size --raw
12243 check_default_stripe_attr --stripe-index --raw
12245 run_test 204e "Print raw stripe attributes"
12248 test_mkdir $DIR/$tdir
12249 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12251 check_default_stripe_attr --stripe-size --raw
12252 check_default_stripe_attr --stripe-index --raw
12254 run_test 204f "Print raw stripe size and offset"
12257 test_mkdir $DIR/$tdir
12258 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12260 check_default_stripe_attr --stripe-count --raw
12261 check_default_stripe_attr --stripe-index --raw
12263 run_test 204g "Print raw stripe count and offset"
12266 test_mkdir $DIR/$tdir
12267 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12269 check_default_stripe_attr --stripe-count --raw
12270 check_default_stripe_attr --stripe-size --raw
12272 run_test 204h "Print raw stripe count and size"
12274 # Figure out which job scheduler is being used, if any,
12275 # or use a fake one
12276 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
12277 JOBENV=SLURM_JOB_ID
12278 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
12280 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
12282 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
12283 JOBENV=LOADL_STEP_ID
12284 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
12287 $LCTL list_param jobid_name > /dev/null 2>&1
12288 if [ $? -eq 0 ]; then
12295 verify_jobstats() {
12300 # we don't really need to clear the stats for this test to work, since each
12301 # command has a unique jobid, but it makes debugging easier if needed.
12302 # for facet in $facets; do
12303 # local dev=$(convert_facet2label $facet)
12304 # # clear old jobstats
12305 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
12308 # use a new JobID for each test, or we might see an old one
12309 [ "$JOBENV" = "FAKE_JOBID" ] &&
12310 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12314 [ "$JOBENV" = "nodelocal" ] && {
12315 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
12316 $LCTL set_param jobid_name=$FAKE_JOBID
12320 log "Test: ${cmd[*]}"
12321 log "Using JobID environment variable $JOBENV=$JOBVAL"
12323 if [ $JOBENV = "FAKE_JOBID" ]; then
12324 FAKE_JOBID=$JOBVAL ${cmd[*]}
12329 # all files are created on OST0000
12330 for facet in $facets; do
12331 local stats="*.$(convert_facet2label $facet).job_stats"
12332 if [ $(do_facet $facet lctl get_param $stats |
12333 grep -c $JOBVAL) -ne 1 ]; then
12334 do_facet $facet lctl get_param $stats
12335 error "No jobstats for $JOBVAL found on $facet::$stats"
12342 NEW_JOBENV=${1:-$OLD_JOBENV}
12343 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
12344 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
12349 do_facet $SINGLEMDS \
12350 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
12351 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
12355 test_205() { # Job stats
12356 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
12357 { skip "Need MDS version with at least 2.7.1"; return 0; }
12359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12360 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12361 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12362 remote_ost_nodsh && skip "remote OST with nodsh" && return
12364 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
12365 skip "Server doesn't support jobstats" && return 0
12366 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
12368 OLD_JOBENV=$($LCTL get_param -n jobid_var)
12369 if [ $OLD_JOBENV != $JOBENV ]; then
12370 jobstats_set $JOBENV
12371 trap cleanup_205 EXIT
12374 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
12375 echo "Registered as changelog user $CL_USER"
12377 OLD_INTERVAL=$(do_facet $SINGLEMDS \
12378 lctl get_param -n mdt.*.job_cleanup_interval)
12379 local interval_new=5
12380 do_facet $SINGLEMDS \
12381 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
12382 local start=$SECONDS
12386 cmd="mkdir $DIR/$tdir"
12387 verify_jobstats "$cmd" "$SINGLEMDS"
12389 cmd="rmdir $DIR/$tdir"
12390 verify_jobstats "$cmd" "$SINGLEMDS"
12391 # mkdir on secondary MDT
12392 if [ $MDSCOUNT -gt 1 ]; then
12393 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
12394 verify_jobstats "$cmd" "mds2"
12397 cmd="mknod $DIR/$tfile c 1 3"
12398 verify_jobstats "$cmd" "$SINGLEMDS"
12400 cmd="rm -f $DIR/$tfile"
12401 verify_jobstats "$cmd" "$SINGLEMDS"
12402 # create all files on OST0000 so verify_jobstats can find OST stats
12404 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
12405 verify_jobstats "$cmd" "$SINGLEMDS"
12407 cmd="touch $DIR/$tfile"
12408 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12410 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
12411 verify_jobstats "$cmd" "ost1"
12413 cancel_lru_locks osc
12414 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
12415 verify_jobstats "$cmd" "ost1"
12417 cmd="$TRUNCATE $DIR/$tfile 0"
12418 verify_jobstats "$cmd" "$SINGLEMDS ost1"
12420 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
12421 verify_jobstats "$cmd" "$SINGLEMDS"
12422 # jobstats expiry - sleep until old stats should be expired
12423 local left=$((interval_new + 5 - (SECONDS - start)))
12424 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
12425 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
12427 cmd="mkdir $DIR/$tdir.expire"
12428 verify_jobstats "$cmd" "$SINGLEMDS"
12429 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
12430 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
12432 # Ensure that jobid are present in changelog (if supported by MDS)
12433 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
12435 $LFS changelog $MDT0 | tail -9
12436 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
12437 [ $jobids -eq 9 ] ||
12438 error "Wrong changelog jobid count $jobids != 9"
12442 jobstats_set $JOBENV
12444 $LFS changelog $MDT0 | tail -1
12445 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
12446 [ $jobids -eq 0 ] ||
12447 error "Unexpected jobids when jobid_var=$JOBENV"
12452 run_test 205 "Verify job stats"
12454 # LU-1480, LU-1773 and LU-1657
12456 mkdir -p $DIR/$tdir
12457 $SETSTRIPE -c -1 $DIR/$tdir
12458 #define OBD_FAIL_LOV_INIT 0x1403
12459 $LCTL set_param fail_loc=0xa0001403
12460 $LCTL set_param fail_val=1
12461 touch $DIR/$tdir/$tfile || true
12463 run_test 206 "fail lov_init_raid0() doesn't lbug"
12466 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12467 local fsz=`stat -c %s $DIR/$tfile`
12468 cancel_lru_locks mdc
12470 # do not return layout in getattr intent
12471 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
12472 $LCTL set_param fail_loc=0x170
12473 local sz=`stat -c %s $DIR/$tfile`
12475 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
12479 run_test 207a "can refresh layout at glimpse"
12482 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
12483 local cksum=`md5sum $DIR/$tfile`
12484 local fsz=`stat -c %s $DIR/$tfile`
12485 cancel_lru_locks mdc
12486 cancel_lru_locks osc
12488 # do not return layout in getattr intent
12489 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
12490 $LCTL set_param fail_loc=0x171
12492 # it will refresh layout after the file is opened but before read issues
12493 echo checksum is "$cksum"
12494 echo "$cksum" |md5sum -c --quiet || error "file differs"
12498 run_test 207b "can refresh layout at open"
12501 # FIXME: in this test suite, only RD lease is used. This is okay
12502 # for now as only exclusive open is supported. After generic lease
12503 # is done, this test suite should be revised. - Jinshan
12505 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12506 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
12507 { skip "Need MDS version at least 2.4.52"; return 0; }
12509 echo "==== test 1: verify get lease work"
12510 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
12512 echo "==== test 2: verify lease can be broken by upcoming open"
12513 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12517 $MULTIOP $DIR/$tfile oO_RDONLY:c
12518 kill -USR1 $PID && wait $PID || error "break lease error"
12520 echo "==== test 3: verify lease can't be granted if an open already exists"
12521 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
12525 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
12526 kill -USR1 $PID && wait $PID || error "open file error"
12528 echo "==== test 4: lease can sustain over recovery"
12529 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
12535 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
12537 echo "==== test 5: lease broken can't be regained by replay"
12538 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
12542 # open file to break lease and then recovery
12543 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
12546 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
12550 run_test 208 "Exclusive open"
12553 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
12554 skip_env "must have disp_stripe" && return
12557 sync; sleep 5; sync;
12559 echo 3 > /proc/sys/vm/drop_caches
12560 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12562 # open/close 500 times
12563 for i in $(seq 500); do
12567 echo 3 > /proc/sys/vm/drop_caches
12568 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
12570 echo "before: $req_before, after: $req_after"
12571 [ $((req_after - req_before)) -ge 300 ] &&
12572 error "open/close requests are not freed"
12575 run_test 209 "read-only open/close requests should be freed promptly"
12579 size=$((size % 8192 + 1))
12580 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12581 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12582 rm -f $DIR/f212 $DIR/f212.xyz
12584 run_test 212 "Sendfile test ============================================"
12587 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12588 cancel_lru_locks osc
12589 lctl set_param fail_loc=0x8000040f
12590 # generate a read lock
12591 cat $DIR/$tfile > /dev/null
12592 # write to the file, it will try to cancel the above read lock.
12593 cat /etc/hosts >> $DIR/$tfile
12595 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12597 test_214() { # for bug 20133
12598 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12599 for (( i=0; i < 340; i++ )) ; do
12600 touch $DIR/$tdir/d214c/a$i
12603 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12604 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12605 ls $DIR/d214c || error "ls $DIR/d214c failed"
12606 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12607 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12609 run_test 214 "hash-indexed directory test - bug 20133"
12611 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12612 create_lnet_proc_files() {
12613 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
12616 # counterpart of create_lnet_proc_files
12617 remove_lnet_proc_files() {
12618 rm -f $TMP/lnet_$1.sys
12621 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12622 # 3rd arg as regexp for body
12623 check_lnet_proc_stats() {
12624 local l=$(cat "$TMP/lnet_$1" |wc -l)
12625 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12627 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12630 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12631 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12632 # optional and can be regexp for 2nd line (lnet.routes case)
12633 check_lnet_proc_entry() {
12634 local blp=2 # blp stands for 'position of 1st line of body'
12635 [ -z "$5" ] || blp=3 # lnet.routes case
12637 local l=$(cat "$TMP/lnet_$1" |wc -l)
12638 # subtracting one from $blp because the body can be empty
12639 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12641 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12642 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12644 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12645 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12647 # bail out if any unexpected line happened
12648 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12649 [ "$?" != 0 ] || error "$2 misformatted"
12652 test_215() { # for bugs 18102, 21079, 21517
12653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12654 local N='(0|[1-9][0-9]*)' # non-negative numeric
12655 local P='[1-9][0-9]*' # positive numeric
12656 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12657 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12658 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12659 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12661 local L1 # regexp for 1st line
12662 local L2 # regexp for 2nd line (optional)
12663 local BR # regexp for the rest (body)
12665 # lnet.stats should look as 11 space-separated non-negative numerics
12666 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12667 create_lnet_proc_files "stats"
12668 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12669 remove_lnet_proc_files "stats"
12671 # lnet.routes should look like this:
12672 # Routing disabled/enabled
12673 # net hops priority state router
12674 # where net is a string like tcp0, hops > 0, priority >= 0,
12675 # state is up/down,
12676 # router is a string like 192.168.1.1@tcp2
12677 L1="^Routing (disabled|enabled)$"
12678 L2="^net +hops +priority +state +router$"
12679 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12680 create_lnet_proc_files "routes"
12681 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12682 remove_lnet_proc_files "routes"
12684 # lnet.routers should look like this:
12685 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12686 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12687 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12688 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12689 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12690 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12691 create_lnet_proc_files "routers"
12692 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12693 remove_lnet_proc_files "routers"
12695 # lnet.peers should look like this:
12696 # nid refs state last max rtr min tx min queue
12697 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12698 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12699 # numeric (0 or >0 or <0), queue >= 0.
12700 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12701 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12702 create_lnet_proc_files "peers"
12703 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12704 remove_lnet_proc_files "peers"
12706 # lnet.buffers should look like this:
12707 # pages count credits min
12708 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12709 L1="^pages +count +credits +min$"
12710 BR="^ +$N +$N +$I +$I$"
12711 create_lnet_proc_files "buffers"
12712 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12713 remove_lnet_proc_files "buffers"
12715 # lnet.nis should look like this:
12716 # nid status alive refs peer rtr max tx min
12717 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12718 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12719 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12720 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12721 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12722 create_lnet_proc_files "nis"
12723 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12724 remove_lnet_proc_files "nis"
12726 # can we successfully write to lnet.stats?
12727 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12729 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12731 test_216() { # bug 20317
12732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12733 remote_ost_nodsh && skip "remote OST with nodsh" && return
12736 local facets=$(get_facets OST)
12737 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12739 save_lustre_params client "osc.*.contention_seconds" > $p
12740 save_lustre_params $facets \
12741 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12742 save_lustre_params $facets \
12743 "ldlm.namespaces.filter-*.contended_locks" >> $p
12744 save_lustre_params $facets \
12745 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12746 clear_stats osc.*.osc_stats
12748 # agressive lockless i/o settings
12749 do_nodes $(comma_list $(osts_nodes)) \
12750 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
12751 ldlm.namespaces.filter-*.contended_locks=0 \
12752 ldlm.namespaces.filter-*.contention_seconds=60"
12753 lctl set_param -n osc.*.contention_seconds=60
12755 $DIRECTIO write $DIR/$tfile 0 10 4096
12756 $CHECKSTAT -s 40960 $DIR/$tfile
12758 # disable lockless i/o
12759 do_nodes $(comma_list $(osts_nodes)) \
12760 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
12761 ldlm.namespaces.filter-*.contended_locks=32 \
12762 ldlm.namespaces.filter-*.contention_seconds=0"
12763 lctl set_param -n osc.*.contention_seconds=0
12764 clear_stats osc.*.osc_stats
12766 dd if=/dev/zero of=$DIR/$tfile count=0
12767 $CHECKSTAT -s 0 $DIR/$tfile
12769 restore_lustre_params <$p
12773 run_test 216 "check lockless direct write updates file size and kms correctly"
12775 test_217() { # bug 22430
12776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12780 for node in $(nodes_list); do
12781 nid=$(host_nids_address $node $NETTYPE)
12782 if [[ $nid = *-* ]] ; then
12783 echo "lctl ping $(h2nettype $nid)"
12784 lctl ping $(h2nettype $nid)
12786 echo "skipping $node (no hyphen detected)"
12790 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12793 # do directio so as not to populate the page cache
12794 log "creating a 10 Mb file"
12795 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12796 log "starting reads"
12797 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12798 log "truncating the file"
12799 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12801 kill %+ || true # reads might have finished
12802 echo "wait until dd is finished"
12804 log "removing the temporary file"
12805 rm -rf $DIR/$tfile || error "tmp file removal failed"
12807 run_test 218 "parallel read and truncate should not deadlock ======================="
12810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12811 # write one partial page
12812 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12813 # set no grant so vvp_io_commit_write will do sync write
12814 $LCTL set_param fail_loc=0x411
12815 # write a full page at the end of file
12816 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12818 $LCTL set_param fail_loc=0
12819 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12820 $LCTL set_param fail_loc=0x411
12821 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12824 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12825 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12827 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12829 test_220() { #LU-325
12830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12831 remote_ost_nodsh && skip "remote OST with nodsh" && return
12832 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12833 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12836 # create on MDT0000 so the last_id and next_id are correct
12838 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12842 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12843 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12844 osc.$mdtosc_proc1.prealloc_last_id)
12845 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12846 osc.$mdtosc_proc1.prealloc_next_id)
12850 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12851 #define OBD_FAIL_OST_ENOINO 0x229
12852 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12853 create_pool $FSNAME.$TESTNAME || return 1
12854 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12856 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12858 MDSOBJS=$((last_id - next_id))
12859 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12861 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12862 echo "OST still has $count kbytes free"
12864 echo "create $MDSOBJS files @next_id..."
12865 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12867 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12868 osc.$mdtosc_proc1.prealloc_last_id)
12869 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12870 osc.$mdtosc_proc1.prealloc_next_id)
12872 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12877 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12878 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12880 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12881 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12882 echo "unlink $MDSOBJS files @$next_id..."
12883 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12885 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12888 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12889 dd if=`which date` of=$MOUNT/date oflag=sync
12890 chmod +x $MOUNT/date
12892 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12893 $LCTL set_param fail_loc=0x80001401
12895 $MOUNT/date > /dev/null
12898 run_test 221 "make sure fault and truncate race to not cause OOM"
12901 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12903 test_mkdir $DIR/$tdir
12904 $LFS setstripe -c 1 -i 0 $DIR/$tdir
12905 createmany -o $DIR/$tdir/$tfile 10
12906 cancel_lru_locks mdc
12907 cancel_lru_locks osc
12908 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12909 $LCTL set_param fail_loc=0x31a
12910 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12911 $LCTL set_param fail_loc=0
12914 run_test 222a "AGL for ls should not trigger CLIO lock failure"
12917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12919 test_mkdir $DIR/$tdir
12920 $LFS setstripe -c 1 -i 0 $DIR/$tdir
12921 createmany -o $DIR/$tdir/$tfile 10
12922 cancel_lru_locks mdc
12923 cancel_lru_locks osc
12924 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12925 $LCTL set_param fail_loc=0x31a
12926 rm -r $DIR/$tdir || error "AGL for rmdir failed"
12927 $LCTL set_param fail_loc=0
12929 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
12932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12934 test_mkdir $DIR/$tdir
12935 $LFS setstripe -c 1 -i 0 $DIR/$tdir
12936 createmany -o $DIR/$tdir/$tfile 10
12937 cancel_lru_locks mdc
12938 cancel_lru_locks osc
12939 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12940 $LCTL set_param fail_loc=0x31b
12941 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12942 $LCTL set_param fail_loc=0
12945 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12947 test_224a() { # LU-1039, MRP-303
12948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12949 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12950 $LCTL set_param fail_loc=0x508
12951 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12952 $LCTL set_param fail_loc=0
12955 run_test 224a "Don't panic on bulk IO failure"
12957 test_224b() { # LU-1039, MRP-303
12958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12959 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12960 cancel_lru_locks osc
12961 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12962 $LCTL set_param fail_loc=0x515
12963 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12964 $LCTL set_param fail_loc=0
12967 run_test 224b "Don't panic on bulk IO failure"
12969 test_224c() { # LU-6441
12970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12971 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12973 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12974 save_writethrough $p
12975 set_cache writethrough on
12977 local pages_per_rpc=$($LCTL get_param \
12978 osc.*.max_pages_per_rpc)
12979 local at_max=$($LCTL get_param -n at_max)
12980 local timeout=$($LCTL get_param -n timeout)
12981 local test_at="$LCTL get_param -n at_max"
12982 local param_at="$FSNAME.sys.at_max"
12983 local test_timeout="$LCTL get_param -n timeout"
12984 local param_timeout="$FSNAME.sys.timeout"
12986 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12988 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12989 error "conf_param at_max=0 failed"
12990 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12991 error "conf_param timeout=5 failed"
12993 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12994 do_facet ost1 $LCTL set_param fail_loc=0x520
12995 $LFS setstripe -c 1 -i 0 $DIR/$tfile
12996 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12998 do_facet ost1 $LCTL set_param fail_loc=0
13000 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13001 error "conf_param at_max=$at_max failed"
13002 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13003 $timeout || error "conf_param timeout=$timeout failed"
13005 $LCTL set_param -n $pages_per_rpc
13006 restore_lustre_params < $p
13009 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13011 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13014 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13015 if [ -z ${MDSSURVEY} ]; then
13016 skip_env "mds-survey not found" && return
13019 [ $MDSCOUNT -ge 2 ] &&
13020 skip "skipping now for more than one MDT" && return
13022 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13023 { skip "Need MDS version at least 2.2.51"; return; }
13025 local mds=$(facet_host $SINGLEMDS)
13026 local target=$(do_nodes $mds 'lctl dl' | \
13027 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13029 local cmd1="file_count=1000 thrhi=4"
13030 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13031 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13032 local cmd="$cmd1 $cmd2 $cmd3"
13034 rm -f ${TMP}/mds_survey*
13036 eval $cmd || error "mds-survey with zero-stripe failed"
13037 cat ${TMP}/mds_survey*
13038 rm -f ${TMP}/mds_survey*
13040 run_test 225a "Metadata survey sanity with zero-stripe"
13043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13044 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13045 if [ -z ${MDSSURVEY} ]; then
13046 skip_env "mds-survey not found" && return
13048 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13049 { skip "Need MDS version at least 2.2.51"; return; }
13051 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13052 skip_env "Need to mount OST to test" && return
13055 [ $MDSCOUNT -ge 2 ] &&
13056 skip "skipping now for more than one MDT" && return
13057 local mds=$(facet_host $SINGLEMDS)
13058 local target=$(do_nodes $mds 'lctl dl' | \
13059 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13061 local cmd1="file_count=1000 thrhi=4"
13062 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13063 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13064 local cmd="$cmd1 $cmd2 $cmd3"
13066 rm -f ${TMP}/mds_survey*
13068 eval $cmd || error "mds-survey with stripe_count failed"
13069 cat ${TMP}/mds_survey*
13070 rm -f ${TMP}/mds_survey*
13072 run_test 225b "Metadata survey sanity with stripe_count = 1"
13074 mcreate_path2fid () {
13080 local path=$DIR/$tdir/$name
13085 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13086 error "cannot create $desc"
13088 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13090 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13092 fid_path=$($LFS fid2path $MOUNT $fid)
13094 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13096 [ "$path" == "$fid_path" ] ||
13097 error "fid2path returned $fid_path, expected $path"
13099 echo "pass with $path and $fid"
13104 mkdir -p $DIR/$tdir
13106 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13107 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13108 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13109 mcreate_path2fid 0040666 0 0 dir "directory"
13110 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13111 mcreate_path2fid 0100666 0 0 file "regular file"
13112 mcreate_path2fid 0120666 0 0 link "symbolic link"
13113 mcreate_path2fid 0140666 0 0 sock "socket"
13115 run_test 226a "call path2fid and fid2path on files of all type"
13118 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13122 mkdir -p $DIR/$tdir
13123 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13124 error "create remote directory failed"
13125 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13126 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13127 "character special file (null)"
13128 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13129 "character special file (no device)"
13130 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13131 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13132 "block special file (loop)"
13133 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13134 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13135 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13137 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13139 # LU-1299 Executing or running ldd on a truncated executable does not
13140 # cause an out-of-memory condition.
13142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13143 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13144 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13145 chmod +x $MOUNT/date
13147 $MOUNT/date > /dev/null
13148 ldd $MOUNT/date > /dev/null
13151 run_test 227 "running truncated executable does not cause OOM"
13153 # LU-1512 try to reuse idle OI blocks
13155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13156 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13157 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13158 skip "ldiskfs only test" && return
13160 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13161 local myDIR=$DIR/$tdir
13164 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13165 $LCTL set_param fail_loc=0x80001002
13166 createmany -o $myDIR/t- 10000
13167 $LCTL set_param fail_loc=0
13168 # The guard is current the largest FID holder
13170 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13172 local IDX=$(($SEQ % 64))
13174 do_facet $SINGLEMDS sync
13175 # Make sure journal flushed.
13177 local blk1=$(do_facet $SINGLEMDS \
13178 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13179 grep Blockcount | awk '{print $4}')
13181 # Remove old files, some OI blocks will become idle.
13182 unlinkmany $myDIR/t- 10000
13183 # Create new files, idle OI blocks should be reused.
13184 createmany -o $myDIR/t- 2000
13185 do_facet $SINGLEMDS sync
13186 # Make sure journal flushed.
13188 local blk2=$(do_facet $SINGLEMDS \
13189 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13190 grep Blockcount | awk '{print $4}')
13192 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13194 run_test 228a "try to reuse idle OI blocks"
13197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13198 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13199 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13200 skip "ldiskfs only test" && return
13202 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13203 local myDIR=$DIR/$tdir
13206 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13207 $LCTL set_param fail_loc=0x80001002
13208 createmany -o $myDIR/t- 10000
13209 $LCTL set_param fail_loc=0
13210 # The guard is current the largest FID holder
13212 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13214 local IDX=$(($SEQ % 64))
13216 do_facet $SINGLEMDS sync
13217 # Make sure journal flushed.
13219 local blk1=$(do_facet $SINGLEMDS \
13220 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13221 grep Blockcount | awk '{print $4}')
13223 # Remove old files, some OI blocks will become idle.
13224 unlinkmany $myDIR/t- 10000
13227 stop $SINGLEMDS || error "Fail to stop MDT."
13229 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13231 df $MOUNT || error "Fail to df."
13232 # Create new files, idle OI blocks should be reused.
13233 createmany -o $myDIR/t- 2000
13234 do_facet $SINGLEMDS sync
13235 # Make sure journal flushed.
13237 local blk2=$(do_facet $SINGLEMDS \
13238 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13239 grep Blockcount | awk '{print $4}')
13241 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13243 run_test 228b "idle OI blocks can be reused after MDT restart"
13247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13248 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13249 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13250 skip "ldiskfs only test" && return
13252 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13253 local myDIR=$DIR/$tdir
13256 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13257 $LCTL set_param fail_loc=0x80001002
13258 # 20000 files can guarantee there are index nodes in the OI file
13259 createmany -o $myDIR/t- 20000
13260 $LCTL set_param fail_loc=0
13261 # The guard is current the largest FID holder
13263 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13265 local IDX=$(($SEQ % 64))
13267 do_facet $SINGLEMDS sync
13268 # Make sure journal flushed.
13270 local blk1=$(do_facet $SINGLEMDS \
13271 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13272 grep Blockcount | awk '{print $4}')
13274 # Remove old files, some OI blocks will become idle.
13275 unlinkmany $myDIR/t- 20000
13277 # The OI file should become empty now
13279 # Create new files, idle OI blocks should be reused.
13280 createmany -o $myDIR/t- 2000
13281 do_facet $SINGLEMDS sync
13282 # Make sure journal flushed.
13284 local blk2=$(do_facet $SINGLEMDS \
13285 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13286 grep Blockcount | awk '{print $4}')
13288 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13290 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
13292 test_229() { # LU-2482, LU-3448
13293 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
13294 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
13296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13297 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
13301 # Create a file with a released layout and stripe count 2.
13302 $MULTIOP $DIR/$tfile H2c ||
13303 error "failed to create file with released layout"
13305 $GETSTRIPE -v $DIR/$tfile
13307 local pattern=$($GETSTRIPE -L $DIR/$tfile)
13308 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
13310 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
13311 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
13312 stat $DIR/$tfile || error "failed to stat released file"
13314 chown $RUNAS_ID $DIR/$tfile ||
13315 error "chown $RUNAS_ID $DIR/$tfile failed"
13317 chgrp $RUNAS_ID $DIR/$tfile ||
13318 error "chgrp $RUNAS_ID $DIR/$tfile failed"
13320 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
13321 rm $DIR/$tfile || error "failed to remove released file"
13323 run_test 229 "getstripe/stat/rm/attr changes work on released files"
13326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13327 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13330 test_mkdir $DIR/$tdir
13331 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
13332 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
13333 [ $mdt_idx -ne 0 ] &&
13334 error "create local directory on wrong MDT $mdt_idx"
13336 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
13337 error "create remote directory failed"
13338 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
13339 [ $mdt_idx -ne $MDTIDX ] &&
13340 error "create remote directory on wrong MDT $mdt_idx"
13342 createmany -o $DIR/$tdir/test_230/t- 10 ||
13343 error "create files on remote directory failed"
13344 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
13345 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
13346 rm -r $DIR/$tdir || error "unlink remote directory failed"
13348 run_test 230a "Create remote directory and files under the remote directory"
13351 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13352 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13359 local migrate_dir=$DIR/$tdir/migrate_dir
13360 local other_dir=$DIR/$tdir/other_dir
13362 test_mkdir $DIR/$tdir
13363 test_mkdir -i0 -c1 $migrate_dir
13364 test_mkdir -i0 -c1 $other_dir
13365 for ((i=0; i<10; i++)); do
13366 mkdir -p $migrate_dir/dir_${i}
13367 createmany -o $migrate_dir/dir_${i}/f 10 ||
13368 error "create files under remote dir failed $i"
13371 cp /etc/passwd $migrate_dir/$tfile
13372 cp /etc/passwd $other_dir/$tfile
13373 chattr +SAD $migrate_dir
13374 chattr +SAD $migrate_dir/$tfile
13376 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13377 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13378 local old_dir_mode=$(stat -c%f $migrate_dir)
13379 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
13381 mkdir -p $migrate_dir/dir_default_stripe2
13382 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
13383 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
13385 mkdir -p $other_dir
13386 ln $migrate_dir/$tfile $other_dir/luna
13387 ln $migrate_dir/$tfile $migrate_dir/sofia
13388 ln $other_dir/$tfile $migrate_dir/david
13389 ln -s $migrate_dir/$tfile $other_dir/zachary
13390 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
13391 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
13393 $LFS migrate -m $MDTIDX $migrate_dir ||
13394 error "fails on migrating remote dir to MDT1"
13396 echo "migratate to MDT1, then checking.."
13397 for ((i = 0; i < 10; i++)); do
13398 for file in $(find $migrate_dir/dir_${i}); do
13399 mdt_index=$($LFS getstripe -M $file)
13400 [ $mdt_index == $MDTIDX ] ||
13401 error "$file is not on MDT${MDTIDX}"
13405 # the multiple link file should still in MDT0
13406 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
13407 [ $mdt_index == 0 ] ||
13408 error "$file is not on MDT${MDTIDX}"
13410 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13411 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13412 error " expect $old_dir_flag get $new_dir_flag"
13414 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13415 [ "$old_file_flag" = "$new_file_flag" ] ||
13416 error " expect $old_file_flag get $new_file_flag"
13418 local new_dir_mode=$(stat -c%f $migrate_dir)
13419 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13420 error "expect mode $old_dir_mode get $new_dir_mode"
13422 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13423 [ "$old_file_mode" = "$new_file_mode" ] ||
13424 error "expect mode $old_file_mode get $new_file_mode"
13426 diff /etc/passwd $migrate_dir/$tfile ||
13427 error "$tfile different after migration"
13429 diff /etc/passwd $other_dir/luna ||
13430 error "luna different after migration"
13432 diff /etc/passwd $migrate_dir/sofia ||
13433 error "sofia different after migration"
13435 diff /etc/passwd $migrate_dir/david ||
13436 error "david different after migration"
13438 diff /etc/passwd $other_dir/zachary ||
13439 error "zachary different after migration"
13441 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13442 error "${tfile}_ln different after migration"
13444 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13445 error "${tfile}_ln_other different after migration"
13447 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
13448 [ $stripe_count = 2 ] ||
13449 error "dir strpe_count $d != 2 after migration."
13451 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
13452 [ $stripe_count = 2 ] ||
13453 error "file strpe_count $d != 2 after migration."
13455 #migrate back to MDT0
13458 $LFS migrate -m $MDTIDX $migrate_dir ||
13459 error "fails on migrating remote dir to MDT0"
13461 echo "migrate back to MDT0, checking.."
13462 for file in $(find $migrate_dir); do
13463 mdt_index=$($LFS getstripe -M $file)
13464 [ $mdt_index == $MDTIDX ] ||
13465 error "$file is not on MDT${MDTIDX}"
13468 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
13469 [ "$old_dir_flag" = "$new_dir_flag" ] ||
13470 error " expect $old_dir_flag get $new_dir_flag"
13472 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
13473 [ "$old_file_flag" = "$new_file_flag" ] ||
13474 error " expect $old_file_flag get $new_file_flag"
13476 local new_dir_mode=$(stat -c%f $migrate_dir)
13477 [ "$old_dir_mode" = "$new_dir_mode" ] ||
13478 error "expect mode $old_dir_mode get $new_dir_mode"
13480 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
13481 [ "$old_file_mode" = "$new_file_mode" ] ||
13482 error "expect mode $old_file_mode get $new_file_mode"
13484 diff /etc/passwd ${migrate_dir}/$tfile ||
13485 error "$tfile different after migration"
13487 diff /etc/passwd ${other_dir}/luna ||
13488 error "luna different after migration"
13490 diff /etc/passwd ${migrate_dir}/sofia ||
13491 error "sofia different after migration"
13493 diff /etc/passwd ${other_dir}/zachary ||
13494 error "zachary different after migration"
13496 diff /etc/passwd $migrate_dir/${tfile}_ln ||
13497 error "${tfile}_ln different after migration"
13499 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
13500 error "${tfile}_ln_other different after migration"
13502 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
13503 [ $stripe_count = 2 ] ||
13504 error "dir strpe_count $d != 2 after migration."
13506 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
13507 [ $stripe_count = 2 ] ||
13508 error "file strpe_count $d != 2 after migration."
13510 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13512 run_test 230b "migrate directory"
13515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13516 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13517 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13521 local migrate_dir=$DIR/$tdir/migrate_dir
13523 #If migrating directory fails in the middle, all entries of
13524 #the directory is still accessiable.
13525 test_mkdir $DIR/$tdir
13526 test_mkdir -i0 -c1 $migrate_dir
13528 createmany -o $migrate_dir/f 10 ||
13529 error "create files under ${migrate_dir} failed"
13531 #failed after migrating 5 entries
13532 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
13533 do_facet mds1 lctl set_param fail_loc=0x20001801
13534 do_facet mds1 lctl set_param fail_val=5
13535 local t=$(ls $migrate_dir | wc -l)
13536 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
13537 error "migrate should fail after 5 entries"
13539 mkdir $migrate_dir/dir &&
13540 error "mkdir succeeds under migrating directory"
13541 touch $migrate_dir/file &&
13542 error "touch file succeeds under migrating directory"
13544 local u=$(ls $migrate_dir | wc -l)
13545 [ "$u" == "$t" ] || error "$u != $t during migration"
13547 for file in $(find $migrate_dir); do
13548 stat $file || error "stat $file failed"
13551 do_facet mds1 lctl set_param fail_loc=0
13552 do_facet mds1 lctl set_param fail_val=0
13554 $LFS migrate -m $MDTIDX $migrate_dir ||
13555 error "migrate open files should failed with open files"
13557 echo "Finish migration, then checking.."
13558 for file in $(find $migrate_dir); do
13559 mdt_index=$($LFS getstripe -M $file)
13560 [ $mdt_index == $MDTIDX ] ||
13561 error "$file is not on MDT${MDTIDX}"
13564 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13566 run_test 230c "check directory accessiblity if migration is failed"
13569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13570 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13573 local migrate_dir=$DIR/$tdir/migrate_dir
13577 test_mkdir $DIR/$tdir
13578 test_mkdir -i0 -c1 $migrate_dir
13580 for ((i=0; i<100; i++)); do
13581 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
13582 createmany -o $migrate_dir/dir_${i}/f 100 ||
13583 error "create files under remote dir failed $i"
13586 $LFS migrate -m $MDTIDX $migrate_dir ||
13587 error "migrate remote dir error"
13589 echo "Finish migration, then checking.."
13590 for file in $(find $migrate_dir); do
13591 mdt_index=$($LFS getstripe -M $file)
13592 [ $mdt_index == $MDTIDX ] ||
13593 error "$file is not on MDT${MDTIDX}"
13596 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13598 run_test 230d "check migrate big directory"
13601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13602 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13608 mkdir -p $DIR/$tdir
13609 mkdir $DIR/$tdir/migrate_dir
13610 mkdir $DIR/$tdir/other_dir
13611 touch $DIR/$tdir/migrate_dir/a
13612 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13613 ls $DIR/$tdir/other_dir
13615 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13616 error "migrate dir fails"
13618 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13619 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13621 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13622 [ $mdt_index == 0 ] || error "a is not on MDT0"
13624 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13625 error "migrate dir fails"
13627 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13628 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13630 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13631 [ $mdt_index == 1 ] || error "a is not on MDT1"
13633 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13634 [ $mdt_index == 1 ] || error "b is not on MDT1"
13636 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13637 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13639 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13641 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13643 run_test 230e "migrate mulitple local link files"
13646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13647 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13651 mkdir -p $DIR/$tdir
13652 mkdir $DIR/$tdir/migrate_dir
13653 $LFS mkdir -i1 $DIR/$tdir/other_dir
13654 touch $DIR/$tdir/migrate_dir/a
13655 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13656 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13657 ls $DIR/$tdir/other_dir
13659 # a should be migrated to MDT1, since no other links on MDT0
13660 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13661 error "#1 migrate dir fails"
13662 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13663 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13664 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13665 [ $mdt_index == 1 ] || error "a is not on MDT1"
13667 # a should stay on MDT1, because it is a mulitple link file
13668 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13669 error "#2 migrate dir fails"
13670 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13671 [ $mdt_index == 1 ] || error "a is not on MDT1"
13673 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13674 error "#3 migrate dir fails"
13676 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13677 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13678 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13680 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13681 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13683 # a should be migrated to MDT0, since no other links on MDT1
13684 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13685 error "#4 migrate dir fails"
13686 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13687 [ $mdt_index == 0 ] || error "a is not on MDT0"
13689 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13691 run_test 230f "migrate mulitple remote link files"
13694 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13695 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13697 mkdir -p $DIR/$tdir/migrate_dir
13699 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13700 error "migrating dir to non-exist MDT succeeds"
13703 run_test 230g "migrate dir to non-exist MDT"
13706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13707 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13708 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13709 skip "Need MDS version at least 2.7.64" && return
13712 mkdir -p $DIR/$tdir/migrate_dir
13714 $LFS migrate -m1 $DIR &&
13715 error "migrating mountpoint1 should fail"
13717 $LFS migrate -m1 $DIR/$tdir/.. &&
13718 error "migrating mountpoint2 should fail"
13720 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13721 error "migrating $tdir fail"
13723 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13724 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13726 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13727 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13730 run_test 230h "migrate .. and root"
13733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13734 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13736 mkdir -p $DIR/$tdir/migrate_dir
13738 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
13739 error "migration fails with a tailing slash"
13741 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
13742 error "migration fails with two tailing slashes"
13744 run_test 230i "lfs migrate -m tolerates trailing slashes"
13748 # For simplicity this test assumes that max_pages_per_rpc
13749 # is the same across all OSCs
13750 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13751 local bulk_size=$((max_pages * 4096))
13752 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
13755 mkdir -p $DIR/$tdir
13756 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
13757 error "failed to set stripe with -S ${brw_size}M option"
13759 # clear the OSC stats
13760 $LCTL set_param osc.*.stats=0 &>/dev/null
13763 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13764 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13765 oflag=direct &>/dev/null || error "dd failed"
13767 sync; sleep 1; sync # just to be safe
13768 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13769 if [ x$nrpcs != "x1" ]; then
13770 $LCTL get_param osc.*.stats
13771 error "found $nrpcs ost_write RPCs, not 1 as expected"
13775 # Drop the OSC cache, otherwise we will read from it
13776 cancel_lru_locks osc
13778 # clear the OSC stats
13779 $LCTL set_param osc.*.stats=0 &>/dev/null
13781 # Client reads $bulk_size.
13782 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13783 iflag=direct &>/dev/null || error "dd failed"
13785 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13786 if [ x$nrpcs != "x1" ]; then
13787 $LCTL get_param osc.*.stats
13788 error "found $nrpcs ost_read RPCs, not 1 as expected"
13791 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13794 mkdir -p $DIR/$tdir
13796 for i in {0..1023}; do
13797 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13798 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13799 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13803 run_test 231b "must not assert on fully utilized OST request buffer"
13806 mkdir -p $DIR/$tdir
13807 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13808 $LCTL set_param fail_loc=0x31c
13810 # ignore dd failure
13811 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13813 $LCTL set_param fail_loc=0
13814 umount_client $MOUNT || error "umount failed"
13815 mount_client $MOUNT || error "mount failed"
13817 run_test 232 "failed lock should not block umount"
13820 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13821 { skip "Need MDS version at least 2.3.64"; return; }
13822 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13824 local fid=$($LFS path2fid $MOUNT)
13825 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13826 error "cannot access $MOUNT using its FID '$fid'"
13828 run_test 233a "checking that OBF of the FS root succeeds"
13831 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13832 { skip "Need MDS version at least 2.5.90"; return; }
13833 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13835 local fid=$($LFS path2fid $MOUNT/.lustre)
13836 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13837 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13839 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13840 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13841 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13843 run_test 233b "checking that OBF of the FS .lustre succeeds"
13846 local p="$TMP/sanityN-$TESTNAME.parameters"
13847 save_lustre_params client "llite.*.xattr_cache" > $p
13848 lctl set_param llite.*.xattr_cache 1 ||
13849 { skip "xattr cache is not supported"; return 0; }
13851 mkdir -p $DIR/$tdir || error "mkdir failed"
13852 touch $DIR/$tdir/$tfile || error "touch failed"
13853 # OBD_FAIL_LLITE_XATTR_ENOMEM
13854 $LCTL set_param fail_loc=0x1405
13855 # output of the form: attr 2 4 44 3 fc13 x86_64
13856 V=($(IFS=".-" rpm -q attr))
13857 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13858 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13859 # attr pre-2.4.44-7 had a bug with rc
13860 # LU-3703 - SLES 11 and FC13 clients have older attr
13861 getfattr -n user.attr $DIR/$tdir/$tfile &&
13862 error "getfattr should have failed with ENOMEM"
13864 skip "LU-3703: attr version $(getfattr --version) too old"
13866 $LCTL set_param fail_loc=0x0
13869 restore_lustre_params < $p
13872 run_test 234 "xattr cache should not crash on ENOMEM"
13875 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13876 skip "Need MDS version at least 2.4.52" && return
13877 flock_deadlock $DIR/$tfile
13882 124) error "process hangs on a deadlock"
13884 *) error "error executing flock_deadlock $DIR/$tfile"
13888 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13892 check_swap_layouts_support && return 0
13893 test_mkdir -c1 $DIR/$tdir
13895 local ref1=/etc/passwd
13896 local ref2=/etc/group
13897 local file1=$DIR/$tdir/f1
13898 local file2=$DIR/$tdir/f2
13900 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13901 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13902 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13903 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13904 local fd=$(free_fd)
13905 local cmd="exec $fd<>$file2"
13908 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13909 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13912 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13917 run_test 236 "Layout swap on open unlinked file"
13919 # test to verify file handle related system calls
13920 # (name_to_handle_at/open_by_handle_at)
13921 # The new system calls are supported in glibc >= 2.14.
13924 echo "Test file_handle syscalls" > $DIR/$tfile ||
13925 error "write failed"
13926 check_fhandle_syscalls $DIR/$tfile ||
13927 error "check_fhandle_syscalls failed"
13929 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13931 # LU-4659 linkea consistency
13933 local server_version=$(lustre_version_code $SINGLEMDS)
13935 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13936 [[ $server_version -gt $(version_code 2.5.1) &&
13937 $server_version -lt $(version_code 2.5.50) ]] ||
13938 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13941 ln $DIR/$tfile $DIR/$tfile.lnk
13942 touch $DIR/$tfile.new
13943 mv $DIR/$tfile.new $DIR/$tfile
13944 local fid1=$($LFS path2fid $DIR/$tfile)
13945 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13946 local path1=$($LFS fid2path $FSNAME "$fid1")
13947 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13948 local path2=$($LFS fid2path $FSNAME "$fid2")
13949 [ $tfile.lnk == $path2 ] ||
13950 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13953 run_test 238 "Verify linkea consistency"
13956 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13957 skip "Need MDS version at least 2.5.60" && return
13958 local list=$(comma_list $(mdts_nodes))
13960 mkdir -p $DIR/$tdir
13961 createmany -o $DIR/$tdir/f- 5000
13962 unlinkmany $DIR/$tdir/f- 5000
13963 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13964 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13965 osc.*MDT*.sync_in_flight" | calc_sum)
13966 [ "$changes" -eq 0 ] || error "$changes not synced"
13968 run_test 239 "osp_sync test"
13970 test_239a() { #LU-5297
13971 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13973 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13974 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13975 chgrp $RUNAS_GID $DIR/$tfile
13976 wait_delete_completed
13978 run_test 239a "process invalid osp sync record correctly"
13980 test_239b() { #LU-5297
13981 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13983 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13984 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13985 chgrp $RUNAS_GID $DIR/$tfile1
13986 wait_delete_completed
13987 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13989 chgrp $RUNAS_GID $DIR/$tfile2
13990 wait_delete_completed
13992 run_test 239b "process osp sync record with ENOMEM error correctly"
13995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13996 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13998 mkdir -p $DIR/$tdir
14000 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14001 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14002 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14003 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14005 umount_client $MOUNT || error "umount failed"
14006 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14007 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14008 mount_client $MOUNT || error "failed to mount client"
14010 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14011 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14013 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14016 for LOOP in $(seq $1); do
14017 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14018 cancel_lru_locks osc || true
14023 for LOOP in $(seq $1); do
14024 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14025 iflag=direct 2>/dev/null
14029 test_241a() { # was test_241
14030 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14032 cancel_lru_locks osc
14033 test_241_bio 1000 &
14038 run_test 241a "bio vs dio"
14041 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14043 test_241_dio 1000 &
14048 run_test 241b "dio vs dio"
14051 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14052 mkdir -p $DIR/$tdir
14053 touch $DIR/$tdir/$tfile
14055 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14056 do_facet mds1 lctl set_param fail_loc=0x105
14057 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14059 do_facet mds1 lctl set_param fail_loc=0
14060 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14062 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14066 test_mkdir $DIR/$tdir
14067 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14069 run_test 243 "various group lock tests"
14073 test_mkdir $DIR/$tdir
14074 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14075 sendfile_grouplock $DIR/$tdir/$tfile || \
14076 error "sendfile+grouplock failed"
14079 run_test 244 "sendfile with group lock tests"
14082 local flagname="multi_mod_rpcs"
14083 local connect_data_name="max_mod_rpcs"
14086 # check if multiple modify RPCs flag is set
14087 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14088 grep "connect_flags:")
14091 echo "$out" | grep -qw $flagname
14092 if [ $? -ne 0 ]; then
14093 echo "connect flag $flagname is not set"
14097 # check if multiple modify RPCs data is set
14098 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14101 echo "$out" | grep -qw $connect_data_name ||
14102 error "import should have connect data $connect_data_name"
14104 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14106 test_246() { # LU-7371
14107 remote_ost_nodsh && skip "remote OST with nodsh" && return
14108 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14109 skip "Need OST version >= 2.7.62" && return 0
14110 do_facet ost1 $LCTL set_param fail_val=4095
14111 #define OBD_FAIL_OST_READ_SIZE 0x234
14112 do_facet ost1 $LCTL set_param fail_loc=0x234
14113 $LFS setstripe $DIR/$tfile -i 0 -c 1
14114 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14115 cancel_lru_locks $FSNAME-OST0000
14116 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14118 run_test 246 "Read file of size 4095 should return right length"
14121 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14123 { skip "Fileset feature is not supported"; return; }
14125 local submount=${MOUNT}_$tdir
14128 mkdir -p $submount || error "mkdir $submount failed"
14129 FILESET="$FILESET/$tdir" mount_client $submount ||
14130 error "mount $submount failed"
14131 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14132 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14133 error "read $MOUNT/$tdir/$tfile failed"
14134 umount_client $submount || error "umount $submount failed"
14137 run_test 247a "mount subdir as fileset"
14140 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14141 { skip "Fileset feature is not supported"; return; }
14143 local submount=${MOUNT}_$tdir
14145 rm -rf $MOUNT/$tdir
14146 mkdir -p $submount || error "mkdir $submount failed"
14148 FILESET="$FILESET/$tdir" mount_client $submount &&
14149 error "mount $submount should fail"
14152 run_test 247b "mount subdir that dose not exist"
14155 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14156 { skip "Fileset feature is not supported"; return; }
14158 local submount=${MOUNT}_$tdir
14160 mkdir -p $MOUNT/$tdir/dir1
14161 mkdir -p $submount || error "mkdir $submount failed"
14162 FILESET="$FILESET/$tdir" mount_client $submount ||
14163 error "mount $submount failed"
14164 local fid=$($LFS path2fid $MOUNT/)
14165 $LFS fid2path $submount $fid && error "fid2path should fail"
14166 umount_client $submount || error "umount $submount failed"
14169 run_test 247c "running fid2path outside root"
14172 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14173 { skip "Fileset feature is not supported"; return; }
14175 local submount=${MOUNT}_$tdir
14177 mkdir -p $MOUNT/$tdir/dir1
14178 mkdir -p $submount || error "mkdir $submount failed"
14179 FILESET="$FILESET/$tdir" mount_client $submount ||
14180 error "mount $submount failed"
14181 local fid=$($LFS path2fid $submount/dir1)
14182 $LFS fid2path $submount $fid || error "fid2path should succeed"
14183 umount_client $submount || error "umount $submount failed"
14186 run_test 247d "running fid2path inside root"
14190 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14192 { skip "Fileset feature is not supported"; return; }
14194 local submount=${MOUNT}_$tdir
14197 mkdir -p $submount || error "mkdir $submount failed"
14198 FILESET="$FILESET/.." mount_client $submount &&
14199 error "mount $submount should fail"
14202 run_test 247e "mount .. as fileset"
14205 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14206 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14208 # create a large file for fast read verification
14209 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14211 # make sure the file is created correctly
14212 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14213 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14215 echo "Test 1: verify that fast read is 4 times faster on cache read"
14217 # small read with fast read enabled
14218 $LCTL set_param -n llite.*.fast_read=1
14219 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14220 awk '/copied/ { print $6 }')
14222 # small read with fast read disabled
14223 $LCTL set_param -n llite.*.fast_read=0
14224 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14225 awk '/copied/ { print $6 }')
14227 # verify that fast read is 4 times faster for cache read
14228 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
14229 error_not_in_vm "fast read was not 4 times faster: " \
14230 "$t_fast vs $t_slow"
14232 echo "Test 2: verify the performance between big and small read"
14233 $LCTL set_param -n llite.*.fast_read=1
14235 # 1k non-cache read
14236 cancel_lru_locks osc
14237 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14238 awk '/copied/ { print $6 }')
14240 # 1M non-cache read
14241 cancel_lru_locks osc
14242 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
14243 awk '/copied/ { print $6 }')
14245 # verify that big IO is not 4 times faster than small IO
14246 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
14247 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
14249 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
14252 run_test 248 "fast read verification"
14254 test_249() { # LU-7890
14256 $SETSTRIPE -c 1 $DIR/$tfile
14258 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
14259 skip "Need at least version 2.8.54"
14261 # Offset 2T == 4k * 512M
14262 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
14263 error "dd to 2T offset failed"
14265 run_test 249 "Write above 2T file size"
14268 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
14269 && skip "no 16TB file size limit on ZFS" && return
14271 $SETSTRIPE -c 1 $DIR/$tfile
14272 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
14273 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
14274 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
14275 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
14276 conv=notrunc,fsync && error "append succeeded"
14279 run_test 250 "Write above 16T limit"
14282 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
14284 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
14285 #Skip once - writing the first stripe will succeed
14286 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14287 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
14288 error "short write happened"
14290 $LCTL set_param fail_loc=0xa0001407 fail_val=1
14291 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
14292 error "short read happened"
14296 run_test 251 "Handling short read and write correctly"
14306 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14307 remote_ost_nodsh && skip "remote OST with nodsh" && return
14308 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
14309 "$(facet_fstype mds1)" != "ldiskfs" ]; then
14310 skip "ldiskfs only test"
14314 # check lr_reader on OST0000
14316 dev=$(facet_device $tgt)
14317 out=$(do_facet $tgt $LR_READER $dev)
14318 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14320 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
14321 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
14322 error "Invalid uuid returned by $LR_READER on target $tgt"
14323 echo -e "uuid returned by $LR_READER is '$uuid'\n"
14325 # check lr_reader -c on MDT0000
14327 dev=$(facet_device $tgt)
14328 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
14329 echo "$LR_READER does not support additional options"
14332 out=$(do_facet $tgt $LR_READER -c $dev)
14333 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14335 num=$(echo "$out" | grep -c "mdtlov")
14336 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
14337 error "Invalid number of mdtlov clients returned by $LR_READER"
14338 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
14340 # check lr_reader -cr on MDT0000
14341 out=$(do_facet $tgt $LR_READER -cr $dev)
14342 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
14344 echo "$out" | grep -q "^reply_data:$" ||
14345 error "$LR_READER should have returned 'reply_data' section"
14346 num=$(echo "$out" | grep -c "client_generation")
14347 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
14349 run_test 252 "check lr_reader tool"
14351 test_253_fill_ost() {
14352 local size_mb #how many MB should we write to pass watermark
14353 local lwm=$3 #low watermark
14354 local free_10mb #10% of free space
14356 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14357 size_mb=$((free_kb / 1024 - lwm))
14358 free_10mb=$((free_kb / 10240))
14359 #If 10% of free space cross low watermark use it
14360 if (( free_10mb > size_mb )); then
14363 #At least we need to store 1.1 of difference between
14364 #free space and low watermark
14365 size_mb=$((size_mb + size_mb / 10))
14367 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
14368 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
14369 oflag=append conv=notrunc
14374 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
14375 echo "OST still has $((free_kb / 1024)) mbytes free"
14382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14383 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14384 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
14386 local ost_name=$($LFS osts |
14387 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
14389 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
14390 do_facet $SINGLEMDS $LCTL get_param -n \
14391 osp.$mdtosc_proc1.reserved_mb_high ||
14392 { skip "remote MDS does not support reserved_mb_high" &&
14397 wait_delete_completed
14400 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
14401 osp.$mdtosc_proc1.reserved_mb_high)
14402 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
14403 osp.$mdtosc_proc1.reserved_mb_low)
14404 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
14406 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
14407 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
14408 error "Adding $ost_name to pool failed"
14410 # Wait for client to see a OST at pool
14411 wait_update $HOSTNAME "$LCTL get_param -n
14412 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
14413 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
14414 error "Client can not see the pool"
14415 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
14416 error "Setstripe failed"
14418 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
14419 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
14420 echo "OST still has $((blocks/1024)) mbytes free"
14422 local new_lwm=$((blocks/1024-10))
14423 do_facet $SINGLEMDS $LCTL set_param \
14424 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
14425 do_facet $SINGLEMDS $LCTL set_param \
14426 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
14428 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14430 #First enospc could execute orphan deletion so repeat.
14431 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
14433 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14434 osp.$mdtosc_proc1.prealloc_status)
14435 echo "prealloc_status $oa_status"
14437 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
14438 error "File creation should fail"
14439 #object allocation was stopped, but we still able to append files
14440 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
14441 error "Append failed"
14442 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
14444 wait_delete_completed
14448 for i in $(seq 10 12); do
14449 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
14450 error "File creation failed after rm";
14453 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
14454 osp.$mdtosc_proc1.prealloc_status)
14455 echo "prealloc_status $oa_status"
14457 if (( oa_status != 0 )); then
14458 error "Object allocation still disable after rm"
14460 do_facet $SINGLEMDS $LCTL set_param \
14461 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
14462 do_facet $SINGLEMDS $LCTL set_param \
14463 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
14466 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
14467 error "Remove $ost_name from pool failed"
14468 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14469 error "Pool destroy fialed"
14471 run_test 253 "Check object allocation limit"
14476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14477 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14478 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
14479 { skip "MDS does not support changelog_size" && return; }
14481 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14482 echo "Registered as changelog user $cl_user"
14484 $LFS changelog_clear $MDT0 $cl_user 0
14486 local size1=$(do_facet mds1 \
14487 $LCTL get_param -n mdd.$MDT0.changelog_size)
14488 echo "Changelog size $size1"
14491 $LFS mkdir -i 0 $DIR/$tdir
14493 mkdir -p $DIR/$tdir/pics/2008/zachy
14494 touch $DIR/$tdir/pics/2008/zachy/timestamp
14495 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
14496 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14497 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14498 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14499 rm $DIR/$tdir/pics/desktop.jpg
14501 local size2=$(do_facet mds1 \
14502 $LCTL get_param -n mdd.$MDT0.changelog_size)
14503 echo "Changelog size after work $size2"
14505 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14507 if (( size2 <= size1 )); then
14508 error "Changelog size after work should be greater than original"
14512 run_test 254 "Check changelog size"
14519 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
14520 awk -F: '{print $2}' | grep $type > /dev/null
14521 if [ $? -ne 0 ]; then
14531 lfs ladvise -a willread $file > /dev/null 2>&1
14532 if [ $? -eq 0 ]; then
14536 lfs ladvise -a willread $file 2>&1 |
14537 grep "Inappropriate ioctl for device" > /dev/null
14538 if [ $? -eq 0 ]; then
14545 bc <<<"scale=2; ($1 - $2) * 100 / $2"
14548 # run a random read IO workload
14549 # usage: random_read_iops <filename> <filesize> <iosize>
14550 random_read_iops() {
14553 local iosize=${3:-4096}
14555 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
14556 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
14559 drop_file_oss_cache() {
14563 $LFS ladvise -a dontneed $file 2>/dev/null ||
14564 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
14567 ladvise_willread_performance()
14570 local average_origin=0
14571 local average_cache=0
14572 local average_ladvise=0
14574 for ((i = 1; i <= $repeat; i++)); do
14575 echo "Iter $i/$repeat: reading without willread hint"
14576 cancel_lru_locks osc
14577 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14578 local speed_origin=$(random_read_iops $DIR/$tfile $size)
14579 echo "Iter $i/$repeat: uncached speed: $speed_origin"
14580 average_origin=$(bc <<<"$average_origin + $speed_origin")
14582 cancel_lru_locks osc
14583 local speed_cache=$(random_read_iops $DIR/$tfile $size)
14584 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
14585 average_cache=$(bc <<<"$average_cache + $speed_cache")
14587 cancel_lru_locks osc
14588 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
14589 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
14590 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
14591 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
14592 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
14594 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
14595 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
14596 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
14598 speedup_cache=$(percent $average_cache $average_origin)
14599 speedup_ladvise=$(percent $average_ladvise $average_origin)
14601 echo "Average uncached read: $average_origin"
14602 echo "Average speedup with OSS cached read: " \
14603 "$average_cache = +$speedup_cache%"
14604 echo "Average speedup with ladvise willread: " \
14605 "$average_ladvise = +$speedup_ladvise%"
14607 local lowest_speedup=20
14608 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
14609 echo "Speedup with OSS cached read less than $lowest_speedup%, "
14610 "got $average_cache%. Skipping ladvise willread check."
14614 # the test won't work on ZFS until it supports 'ladvise dontneed', but
14615 # it is still good to run until then to exercise 'ladvise willread'
14616 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14617 [ "$(facet_fstype ost1)" = "zfs" ] &&
14618 echo "osd-zfs does not support dontneed or drop_caches" &&
14621 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
14622 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
14623 error_not_in_vm "Speedup with willread is less than " \
14624 "$lowest_speedup%, got $average_ladvise%"
14628 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14629 skip "lustre < 2.8.54 does not support ladvise " && return
14630 remote_ost_nodsh && skip "remote OST with nodsh" && return
14632 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
14634 ladvise_no_type willread $DIR/$tfile &&
14635 skip "willread ladvise is not supported" && return
14637 ladvise_no_ioctl $DIR/$tfile &&
14638 skip "ladvise ioctl is not supported" && return
14641 local size=$((size_mb * 1048576))
14642 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14643 error "dd to $DIR/$tfile failed"
14645 lfs ladvise -a willread $DIR/$tfile ||
14646 error "Ladvise failed with no range argument"
14648 lfs ladvise -a willread -s 0 $DIR/$tfile ||
14649 error "Ladvise failed with no -l or -e argument"
14651 lfs ladvise -a willread -e 1 $DIR/$tfile ||
14652 error "Ladvise failed with only -e argument"
14654 lfs ladvise -a willread -l 1 $DIR/$tfile ||
14655 error "Ladvise failed with only -l argument"
14657 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
14658 error "End offset should not be smaller than start offset"
14660 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
14661 error "End offset should not be equal to start offset"
14663 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
14664 error "Ladvise failed with overflowing -s argument"
14666 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
14667 error "Ladvise failed with overflowing -e argument"
14669 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
14670 error "Ladvise failed with overflowing -l argument"
14672 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
14673 error "Ladvise succeeded with conflicting -l and -e arguments"
14675 echo "Synchronous ladvise should wait"
14677 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
14678 do_nodes $(comma_list $(osts_nodes)) \
14679 $LCTL set_param fail_val=$delay fail_loc=0x237
14681 local start_ts=$SECONDS
14682 lfs ladvise -a willread $DIR/$tfile ||
14683 error "Ladvise failed with no range argument"
14684 local end_ts=$SECONDS
14685 local inteval_ts=$((end_ts - start_ts))
14687 if [ $inteval_ts -lt $(($delay - 1)) ]; then
14688 error "Synchronous advice didn't wait reply"
14691 echo "Asynchronous ladvise shouldn't wait"
14692 local start_ts=$SECONDS
14693 lfs ladvise -a willread -b $DIR/$tfile ||
14694 error "Ladvise failed with no range argument"
14695 local end_ts=$SECONDS
14696 local inteval_ts=$((end_ts - start_ts))
14698 if [ $inteval_ts -gt $(($delay / 2)) ]; then
14699 error "Asynchronous advice blocked"
14702 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
14703 ladvise_willread_performance
14705 run_test 255a "check 'lfs ladvise -a willread'"
14711 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
14715 remote_ost_nodsh && skip "remote OST with nodsh" && return
14717 lfs setstripe -c 1 -i 0 $DIR/$tfile
14719 ladvise_no_type dontneed $DIR/$tfile &&
14720 skip "dontneed ladvise is not supported" && return
14722 ladvise_no_ioctl $DIR/$tfile &&
14723 skip "ladvise ioctl is not supported" && return
14725 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
14726 skip "lustre < 2.8.54 does not support ladvise" && return
14728 ! $LFS ladvise -a dontneed $DIR/$tfile &&
14729 [ "$(facet_fstype ost1)" = "zfs" ] &&
14730 skip "zfs-osd does not support 'ladvise dontneed'" && return
14733 local size=$((size_mb * 1048576))
14734 # In order to prevent disturbance of other processes, only check 3/4
14735 # of the memory usage
14736 local kibibytes=$((size_mb * 1024 * 3 / 4))
14738 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
14739 error "dd to $DIR/$tfile failed"
14741 local total=$(facet_meminfo ost1 MemTotal)
14742 echo "Total memory: $total KiB"
14744 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
14745 local before_read=$(facet_meminfo ost1 Cached)
14746 echo "Cache used before read: $before_read KiB"
14748 lfs ladvise -a willread $DIR/$tfile ||
14749 error "Ladvise willread failed"
14750 local after_read=$(facet_meminfo ost1 Cached)
14751 echo "Cache used after read: $after_read KiB"
14753 lfs ladvise -a dontneed $DIR/$tfile ||
14754 error "Ladvise dontneed again failed"
14755 local no_read=$(facet_meminfo ost1 Cached)
14756 echo "Cache used after dontneed ladvise: $no_read KiB"
14758 if [ $total -lt $((before_read + kibibytes)) ]; then
14759 echo "Memory is too small, abort checking"
14763 if [ $((before_read + kibibytes)) -gt $after_read ]; then
14764 error "Ladvise willread should use more memory" \
14765 "than $kibibytes KiB"
14768 if [ $((no_read + kibibytes)) -gt $after_read ]; then
14769 error "Ladvise dontneed should release more memory" \
14770 "than $kibibytes KiB"
14773 run_test 255b "check 'lfs ladvise -a dontneed'"
14781 test_mkdir -p $DIR/$tdir
14782 $SETSTRIPE -i 0 $DIR/$tdir
14784 #test 10 returns only success/failure
14786 lockahead_test -d $DIR/$tdir -t $i
14788 if [ $rc -eq 255 ]; then
14789 error "Ladvise test${i} failed, ${rc}"
14792 #test 11 counts lock enqueue requests, all others count new locks
14794 count=$(do_facet ost1 \
14795 $LCTL get_param -n ost.OSS.ost.stats)
14796 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
14798 lockahead_test -d $DIR/$tdir -t $i
14800 if [ $rc -eq 255 ]; then
14801 error "Ladvise test${i} failed, ${rc}"
14804 new_count=$(do_facet ost1 \
14805 $LCTL get_param -n ost.OSS.ost.stats)
14806 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
14807 awk '{ print $2 }')
14809 difference="$((new_count - count))"
14810 if [ $difference -ne $rc ]; then
14811 error "Ladvise test${i}, bad enqueue count, returned " \
14812 "${rc}, actual ${difference}"
14815 for i in $(seq 12 21); do
14816 # If we do not do this, we run the risk of having too many
14817 # locks and starting lock cancellation while we are checking
14819 cancel_lru_locks osc
14821 count=$($LCTL get_param -n \
14822 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
14824 lockahead_test -d $DIR/$tdir -t $i
14826 if [ $rc -eq 255 ]; then
14827 error "Ladvise test ${i} failed, ${rc}"
14830 new_count=$($LCTL get_param -n \
14831 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
14832 difference="$((new_count - count))"
14834 # Test 15 output is divided by 1000 to map down to valid return
14835 if [ $i -eq 15 ]; then
14836 rc="$((rc * 1000))"
14839 if [ $difference -ne $rc ]; then
14840 error "Ladvise test ${i}, bad lock count, returned " \
14841 "${rc}, actual ${difference}"
14845 #test 22 returns only success/failure
14847 lockahead_test -d $DIR/$tdir -t $i
14849 if [ $rc -eq 255 ]; then
14850 error "Ladvise test${i} failed, ${rc}"
14854 run_test 255c "suite of ladvise lockahead tests"
14861 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14862 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14863 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
14864 skip "ldiskfs only test" && return
14866 mdt_dev=$(mdsdevname 1)
14868 cl_user=$(do_facet mds1 \
14869 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
14870 if [[ -n $cl_user ]]; then
14871 skip "active changelog user"
14875 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
14876 echo "Registered as changelog user $cl_user"
14879 mkdir -p $DIR/$tdir
14881 $LFS changelog_clear $MDT0 $cl_user 0
14884 touch $DIR/$tdir/{1..10}
14887 stop mds1 || error "Fail to stop MDT."
14890 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
14892 #after mount new plainllog is used
14893 touch $DIR/$tdir/{11..19}
14894 local TEMP256FILE=$(mktemp TEMP256XXXXXX)
14895 cat_sl=$(do_facet mds1 \
14896 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
14897 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
14900 if (( cat_sl != 2 )); then
14901 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14902 error "Changelog catalog has wrong number of slots $cat_sl"
14905 $LFS changelog_clear $MDT0 $cl_user 0
14907 TEMP256FILE=$(mktemp TEMP256XXXXXX)
14908 cat_sl=$(do_facet mds1 \
14909 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
14910 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
14913 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
14915 if (( cat_sl == 2 )); then
14916 error "Empty plain llog was not deleted from changelog catalog"
14918 if (( cat_sl != 1 )); then
14919 error "Active plain llog shouldn\`t be deleted from catalog"
14922 run_test 256 "Check llog delete for empty and not full state"
14925 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14926 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
14927 skip "Need MDS version at least 2.8.55" && return
14929 test_mkdir $DIR/$tdir
14931 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
14932 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
14935 #define OBD_FAIL_MDS_XATTR_REP 0x161
14936 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
14937 local facet=mds$((mdtidx + 1))
14938 set_nodes_failloc $(facet_active_host $facet) 0x80000161
14939 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
14941 stop $facet || error "stop MDS failed"
14942 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
14943 error "start MDS fail"
14945 run_test 257 "xattr locks are not lost"
14947 # Verify we take the i_mutex when security requires it
14949 #define OBD_FAIL_IMUTEX_SEC 0x141c
14950 $LCTL set_param fail_loc=0x141c
14952 chmod u+s $DIR/$tfile
14953 chmod a+rwx $DIR/$tfile
14954 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
14956 if [ $RC -ne 0 ]; then
14957 error "error, failed to take i_mutex, rc=$?"
14963 # Verify we do NOT take the i_mutex in the normal case
14965 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
14966 $LCTL set_param fail_loc=0x141d
14969 chmod a+rw $DIR/$tfile
14970 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
14972 if [ $RC -ne 0 ]; then
14973 error "error, took i_mutex unnecessarily, rc=$?"
14978 run_test 258b "verify i_mutex security behavior"
14981 #define OBD_FAIL_MDC_CLOSE 0x806
14982 $LCTL set_param fail_loc=0x80000806
14986 run_test 260 "Check mdc_close fail"
14988 cleanup_test_300() {
14992 test_striped_dir() {
14997 mkdir -p $DIR/$tdir
14999 SAVE_UMASK=$(umask)
15000 trap cleanup_test_300 RETURN EXIT
15002 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
15003 $DIR/$tdir/striped_dir ||
15004 error "set striped dir error"
15006 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
15007 [ "$mode" = "755" ] || error "expect 755 got $mode"
15009 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
15010 error "getdirstripe failed"
15011 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
15012 if [ "$stripe_count" != "2" ]; then
15013 error "1:stripe_count is $stripe_count, expect 2"
15015 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
15016 if [ "$stripe_count" != "2" ]; then
15017 error "2:stripe_count is $stripe_count, expect 2"
15020 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
15021 if [ "$stripe_index" != "$mdt_index" ]; then
15022 error "stripe_index is $stripe_index, expect $mdt_index"
15025 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15026 error "nlink error after create striped dir"
15028 mkdir $DIR/$tdir/striped_dir/a
15029 mkdir $DIR/$tdir/striped_dir/b
15031 stat $DIR/$tdir/striped_dir/a ||
15032 error "create dir under striped dir failed"
15033 stat $DIR/$tdir/striped_dir/b ||
15034 error "create dir under striped dir failed"
15036 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
15037 error "nlink error after mkdir"
15039 rmdir $DIR/$tdir/striped_dir/a
15040 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
15041 error "nlink error after rmdir"
15043 rmdir $DIR/$tdir/striped_dir/b
15044 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
15045 error "nlink error after rmdir"
15047 chattr +i $DIR/$tdir/striped_dir
15048 createmany -o $DIR/$tdir/striped_dir/f 10 &&
15049 error "immutable flags not working under striped dir!"
15050 chattr -i $DIR/$tdir/striped_dir
15052 rmdir $DIR/$tdir/striped_dir ||
15053 error "rmdir striped dir error"
15061 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15062 skip "skipped for lustre < 2.7.0" && return
15063 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15064 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15066 test_striped_dir 0 || error "failed on striped dir on MDT0"
15067 test_striped_dir 1 || error "failed on striped dir on MDT0"
15069 run_test 300a "basic striped dir sanity test"
15072 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15073 skip "skipped for lustre < 2.7.0" && return
15074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15075 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15081 test_mkdir $DIR/$tdir
15082 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15083 error "set striped dir error"
15084 for ((i=0; i<10; i++)); do
15085 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
15087 touch $DIR/$tdir/striped_dir/file_$i ||
15088 error "touch error $i"
15089 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
15090 [ $mtime1 -eq $mtime2 ] &&
15091 error "mtime not change after create"
15093 rm -f $DIR/$tdir/striped_dir/file_$i ||
15094 error "unlink error $i"
15095 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
15096 [ $mtime2 -eq $mtime3 ] &&
15097 error "mtime did not change after unlink"
15101 run_test 300b "check ctime/mtime for striped dir"
15104 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15105 skip "skipped for lustre < 2.7.0" && return
15106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15107 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15110 mkdir -p $DIR/$tdir
15111 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
15112 error "set striped dir error"
15114 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
15115 error "chown striped dir failed"
15117 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
15118 error "create 5k files failed"
15120 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
15122 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
15126 run_test 300c "chown && check ls under striped directory"
15129 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
15130 skip "skipped for lustre < 2.7.0" && return
15131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15132 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15136 mkdir -p $DIR/$tdir
15137 $SETSTRIPE -c 2 $DIR/$tdir
15139 #local striped directory
15140 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15141 error "set striped dir error"
15142 createmany -o $DIR/$tdir/striped_dir/f 10 ||
15143 error "create 10 files failed"
15145 #remote striped directory
15146 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
15147 error "set striped dir error"
15148 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
15149 error "create 10 files failed"
15151 for file in $(find $DIR/$tdir); do
15152 stripe_count=$($GETSTRIPE -c $file)
15153 [ $stripe_count -eq 2 ] ||
15154 error "wrong stripe $stripe_count for $file"
15159 run_test 300d "check default stripe under striped directory"
15162 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15163 skip "Need MDS version at least 2.7.55" && return
15164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15165 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15169 mkdir -p $DIR/$tdir
15171 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15172 error "set striped dir error"
15174 touch $DIR/$tdir/striped_dir/a
15175 touch $DIR/$tdir/striped_dir/b
15176 touch $DIR/$tdir/striped_dir/c
15178 mkdir $DIR/$tdir/striped_dir/dir_a
15179 mkdir $DIR/$tdir/striped_dir/dir_b
15180 mkdir $DIR/$tdir/striped_dir/dir_c
15182 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
15183 error "set striped adir under striped dir error"
15185 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
15186 error "set striped bdir under striped dir error"
15188 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
15189 error "set striped cdir under striped dir error"
15191 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
15192 error "rename dir under striped dir fails"
15194 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
15195 error "rename dir under different stripes fails"
15197 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
15198 error "rename file under striped dir should succeed"
15200 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
15201 error "rename dir under striped dir should succeed"
15205 run_test 300e "check rename under striped directory"
15208 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15209 skip "Need MDS version at least 2.7.55" && return
15210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15211 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15216 mkdir -p $DIR/$tdir
15218 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
15219 error "set striped dir error"
15221 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
15222 error "set striped dir error"
15224 touch $DIR/$tdir/striped_dir/a
15225 mkdir $DIR/$tdir/striped_dir/dir_a
15226 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
15227 error "create striped dir under striped dir fails"
15229 touch $DIR/$tdir/striped_dir1/b
15230 mkdir $DIR/$tdir/striped_dir1/dir_b
15231 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
15232 error "create striped dir under striped dir fails"
15234 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
15235 error "rename dir under different striped dir should fail"
15237 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
15238 error "rename striped dir under diff striped dir should fail"
15240 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
15241 error "rename file under diff striped dirs fails"
15245 run_test 300f "check rename cross striped directory"
15247 test_300_check_default_striped_dir()
15250 local default_count=$2
15251 local default_index=$3
15254 local dir_stripe_index
15257 echo "checking $dirname $default_count $default_index"
15258 $LFS setdirstripe -D -c $default_count -i $default_index \
15259 -t all_char $DIR/$tdir/$dirname ||
15260 error "set default stripe on striped dir error"
15261 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
15262 [ $stripe_count -eq $default_count ] ||
15263 error "expect $default_count get $stripe_count for $dirname"
15265 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
15266 [ $stripe_index -eq $default_index ] ||
15267 error "expect $default_index get $stripe_index for $dirname"
15269 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
15270 error "create dirs failed"
15272 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
15273 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
15274 for dir in $(find $DIR/$tdir/$dirname/*); do
15275 stripe_count=$($LFS getdirstripe -c $dir)
15276 [ $stripe_count -eq $default_count ] ||
15277 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
15278 error "stripe count $default_count != $stripe_count for $dir"
15280 stripe_index=$($LFS getdirstripe -i $dir)
15281 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
15282 error "$stripe_index != $default_index for $dir"
15284 #check default stripe
15285 stripe_count=$($LFS getdirstripe -D -c $dir)
15286 [ $stripe_count -eq $default_count ] ||
15287 error "default count $default_count != $stripe_count for $dir"
15289 stripe_index=$($LFS getdirstripe -D -i $dir)
15290 [ $stripe_index -eq $default_index ] ||
15291 error "default index $default_index != $stripe_index for $dir"
15293 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
15297 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15298 skip "Need MDS version at least 2.7.55" && return
15299 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15305 mkdir $DIR/$tdir/normal_dir
15307 #Checking when client cache stripe index
15308 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
15309 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
15310 error "create striped_dir failed"
15312 mkdir $DIR/$tdir/striped_dir/dir1 ||
15313 error "create dir1 fails"
15314 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
15315 [ $stripe_index -eq 1 ] ||
15316 error "dir1 expect 1 got $stripe_index"
15318 $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
15319 error "create dir2 fails"
15320 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
15321 [ $stripe_index -eq 2 ] ||
15322 error "dir2 expect 2 got $stripe_index"
15324 #check default stripe count/stripe index
15325 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
15326 test_300_check_default_striped_dir normal_dir 1 0
15327 test_300_check_default_striped_dir normal_dir 2 1
15328 test_300_check_default_striped_dir normal_dir 2 -1
15330 #delete default stripe information
15331 echo "delete default stripeEA"
15332 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
15333 error "set default stripe on striped dir error"
15335 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
15336 for dir in $(find $DIR/$tdir/normal_dir/*); do
15337 stripe_count=$($LFS getdirstripe -c $dir)
15338 [ $stripe_count -eq 0 ] ||
15339 error "expect 1 get $stripe_count for $dir"
15340 stripe_index=$($LFS getdirstripe -i $dir)
15341 [ $stripe_index -eq 0 ] ||
15342 error "expect 0 get $stripe_index for $dir"
15345 run_test 300g "check default striped directory for normal directory"
15348 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15349 skip "Need MDS version at least 2.7.55" && return
15350 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15355 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
15356 $DIR/$tdir/striped_dir ||
15357 error "set striped dir error"
15359 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
15360 test_300_check_default_striped_dir striped_dir 1 0
15361 test_300_check_default_striped_dir striped_dir 2 1
15362 test_300_check_default_striped_dir striped_dir 2 -1
15364 #delete default stripe information
15365 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
15366 error "set default stripe on striped dir error"
15368 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
15369 for dir in $(find $DIR/$tdir/striped_dir/*); do
15370 stripe_count=$($LFS getdirstripe -c $dir)
15371 [ $stripe_count -eq 0 ] ||
15372 error "expect 1 get $stripe_count for $dir"
15375 run_test 300h "check default striped directory for striped directory"
15378 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15379 skip "Need MDS version at least 2.7.55" && return
15380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15381 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15387 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15388 error "set striped dir error"
15390 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15391 error "create files under striped dir failed"
15393 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
15394 error "set striped hashdir error"
15396 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
15397 error "create dir0 under hash dir failed"
15398 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
15399 error "create dir1 under hash dir failed"
15401 # unfortunately, we need to umount to clear dir layout cache for now
15402 # once we fully implement dir layout, we can drop this
15403 umount_client $MOUNT || error "umount failed"
15404 mount_client $MOUNT || error "mount failed"
15406 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
15407 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
15408 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
15410 #set the stripe to be unknown hash type
15411 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
15412 $LCTL set_param fail_loc=0x1901
15413 for ((i = 0; i < 10; i++)); do
15414 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
15415 error "stat f-$i failed"
15416 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
15419 touch $DIR/$tdir/striped_dir/f0 &&
15420 error "create under striped dir with unknown hash should fail"
15422 $LCTL set_param fail_loc=0
15424 umount_client $MOUNT || error "umount failed"
15425 mount_client $MOUNT || error "mount failed"
15429 run_test 300i "client handle unknown hash type striped directory"
15432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15433 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15434 skip "Need MDS version at least 2.7.55" && return
15435 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15441 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
15442 $LCTL set_param fail_loc=0x1702
15443 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
15444 error "set striped dir error"
15446 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
15447 error "create files under striped dir failed"
15449 $LCTL set_param fail_loc=0
15451 rm -rf $DIR/$tdir || error "unlink striped dir fails"
15455 run_test 300j "test large update record"
15458 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15459 skip "Need MDS version at least 2.7.55" && return
15460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15461 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15467 #define OBD_FAIL_LARGE_STRIPE 0x1703
15468 $LCTL set_param fail_loc=0x1703
15469 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
15470 error "set striped dir error"
15471 $LCTL set_param fail_loc=0
15473 $LFS getdirstripe $DIR/$tdir/striped_dir ||
15474 error "getstripeddir fails"
15475 rm -rf $DIR/$tdir/striped_dir ||
15476 error "unlink striped dir fails"
15480 run_test 300k "test large striped directory"
15483 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15484 skip "Need MDS version at least 2.7.55" && return
15485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15486 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15489 test_mkdir -p $DIR/$tdir/striped_dir
15490 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
15491 error "chown $RUNAS_ID failed"
15492 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
15493 error "set default striped dir failed"
15495 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
15496 $LCTL set_param fail_loc=0x80000158
15497 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
15499 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
15500 [ $stripe_index -eq 1 ] ||
15501 error "expect 1 get $stripe_index for $dir"
15503 run_test 300l "non-root user to create dir under striped dir with stale layout"
15506 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15507 skip "Need MDS version at least 2.7.55" && return
15508 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15509 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
15511 mkdir -p $DIR/$tdir/striped_dir
15512 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
15513 error "set default stripes dir error"
15515 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
15517 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
15518 [ $stripe_count -eq 0 ] ||
15519 error "expect 0 get $stripe_count for a"
15521 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
15522 error "set default stripes dir error"
15524 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
15526 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
15527 [ $stripe_count -eq 0 ] ||
15528 error "expect 0 get $stripe_count for b"
15530 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
15531 error "set default stripes dir error"
15533 mkdir $DIR/$tdir/striped_dir/c &&
15534 error "default stripe_index is invalid, mkdir c should fails"
15536 rm -rf $DIR/$tdir || error "rmdir fails"
15538 run_test 300m "setstriped directory on single MDT FS"
15541 local list=$(comma_list $(mdts_nodes))
15544 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15548 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15549 skip "Need MDS version at least 2.7.55" && return
15550 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15551 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15552 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15555 local list=$(comma_list $(mdts_nodes))
15557 trap cleanup_300n RETURN EXIT
15558 mkdir -p $DIR/$tdir
15559 chmod 777 $DIR/$tdir
15560 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
15561 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15562 error "create striped dir succeeds with gid=0"
15564 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15565 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
15566 error "create striped dir fails with gid=-1"
15568 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15569 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
15570 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
15571 error "set default striped dir succeeds with gid=0"
15574 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
15575 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
15576 error "set default striped dir fails with gid=-1"
15579 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
15580 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
15581 error "create test_dir fails"
15582 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
15583 error "create test_dir1 fails"
15584 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
15585 error "create test_dir2 fails"
15588 run_test 300n "non-root user to create dir under striped dir with default EA"
15591 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
15592 skip "Need MDS version at least 2.7.55" && return
15593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15594 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15598 mkdir -p $DIR/$tdir
15600 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
15601 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
15602 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
15603 skip "not enough free inodes $numfree1 $numfree2"
15607 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
15608 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
15609 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
15610 skip "not enough free space $numfree1 $numfree2"
15614 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
15615 error "setdirstripe fails"
15617 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
15618 error "create dirs fails"
15620 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
15621 ls $DIR/$tdir/striped_dir > /dev/null ||
15622 error "ls striped dir fails"
15623 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
15624 error "unlink big striped dir fails"
15626 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
15629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15630 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15631 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15633 mkdir -p $DIR/$tdir
15635 #define OBD_FAIL_OUT_ENOSPC 0x1704
15636 do_facet mds2 lctl set_param fail_loc=0x80001704
15637 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
15638 error "create striped directory should fail"
15640 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
15642 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
15645 run_test 300p "create striped directory without space"
15648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15649 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
15651 local fd=$(free_fd)
15652 local cmd="exec $fd<$tdir"
15654 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
15657 trap "eval $cmd" EXIT
15658 cd $tdir || error "cd $tdir fails"
15659 rmdir ../$tdir || error "rmdir $tdir fails"
15660 mkdir local_dir && error "create dir succeeds"
15661 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
15665 run_test 300q "create remote directory under orphan directory"
15667 prepare_remote_file() {
15668 mkdir $DIR/$tdir/src_dir ||
15669 error "create remote source failed"
15671 cp /etc/hosts $DIR/$tdir/src_dir/a || error
15672 touch $DIR/$tdir/src_dir/a
15674 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
15675 error "create remote target dir failed"
15677 touch $DIR/$tdir/tgt_dir/b
15679 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
15680 error "rename dir cross MDT failed!"
15682 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
15683 error "src_child still exists after rename"
15685 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
15686 error "missing file(a) after rename"
15688 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
15689 error "diff after rename"
15693 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15694 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15695 local remote_file=$DIR/$tdir/tgt_dir/b
15697 mkdir -p $DIR/$tdir
15699 prepare_remote_file || error "prepare remote file failed"
15702 $OPENUNLINK $remote_file $remote_file || error
15703 $CHECKSTAT -a $remote_file || error
15705 run_test 310a "open unlink remote file"
15708 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
15709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15710 local remote_file=$DIR/$tdir/tgt_dir/b
15712 mkdir -p $DIR/$tdir
15714 prepare_remote_file || error "prepare remote file failed"
15716 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15717 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
15718 $CHECKSTAT -t file $remote_file || error "check file failed"
15720 run_test 310b "unlink remote file with multiple links while open"
15723 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
15724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15725 local remote_file=$DIR/$tdir/tgt_dir/b
15727 mkdir -p $DIR/$tdir
15729 prepare_remote_file || error "prepare remote file failed"
15731 ln $remote_file $DIR/$tfile || error "link failed for remote file"
15732 multiop_bg_pause $remote_file O_uc ||
15733 error "mulitop failed for remote file"
15735 $MULTIOP $DIR/$tfile Ouc
15736 kill -USR1 $MULTIPID
15739 run_test 310c "open-unlink remote file with multiple links"
15743 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
15744 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
15745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15746 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15748 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
15750 mkdir -p $DIR/$tdir
15751 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
15752 createmany -o $DIR/$tdir/$tfile. 1000
15754 # statfs data is not real time, let's just calculate it
15755 old_iused=$((old_iused + 1000))
15757 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
15758 osp.*OST0000*MDT0000.create_count")
15759 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
15760 osp.*OST0000*MDT0000.max_create_count")
15761 for idx in $(seq $MDSCOUNT); do
15762 do_facet mds$idx "lctl set_param -n \
15763 osp.*OST0000*MDT000?.max_create_count=0"
15766 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
15767 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
15768 [ $index -ne 0 ] || error "$tfile stripe index is 0"
15770 unlinkmany $DIR/$tdir/$tfile. 1000
15772 for idx in $(seq $MDSCOUNT); do
15773 do_facet mds$idx "lctl set_param -n \
15774 osp.*OST0000*MDT000?.max_create_count=$max_count"
15775 do_facet mds$idx "lctl set_param -n \
15776 osp.*OST0000*MDT000?.create_count=$count"
15780 for i in $(seq 120); do
15781 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
15782 # system may be too busy to destroy all objs in time, use
15783 # a somewhat small value to not fail autotest
15784 [ $((old_iused - new_iused)) -gt 400 ] && break
15788 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
15789 [ $((old_iused - new_iused)) -gt 400 ] ||
15790 error "objs not destroyed after unlink"
15792 run_test 311 "disable OSP precreate, and unlink should destroy objs"
15799 local vdevdir=$(dirname $(facet_vdevice $ost))
15800 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
15801 local zfs_zapid=$(do_facet $ost $cmd |
15802 grep -w "/O/0/d$((objid%32))" -C 5 |
15803 awk '/Object/{getline; print $1}')
15804 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
15805 awk "/$objid = /"'{printf $3}')
15810 zfs_object_blksz() {
15814 local vdevdir=$(dirname $(facet_vdevice $ost))
15815 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
15816 local blksz=$(do_facet $ost $cmd $objid |
15817 awk '/dblk/{getline; printf $4}')
15819 case "${blksz: -1}" in
15820 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
15821 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
15828 test_312() { # LU-4856
15829 remote_ost_nodsh && skip "remote OST with nodsh" && return
15831 [ $(facet_fstype ost1) = "zfs" ] ||
15832 { skip "the test only applies to zfs" && return; }
15834 local max_blksz=$(do_facet ost1 \
15835 $ZFS get -p recordsize $(facet_device ost1) |
15836 awk '!/VALUE/{print $3}')
15837 local min_blksz=$(getconf PAGE_SIZE)
15839 # to make life a little bit easier
15840 $LFS mkdir -c 1 -i 0 $DIR/$tdir
15841 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15843 local tf=$DIR/$tdir/$tfile
15845 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
15847 # Get ZFS object id
15848 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
15850 # block size change by sequential over write
15852 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
15853 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
15855 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15856 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
15860 # block size change by sequential append write
15861 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
15862 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
15863 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
15865 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
15866 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
15867 oflag=sync conv=notrunc
15869 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15870 [ $blksz -eq $((2 * count * min_blksz)) ] ||
15871 error "blksz error, actual $blksz, " \
15872 "expected: 2 * $count * $min_blksz"
15878 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
15879 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
15881 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
15882 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15883 [ $blksz -eq $min_blksz ] ||
15884 error "blksz error: $blksz, expected: $min_blksz"
15886 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
15887 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15888 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
15890 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
15891 blksz=$(zfs_object_blksz ost1 $zfs_objid)
15892 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
15894 run_test 312 "make sure ZFS adjusts its block size by write pattern"
15897 remote_ost_nodsh && skip "remote OST with nodsh" && return
15899 local file=$DIR/$tfile
15901 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
15903 # define OBD_FAIL_TGT_RCVD_EIO 0x720
15904 do_facet ost1 "$LCTL set_param fail_loc=0x720"
15905 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
15906 error "write should failed"
15907 do_facet ost1 "$LCTL set_param fail_loc=0"
15910 run_test 313 "io should fail after last_rcvd update fail"
15913 local read_write=$1
15914 if [ "$read_write" = "write" ]; then
15915 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
15916 elif [ "$read_write" = "read" ]; then
15917 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
15919 error "argument error"
15922 # turn off debug for performance testing
15923 local saved_debug=$($LCTL get_param -n debug)
15924 $LCTL set_param debug=0
15926 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
15928 # get ost1 size - lustre-OST0000
15929 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
15930 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
15931 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
15933 if [ "$read_write" = "read" ]; then
15934 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
15937 local start_time=$(date +%s.%N)
15938 $dd_cmd bs=1M count=$blocks oflag=sync ||
15939 error "real dd $read_write error"
15940 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
15942 if [ "$read_write" = "write" ]; then
15946 # define OBD_FAIL_OST_FAKE_RW 0x238
15947 do_facet ost1 $LCTL set_param fail_loc=0x238
15949 local start_time=$(date +%s.%N)
15950 $dd_cmd bs=1M count=$blocks oflag=sync ||
15951 error "fake dd $read_write error"
15952 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
15954 if [ "$read_write" = "write" ]; then
15956 cancel_lru_locks osc
15957 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
15958 error "$tfile size not $blocks MB"
15960 do_facet ost1 $LCTL set_param fail_loc=0
15962 echo "fake $read_write $duration_fake vs. normal $read_write" \
15963 "$duration in seconds"
15964 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
15965 error_not_in_vm "fake write is slower"
15967 $LCTL set_param -n debug="$saved_debug"
15970 test_399a() { # LU-7655 for OST fake write
15971 remote_ost_nodsh && skip "remote OST with nodsh" && return
15975 run_test 399a "fake write should not be slower than normal write"
15977 test_399b() { # LU-8726 for OST fake read
15978 remote_ost_nodsh && skip "remote OST with nodsh" && return
15980 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
15981 skip "ldiskfs only test" && return 0
15985 run_test 399b "fake read should not be slower than normal read"
15987 test_400a() { # LU-1606, was conf-sanity test_74
15988 local extra_flags=''
15989 local out=$TMP/$tfile
15990 local prefix=/usr/include/lustre
15993 if ! which $CC > /dev/null 2>&1; then
15994 skip_env "$CC is not installed"
15998 if ! [[ -d $prefix ]]; then
15999 # Assume we're running in tree and fixup the include path.
16000 extra_flags+=" -I$LUSTRE/include"
16001 extra_flags+=" -L$LUSTRE/utils"
16004 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
16005 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
16006 error "client api broken"
16010 run_test 400a "Lustre client api program can compile and link"
16012 test_400b() { # LU-1606, LU-5011
16014 local out=$TMP/$tfile
16015 local prefix=/usr/include/linux/lustre
16017 # We use a hard coded prefix so that this test will not fail
16018 # when run in tree. There are headers in lustre/include/lustre/
16019 # that are not packaged (like lustre_idl.h) and have more
16020 # complicated include dependencies (like config.h and lnet/types.h).
16021 # Since this test about correct packaging we just skip them when
16022 # they don't exist (see below) rather than try to fixup cppflags.
16024 if ! which $CC > /dev/null 2>&1; then
16025 skip_env "$CC is not installed"
16029 for header in $prefix/*.h; do
16030 if ! [[ -f "$header" ]]; then
16034 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
16035 continue # lustre_ioctl.h is internal header
16038 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
16039 error "cannot compile '$header'"
16043 run_test 400b "packaged headers can be compiled"
16045 test_401a() { #LU-7437
16046 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
16047 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
16049 #count the number of parameters by "list_param -R"
16050 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
16051 #count the number of parameters by listing proc files
16052 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
16053 echo "proc_dirs='$proc_dirs'"
16054 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
16055 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
16058 [ $params -eq $procs ] ||
16059 error "found $params parameters vs. $procs proc files"
16061 # test the list_param -D option only returns directories
16062 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
16063 #count the number of parameters by listing proc directories
16064 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
16067 [ $params -eq $procs ] ||
16068 error "found $params parameters vs. $procs proc files"
16070 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
16073 local save=$($LCTL get_param -n jobid_var)
16076 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
16077 error "no error returned when setting bad parameters"
16079 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
16080 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
16082 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
16083 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
16084 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
16086 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
16089 local jobid_var_old=$($LCTL get_param -n jobid_var)
16090 local jobid_var_new
16092 $LCTL set_param jobid_var= &&
16093 error "no error returned for 'set_param a='"
16095 jobid_var_new=$($LCTL get_param -n jobid_var)
16096 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16097 error "jobid_var was changed by setting without value"
16099 $LCTL set_param jobid_var &&
16100 error "no error returned for 'set_param a'"
16102 jobid_var_new=$($LCTL get_param -n jobid_var)
16103 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
16104 error "jobid_var was changed by setting without value"
16106 run_test 401c "Verify 'lctl set_param' without value fails in either format."
16109 local jobid_var_old=$($LCTL get_param -n jobid_var)
16110 local jobid_var_new
16111 local new_value="foo=bar"
16113 $LCTL set_param jobid_var=$new_value ||
16114 error "'set_param a=b' did not accept a value containing '='"
16116 jobid_var_new=$($LCTL get_param -n jobid_var)
16117 [[ "$jobid_var_new" == "$new_value" ]] ||
16118 error "'set_param a=b' failed on a value containing '='"
16120 # Reset the jobid_var to test the other format
16121 $LCTL set_param jobid_var=$jobid_var_old
16122 jobid_var_new=$($LCTL get_param -n jobid_var)
16123 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16124 error "failed to reset jobid_var"
16126 $LCTL set_param jobid_var $new_value ||
16127 error "'set_param a b' did not accept a value containing '='"
16129 jobid_var_new=$($LCTL get_param -n jobid_var)
16130 [[ "$jobid_var_new" == "$new_value" ]] ||
16131 error "'set_param a b' failed on a value containing '='"
16133 $LCTL set_param jobid_var $jobid_var_old
16134 jobid_var_new=$($LCTL get_param -n jobid_var)
16135 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
16136 error "failed to reset jobid_var"
16138 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
16141 local server_version=$(lustre_version_code $SINGLEMDS)
16142 [[ $server_version -ge $(version_code 2.7.66) ]] ||
16143 [[ $server_version -ge $(version_code 2.7.18.4) &&
16144 $server_version -lt $(version_code 2.7.50) ]] ||
16145 [[ $server_version -ge $(version_code 2.7.2) &&
16146 $server_version -lt $(version_code 2.7.11) ]] ||
16147 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
16149 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16150 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
16151 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
16152 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
16153 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
16154 echo "Touch failed - OK"
16156 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
16159 local file1=$DIR/$tfile.1
16160 local file2=$DIR/$tfile.2
16161 local tfile=$TMP/$tfile
16163 rm -f $file1 $file2 $tfile
16168 # 30 sec OBD_TIMEOUT in ll_getattr()
16169 # right before populating st_nlink
16170 $LCTL set_param fail_loc=0x80001409
16171 stat -c %h $file1 > $tfile &
16173 # create an alias, drop all locks and reclaim the dentry
16175 cancel_lru_locks mdc
16176 cancel_lru_locks osc
16177 sysctl -w vm.drop_caches=2
16181 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
16183 rm -f $tfile $file1 $file2
16185 run_test 403 "i_nlink should not drop to zero due to aliasing"
16187 test_404() { # LU-6601
16188 local server_version=$(lustre_version_code $SINGLEMDS)
16189 [[ $server_version -ge $(version_code 2.8.53) ]] ||
16190 { skip "Need server version newer than 2.8.52"; return 0; }
16192 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16193 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
16194 awk '/osp .*-osc-MDT/ { print $4}')
16197 for osp in $mosps; do
16198 echo "Deactivate: " $osp
16199 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
16200 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16201 awk -vp=$osp '$4 == p { print $2 }')
16202 [ $stat = IN ] || {
16203 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16204 error "deactivate error"
16206 echo "Activate: " $osp
16207 do_facet $SINGLEMDS $LCTL --device %$osp activate
16208 local stat=$(do_facet $SINGLEMDS $LCTL dl |
16209 awk -vp=$osp '$4 == p { print $2 }')
16210 [ $stat = UP ] || {
16211 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
16212 error "activate error"
16216 run_test 404 "validate manual {de}activated works properly for OSPs"
16219 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
16220 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
16221 skip "Layout swap lock is not supported" && return
16223 check_swap_layouts_support && return 0
16225 test_mkdir $DIR/$tdir
16226 swap_lock_test -d $DIR/$tdir ||
16227 error "One layout swap locked test failed"
16229 run_test 405 "Various layout swap lock tests"
16232 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16233 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
16234 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
16235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16236 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
16237 skip "Need MDS version at least 2.8.50" && return
16239 local def_stripe_count=$($GETSTRIPE -c $MOUNT)
16240 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
16241 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
16242 local def_pool=$($GETSTRIPE -p $MOUNT)
16244 local test_pool=$TESTNAME
16245 pool_add $test_pool || error "pool_add failed"
16246 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
16247 error "pool_add_targets failed"
16249 # parent set default stripe count only, child will stripe from both
16250 # parent and fs default
16251 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
16252 error "setstripe $MOUNT failed"
16253 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
16254 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
16255 for i in $(seq 10); do
16256 local f=$DIR/$tdir/$tfile.$i
16257 touch $f || error "touch failed"
16258 local count=$($GETSTRIPE -c $f)
16259 [ $count -eq $OSTCOUNT ] ||
16260 error "$f stripe count $count != $OSTCOUNT"
16261 local offset=$($GETSTRIPE -i $f)
16262 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
16263 local size=$($GETSTRIPE -S $f)
16264 [ $size -eq $((def_stripe_size * 2)) ] ||
16265 error "$f stripe size $size != $((def_stripe_size * 2))"
16266 local pool=$($GETSTRIPE -p $f)
16267 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
16270 # change fs default striping, delete parent default striping, now child
16271 # will stripe from new fs default striping only
16272 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
16273 error "change $MOUNT default stripe failed"
16274 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
16275 for i in $(seq 11 20); do
16276 local f=$DIR/$tdir/$tfile.$i
16277 touch $f || error "touch $f failed"
16278 local count=$($GETSTRIPE -c $f)
16279 [ $count -eq 1 ] || error "$f stripe count $count != 1"
16280 local offset=$($GETSTRIPE -i $f)
16281 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
16282 local size=$($GETSTRIPE -S $f)
16283 [ $size -eq $def_stripe_size ] ||
16284 error "$f stripe size $size != $def_stripe_size"
16285 local pool=$($GETSTRIPE -p $f)
16286 [ "#$pool" == "#" ] || error "$f pool $pool is set"
16290 unlinkmany $DIR/$tdir/$tfile. 1 20
16292 # restore FS default striping
16293 if [ -z $def_pool ]; then
16294 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16295 -i $def_stripe_offset $MOUNT ||
16296 error "restore default striping failed"
16298 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
16299 -i $def_stripe_offset -p $def_pool $MOUNT ||
16300 error "restore default striping with $def_pool failed"
16303 local f=$DIR/$tdir/$tfile
16304 pool_remove_all_targets $test_pool $f
16305 pool_remove $test_pool $f
16307 run_test 406 "DNE support fs default striping"
16310 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16311 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16312 skip "Need MDS version at least 2.8.55" && return
16313 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16315 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
16316 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
16317 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
16318 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
16319 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
16321 #define OBD_FAIL_DT_TXN_STOP 0x2019
16322 for idx in $(seq $MDSCOUNT); do
16323 do_facet mds$idx "lctl set_param fail_loc=0x2019"
16325 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
16326 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
16327 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
16330 run_test 407 "transaction fail should cause operation fail"
16333 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
16335 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
16336 lctl set_param fail_loc=0x8000040a
16337 # let ll_prepare_partial_page() fail
16338 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
16342 # create at least 100 unused inodes so that
16343 # shrink_icache_memory(0) should not return 0
16344 touch $DIR/$tfile-{0..100}
16345 rm -f $DIR/$tfile-{0..100}
16348 echo 2 > /proc/sys/vm/drop_caches
16350 run_test 408 "drop_caches should not hang due to page leaks"
16354 [ $MDSCOUNT -lt 2 ] &&
16355 skip "We need at least 2 MDTs for this test" && return
16357 check_mount_and_prep
16359 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
16360 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
16361 touch $DIR/$tdir/guard || error "(2) Fail to create"
16363 local PREFIX=$(str_repeat 'A' 128)
16364 echo "Create 1K hard links start at $(date)"
16365 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16366 error "(3) Fail to hard link"
16368 echo "Links count should be right although linkEA overflow"
16369 stat $DIR/$tdir/guard || error "(4) Fail to stat"
16370 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
16371 [ $linkcount -eq 1001 ] ||
16372 error "(5) Unexpected hard links count: $linkcount"
16374 echo "List all links start at $(date)"
16375 ls -l $DIR/$tdir/foo > /dev/null ||
16376 error "(6) Fail to list $DIR/$tdir/foo"
16378 echo "Unlink hard links start at $(date)"
16379 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
16380 error "(7) Fail to unlink"
16382 run_test 409 "Large amount of cross-MDTs hard links on the same file"
16386 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
16387 skip "Need client version at least 2.9.59" && return
16389 # Create a file, and stat it from the kernel
16390 local testfile=$DIR/$tfile
16393 local run_id=$RANDOM
16394 local my_ino=$(stat --format "%i" $testfile)
16396 # Try to insert the module. This will always fail as the
16397 # module is designed to not be inserted.
16398 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
16401 # Anything but success is a test failure
16403 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
16404 error "no inode match"
16406 run_test 410 "Test inode number returned from kernel thread"
16408 cleanup_test411_cgroup() {
16414 local cg_basedir=/sys/fs/cgroup/memory
16416 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
16417 { skip "no setup for cgroup"; return; }
16419 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
16420 error "test file creation failed"
16421 cancel_lru_locks osc
16423 # Create a very small memory cgroup to force a slab allocation error
16424 local cgdir=$cg_basedir/osc_slab_alloc
16425 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
16426 trap "cleanup_test411_cgroup $cgdir" EXIT
16427 echo 2M > $cgdir/memory.kmem.limit_in_bytes
16428 echo 1M > $cgdir/memory.limit_in_bytes
16430 # Should not LBUG, just be killed by oom-killer
16431 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
16432 error "fail to trigger a memory allocation error"
16434 cleanup_test411_cgroup $cgdir
16438 run_test 411 "Slab allocation error with cgroup does not LBUG"
16441 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16442 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16443 skip "Need server version at least 2.9.55" & exit 0
16444 start_full_debug_logging
16448 stop_full_debug_logging
16452 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16453 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16454 awk '/The barrier for/ { print $7 }')
16457 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
16462 barrier_expired() {
16465 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
16466 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
16467 awk '/will be expired/ { print $7 }')
16469 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
16478 echo "Start barrier_freeze at: $(date)"
16479 #define OBD_FAIL_BARRIER_DELAY 0x2202
16480 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16481 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
16484 local b_status=$(barrier_stat)
16485 echo "Got barrier status at: $(date)"
16486 [ "$b_status" = "'freezing_p1'" ] ||
16487 error "(1) unexpected barrier status $b_status"
16489 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16491 b_status=$(barrier_stat)
16492 [ "$b_status" = "'frozen'" ] ||
16493 error "(2) unexpected barrier status $b_status"
16495 local expired=$(barrier_expired)
16496 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
16497 sleep $((expired + 3))
16499 b_status=$(barrier_stat)
16500 [ "$b_status" = "'expired'" ] ||
16501 error "(3) unexpected barrier status $b_status"
16503 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
16504 error "(4) fail to freeze barrier"
16506 b_status=$(barrier_stat)
16507 [ "$b_status" = "'frozen'" ] ||
16508 error "(5) unexpected barrier status $b_status"
16510 echo "Start barrier_thaw at: $(date)"
16511 #define OBD_FAIL_BARRIER_DELAY 0x2202
16512 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
16513 do_facet mgs $LCTL barrier_thaw $FSNAME &
16516 b_status=$(barrier_stat)
16517 echo "Got barrier status at: $(date)"
16518 [ "$b_status" = "'thawing'" ] ||
16519 error "(6) unexpected barrier status $b_status"
16521 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
16523 b_status=$(barrier_stat)
16524 [ "$b_status" = "'thawed'" ] ||
16525 error "(7) unexpected barrier status $b_status"
16527 #define OBD_FAIL_BARRIER_FAILURE 0x2203
16528 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
16529 do_facet mgs $LCTL barrier_freeze $FSNAME
16531 b_status=$(barrier_stat)
16532 [ "$b_status" = "'failed'" ] ||
16533 error "(8) unexpected barrier status $b_status"
16535 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16536 do_facet mgs $LCTL barrier_thaw $FSNAME
16540 run_test 801a "write barrier user interfaces and stat machine"
16545 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16546 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
16547 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
16548 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
16549 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
16551 cancel_lru_locks mdc
16553 # 180 seconds should be long enough
16554 do_facet mgs $LCTL barrier_freeze $FSNAME 180
16556 local b_status=$(barrier_stat)
16557 [ "$b_status" = "'frozen'" ] ||
16558 error "(6) unexpected barrier status $b_status"
16560 mkdir $DIR/$tdir/d0/d10 &
16563 touch $DIR/$tdir/d1/f13 &
16566 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
16569 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
16572 rm -f $DIR/$tdir/d4/f12 &
16575 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
16577 # To guarantee taht the 'stat' is not blocked
16578 b_status=$(barrier_stat)
16579 [ "$b_status" = "'frozen'" ] ||
16580 error "(8) unexpected barrier status $b_status"
16582 # let above commands to run at background
16585 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
16586 ps -p $touch_pid || error "(10) touch should be blocked"
16587 ps -p $ln_pid || error "(11) link should be blocked"
16588 ps -p $mv_pid || error "(12) rename should be blocked"
16589 ps -p $rm_pid || error "(13) unlink should be blocked"
16591 b_status=$(barrier_stat)
16592 [ "$b_status" = "'frozen'" ] ||
16593 error "(14) unexpected barrier status $b_status"
16595 do_facet mgs $LCTL barrier_thaw $FSNAME
16596 b_status=$(barrier_stat)
16597 [ "$b_status" = "'thawed'" ] ||
16598 error "(15) unexpected barrier status $b_status"
16600 wait $mkdir_pid || error "(16) mkdir should succeed"
16601 wait $touch_pid || error "(17) touch should succeed"
16602 wait $ln_pid || error "(18) link should succeed"
16603 wait $mv_pid || error "(19) rename should succeed"
16604 wait $rm_pid || error "(20) unlink should succeed"
16608 run_test 801b "modification will be blocked by write barrier"
16611 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
16615 stop mds2 || error "(1) Fail to stop mds2"
16617 do_facet mgs $LCTL barrier_freeze $FSNAME 30
16619 local b_status=$(barrier_stat)
16620 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
16621 do_facet mgs $LCTL barrier_thaw $FSNAME
16622 error "(2) unexpected barrier status $b_status"
16625 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16626 error "(3) Fail to rescan barrier bitmap"
16628 do_facet mgs $LCTL barrier_freeze $FSNAME 10
16630 b_status=$(barrier_stat)
16631 [ "$b_status" = "'frozen'" ] ||
16632 error "(4) unexpected barrier status $b_status"
16634 do_facet mgs $LCTL barrier_thaw $FSNAME
16635 b_status=$(barrier_stat)
16636 [ "$b_status" = "'thawed'" ] ||
16637 error "(5) unexpected barrier status $b_status"
16639 local devname=$(mdsdevname 2)
16641 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
16643 do_facet mgs $LCTL barrier_rescan $FSNAME ||
16644 error "(7) Fail to rescan barrier bitmap"
16648 run_test 801c "rescan barrier bitmap"
16650 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
16651 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
16652 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
16658 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
16659 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
16660 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
16666 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
16667 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
16668 skip "Need server version at least 2.9.55" & exit 0
16670 mkdir $DIR/$tdir || error "(1) fail to mkdir"
16672 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
16673 error "(2) Fail to copy"
16675 trap cleanup_802 EXIT
16677 # sync by force before remount as readonly
16678 sync; sync_all_data; sleep 3; sync_all_data
16682 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
16683 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
16684 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
16686 echo "Mount the server as read only"
16687 setupall server_only || error "(3) Fail to start servers"
16689 echo "Mount client without ro should fail"
16690 mount_client $MOUNT &&
16691 error "(4) Mount client without 'ro' should fail"
16693 echo "Mount client with ro should succeed"
16694 mount_client $MOUNT ro ||
16695 error "(5) Mount client with 'ro' should succeed"
16697 echo "Modify should be refused"
16698 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
16700 echo "Read should be allowed"
16701 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
16702 error "(7) Read should succeed under ro mode"
16706 run_test 802 "simulate readonly device"
16709 # tests that do cleanup/setup should be run at the end
16713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16715 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
16716 $LCTL set_param fail_loc=0x903
16718 cancel_lru_locks MGC
16720 FAIL_ON_ERROR=true cleanup
16721 FAIL_ON_ERROR=true setup
16723 run_test 900 "umount should not race with any mgc requeue thread"
16726 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
16727 check_and_cleanup_lustre
16728 if [ "$I_MOUNTED" != "yes" ]; then
16729 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true