2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: LU-9693 LU-6493 LU-9693
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054
16 ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
18 # Check Grants after these tests
19 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
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
46 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
47 CREATETEST=${CREATETEST:-createtest}
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" ||
1679 run_test 27u "skip object creation on OSC w/o objects"
1681 test_27v() { # bug 4900
1682 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1684 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1685 remote_ost_nodsh && skip "remote OST with nodsh" && return
1687 exhaust_all_precreations 0x215
1690 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1692 touch $DIR/$tdir/$tfile
1693 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1695 for (( i=1; i < OSTCOUNT; i++ )); do
1696 do_facet ost$i lctl set_param fail_loc=0x705
1698 local START=`date +%s`
1699 createmany -o $DIR/$tdir/$tfile 32
1701 local FINISH=`date +%s`
1702 local TIMEOUT=`lctl get_param -n timeout`
1703 local PROCESS=$((FINISH - START))
1704 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1705 error "$FINISH - $START >= $TIMEOUT / 2"
1706 sleep $((TIMEOUT / 2 - PROCESS))
1709 run_test 27v "skip object creation on slow OST"
1711 test_27w() { # bug 10997
1712 test_mkdir $DIR/$tdir
1713 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1714 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1715 error "stripe size $size != 65536" || true
1716 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1717 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1719 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1722 [[ $OSTCOUNT -lt 2 ]] &&
1723 skip_env "skipping multiple stripe count/offset test" && return
1725 test_mkdir $DIR/$tdir
1726 for i in $(seq 1 $OSTCOUNT); do
1728 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1729 error "setstripe -c $i -i $offset failed"
1730 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1731 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1732 [ $count -ne $i ] && error "stripe count $count != $i" || true
1733 [ $index -ne $offset ] &&
1734 error "stripe offset $index != $offset" || true
1737 run_test 27wa "check $LFS setstripe -c -i options"
1740 remote_ost_nodsh && skip "remote OST with nodsh" && return
1741 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1743 OFFSET=$(($OSTCOUNT - 1))
1745 local OST=$(ostname_from_index $OSTIDX)
1747 test_mkdir $DIR/$tdir
1748 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1749 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1751 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1752 for i in $(seq 0 $OFFSET); do
1753 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1754 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1755 error "OST0 was degraded but new created file still use it"
1757 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1759 run_test 27x "create files while OST0 is degraded"
1762 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
1763 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1764 remote_ost_nodsh && skip "remote OST with nodsh" && return
1765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1767 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1768 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1769 osc.$mdtosc.prealloc_last_id)
1770 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1771 osc.$mdtosc.prealloc_next_id)
1772 local fcount=$((last_id - next_id))
1773 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1774 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1776 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1777 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1778 local OST_DEACTIVE_IDX=-1
1783 for OSC in $MDS_OSCS; do
1784 OST=$(osc_to_ost $OSC)
1785 OSTIDX=$(index_from_ostuuid $OST)
1786 if [ $OST_DEACTIVE_IDX == -1 ]; then
1787 OST_DEACTIVE_IDX=$OSTIDX
1789 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1790 echo $OSC "is Deactivated:"
1791 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1795 OSTIDX=$(index_from_ostuuid $OST)
1796 test_mkdir $DIR/$tdir
1797 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1799 for OSC in $MDS_OSCS; do
1800 OST=$(osc_to_ost $OSC)
1801 OSTIDX=$(index_from_ostuuid $OST)
1802 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1803 echo $OST "is degraded:"
1804 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1805 obdfilter.$OST.degraded=1
1810 createmany -o $DIR/$tdir/$tfile $fcount
1812 for OSC in $MDS_OSCS; do
1813 OST=$(osc_to_ost $OSC)
1814 OSTIDX=$(index_from_ostuuid $OST)
1815 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1816 echo $OST "is recovered from degraded:"
1817 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1818 obdfilter.$OST.degraded=0
1820 do_facet $SINGLEMDS lctl --device %$OSC activate
1824 # all osp devices get activated, hence -1 stripe count restored
1825 local stripe_count=0
1827 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1828 # devices get activated.
1830 $LFS setstripe -c -1 $DIR/$tfile
1831 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1833 [ $stripe_count -ne $OSTCOUNT ] &&
1834 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1837 run_test 27y "create files while OST0 is degraded and the rest inactive"
1843 lmm_count=$($GETSTRIPE -c $1)
1844 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1845 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1847 local old_ifs="$IFS"
1849 fid=($($LFS path2fid $1))
1852 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1853 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1855 # compare lmm_seq and lu_fid->f_seq
1856 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1857 # compare lmm_object_id and lu_fid->oid
1858 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1860 # check the trusted.fid attribute of the OST objects of the file
1861 local have_obdidx=false
1863 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1864 # skip lines up to and including "obdidx"
1865 [ -z "$obdidx" ] && break
1866 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1867 $have_obdidx || continue
1869 local ost=$((obdidx + 1))
1870 local dev=$(ostdevname $ost)
1873 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1875 seq=$(echo $seq | sed -e "s/^0x//g")
1876 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1877 oid_hex=$(echo $oid)
1879 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1881 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1885 # Don't unmount/remount the OSTs if we don't need to do that.
1886 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1887 # update too, until that use mount/ll_decode_filter_fid/mount.
1888 # Re-enable when debugfs will understand new filter_fid.
1890 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
1891 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1892 $dev 2>/dev/null" | grep "parent=")
1894 if [ -z "$ff" ]; then
1896 mount_fstype ost$ost
1897 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1898 $(facet_mntpt ost$ost)/$obj_file)
1899 unmount_fstype ost$ost
1900 start ost$ost $dev $OST_MOUNT_OPTS
1904 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1906 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1908 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1909 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1911 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
1912 # stripe_size=1048576 component_id=1 component_start=0 \
1913 # component_end=33554432
1914 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
1915 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
1916 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
1918 if grep -q 'stripe=' <<<$ff; then
1919 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
1921 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1922 # into f_ver in this case. See comment on ff_parent.
1923 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
1926 # compare lmm_seq and filter_fid->ff_parent.f_seq
1927 [ $ff_pseq = $lmm_seq ] ||
1928 error "FF parent SEQ $ff_pseq != $lmm_seq"
1929 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1930 [ $ff_poid = $lmm_oid ] ||
1931 error "FF parent OID $ff_poid != $lmm_oid"
1932 (($ff_pstripe == $stripe_nr)) ||
1933 error "FF stripe $ff_pstripe != $stripe_nr"
1935 stripe_nr=$((stripe_nr + 1))
1936 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
1938 if grep -q 'stripe_count=' <<<$ff; then
1939 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
1940 -e 's/ .*//' <<<$ff)
1941 [ $lmm_count = $ff_scnt ] ||
1942 error "FF stripe count $lmm_count != $ff_scnt"
1948 remote_ost_nodsh && skip "remote OST with nodsh" && return
1949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1950 test_mkdir $DIR/$tdir
1952 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1953 { error "setstripe -c -1 failed"; return 1; }
1954 # We need to send a write to every object to get parent FID info set.
1955 # This _should_ also work for setattr, but does not currently.
1956 # touch $DIR/$tdir/$tfile-1 ||
1957 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1958 { error "dd $tfile-1 failed"; return 2; }
1959 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1960 { error "setstripe -c -1 failed"; return 3; }
1961 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1962 { error "dd $tfile-2 failed"; return 4; }
1964 # make sure write RPCs have been sent to OSTs
1967 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1968 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1970 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1972 test_27A() { # b=19102
1973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1974 local restore_size=$($GETSTRIPE -S $MOUNT)
1975 local restore_count=$($GETSTRIPE -c $MOUNT)
1976 local restore_offset=$($GETSTRIPE -i $MOUNT)
1977 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1978 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1979 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1980 local default_size=$($GETSTRIPE -S $MOUNT)
1981 local default_offset=$($GETSTRIPE -i $MOUNT)
1982 local dsize=$((1024 * 1024))
1983 [ $default_size -eq $dsize ] ||
1984 error "stripe size $default_size != $dsize"
1985 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1986 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1988 run_test 27A "check filesystem-wide default LOV EA values"
1990 test_27B() { # LU-2523
1991 test_mkdir $DIR/$tdir
1992 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1994 # open f1 with O_LOV_DELAY_CREATE
1996 # call setstripe ioctl on open file descriptor for f1
1998 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2002 # open f1 with O_LOV_DELAY_CREATE
2004 # call setstripe ioctl on open file descriptor for f1
2006 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2008 # Allow multiop to fail in imitation of NFS's busted semantics.
2011 run_test 27B "call setstripe on open unlinked file/rename victim"
2013 test_27C() { #LU-2871
2014 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
2022 test_mkdir $DIR/$tdir
2024 for i in $(seq 0 $((OSTCOUNT - 1))); do
2025 # set stripe across all OSTs starting from OST$i
2026 $SETSTRIPE -i $i -c -1 $tfile$i
2027 # get striping information
2028 ost_idx=($($GETSTRIPE $tfile$i |
2029 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2033 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2034 error "${#ost_idx[@]} != $OSTCOUNT"
2036 for index in $(seq 0 $((OSTCOUNT - 1))); do
2038 for j in $(echo ${ost_idx[@]}); do
2039 if [ $index -eq $j ]; then
2045 error "Can not find $index in ${ost_idx[@]}"
2049 run_test 27C "check full striping across all OSTs"
2052 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2053 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2054 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2055 local POOL=${POOL:-testpool}
2057 local last_ost=$(($OSTCOUNT - 1))
2059 local ost_list=$(seq $first_ost $ost_step $last_ost)
2060 local ost_range="$first_ost $last_ost $ost_step"
2062 if ! combined_mgs_mds ; then
2066 test_mkdir $DIR/$tdir
2067 pool_add $POOL || error "pool_add failed"
2068 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2071 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2073 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2074 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2075 skip27D += "-s 30,31"
2076 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2077 error "llapi_layout_test failed"
2079 destroy_test_pools || error "destroy test pools failed"
2081 if ! combined_mgs_mds ; then
2085 run_test 27D "validate llapi_layout API"
2087 # Verify that default_easize is increased from its initial value after
2088 # accessing a widely striped file.
2090 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2091 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2092 skip "client does not have LU-3338 fix" && return
2094 # 72 bytes is the minimum space required to store striping
2095 # information for a file striped across one OST:
2096 # (sizeof(struct lov_user_md_v3) +
2097 # sizeof(struct lov_user_ost_data_v1))
2099 $LCTL set_param -n llite.*.default_easize $min_easize ||
2100 error "lctl set_param failed"
2101 local easize=$($LCTL get_param -n llite.*.default_easize)
2103 [ $easize -eq $min_easize ] ||
2104 error "failed to set default_easize"
2106 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2107 error "setstripe failed"
2111 easize=$($LCTL get_param -n llite.*.default_easize)
2113 [ $easize -gt $min_easize ] ||
2114 error "default_easize not updated"
2116 run_test 27E "check that default extended attribute size properly increases"
2118 test_27F() { # LU-5346/LU-7975
2119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2120 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2121 skip "Need MDS version at least 2.8.51" && return
2122 remote_ost_nodsh && skip "remote OST with nodsh" && return
2124 test_mkdir $DIR/$tdir
2126 $SETSTRIPE -c 2 $DIR/$tdir
2128 # stop all OSTs to reproduce situation for LU-7975 ticket
2129 for num in $(seq $OSTCOUNT); do
2133 # open/create f0 with O_LOV_DELAY_CREATE
2134 # truncate f0 to a non-0 size
2136 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2138 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2139 # open/write it again to force delayed layout creation
2140 cat /etc/hosts > $DIR/$tdir/f0 &
2144 for num in $(seq $OSTCOUNT); do
2145 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2146 error "ost$num failed to start"
2149 wait $catpid || error "cat failed"
2151 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2152 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2155 run_test 27F "Client resend delayed layout creation with non-zero size"
2157 # createtest also checks that device nodes are created and
2158 # then visible correctly (#2091)
2159 test_28() { # bug 2091
2161 $CREATETEST $DIR/d28/ct || error
2163 run_test 28 "create/mknod/mkdir with bad file types ============"
2166 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
2167 sync; sleep 1; sync # flush out any dirty pages from previous tests
2174 declare -i LOCKCOUNTORIG=0
2175 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2176 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2178 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2180 declare -i LOCKUNUSEDCOUNTORIG=0
2181 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2182 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2189 declare -i LOCKCOUNTCURRENT=0
2190 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2191 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2194 declare -i LOCKUNUSEDCOUNTCURRENT=0
2195 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2196 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2199 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2200 $LCTL set_param -n ldlm.dump_namespaces ""
2201 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2202 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2203 log "dumped log to $TMP/test_29.dk (bug 5793)"
2206 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2207 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2208 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2209 log "dumped log to $TMP/test_29.dk (bug 5793)"
2213 run_test 29 "IT_GETATTR regression ============================"
2215 test_30a() { # was test_30
2216 cp $(which ls) $DIR || cp /bin/ls $DIR
2220 run_test 30a "execute binary from Lustre (execve) =============="
2223 cp `which ls` $DIR || cp /bin/ls $DIR
2225 $RUNAS $DIR/ls / || error
2228 run_test 30b "execute binary from Lustre as non-root ==========="
2230 test_30c() { # b=22376
2231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2232 cp `which ls` $DIR || cp /bin/ls $DIR
2234 cancel_lru_locks mdc
2235 cancel_lru_locks osc
2236 $RUNAS $DIR/ls / || error
2239 run_test 30c "execute binary from Lustre without read perms ===="
2242 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2243 $CHECKSTAT -a $DIR/f31 || error
2245 run_test 31a "open-unlink file =================================="
2248 touch $DIR/f31 || error
2249 ln $DIR/f31 $DIR/f31b || error
2250 $MULTIOP $DIR/f31b Ouc || error
2251 $CHECKSTAT -t file $DIR/f31 || error
2253 run_test 31b "unlink file with multiple links while open ======="
2256 touch $DIR/f31 || error
2257 ln $DIR/f31 $DIR/f31c || error
2258 multiop_bg_pause $DIR/f31 O_uc || return 1
2260 $MULTIOP $DIR/f31c Ouc
2261 kill -USR1 $MULTIPID
2264 run_test 31c "open-unlink file with multiple links ============="
2267 opendirunlink $DIR/d31d $DIR/d31d || error
2268 $CHECKSTAT -a $DIR/d31d || error
2270 run_test 31d "remove of open directory ========================="
2272 test_31e() { # bug 2904
2273 openfilleddirunlink $DIR/d31e || error
2275 run_test 31e "remove of open non-empty directory ==============="
2277 test_31f() { # bug 4554
2278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
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 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2289 test_mkdir $DIR/d31f
2290 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2291 cp /etc/hosts $DIR/d31f
2293 $GETSTRIPE $DIR/d31f/hosts
2294 multiop_bg_pause $DIR/d31f D_c || return 1
2297 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2298 wait $MULTIPID || error "first opendir $MULTIPID failed"
2302 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2303 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2306 run_test 31f "remove of open directory with open-unlink file ==="
2309 echo "-- cross directory link --"
2310 test_mkdir -c1 $DIR/${tdir}ga
2311 test_mkdir -c1 $DIR/${tdir}gb
2312 touch $DIR/${tdir}ga/f
2313 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2314 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2315 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2316 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2317 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2319 run_test 31g "cross directory link==============="
2322 echo "-- cross directory link --"
2323 test_mkdir -c1 $DIR/${tdir}
2324 test_mkdir -c1 $DIR/${tdir}/dir
2325 touch $DIR/${tdir}/f
2326 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2327 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2328 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2329 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2330 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2332 run_test 31h "cross directory link under child==============="
2335 echo "-- cross directory link --"
2336 test_mkdir -c1 $DIR/$tdir
2337 test_mkdir -c1 $DIR/$tdir/dir
2338 touch $DIR/$tdir/dir/f
2339 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2340 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2341 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2342 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2343 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2345 run_test 31i "cross directory link under parent==============="
2348 test_mkdir -c1 -p $DIR/$tdir
2349 test_mkdir -c1 -p $DIR/$tdir/dir1
2350 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2351 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2352 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2353 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2356 run_test 31j "link for directory==============="
2359 test_mkdir -c1 -p $DIR/$tdir
2361 touch $DIR/$tdir/exist
2362 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2363 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2364 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2365 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2366 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2367 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2368 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2371 run_test 31k "link to file: the same, non-existing, dir==============="
2377 touch $DIR/d31m2/exist
2378 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2379 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2380 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2381 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2382 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2383 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2386 run_test 31m "link to file: the same, non-existing, dir==============="
2389 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2390 nlink=$(stat --format=%h $DIR/$tfile)
2391 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2393 local cmd="exec $fd<$DIR/$tfile"
2396 trap "eval $cmd" EXIT
2397 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2398 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2399 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2400 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2401 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2404 run_test 31n "check link count of unlinked file"
2407 local TEMPNAME=$(mktemp $1_XXXXXX)
2408 mlink $TEMPNAME $1 2> /dev/null &&
2409 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2413 test_31o() { # LU-2901
2414 test_mkdir $DIR/$tdir
2415 for LOOP in $(seq 100); do
2416 rm -f $DIR/$tdir/$tfile*
2417 for THREAD in $(seq 8); do
2418 link_one $DIR/$tdir/$tfile.$LOOP &
2421 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2422 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2423 error "$LINKS duplicate links to $tfile.$LOOP" &&
2427 run_test 31o "duplicate hard links with same filename"
2430 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2432 test_mkdir $DIR/$tdir
2433 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2434 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2436 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2437 error "open unlink test1 failed"
2438 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2439 error "open unlink test2 failed"
2441 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2442 error "test1 still exists"
2443 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2444 error "test2 still exists"
2446 run_test 31p "remove of open striped directory"
2448 cleanup_test32_mount() {
2451 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2452 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2453 losetup -d $loopdev || true
2459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2460 echo "== more mountpoints and symlinks ================="
2461 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2462 trap cleanup_test32_mount EXIT
2463 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2464 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2465 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2466 cleanup_test32_mount
2468 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2472 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2473 trap cleanup_test32_mount EXIT
2474 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2475 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2476 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2477 cleanup_test32_mount
2479 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2483 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2484 trap cleanup_test32_mount EXIT
2485 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2486 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2487 test_mkdir -p $DIR/$tdir/d2/test_dir
2488 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2489 cleanup_test32_mount
2491 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2494 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2495 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2496 trap cleanup_test32_mount EXIT
2497 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2498 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2499 test_mkdir -p $DIR/$tdir/d2/test_dir
2500 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2501 cleanup_test32_mount
2503 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2507 test_mkdir -p $DIR/$tdir/tmp
2508 local tmp_dir=$DIR/$tdir/tmp
2509 ln -s $DIR/$tdir $tmp_dir/symlink11
2510 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2511 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2512 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2514 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2518 test_mkdir -p $DIR/$tdir/tmp
2519 local tmp_dir=$DIR/$tdir/tmp
2520 ln -s $DIR/$tdir $tmp_dir/symlink11
2521 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2522 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2523 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2525 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2528 local tmp_dir=$DIR/$tdir/tmp
2529 test_mkdir -p $tmp_dir
2530 test_mkdir $DIR/${tdir}2
2531 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2532 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2533 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2534 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2535 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2536 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2538 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2541 rm -fr $DIR/$tdir $DIR/${tdir}2
2542 tmp_dir=$DIR/$tdir/tmp
2543 test_mkdir -p $tmp_dir
2544 test_mkdir $DIR/${tdir}2
2545 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2546 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2547 ls $tmp_dir/symlink12 || error "listing symlink12"
2548 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2550 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2554 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2555 trap cleanup_test32_mount EXIT
2556 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2557 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2558 touch $DIR/$tdir/test_file
2559 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2560 cleanup_test32_mount
2562 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2566 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2567 trap cleanup_test32_mount EXIT
2568 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2569 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2570 touch $DIR/$tdir/test_file
2571 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2572 cleanup_test32_mount
2574 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2579 trap cleanup_test32_mount EXIT
2580 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2581 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2582 test_mkdir -p $DIR/$tdir/d2
2583 touch $DIR/$tdir/d2/test_file || error
2584 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2585 cleanup_test32_mount
2587 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2592 trap cleanup_test32_mount EXIT
2593 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2594 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2595 test_mkdir -p $DIR/$tdir/d2
2596 touch $DIR/$tdir/d2/test_file
2597 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2598 cleanup_test32_mount
2600 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2604 test_mkdir -p $DIR/d32m/tmp
2605 TMP_DIR=$DIR/d32m/tmp
2606 ln -s $DIR $TMP_DIR/symlink11
2607 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2608 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2609 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2611 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2615 test_mkdir -p $DIR/d32n/tmp
2616 TMP_DIR=$DIR/d32n/tmp
2617 ln -s $DIR $TMP_DIR/symlink11
2618 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2619 ls -l $DIR/d32n/tmp/symlink11 || error
2620 ls -l $DIR/d32n/symlink01 || error
2622 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2626 test_mkdir -p $DIR/d32o/tmp
2627 TMP_DIR=$DIR/d32o/tmp
2628 ln -s $DIR/$tfile $TMP_DIR/symlink12
2629 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2630 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2631 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2632 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2633 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2635 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2645 test_mkdir -p $DIR/d32p/tmp
2647 TMP_DIR=$DIR/d32p/tmp
2649 ln -s $DIR/$tfile $TMP_DIR/symlink12
2651 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2653 cat $DIR/d32p/tmp/symlink12 || error
2655 cat $DIR/d32p/symlink02 || error
2658 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2662 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2663 trap cleanup_test32_mount EXIT
2664 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2665 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2666 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2667 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2668 cleanup_test32_mount
2670 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2674 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2675 trap cleanup_test32_mount EXIT
2676 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2677 touch $DIR/$tdir/ext2-mountpoint/under_the_mount
2678 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2679 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2680 cleanup_test32_mount
2682 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2687 chmod 444 $DIR/$tfile
2688 chown $RUNAS_ID $DIR/$tfile
2690 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2693 run_test 33aa "write file with mode 444 (should return error)"
2697 test_mkdir $DIR/$tdir
2698 chown $RUNAS_ID $DIR/$tdir
2699 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2700 error "$RUNAS create $tdir/$tfile failed"
2701 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2702 error "open RDWR" || true
2704 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2708 test_mkdir $DIR/$tdir
2709 chown $RUNAS_ID $DIR/$tdir
2710 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2712 run_test 33b "test open file with malformed flags (No panic)"
2715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2721 remote_ost_nodsh && skip "remote OST with nodsh" && return
2724 test_mkdir $DIR/$tdir
2725 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2728 for ostnum in $(seq $OSTCOUNT); do
2729 # test-framework's OST numbering is one-based, while Lustre's
2731 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2732 # Parsing llobdstat's output sucks; we could grep the /proc
2733 # path, but that's likely to not be as portable as using the
2734 # llobdstat utility. So we parse lctl output instead.
2735 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2736 obdfilter/$ostname/stats |
2737 awk '/^write_bytes/ {print $7}' )
2738 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2739 if (( ${write_bytes:-0} > 0 ))
2746 $all_zeros || return 0
2749 echo foo > $DIR/$tdir/bar
2753 # Total up write_bytes after writing. We'd better find non-zeros.
2754 for ostnum in $(seq $OSTCOUNT); do
2755 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2756 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2757 obdfilter/$ostname/stats |
2758 awk '/^write_bytes/ {print $7}' )
2759 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2760 if (( ${write_bytes:-0} > 0 ))
2769 for ostnum in $(seq $OSTCOUNT); do
2770 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2771 echo "Check that write_bytes is present in obdfilter/*/stats:"
2772 do_facet ost$ostnum lctl get_param -n \
2773 obdfilter/$ostname/stats
2775 error "OST not keeping write_bytes stats (b22312)"
2778 run_test 33c "test llobdstat and write_bytes"
2781 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2784 local remote_dir=$DIR/$tdir/remote_dir
2786 test_mkdir $DIR/$tdir
2787 $LFS mkdir -i $MDTIDX $remote_dir ||
2788 error "create remote directory failed"
2790 touch $remote_dir/$tfile
2791 chmod 444 $remote_dir/$tfile
2792 chown $RUNAS_ID $remote_dir/$tfile
2794 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2796 chown $RUNAS_ID $remote_dir
2797 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2798 error "create" || true
2799 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2800 error "open RDWR" || true
2801 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2803 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2806 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2810 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2811 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2812 mkdir $DIR/$tdir/local_dir
2814 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2815 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2816 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2818 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2819 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2821 rmdir $DIR/$tdir/* || error "rmdir failed"
2824 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2825 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2826 mkdir $DIR/$tdir/local_dir
2828 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2829 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2830 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2832 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2833 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2835 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2838 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2839 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2840 mkdir $DIR/$tdir/local_dir
2842 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2843 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2844 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2846 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2847 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2849 run_test 33e "mkdir and striped directory should have same mode"
2853 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2857 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2858 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2861 chmod go+rwx $DIR/$tdir
2862 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2863 trap cleanup_33f EXIT
2865 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2866 error "cannot create striped directory"
2868 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2869 error "cannot create files in striped directory"
2871 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2872 error "cannot remove files in striped directory"
2874 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2875 error "cannot remove striped directory"
2879 run_test 33f "nonroot user can create, access, and remove a striped directory"
2882 mkdir -p $DIR/$tdir/dir2
2884 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
2886 [[ $err =~ "exists" ]] || error "Not exists error"
2888 run_test 33g "nonroot user create already existing root created file"
2890 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2893 $MCREATE $DIR/f34 || error
2894 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2895 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2896 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2897 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2899 run_test 34a "truncate file that has not been opened ==========="
2902 [ ! -f $DIR/f34 ] && test_34a
2903 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2904 $OPENFILE -f O_RDONLY $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 34b "O_RDONLY opening file doesn't create objects ====="
2911 [ ! -f $DIR/f34 ] && test_34a
2912 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2913 $OPENFILE -f O_RDWR $DIR/f34
2914 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2915 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2917 run_test 34c "O_RDWR opening file-with-size works =============="
2920 [ ! -f $DIR/f34 ] && test_34a
2921 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2922 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2925 run_test 34d "write to sparse file ============================="
2929 $MCREATE $DIR/f34e || error
2930 $TRUNCATE $DIR/f34e 1000 || error
2931 $CHECKSTAT -s 1000 $DIR/f34e || error
2932 $OPENFILE -f O_RDWR $DIR/f34e
2933 $CHECKSTAT -s 1000 $DIR/f34e || error
2935 run_test 34e "create objects, some with size and some without =="
2937 test_34f() { # bug 6242, 6243
2938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2941 $MCREATE $DIR/f34f || error
2942 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2943 dd if=$DIR/f34f of=$TMP/f34f
2944 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2945 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2946 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2947 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2948 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2950 run_test 34f "read from a file with no objects until EOF ======="
2953 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2954 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2955 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2956 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2957 cancel_lru_locks osc
2958 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2959 error "wrong size after lock cancel"
2961 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2962 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2963 error "expanding truncate failed"
2964 cancel_lru_locks osc
2965 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2966 error "wrong expanded size after lock cancel"
2968 run_test 34g "truncate long file ==============================="
2971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2975 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2976 sync # Flush the cache so that multiop below does not block on cache
2977 # flush when getting the group lock
2978 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2981 # Since just timed wait is not good enough, let's do a sync write
2982 # that way we are sure enough time for a roundtrip + processing
2983 # passed + 2 seconds of extra margin.
2984 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2988 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2989 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2993 local nsz=`stat -c %s $DIR/$tfile`
2994 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2996 run_test 34h "ftruncate file under grouplock should not block"
2999 cp /bin/sh $DIR/f35a
3001 chown $RUNAS_ID $DIR/f35a
3002 $RUNAS $DIR/f35a && error || true
3005 run_test 35a "exec file with mode 444 (should return and not leak)"
3009 utime $DIR/f36 || error
3011 run_test 36a "MDS utime check (mknod, utime)"
3015 utime $DIR/f36 || error
3017 run_test 36b "OST utime check (open, utime)"
3022 chown $RUNAS_ID $DIR/d36
3023 $RUNAS utime $DIR/d36/f36 || error
3025 run_test 36c "non-root MDS utime check (mknod, utime)"
3028 [ ! -d $DIR/d36 ] && test_36c
3029 echo "" > $DIR/d36/f36
3030 $RUNAS utime $DIR/d36/f36 || error
3032 run_test 36d "non-root OST utime check (open, utime)"
3035 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3036 test_mkdir $DIR/$tdir
3037 touch $DIR/$tdir/$tfile
3038 $RUNAS utime $DIR/$tdir/$tfile &&
3039 error "utime worked, expected failure" || true
3041 run_test 36e "utime on non-owned file (should return error)"
3045 local LANG_SAVE=$LANG
3046 local LC_LANG_SAVE=$LC_LANG
3047 export LANG=C LC_LANG=C # for date language
3049 DATESTR="Dec 20 2000"
3050 test_mkdir $DIR/$tdir
3051 lctl set_param fail_loc=$fl
3053 cp /etc/hosts $DIR/$tdir/$tfile
3054 sync & # write RPC generated with "current" inode timestamp, but delayed
3056 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3057 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3058 cancel_lru_locks osc
3059 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3061 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3062 echo "BEFORE: $LS_BEFORE" && \
3063 echo "AFTER : $LS_AFTER" && \
3064 echo "WANT : $DATESTR" && \
3065 error "$DIR/$tdir/$tfile timestamps changed" || true
3067 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3072 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3073 subr_36fh "0x80000214"
3075 run_test 36f "utime on file racing with OST BRW write =========="
3078 remote_ost_nodsh && skip "remote OST with nodsh" && return
3079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3084 test_mkdir $DIR/$tdir
3085 fmd_max_age=$(do_facet ost1 \
3086 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3089 fmd_before=$(do_facet ost1 \
3090 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3091 touch $DIR/$tdir/$tfile
3092 sleep $((fmd_max_age + 12))
3093 fmd_after=$(do_facet ost1 \
3094 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3096 echo "fmd_before: $fmd_before"
3097 echo "fmd_after: $fmd_after"
3098 [[ $fmd_after -gt $fmd_before ]] &&
3099 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3100 error "fmd didn't expire after ping" || true
3102 run_test 36g "filter mod data cache expiry ====================="
3105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3106 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3107 subr_36fh "0x80000227"
3109 run_test 36h "utime on file racing with OST BRW write =========="
3112 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3114 test_mkdir $DIR/$tdir
3115 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3117 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3118 local new_mtime=$((mtime + 200))
3120 #change Modify time of striped dir
3121 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3122 error "change mtime failed"
3124 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3126 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3128 run_test 36i "change mtime on striped directory"
3130 # test_37 - duplicate with tests 32q 32r
3133 local file=$DIR/$tfile
3135 openfile -f O_DIRECTORY $file
3138 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3139 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3141 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3143 test_39a() { # was test_39
3145 touch $DIR/${tfile}2
3146 # ls -l $DIR/$tfile $DIR/${tfile}2
3147 # ls -lu $DIR/$tfile $DIR/${tfile}2
3148 # ls -lc $DIR/$tfile $DIR/${tfile}2
3150 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3151 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3153 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3155 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3157 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3158 error "O_TRUNC didn't change timestamps"
3161 run_test 39a "mtime changed on create"
3164 test_mkdir -c1 $DIR/$tdir
3165 cp -p /etc/passwd $DIR/$tdir/fopen
3166 cp -p /etc/passwd $DIR/$tdir/flink
3167 cp -p /etc/passwd $DIR/$tdir/funlink
3168 cp -p /etc/passwd $DIR/$tdir/frename
3169 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3172 echo "aaaaaa" >> $DIR/$tdir/fopen
3173 echo "aaaaaa" >> $DIR/$tdir/flink
3174 echo "aaaaaa" >> $DIR/$tdir/funlink
3175 echo "aaaaaa" >> $DIR/$tdir/frename
3177 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3178 local link_new=`stat -c %Y $DIR/$tdir/flink`
3179 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3180 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3182 cat $DIR/$tdir/fopen > /dev/null
3183 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3184 rm -f $DIR/$tdir/funlink2
3185 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3187 for (( i=0; i < 2; i++ )) ; do
3188 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3189 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3190 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3191 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3193 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3194 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3195 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3196 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3198 cancel_lru_locks osc
3199 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3202 run_test 39b "mtime change on open, link, unlink, rename ======"
3204 # this should be set to past
3205 TEST_39_MTIME=`date -d "1 year ago" +%s`
3211 local mtime0=`stat -c %Y $DIR1/$tfile`
3213 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3214 local mtime1=`stat -c %Y $DIR1/$tfile`
3215 [ "$mtime1" = $TEST_39_MTIME ] || \
3216 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3219 echo hello >> $DIR1/$tfile
3221 local mtime2=`stat -c %Y $DIR1/$tfile`
3222 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3223 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3225 mv $DIR1/$tfile $DIR1/$tfile-1
3227 for (( i=0; i < 2; i++ )) ; do
3228 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3229 [ "$mtime2" = "$mtime3" ] || \
3230 error "mtime ($mtime2) changed (to $mtime3) on rename"
3232 cancel_lru_locks osc
3233 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3236 run_test 39c "mtime change on rename ==========================="
3240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3243 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3245 for (( i=0; i < 2; i++ )) ; do
3246 local mtime=`stat -c %Y $DIR1/$tfile`
3247 [ $mtime = $TEST_39_MTIME ] || \
3248 error "mtime($mtime) is not set to $TEST_39_MTIME"
3250 cancel_lru_locks osc
3251 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3254 run_test 39d "create, utime, stat =============================="
3258 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3260 local mtime1=`stat -c %Y $DIR1/$tfile`
3262 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3264 for (( i=0; i < 2; i++ )) ; do
3265 local mtime2=`stat -c %Y $DIR1/$tfile`
3266 [ $mtime2 = $TEST_39_MTIME ] || \
3267 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3269 cancel_lru_locks osc
3270 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3273 run_test 39e "create, stat, utime, stat ========================"
3277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3279 mtime1=`stat -c %Y $DIR1/$tfile`
3282 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3284 for (( i=0; i < 2; i++ )) ; do
3285 local mtime2=`stat -c %Y $DIR1/$tfile`
3286 [ $mtime2 = $TEST_39_MTIME ] || \
3287 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3289 cancel_lru_locks osc
3290 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3293 run_test 39f "create, stat, sleep, utime, stat ================="
3297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3298 echo hello >> $DIR1/$tfile
3299 local mtime1=`stat -c %Y $DIR1/$tfile`
3302 chmod o+r $DIR1/$tfile
3304 for (( i=0; i < 2; i++ )) ; do
3305 local mtime2=`stat -c %Y $DIR1/$tfile`
3306 [ "$mtime1" = "$mtime2" ] || \
3307 error "lost mtime: $mtime2, should be $mtime1"
3309 cancel_lru_locks osc
3310 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3313 run_test 39g "write, chmod, stat ==============================="
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3322 echo hello >> $DIR1/$tfile
3323 local mtime1=`stat -c %Y $DIR1/$tfile`
3325 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3327 if [ "$d1" != "$d2" ]; then
3328 echo "write and touch not within one second"
3330 for (( i=0; i < 2; i++ )) ; do
3331 local mtime2=`stat -c %Y $DIR1/$tfile`
3332 [ "$mtime2" = $TEST_39_MTIME ] || \
3333 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3335 cancel_lru_locks osc
3336 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3340 run_test 39h "write, utime within one second, stat ============="
3343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3347 echo hello >> $DIR1/$tfile
3348 local mtime1=`stat -c %Y $DIR1/$tfile`
3350 mv $DIR1/$tfile $DIR1/$tfile-1
3352 for (( i=0; i < 2; i++ )) ; do
3353 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3355 [ "$mtime1" = "$mtime2" ] || \
3356 error "lost mtime: $mtime2, should be $mtime1"
3358 cancel_lru_locks osc
3359 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3362 run_test 39i "write, rename, stat =============================="
3365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3366 start_full_debug_logging
3370 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3371 lctl set_param fail_loc=0x80000412
3372 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3373 error "multiop failed"
3375 local mtime1=`stat -c %Y $DIR1/$tfile`
3377 mv $DIR1/$tfile $DIR1/$tfile-1
3379 kill -USR1 $multipid
3380 wait $multipid || error "multiop close failed"
3382 for (( i=0; i < 2; i++ )) ; do
3383 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3384 [ "$mtime1" = "$mtime2" ] ||
3385 error "mtime is lost on close: $mtime2, " \
3388 cancel_lru_locks osc
3389 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3391 lctl set_param fail_loc=0
3392 stop_full_debug_logging
3394 run_test 39j "write, rename, close, stat ======================="
3397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3401 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3403 local mtime1=`stat -c %Y $DIR1/$tfile`
3405 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3407 kill -USR1 $multipid
3408 wait $multipid || error "multiop close failed"
3410 for (( i=0; i < 2; i++ )) ; do
3411 local mtime2=`stat -c %Y $DIR1/$tfile`
3413 [ "$mtime2" = $TEST_39_MTIME ] || \
3414 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3416 cancel_lru_locks osc
3417 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3420 run_test 39k "write, utime, close, stat ========================"
3422 # this should be set to future
3423 TEST_39_ATIME=`date -d "1 year" +%s`
3426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3427 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3428 local atime_diff=$(do_facet $SINGLEMDS \
3429 lctl get_param -n mdd.*MDT0000*.atime_diff)
3433 # test setting directory atime to future
3434 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3435 local atime=$(stat -c %X $DIR/$tdir)
3436 [ "$atime" = $TEST_39_ATIME ] ||
3437 error "atime is not set to future: $atime, $TEST_39_ATIME"
3439 # test setting directory atime from future to now
3440 local now=$(date +%s)
3441 touch -a -d @$now $DIR/$tdir
3443 atime=$(stat -c %X $DIR/$tdir)
3444 [ "$atime" -eq "$now" ] ||
3445 error "atime is not updated from future: $atime, $now"
3447 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3450 # test setting directory atime when now > dir atime + atime_diff
3451 local d1=$(date +%s)
3453 local d2=$(date +%s)
3454 cancel_lru_locks mdc
3455 atime=$(stat -c %X $DIR/$tdir)
3456 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3457 error "atime is not updated : $atime, should be $d2"
3459 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3462 # test not setting directory atime when now < dir atime + atime_diff
3464 cancel_lru_locks mdc
3465 atime=$(stat -c %X $DIR/$tdir)
3466 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3467 error "atime is updated to $atime, should remain $d1<atime<$d2"
3469 do_facet $SINGLEMDS \
3470 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3472 run_test 39l "directory atime update ==========================="
3475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3478 local far_past_mtime=$(date -d "May 29 1953" +%s)
3479 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3481 touch -m -d @$far_past_mtime $DIR1/$tfile
3482 touch -a -d @$far_past_atime $DIR1/$tfile
3484 for (( i=0; i < 2; i++ )) ; do
3485 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3486 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3487 error "atime or mtime set incorrectly"
3489 cancel_lru_locks osc
3490 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3493 run_test 39m "test atime and mtime before 1970"
3495 test_39n() { # LU-3832
3496 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3497 local atime_diff=$(do_facet $SINGLEMDS \
3498 lctl get_param -n mdd.*MDT0000*.atime_diff)
3503 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3506 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3507 atime0=$(stat -c %X $DIR/$tfile)
3510 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3511 atime1=$(stat -c %X $DIR/$tfile)
3514 cancel_lru_locks mdc
3515 cancel_lru_locks osc
3516 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3517 atime2=$(stat -c %X $DIR/$tfile)
3519 do_facet $SINGLEMDS \
3520 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3522 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3523 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3525 run_test 39n "check that O_NOATIME is honored"
3528 TESTDIR=$DIR/$tdir/$tfile
3529 [ -e $TESTDIR ] && rm -rf $TESTDIR
3536 links2=$(stat -c %h .)
3537 [ $(($links1 + 2)) != $links2 ] &&
3538 error "wrong links count $(($links1 + 2)) != $links2"
3540 links3=$(stat -c %h .)
3541 [ $(($links1 + 1)) != $links3 ] &&
3542 error "wrong links count $links1 != $links3"
3545 run_test 39o "directory cached attributes updated after create"
3548 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3550 TESTDIR=$DIR/$tdir/$tdir
3551 [ -e $TESTDIR ] && rm -rf $TESTDIR
3552 test_mkdir -p $TESTDIR
3556 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3557 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3559 links2=$(stat -c %h .)
3560 [ $(($links1 + 2)) != $links2 ] &&
3561 error "wrong links count $(($links1 + 2)) != $links2"
3563 links3=$(stat -c %h .)
3564 [ $(($links1 + 1)) != $links3 ] &&
3565 error "wrong links count $links1 != $links3"
3568 run_test 39p "remote directory cached attributes updated after create ========"
3571 test_39q() { # LU-8041
3572 local testdir=$DIR/$tdir
3574 multiop_bg_pause $testdir D_c || error "multiop failed"
3576 cancel_lru_locks mdc
3577 kill -USR1 $multipid
3578 local atime=$(stat -c %X $testdir)
3579 [ "$atime" -ne 0 ] || error "atime is zero"
3581 run_test 39q "close won't zero out atime"
3584 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3585 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3586 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3587 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3588 error "$tfile is not 4096 bytes in size"
3590 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3594 small_write $DIR/f41 18
3596 run_test 41 "test small file write + fstat ====================="
3598 count_ost_writes() {
3599 lctl get_param -n ${OSC}.*.stats |
3600 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3601 END { printf("%0.0f", writes) }'
3608 BG_DIRTY_RATIO_SAVE=10
3609 MAX_BG_DIRTY_RATIO=25
3613 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3614 # dirty_ratio, dirty_background_ratio
3615 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3616 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3617 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3618 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3620 # if file not here, we are a 2.4 kernel
3621 kill -CONT `pidof kupdated`
3626 # setup the trap first, so someone cannot exit the test at the
3627 # exact wrong time and mess up a machine
3628 trap start_writeback EXIT
3629 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3630 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3631 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3632 sysctl -w vm.dirty_writeback_centisecs=0
3633 sysctl -w vm.dirty_writeback_centisecs=0
3634 # save and increase /proc/sys/vm/dirty_ratio
3635 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3636 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3637 # save and increase /proc/sys/vm/dirty_background_ratio
3638 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3639 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3641 # if file not here, we are a 2.4 kernel
3642 kill -STOP `pidof kupdated`
3646 # ensure that all stripes have some grant before we test client-side cache
3648 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3649 dd if=/dev/zero of=$i bs=4k count=1
3654 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3655 # file truncation, and file removal.
3657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3659 cancel_lru_locks $OSC
3661 sync; sleep 1; sync # just to be safe
3662 BEFOREWRITES=`count_ost_writes`
3663 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3664 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3665 AFTERWRITES=`count_ost_writes`
3666 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3667 error "$BEFOREWRITES < $AFTERWRITES"
3670 run_test 42a "ensure that we don't flush on close"
3673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3675 cancel_lru_locks $OSC
3678 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3679 BEFOREWRITES=$(count_ost_writes)
3680 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3681 AFTERWRITES=$(count_ost_writes)
3682 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3683 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3685 BEFOREWRITES=$(count_ost_writes)
3686 sync || error "sync: $?"
3687 AFTERWRITES=$(count_ost_writes)
3688 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3689 error "$BEFOREWRITES < $AFTERWRITES on sync"
3691 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3695 run_test 42b "test destroy of file with cached dirty data ======"
3697 # if these tests just want to test the effect of truncation,
3698 # they have to be very careful. consider:
3699 # - the first open gets a {0,EOF}PR lock
3700 # - the first write conflicts and gets a {0, count-1}PW
3701 # - the rest of the writes are under {count,EOF}PW
3702 # - the open for truncate tries to match a {0,EOF}PR
3703 # for the filesize and cancels the PWs.
3704 # any number of fixes (don't get {0,EOF} on open, match
3705 # composite locks, do smarter file size management) fix
3706 # this, but for now we want these tests to verify that
3707 # the cancellation with truncate intent works, so we
3708 # start the file with a full-file pw lock to match against
3709 # until the truncate.
3714 cancel_lru_locks $OSC
3716 # prime the file with 0,EOF PW to match
3720 # now the real test..
3721 dd if=/dev/zero of=$file bs=1024 count=100
3722 BEFOREWRITES=`count_ost_writes`
3723 $TRUNCATE $file $offset
3724 cancel_lru_locks $OSC
3725 AFTERWRITES=`count_ost_writes`
3730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3732 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3733 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3736 run_test 42c "test partial truncate of file with cached dirty data"
3739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3741 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3742 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3745 run_test 42d "test complete truncate of file with cached dirty data"
3747 test_42e() { # bug22074
3748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3749 local TDIR=$DIR/${tdir}e
3750 local pagesz=$(page_size)
3751 local pages=16 # hardcoded 16 pages, don't change it.
3752 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3753 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3757 test_mkdir $DIR/${tdir}e
3758 $SETSTRIPE -c 1 $TDIR
3759 createmany -o $TDIR/f $files
3761 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3763 # we assume that with $OSTCOUNT files, at least one of them will
3764 # be allocated on OST0.
3765 warmup_files=$((OSTCOUNT * max_dirty_mb))
3766 createmany -o $TDIR/w $warmup_files
3768 # write a large amount of data into one file and sync, to get good
3769 # avail_grant number from OST.
3770 for ((i=0; i<$warmup_files; i++)); do
3771 idx=$($GETSTRIPE -i $TDIR/w$i)
3772 [ $idx -ne 0 ] && continue
3773 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3776 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3778 $LCTL get_param $proc_osc0/cur_dirty_bytes
3779 $LCTL get_param $proc_osc0/cur_grant_bytes
3781 # create as much dirty pages as we can while not to trigger the actual
3782 # RPCs directly. but depends on the env, VFS may trigger flush during this
3783 # period, hopefully we are good.
3784 for ((i=0; i<$warmup_files; i++)); do
3785 idx=$($GETSTRIPE -i $TDIR/w$i)
3786 [ $idx -ne 0 ] && continue
3787 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3789 $LCTL get_param $proc_osc0/cur_dirty_bytes
3790 $LCTL get_param $proc_osc0/cur_grant_bytes
3792 # perform the real test
3793 $LCTL set_param $proc_osc0/rpc_stats 0
3794 for ((;i<$files; i++)); do
3795 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3796 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3799 $LCTL get_param $proc_osc0/rpc_stats
3802 local have_ppr=false
3803 $LCTL get_param $proc_osc0/rpc_stats |
3804 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3805 # skip lines until we are at the RPC histogram data
3806 [ "$PPR" == "pages" ] && have_ppr=true && continue
3807 $have_ppr || continue
3809 # we only want the percent stat for < 16 pages
3810 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3812 percent=$((percent + WPCT))
3813 if [[ $percent -gt 15 ]]; then
3814 error "less than 16-pages write RPCs" \
3821 run_test 42e "verify sub-RPC writes are not done synchronously"
3823 test_43A() { # was test_43
3824 test_mkdir $DIR/$tdir
3825 cp -p /bin/ls $DIR/$tdir/$tfile
3826 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3828 # give multiop a chance to open
3831 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
3834 run_test 43A "execution of file opened for write should return -ETXTBSY"
3837 test_mkdir $DIR/$tdir
3838 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3839 cp -p multiop $DIR/$tdir/multiop
3840 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3841 error "multiop open $TMP/$tfile.junk failed"
3842 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
3844 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3845 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3846 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3848 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3851 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3852 test_mkdir $DIR/$tdir
3853 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
3854 cp -p multiop $DIR/$tdir/multiop
3855 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3856 error "multiop open $TMP/$tfile.junk failed"
3857 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
3859 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3860 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
3861 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
3863 run_test 43b "truncate of file being executed should return -ETXTBSY"
3866 local testdir="$DIR/$tdir"
3869 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
3870 ( cd $testdir && md5sum -c )
3872 run_test 43c "md5sum of copy into lustre"
3874 test_44A() { # was test_44
3875 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
3876 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3877 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3879 run_test 44A "zero length read from a sparse stripe"
3882 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3884 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3885 [[ $nstripe -gt $OSTCOUNT ]] &&
3886 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3888 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3890 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3891 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3895 OFFSETS="0 $((stride/2)) $((stride-1))"
3896 for offset in $OFFSETS; do
3897 for i in $(seq 0 $((nstripe-1))); do
3898 local GLOBALOFFSETS=""
3900 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3901 local myfn=$DIR/d44a-$size
3902 echo "--------writing $myfn at $size"
3903 ll_sparseness_write $myfn $size ||
3904 error "ll_sparseness_write"
3905 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3906 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3907 error "ll_sparseness_verify $GLOBALOFFSETS"
3909 for j in $(seq 0 $((nstripe-1))); do
3911 size=$((((j + $nstripe )*$stride + $offset)))
3912 ll_sparseness_write $myfn $size ||
3913 error "ll_sparseness_write"
3914 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3916 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3917 error "ll_sparseness_verify $GLOBALOFFSETS"
3922 run_test 44a "test sparse pwrite ==============================="
3926 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
3932 before=`dirty_osc_total`
3933 echo executing "\"$*\""
3935 after=`dirty_osc_total`
3936 echo before $before, after $after
3939 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3941 # Obtain grants from OST if it supports it
3942 echo blah > ${f}_grant
3945 do_dirty_record "echo blah > $f"
3946 [[ $before -eq $after ]] && error "write wasn't cached"
3947 do_dirty_record "> $f"
3948 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3949 do_dirty_record "echo blah > $f"
3950 [[ $before -eq $after ]] && error "write wasn't cached"
3951 do_dirty_record "sync"
3952 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3953 do_dirty_record "echo blah > $f"
3954 [[ $before -eq $after ]] && error "write wasn't cached"
3955 do_dirty_record "cancel_lru_locks osc"
3956 [[ $before -gt $after ]] ||
3957 error "lock cancellation didn't lower dirty count"
3960 run_test 45 "osc io page accounting ============================"
3962 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3963 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3964 # objects offset and an assert hit when an rpc was built with 1023's mapped
3965 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3971 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3973 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3974 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3978 run_test 46 "dirtying a previously written page ================"
3980 # test_47 is removed "Device nodes check" is moved to test_28
3982 test_48a() { # bug 2399
3983 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3984 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3985 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3987 test_mkdir $DIR/$tdir
3989 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3990 test_mkdir $DIR/$tdir
3991 touch foo || error "'touch foo' failed after recreating cwd"
3993 touch .foo || error "'touch .foo' failed after recreating cwd"
3995 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3996 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3997 cd . || error "'cd .' failed after recreating cwd"
3998 mkdir . && error "'mkdir .' worked after recreating cwd"
3999 rmdir . && error "'rmdir .' worked after recreating cwd"
4000 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4001 cd .. || error "'cd ..' failed after recreating cwd"
4003 run_test 48a "Access renamed working dir (should return errors)="
4005 test_48b() { # bug 2399
4007 test_mkdir $DIR/$tdir
4009 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4010 touch foo && error "'touch foo' worked after removing cwd"
4011 mkdir foo && error "'mkdir foo' worked after removing cwd"
4012 touch .foo && error "'touch .foo' worked after removing cwd"
4013 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4014 ls . > /dev/null && error "'ls .' worked after removing cwd"
4015 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4016 mkdir . && error "'mkdir .' worked after removing cwd"
4017 rmdir . && error "'rmdir .' worked after removing cwd"
4018 ln -s . foo && error "'ln -s .' worked after removing cwd"
4019 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4021 run_test 48b "Access removed working dir (should return errors)="
4023 test_48c() { # bug 2350
4024 #lctl set_param debug=-1
4027 test_mkdir -p $DIR/$tdir/dir
4029 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4030 $TRACE touch foo && error "touch foo worked after removing cwd"
4031 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4032 touch .foo && error "touch .foo worked after removing cwd"
4033 mkdir .foo && error "mkdir .foo worked after removing cwd"
4034 $TRACE ls . && error "'ls .' worked after removing cwd"
4035 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4036 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4037 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4038 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4039 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4041 run_test 48c "Access removed working subdir (should return errors)"
4043 test_48d() { # bug 2350
4044 #lctl set_param debug=-1
4047 test_mkdir -p $DIR/$tdir/dir
4049 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4050 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4051 $TRACE touch foo && error "'touch foo' worked after removing parent"
4052 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4053 touch .foo && error "'touch .foo' worked after removing parent"
4054 mkdir .foo && error "mkdir .foo worked after removing parent"
4055 $TRACE ls . && error "'ls .' worked after removing parent"
4056 $TRACE ls .. && error "'ls ..' worked after removing parent"
4057 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4058 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4059 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4062 run_test 48d "Access removed parent subdir (should return errors)"
4064 test_48e() { # bug 4134
4065 #lctl set_param debug=-1
4068 test_mkdir -p $DIR/$tdir/dir
4070 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4071 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4072 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4073 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4074 # On a buggy kernel addition of "touch foo" after cd .. will
4075 # produce kernel oops in lookup_hash_it
4076 touch ../foo && error "'cd ..' worked after recreate parent"
4078 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4080 run_test 48e "Access to recreated parent subdir (should return errors)"
4082 test_49() { # LU-1030
4083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4084 remote_ost_nodsh && skip "remote OST with nodsh" && return
4085 # get ost1 size - lustre-OST0000
4086 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4088 # write 800M at maximum
4089 [[ $ost1_size -lt 2 ]] && ost1_size=2
4090 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4092 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4093 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4096 # change max_pages_per_rpc while writing the file
4097 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4098 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4099 # loop until dd process exits
4100 while ps ax -opid | grep -wq $dd_pid; do
4101 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4102 sleep $((RANDOM % 5 + 1))
4104 # restore original max_pages_per_rpc
4105 $LCTL set_param $osc1_mppc=$orig_mppc
4106 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4108 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4112 test_mkdir $DIR/$tdir
4114 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4116 run_test 50 "special situations: /proc symlinks ==============="
4118 test_51a() { # was test_51
4119 # bug 1516 - create an empty entry right after ".." then split dir
4120 test_mkdir -c1 $DIR/$tdir
4121 touch $DIR/$tdir/foo
4122 $MCREATE $DIR/$tdir/bar
4124 createmany -m $DIR/$tdir/longfile 201
4126 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4127 $MCREATE $DIR/$tdir/longfile$FNUM
4132 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4134 run_test 51a "special situations: split htree with empty entry =="
4136 cleanup_print_lfs_df () {
4143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4144 local dir=$DIR/$tdir
4146 local nrdirs=$((65536 + 100))
4148 # cleanup the directory
4155 local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
4156 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4157 [[ $numfree -lt $nrdirs ]] &&
4158 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4161 # need to check free space for the directories as well
4162 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4163 numfree=$(( blkfree / $(fs_inode_ksize) ))
4164 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
4167 trap cleanup_print_lfs_df EXIT
4170 createmany -d $dir/d $nrdirs || {
4171 unlinkmany $dir/d $nrdirs
4172 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4176 nrdirs=$(ls -U $dir | wc -l)
4178 # unlink all but 100 subdirectories, then check it still works
4180 local delete=$((nrdirs - left))
4185 # for ldiskfs the nlink count should be 1, but this is OSD specific
4186 # and so this is listed for informational purposes only
4187 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4188 unlinkmany -d $dir/d $delete ||
4189 error "unlink of first $delete subdirs failed"
4191 echo "nlink between: $(stat -c %h $dir)"
4192 local found=$(ls -U $dir | wc -l)
4193 [ $found -ne $left ] &&
4194 error "can't find subdirs: found only $found, expected $left"
4196 unlinkmany -d $dir/d $delete $left ||
4197 error "unlink of second $left subdirs failed"
4198 # regardless of whether the backing filesystem tracks nlink accurately
4199 # or not, the nlink count shouldn't be more than "." and ".." here
4200 local after=$(stat -c %h $dir)
4201 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4202 echo "nlink after: $after"
4204 cleanup_print_lfs_df
4206 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4210 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
4211 test_mkdir $DIR/$tdir
4212 createmany -o $DIR/$tdir/t- 1000
4213 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4214 for N in $(seq 0 $((OSTCOUNT - 1))); do
4215 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4216 END { printf("%0.0f", objs) }' $TMP/$tfile)
4217 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4218 '($1 == '$N') { objs += 1 } \
4219 END { printf("%0.0f", objs) }')
4220 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4222 unlinkmany $DIR/$tdir/t- 1000
4225 for N in $(seq 1 $((OSTCOUNT - 1))); do
4226 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4227 error "OST $N has less objects vs OST $NLAST" \
4228 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4229 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4230 error "OST $N has less objects vs OST $NLAST" \
4231 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4233 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4234 error "OST $N has less #0 objects vs OST $NLAST" \
4235 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4236 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4237 error "OST $N has less #0 objects vs OST $NLAST" \
4238 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4243 run_test 51d "check object distribution"
4246 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4247 skip "ldiskfs only test"
4251 test_mkdir -c1 $DIR/$tdir
4252 test_mkdir -c1 $DIR/$tdir/d0
4254 touch $DIR/$tdir/d0/foo
4255 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4256 error "file exceed 65000 nlink limit!"
4257 unlinkmany $DIR/$tdir/d0/f- 65001
4260 run_test 51e "check file nlink limit"
4263 test_mkdir $DIR/$tdir
4266 local ulimit_old=$(ulimit -n)
4267 local spare=20 # number of spare fd's for scripts/libraries, etc.
4268 local mdt=$(lfs getstripe -M $DIR/$tdir)
4269 local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4271 echo "MDT$mdt numfree=$numfree, max=$max"
4272 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4273 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4274 while ! ulimit -n $((numfree + spare)); do
4275 numfree=$((numfree * 3 / 4))
4277 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4279 echo "left ulimit at $ulimit_old"
4282 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4283 unlinkmany $DIR/$tdir/f $numfree
4284 error "create+open $numfree files in $DIR/$tdir failed"
4286 ulimit -n $ulimit_old
4288 # if createmany exits at 120s there will be fewer than $numfree files
4289 unlinkmany $DIR/$tdir/f $numfree || true
4291 run_test 51f "check many open files limit"
4294 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4295 test_mkdir $DIR/$tdir
4296 touch $DIR/$tdir/foo
4297 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4298 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4299 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4300 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4301 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4303 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4304 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4305 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4307 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4308 cp -r $DIR/$tdir $TMP/
4309 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4311 run_test 52a "append-only flag test (should return errors)"
4314 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4315 test_mkdir $DIR/$tdir
4316 touch $DIR/$tdir/foo
4317 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4318 cat test > $DIR/$tdir/foo && error "cat test worked"
4319 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4320 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4321 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4323 echo foo >> $DIR/$tdir/foo && error "echo worked"
4324 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4325 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4326 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4327 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4329 chattr -i $DIR/$tdir/foo || error "chattr failed"
4331 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4333 run_test 52b "immutable flag test (should return errors) ======="
4336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4337 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4338 remote_ost_nodsh && skip "remote OST with nodsh" && return
4351 local support_last_seq=true
4353 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4354 support_last_seq=false
4357 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4359 for value in $(do_facet $SINGLEMDS \
4360 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4361 param=$(echo ${value[0]} | cut -d "=" -f1)
4362 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4364 if $support_last_seq; then
4365 param_seq=$(echo $param |
4366 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4367 mds_last_seq=$(do_facet $SINGLEMDS \
4368 $LCTL get_param -n $param_seq)
4370 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4372 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4373 node=$(facet_active_host ost$((ostnum+1)))
4374 param="obdfilter.$ostname.last_id"
4375 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4376 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4377 ost_last_id=$ost_last
4379 if $support_last_seq; then
4380 ost_last_id=$(echo $ost_last |
4381 awk -F':' '{print $2}' |
4383 ost_last_seq=$(echo $ost_last |
4384 awk -F':' '{print $1}')
4385 [[ $ost_last_seq = $mds_last_seq ]] || continue
4388 if [[ $ost_last_id != $mds_last ]]; then
4389 error "$ost_last_id != $mds_last"
4396 $found || error "can not match last_seq/last_id for $mdtosc"
4399 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4402 perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
4404 $SOCKETSERVER $DIR/socket ||
4405 error "$SOCKETSERVER $DIR/socket failed: $?"
4406 $SOCKETCLIENT $DIR/socket ||
4407 error "$SOCKETCLIENT $DIR/socket failed: $?"
4408 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4410 run_test 54a "unix domain socket test =========================="
4416 dd if=/dev/zero of=$f bs=$(page_size) count=1
4418 run_test 54b "char device works in lustre ======================"
4421 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4422 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4423 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4425 for i in $(seq 3 7); do
4426 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4435 loopdev="$DIR/loop54c"
4438 $UMOUNT $DIR/$tdir || rc=$?
4439 losetup -d $loopdev || true
4440 losetup -d $LOOPDEV || true
4441 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4447 loopdev="$DIR/loop54c"
4450 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4451 trap cleanup_54c EXIT
4452 mknod $loopdev b 7 $LOOPNUM
4453 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4454 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4455 losetup $loopdev $DIR/$tfile ||
4456 error "can't set up $loopdev for $DIR/$tfile"
4457 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4458 test_mkdir $DIR/$tdir
4459 mount -t ext2 $loopdev $DIR/$tdir ||
4460 error "error mounting $loopdev on $DIR/$tdir"
4461 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4464 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4468 run_test 54c "block device works in lustre ====================="
4474 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4476 run_test 54d "fifo device works in lustre ======================"
4481 cp -aL /dev/console $f
4482 echo $string > $f || error "echo $string to $f failed"
4484 run_test 54e "console/tty device works in lustre ======================"
4488 local dir=$DIR/$tdir
4491 test_mkdir -p $dir/dir
4492 for i in $(seq $numfiles); do
4494 touch $dir/dir/file$i
4497 local numcomp=$($LFS getstripe --component-count $dir)
4499 [[ $numcomp == 0 ]] && numcomp=1
4501 # test lfs getstripe with --recursive
4502 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
4504 [[ $filenum -eq $((numfiles * 2)) ]] ||
4505 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
4506 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
4507 [[ $filenum -eq $numfiles ]] ||
4508 error "$LFS getstripe $dir: found $filenum, not $numfiles"
4509 echo "$LFS getstripe showed obdidx or l_ost_idx"
4511 # test lfs getstripe with file instead of dir
4512 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
4513 [[ $filenum -eq 1 ]] ||
4514 error "$LFS getstripe $dir/file1: found $filenum, not 1"
4515 echo "$LFS getstripe file1 passed"
4517 #test lfs getstripe with --verbose
4518 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
4519 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4520 error "$LFS getstripe --verbose $dir: "\
4521 "got $filenum want $((numfiles * numcomp)) lmm_magic"
4522 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
4523 error "$LFS getstripe $dir: showed lmm_magic"
4525 #test lfs getstripe with -v prints lmm_fid
4526 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
4527 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4528 error "$LFS getstripe -v $dir: "\
4529 "got $filenum want $((numfiles * numcomp)) lmm_fid"
4530 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
4531 error "$LFS getstripe $dir: showed lmm_fid by default"
4532 echo "$LFS getstripe --verbose passed"
4534 #check for FID information
4535 local fid1=$($LFS getstripe --fid $dir/file1)
4536 local fid2=$($LFS getstripe --verbose $dir/file1 |
4537 awk '/lmm_fid: / { print $2; exit; }')
4538 local fid3=$($LFS path2fid $dir/file1)
4540 [ "$fid1" != "$fid2" ] &&
4541 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
4542 [ "$fid1" != "$fid3" ] &&
4543 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
4544 echo "$LFS getstripe --fid passed"
4546 #test lfs getstripe with --obd
4547 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
4548 error "$LFS getstripe --obd wrong_uuid: should return error"
4550 [[ $OSTCOUNT -lt 2 ]] &&
4551 skip_env "skip '$LFS getstripe --obd' tests: $OSTCOUNT < 2" &&
4555 local obduuid=$(ostuuid_from_index $ostidx)
4556 local found=$($LFS getstripe -r --obd $obduuid $dir |
4557 egrep -c "obdidx|l_ost_idx")
4559 filenum=$($LFS getstripe -ir $dir | grep "^$ostidx\$" | wc -l)
4560 [[ $found -eq $filenum ]] ||
4561 error "$LFS getstripe --obd: found $found expect $filenum"
4562 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
4563 sed '/^[ ]*'${ostidx}'[ ]/d' |
4564 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4565 error "$LFS getstripe --obd: should not show file on other obd"
4566 echo "$LFS getstripe --obd passed"
4568 run_test 56a "check $LFS getstripe"
4571 local dir=$DIR/$tdir
4575 for i in $(seq $numdirs); do
4576 test_mkdir $dir/dir$i
4579 # test lfs getdirstripe default mode is non-recursion, which is
4580 # different from lfs getstripe
4581 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
4583 [[ $dircnt -eq 1 ]] ||
4584 error "$LFS getdirstripe: found $dircnt, not 1"
4585 dircnt=$($LFS getdirstripe --recursive $dir |
4586 grep -c lmv_stripe_count)
4587 [[ $dircnt -eq $((numdirs + 1)) ]] ||
4588 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
4590 run_test 56b "check $LFS getdirstripe"
4594 local ost_name=$(ostname_from_index $ost_idx)
4595 local old_status=$(ost_dev_status $ost_idx)
4597 [[ -z "$old_status" ]] ||
4598 { skip_env "OST $ost_name is in $old_status status"; return 0; }
4600 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4603 local new_status=$(ost_dev_status $ost_idx)
4605 [[ "$new_status" = "D" ]] ||
4606 error "OST $ost_name is in status of '$new_status', not 'D'"
4608 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4611 new_status=$(ost_dev_status $ost_idx)
4612 [[ -z "$new_status" ]] ||
4613 error "OST $ost_name is in status of '$new_status', not ''"
4615 run_test 56c "check 'lfs df' showing device status"
4620 local local_tdir="$1"
4621 local local_numfiles="$2"
4622 local local_numdirs="$3"
4623 local dir_params="$4"
4624 local dir_stripe_params="$5"
4626 if [ ! -d "$local_tdir" ] ; then
4627 test_mkdir -p $dir_stripe_params $local_tdir
4628 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
4629 for i in $(seq $local_numfiles) ; do
4630 touch $local_tdir/file$i
4632 for i in $(seq $local_numdirs) ; do
4633 test_mkdir $dir_stripe_params $local_tdir/dir$i
4634 for j in $(seq $local_numfiles) ; do
4635 touch $local_tdir/dir$i/file$j
4641 setup_56_special() {
4643 local local_numfiles=$2
4644 local local_numdirs=$3
4646 setup_56 $local_tdir $local_numfiles $local_numdirs
4648 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
4649 for i in $(seq $local_numfiles) ; do
4650 mknod $local_tdir/loop${i}b b 7 $i
4651 mknod $local_tdir/null${i}c c 1 3
4652 ln -s $local_tdir/file1 $local_tdir/link${i}
4654 for i in $(seq $local_numdirs) ; do
4655 mknod $local_tdir/dir$i/loop${i}b b 7 $i
4656 mknod $local_tdir/dir$i/null${i}c c 1 3
4657 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
4663 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4664 local expected=$(($NUMDIRS + 2))
4666 setup_56 $dir $NUMFILES $NUMDIRS
4668 # test lfs find with -name
4669 for i in $(seq $NUMFILES) ; do
4670 local nums=$($LFS find -name "*$i" $dir | wc -l)
4672 [ $nums -eq $expected ] ||
4673 error "lfs find -name '*$i' $dir wrong: "\
4674 "found $nums, expected $expected"
4677 run_test 56g "check lfs find -name"
4680 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4681 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4683 setup_56 $dir $NUMFILES $NUMDIRS
4685 # test lfs find with ! -name
4686 for i in $(seq $NUMFILES) ; do
4687 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
4689 [ $nums -eq $expected ] ||
4690 error "lfs find ! -name '*$i' $dir wrong: "\
4691 "found $nums, expected $expected"
4694 run_test 56h "check lfs find ! -name"
4697 local dir=$DIR/$tdir
4701 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
4704 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
4706 run_test 56i "check 'lfs find -ost UUID' skips directories"
4709 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4711 setup_56_special $dir $NUMFILES $NUMDIRS
4713 local expected=$((NUMDIRS + 1))
4714 local cmd="$LFS find -type d $dir"
4715 local nums=$($cmd | wc -l)
4717 [ $nums -eq $expected ] ||
4718 error "'$cmd' wrong: found $nums, expected $expected"
4720 run_test 56j "check lfs find -type d"
4723 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4725 setup_56_special $dir $NUMFILES $NUMDIRS
4727 local expected=$(((NUMDIRS + 1) * NUMFILES))
4728 local cmd="$LFS find -type f $dir"
4729 local nums=$($cmd | wc -l)
4731 [ $nums -eq $expected ] ||
4732 error "'$cmd' wrong: found $nums, expected $expected"
4734 run_test 56k "check lfs find -type f"
4737 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4739 setup_56_special $dir $NUMFILES $NUMDIRS
4741 local expected=$((NUMDIRS + NUMFILES))
4742 local cmd="$LFS find -type b $dir"
4743 local nums=$($cmd | wc -l)
4745 [ $nums -eq $expected ] ||
4746 error "'$cmd' wrong: found $nums, expected $expected"
4748 run_test 56l "check lfs find -type b"
4751 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4753 setup_56_special $dir $NUMFILES $NUMDIRS
4755 local expected=$((NUMDIRS + NUMFILES))
4756 local cmd="$LFS find -type c $dir"
4757 local nums=$($cmd | wc -l)
4758 [ $nums -eq $expected ] ||
4759 error "'$cmd' wrong: found $nums, expected $expected"
4761 run_test 56m "check lfs find -type c"
4764 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4765 setup_56_special $dir $NUMFILES $NUMDIRS
4767 local expected=$((NUMDIRS + NUMFILES))
4768 local cmd="$LFS find -type l $dir"
4769 local nums=$($cmd | wc -l)
4771 [ $nums -eq $expected ] ||
4772 error "'$cmd' wrong: found $nums, expected $expected"
4774 run_test 56n "check lfs find -type l"
4777 local dir=$DIR/$tdir
4779 setup_56 $dir $NUMFILES $NUMDIRS
4780 utime $dir/file1 > /dev/null || error "utime (1)"
4781 utime $dir/file2 > /dev/null || error "utime (2)"
4782 utime $dir/dir1 > /dev/null || error "utime (3)"
4783 utime $dir/dir2 > /dev/null || error "utime (4)"
4784 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
4785 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
4788 local nums=$($LFS find -mtime +0 $dir | wc -l)
4790 [ $nums -eq $expected ] ||
4791 error "lfs find -mtime +0 $dir: found $nums expect $expected"
4794 cmd="$LFS find -mtime 0 $dir"
4795 nums=$($cmd | wc -l)
4796 [ $nums -eq $expected ] ||
4797 error "'$cmd' wrong: found $nums, expected $expected"
4799 run_test 56o "check lfs find -mtime for old files"
4802 [ $RUNAS_ID -eq $UID ] &&
4803 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4805 local dir=$DIR/$tdir
4807 setup_56 $dir $NUMFILES $NUMDIRS
4808 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
4810 local expected=$NUMFILES
4811 local cmd="$LFS find -uid $RUNAS_ID $dir"
4812 local nums=$($cmd | wc -l)
4814 [ $nums -eq $expected ] ||
4815 error "'$cmd' wrong: found $nums, expected $expected"
4817 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
4818 cmd="$LFS find ! -uid $RUNAS_ID $dir"
4819 nums=$($cmd | wc -l)
4820 [ $nums -eq $expected ] ||
4821 error "'$cmd' wrong: found $nums, expected $expected"
4823 run_test 56p "check lfs find -uid and ! -uid"
4826 [ $RUNAS_ID -eq $UID ] &&
4827 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4829 local dir=$DIR/$tdir
4831 setup_56 $dir $NUMFILES $NUMDIRS
4832 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
4834 local expected=$NUMFILES
4835 local cmd="$LFS find -gid $RUNAS_GID $dir"
4836 local nums=$($cmd | wc -l)
4838 [ $nums -eq $expected ] ||
4839 error "'$cmd' wrong: found $nums, expected $expected"
4841 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4842 cmd="$LFS find ! -gid $RUNAS_GID $dir"
4843 nums=$($cmd | wc -l)
4844 [ $nums -eq $expected ] ||
4845 error "'$cmd' wrong: found $nums, expected $expected"
4847 run_test 56q "check lfs find -gid and ! -gid"
4850 local dir=$DIR/$tdir
4852 setup_56 $dir $NUMFILES $NUMDIRS
4855 local cmd="$LFS find -size 0 -type f $dir"
4856 local nums=$($cmd | wc -l)
4858 [ $nums -eq $expected ] ||
4859 error "'$cmd' wrong: found $nums, expected $expected"
4861 cmd="$LFS find ! -size 0 -type f $dir"
4862 nums=$($cmd | wc -l)
4863 [ $nums -eq $expected ] ||
4864 error "'$cmd' wrong: found $nums, expected $expected"
4865 echo "test" > $dir/$tfile
4866 echo "test2" > $dir/$tfile.2 && sync
4868 cmd="$LFS find -size 5 -type f $dir"
4869 nums=$($cmd | wc -l)
4870 [ $nums -eq $expected ] ||
4871 error "'$cmd' wrong: found $nums, expected $expected"
4873 cmd="$LFS find -size +5 -type f $dir"
4874 nums=$($cmd | wc -l)
4875 [ $nums -eq $expected ] ||
4876 error "'$cmd' wrong: found $nums, expected $expected"
4878 cmd="$LFS find -size +0 -type f $dir"
4879 nums=$($cmd | wc -l)
4880 [ $nums -eq $expected ] ||
4881 error "'$cmd' wrong: found $nums, expected $expected"
4883 cmd="$LFS find ! -size -5 -type f $dir"
4884 nums=$($cmd | wc -l)
4885 [ $nums -eq $expected ] ||
4886 error "'$cmd' wrong: found $nums, expected $expected"
4888 cmd="$LFS find -size -5 -type f $dir"
4889 nums=$($cmd | wc -l)
4890 [ $nums -eq $expected ] ||
4891 error "'$cmd' wrong: found $nums, expected $expected"
4893 run_test 56r "check lfs find -size works"
4895 test_56s() { # LU-611 #LU-9369
4896 [[ $OSTCOUNT -lt 2 ]] && skip "need at least 2 OSTs" && return 0
4898 local dir=$DIR/$tdir
4899 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
4901 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
4902 for i in $(seq $NUMDIRS); do
4903 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
4906 local expected=$NUMDIRS
4907 local cmd="$LFS find -c $OSTCOUNT $dir"
4908 local nums=$($cmd | wc -l)
4910 [ $nums -eq $expected ] || {
4911 $LFS getstripe -R $dir
4912 error "'$cmd' wrong: found $nums, expected $expected"
4915 expected=$((NUMDIRS + onestripe))
4916 cmd="$LFS find -stripe-count +0 -type f $dir"
4917 nums=$($cmd | wc -l)
4918 [ $nums -eq $expected ] || {
4919 $LFS getstripe -R $dir
4920 error "'$cmd' wrong: found $nums, expected $expected"
4924 cmd="$LFS find -stripe-count 1 -type f $dir"
4925 nums=$($cmd | wc -l)
4926 [ $nums -eq $expected ] || {
4927 $LFS getstripe -R $dir
4928 error "'$cmd' wrong: found $nums, expected $expected"
4931 cmd="$LFS find -stripe-count -2 -type f $dir"
4932 nums=$($cmd | wc -l)
4933 [ $nums -eq $expected ] || {
4934 $LFS getstripe -R $dir
4935 error "'$cmd' wrong: found $nums, expected $expected"
4939 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
4940 nums=$($cmd | wc -l)
4941 [ $nums -eq $expected ] || {
4942 $LFS getstripe -R $dir
4943 error "'$cmd' wrong: found $nums, expected $expected"
4946 run_test 56s "check lfs find -stripe-count works"
4948 test_56t() { # LU-611 #LU-9369
4949 local dir=$DIR/$tdir
4951 setup_56 $dir 0 $NUMDIRS
4952 for i in $(seq $NUMDIRS); do
4953 $LFS setstripe -S 4M $dir/dir$i/$tfile
4956 local expected=$NUMDIRS
4957 local cmd="$LFS find -S 4M $dir"
4958 local nums=$($cmd | wc -l)
4960 [ $nums -eq $expected ] || {
4961 $LFS getstripe -R $dir
4962 error "'$cmd' wrong: found $nums, expected $expected"
4966 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
4968 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
4970 expected=$(((NUMDIRS + 1) * NUMFILES))
4971 cmd="$LFS find -stripe-size 512k -type f $dir"
4972 nums=$($cmd | wc -l)
4973 [ $nums -eq $expected ] ||
4974 error "'$cmd' wrong: found $nums, expected $expected"
4976 cmd="$LFS find -stripe-size +320k -type f $dir"
4977 nums=$($cmd | wc -l)
4978 [ $nums -eq $expected ] ||
4979 error "'$cmd' wrong: found $nums, expected $expected"
4981 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
4982 cmd="$LFS find -stripe-size +200k -type f $dir"
4983 nums=$($cmd | wc -l)
4984 [ $nums -eq $expected ] ||
4985 error "'$cmd' wrong: found $nums, expected $expected"
4987 cmd="$LFS find -stripe-size -640k -type f $dir"
4988 nums=$($cmd | wc -l)
4989 [ $nums -eq $expected ] ||
4990 error "'$cmd' wrong: found $nums, expected $expected"
4993 cmd="$LFS find -stripe-size 256k -type f $dir"
4994 nums=$($cmd | wc -l)
4995 [ $nums -eq $expected ] ||
4996 error "'$cmd' wrong: found $nums, expected $expected"
4998 cmd="$LFS find -stripe-size -320k -type f $dir"
4999 nums=$($cmd | wc -l)
5000 [ $nums -eq $expected ] ||
5001 error "'$cmd' wrong: found $nums, expected $expected"
5004 cmd="$LFS find -stripe-size 1024k -type f $dir"
5005 nums=$($cmd | wc -l)
5006 [ $nums -eq $expected ] ||
5007 error "'$cmd' wrong: found $nums, expected $expected"
5009 run_test 56t "check lfs find -stripe-size works"
5011 test_56u() { # LU-611
5012 local dir=$DIR/$tdir
5014 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5016 if [[ $OSTCOUNT -gt 1 ]]; then
5017 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5023 local expected=$(((NUMDIRS + 1) * NUMFILES))
5024 local cmd="$LFS find -stripe-index 0 -type f $dir"
5025 local nums=$($cmd | wc -l)
5027 [ $nums -eq $expected ] ||
5028 error "'$cmd' wrong: found $nums, expected $expected"
5031 cmd="$LFS find -stripe-index 1 -type f $dir"
5032 nums=$($cmd | wc -l)
5033 [ $nums -eq $expected ] ||
5034 error "'$cmd' wrong: found $nums, expected $expected"
5036 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5037 nums=$($cmd | wc -l)
5038 [ $nums -eq $expected ] ||
5039 error "'$cmd' wrong: found $nums, expected $expected"
5042 # This should produce an error and not return any files
5043 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5044 nums=$($cmd 2>/dev/null | wc -l)
5045 [ $nums -eq $expected ] ||
5046 error "'$cmd' wrong: found $nums, expected $expected"
5048 if [[ $OSTCOUNT -gt 1 ]]; then
5049 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5050 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5051 nums=$($cmd | wc -l)
5052 [ $nums -eq $expected ] ||
5053 error "'$cmd' wrong: found $nums, expected $expected"
5056 run_test 56u "check lfs find -stripe-index works"
5060 local dir=$DIR/$tdir
5062 setup_56 $dir $NUMFILES $NUMDIRS
5064 UUID=$(mdtuuid_from_index $MDT_IDX $dir)
5065 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $MDT_IDX"
5067 for file in $($LFS find -mdt $UUID $dir); do
5068 file_mdt_idx=$($LFS getstripe -M $file)
5069 [ $file_mdt_idx -eq $MDT_IDX ] ||
5070 error "lfind -mdt $UUID != getstripe -M $file_mdt_idx"
5073 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
5076 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5078 local dir=$DIR/$tdir
5080 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5082 local stripe_size=$($LFS getstripe -S -d $dir) ||
5083 error "$LFS getstripe -S -d $dir failed"
5084 stripe_size=${stripe_size%% *}
5086 local file_size=$((stripe_size * OSTCOUNT))
5087 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5088 local required_space=$((file_num * file_size))
5089 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5091 [[ $free_space -le $((required_space / 1024)) ]] &&
5092 skip_env "need $required_space, have $free_space kbytes" &&
5096 local dd_count=$((file_size / dd_bs))
5098 # write data into the files
5103 for i in $(seq $NUMFILES); do
5105 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5106 error "write data into $file failed"
5108 for i in $(seq $NUMDIRS); do
5109 for j in $(seq $NUMFILES); do
5110 file=$dir/dir$i/file$j
5111 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5112 error "write data into $file failed"
5116 # $LFS_MIGRATE will fail if hard link migration is unsupported
5117 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5118 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5119 error "creating links to $dir/dir1/file1 failed"
5124 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5127 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5130 eval $cmd || error "$cmd failed"
5132 check_stripe_count $dir/file1 $expected
5134 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5136 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5137 # OST 1 if it is on OST 0. This file is small enough to
5138 # be on only one stripe.
5139 file=$dir/migr_1_ost
5140 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5141 error "write data into $file failed"
5142 local obdidx=$($LFS getstripe -i $file)
5143 local oldmd5=$(md5sum $file)
5146 [[ $obdidx -eq 0 ]] && newobdidx=1
5147 cmd="$LFS migrate -i $newobdidx $file"
5149 eval $cmd || error "$cmd failed"
5151 local realobdix=$($LFS getstripe -i $file)
5152 local newmd5=$(md5sum $file)
5154 [[ $newobdidx -ne $realobdix ]] &&
5155 error "new OST is different (was=$obdidx, "\
5156 "wanted=$newobdidx, got=$realobdix)"
5157 [[ "$oldmd5" != "$newmd5" ]] &&
5158 error "md5sum differ: $oldmd5, $newmd5"
5162 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5164 eval $cmd || error "$cmd failed"
5166 for j in $(seq $NUMFILES); do
5167 check_stripe_count $dir/dir1/file$j $expected
5170 # lfs_migrate works with lfs find
5171 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5172 $LFS_MIGRATE -y -c $expected"
5174 eval $cmd || error "$cmd failed"
5176 for i in $(seq 2 $NUMFILES); do
5177 check_stripe_count $dir/file$i $expected
5179 for i in $(seq 2 $NUMDIRS); do
5180 for j in $(seq $NUMFILES); do
5181 check_stripe_count $dir/dir$i/file$j $expected
5185 run_test 56w "check lfs_migrate -c stripe_count works"
5188 local file1=$DIR/$tdir/file1
5189 local create_pool=false
5190 local initial_pool=$($LFS getstripe -p $DIR)
5194 echo -n "Creating test dir..."
5195 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5198 echo -n "Creating test file..."
5199 touch $file1 || error "cannot create file"
5202 echo -n "Detecting existing pools..."
5203 while IFS='' read thispool; do
5204 pool_list+=("$thispool")
5205 done < <($LFS pool_list $MOUNT | awk -F '.' 'NR>=2 { print $2 }')
5207 if [ ${#pool_list[@]} -gt 0 ]; then
5208 echo "${pool_list[@]}"
5209 for thispool in "${pool_list[@]}"; do
5210 if [[ -z "$initial_pool" ||
5211 "$initial_pool" != "$thispool" ]]; then
5213 echo "Using existing pool '$pool'"
5218 echo "none detected."
5220 if [ -z "$pool" ]; then
5221 pool=${POOL:-testpool}
5222 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5223 echo -n "Creating pool '$pool'..."
5225 pool_add $pool &> /dev/null ||
5226 error "pool_add failed"
5229 echo -n "Adding target to pool..."
5230 pool_add_targets $pool 0 0 1 &> /dev/null ||
5231 error "pool_add_targets failed"
5235 echo -n "Setting pool using -p option..."
5236 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5237 error "migrate failed rc = $?"
5240 echo -n "Verifying test file is in pool after migrating..."
5241 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5242 error "file was not migrated to pool $pool"
5245 echo -n "Removing test file from pool '$pool'..."
5246 $LFS migrate $file1 &> /dev/null ||
5247 error "cannot remove from pool"
5248 [ "$($LFS getstripe -p $file1)" ] &&
5249 error "pool still set"
5252 echo -n "Setting pool using --pool option..."
5253 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5254 error "migrate failed rc = $?"
5259 if $create_pool; then
5260 destroy_test_pools 2> /dev/null ||
5261 error "destroy test pools failed"
5264 run_test 56wb "check lfs_migrate pool support"
5267 local file1="$DIR/$tdir/file 1"
5269 echo -n "Creating test dir..."
5270 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5271 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5272 error "cannot set stripe"
5275 echo -n "Setting initial stripe for test file..."
5276 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5277 error "cannot set stripe"
5278 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5279 error "stripe size not set"
5282 # File currently set to -S 512K -c 1
5284 # Ensure -c and -S options are rejected when -R is set
5285 echo -n "Verifying incompatible options are detected..."
5286 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5287 error "incompatible -c and -R options not detected"
5288 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5289 error "incompatible -S and -R options not detected"
5292 # Ensure unrecognized options are passed through to 'lfs migrate'
5293 echo -n "Verifying -S option is passed through to lfs migrate..."
5294 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5295 error "migration failed"
5296 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5297 error "file was not restriped"
5300 # File currently set to -S 1M -c 1
5302 # Ensure long options are supported
5303 echo -n "Verifying long options supported..."
5304 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5305 error "long option without argument not supported"
5306 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5307 error "long option with argument not supported"
5308 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5309 error "file not restriped with --stripe-size option"
5312 # File currently set to -S 512K -c 1
5314 if [ "$OSTCOUNT" -gt 1 ]; then
5315 echo -n "Verifying explicit stripe count can be set..."
5316 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5317 error "migrate failed"
5318 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
5319 error "file not restriped to explicit count"
5323 # File currently set to -S 512K -c 1 or -S 512K -c 2
5325 # Ensure parent striping is used if -R is set, and no stripe
5326 # count or size is specified
5327 echo -n "Setting stripe for parent directory..."
5328 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5329 error "cannot set stripe"
5332 echo -n "Verifying restripe option uses parent stripe settings..."
5333 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5334 error "migrate failed"
5335 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5336 error "file not restriped to parent settings"
5337 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
5338 error "file not restriped to parent settings"
5341 # File currently set to -S 1M -c 1
5343 # Ensure striping is preserved if -R is not set, and no stripe
5344 # count or size is specified
5345 echo -n "Verifying striping size preserved when not specified..."
5346 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5347 error "cannot set stripe on parent directory"
5348 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5349 error "migrate failed"
5350 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5351 error "file was restriped"
5354 # Ensure file name properly detected when final option has no argument
5355 echo -n "Verifying file name properly detected..."
5356 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5357 error "file name interpreted as option argument"
5363 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5366 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5367 local file1=$DIR/$tdir/file1
5369 echo -n "Creating test dir..."
5370 test_mkdir $DIR/$tdir || error "cannot create dir"
5373 echo -n "Creating test file..."
5377 # Ensure 'lfs migrate' will fail by using a non-existent option,
5378 # and make sure rsync is not called to recover
5379 echo -n "Make sure --no-rsync option works..."
5380 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5381 grep -q 'refusing to fall back to rsync' ||
5382 error "rsync was called with --no-rsync set"
5385 # Ensure rsync is called without trying 'lfs migrate' first
5386 echo -n "Make sure --rsync option works..."
5387 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5388 grep -q 'falling back to rsync' &&
5389 error "lfs migrate was called with --rsync set"
5392 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
5393 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
5394 grep -q 'at the same time' ||
5395 error "--rsync and --no-rsync accepted concurrently"
5401 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
5404 check_swap_layouts_support && return 0
5405 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5407 local dir=$DIR/$tdir
5408 local ref1=/etc/passwd
5409 local file1=$dir/file1
5411 test_mkdir $dir || error "creating dir $dir"
5412 $LFS setstripe -c 2 $file1
5414 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5415 stripe=$($LFS getstripe -c $file1)
5416 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5417 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5422 run_test 56x "lfs migration support"
5425 check_swap_layouts_support && return 0
5426 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
5428 local dir=$DIR/$tdir/$testnum
5432 local ref1=/etc/passwd
5433 local file1=$dir/file1
5435 $LFS setstripe -c 2 $file1
5437 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5439 local stripe=$($LFS getstripe -c $file1)
5441 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5442 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5447 run_test 56xa "lfs migration --block support"
5449 check_migrate_links() {
5451 local file1="$dir/file1"
5454 local total_count=$(($begin + $count - 1))
5455 local symlink_count=10
5458 if [ ! -f "$file1" ]; then
5459 echo -n "creating initial file..."
5460 $LFS setstripe -c 1 -S "512k" "$file1" ||
5461 error "cannot setstripe initial file"
5464 echo -n "creating symlinks..."
5465 for s in $(seq 1 $symlink_count); do
5466 ln -s "$file1" "$dir/slink$s" ||
5467 error "cannot create symlinks"
5471 echo -n "creating nonlinked files..."
5472 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5473 error "cannot create nonlinked files"
5478 if [ ! -f "$dir/file$total_count" ]; then
5479 echo -n "creating hard links $begin:$total_count..."
5480 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5481 /dev/null || error "cannot create hard links"
5485 echo -n "checking number of hard links listed in xattrs..."
5486 local fid=$($LFS getstripe -F "$file1")
5487 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5490 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5491 echo "hard link list has unexpected size, skipping test"
5494 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5495 error "link names should exceed xattrs size"
5498 echo -n "migrating files..."
5499 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5501 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5504 # make sure all links have been properly migrated
5505 echo -n "verifying files..."
5506 fid=$($LFS getstripe -F "$file1") ||
5507 error "cannot get fid for file $file1"
5508 for i in $(seq 2 $total_count); do
5509 local fid2=$($LFS getstripe -F $dir/file$i)
5511 [ "$fid2" == "$fid" ] ||
5512 error "migrated hard link has mismatched FID"
5515 # make sure hard links were properly detected, and migration was
5516 # performed only once for the entire link set; nonlinked files should
5518 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5519 local expected=$(($uniq_count + 1))
5521 [ "$actual" -eq "$expected" ] ||
5522 error "hard links individually migrated ($actual != $expected)"
5524 # make sure the correct number of hard links are present
5525 local hardlinks=$(stat -c '%h' "$file1")
5527 [ $hardlinks -eq $total_count ] ||
5528 error "num hard links $hardlinks != $total_count"
5535 local dir="$DIR/$tdir"
5537 test_mkdir "$dir" || error "cannot create dir $dir"
5539 echo "testing lfs migrate mode when all links fit within xattrs"
5540 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 2 99
5542 echo "testing rsync mode when all links fit within xattrs"
5543 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 2 99
5545 echo "testing lfs migrate mode when all links do not fit within xattrs"
5546 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 101 100
5548 echo "testing rsync mode when all links do not fit within xattrs"
5549 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 101 100
5554 run_test 56xb "lfs migration hard link support"
5557 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5558 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
5562 local dir=$DIR/$tdir
5566 test_mkdir -p $dir || error "creating dir $dir"
5567 touch $f1 || error "creating std file $f1"
5568 $MULTIOP $f2 H2c || error "creating released file $f2"
5570 # a directory can be raid0, so ask only for files
5571 res=$($LFS find $dir -L raid0 -type f | wc -l)
5572 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5574 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
5575 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5577 # only files can be released, so no need to force file search
5578 res=$($LFS find $dir -L released)
5579 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5581 res=$($LFS find $dir -type f \! -L released)
5582 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5584 run_test 56y "lfs find -L raid0|released"
5586 test_56z() { # LU-4824
5587 # This checks to make sure 'lfs find' continues after errors
5588 # There are two classes of errors that should be caught:
5589 # - If multiple paths are provided, all should be searched even if one
5591 # - If errors are encountered during the search, it should not terminate
5593 local dir=$DIR/$tdir
5597 for i in d{0..9}; do
5600 touch $dir/d{0..9}/$tfile
5601 $LFS find $DIR/non_existent_dir $dir &&
5602 error "$LFS find did not return an error"
5603 # Make a directory unsearchable. This should NOT be the last entry in
5604 # directory order. Arbitrarily pick the 6th entry
5605 chmod 700 $($LFS find $dir -type d | sed '6!d')
5607 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
5609 # The user should be able to see 10 directories and 9 files
5610 [ $count == 19 ] || error "$LFS find did not continue after error"
5612 run_test 56z "lfs find should continue after an error"
5614 test_56aa() { # LU-5937
5615 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5617 local dir=$DIR/$tdir
5620 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
5622 createmany -o $dir/striped_dir/${tfile}- 1024
5623 local dirs=$(lfs find --size +8k $dir/)
5625 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5627 run_test 56aa "lfs find --size under striped dir"
5630 # Create composite files with one component
5631 local dir=$DIR/$tdir
5633 setup_56 $dir/1Mfiles 5 1 "--component-end 1M"
5634 # Create composite files with three components
5635 setup_56 $dir/2Mfiles 5 2 "-E 2M -E 4M -E 6M"
5636 # Create non-composite files
5637 createmany -o $dir/${tfile}- 10
5639 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
5641 [[ $nfiles == 10 ]] ||
5642 error "lfs find -E 1M found $nfiles != 10 files"
5644 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
5645 [[ $nfiles == 25 ]] ||
5646 error "lfs find ! -E 1M found $nfiles != 25 files"
5648 # All files have a component that starts at 0
5649 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
5650 [[ $nfiles == 35 ]] ||
5651 error "lfs find --component-start 0 - $nfiles != 35 files"
5653 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
5654 [[ $nfiles == 15 ]] ||
5655 error "lfs find --component-start 2M - $nfiles != 15 files"
5657 # All files created here have a componenet that does not starts at 2M
5658 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
5659 [[ $nfiles == 35 ]] ||
5660 error "lfs find ! --component-start 2M - $nfiles != 35 files"
5662 # Find files with a specified number of components
5663 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
5664 [[ $nfiles == 15 ]] ||
5665 error "lfs find --component-count 3 - $nfiles != 15 files"
5667 # Remember non-composite files have a component count of zero
5668 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
5669 [[ $nfiles == 10 ]] ||
5670 error "lfs find --component-count 0 - $nfiles != 10 files"
5672 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
5673 [[ $nfiles == 20 ]] ||
5674 error "lfs find ! --component-count 3 - $nfiles != 20 files"
5676 # All files have a flag called "init"
5677 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
5678 [[ $nfiles == 35 ]] ||
5679 error "lfs find --component-flags init - $nfiles != 35 files"
5681 # Multi-component files will have a component not initialized
5682 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
5683 [[ $nfiles == 15 ]] ||
5684 error "lfs find !--component-flags init - $nfiles != 15 files"
5689 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
5692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5693 # note test will not do anything if MDS is not local
5694 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5695 skip "ldiskfs only test"
5699 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5700 local MNTDEV="osd*.*MDT*.mntdev"
5701 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5702 [ -z "$DEV" ] && error "can't access $MNTDEV"
5703 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5704 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5705 error "can't access $DEV"
5706 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5707 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5711 run_test 57a "verify MDS filesystem created with large inodes =="
5714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5715 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5716 skip "ldiskfs only test"
5720 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5721 local dir=$DIR/$tdir
5725 local FILEN=$dir/f$FILECOUNT
5727 rm -rf $dir || error "removing $dir"
5729 local mdtidx=$($LFS getstripe -M $dir)
5730 local mdtname=MDT$(printf %04x $mdtidx)
5731 local facet=mds$((mdtidx + 1))
5733 echo "mcreating $FILECOUNT files"
5734 createmany -m $dir/f 1 $FILECOUNT || \
5735 error "creating files in $dir"
5737 # verify that files do not have EAs yet
5738 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5739 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5743 df $dir #make sure we get new statfs data
5744 local MDSFREE=$(do_facet $facet \
5745 lctl get_param -n osd*.*$mdtname.kbytesfree)
5746 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5747 echo "opening files to create objects/EAs"
5749 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5750 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5753 # verify that files have EAs now
5754 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5755 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5757 sleep 1 #make sure we get new statfs data
5759 local MDSFREE2=$(do_facet $facet \
5760 lctl get_param -n osd*.*$mdtname.kbytesfree)
5761 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5762 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5763 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5764 error "MDC before $MDCFREE != after $MDCFREE2"
5766 echo "MDC before $MDCFREE != after $MDCFREE2"
5767 echo "unable to confirm if MDS has large inodes"
5772 run_test 57b "default LOV EAs are stored inside large inodes ==="
5775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5776 [ -z "$(which wiretest 2>/dev/null)" ] &&
5777 skip_env "could not find wiretest" && return
5780 run_test 58 "verify cross-platform wire constants =============="
5783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5784 echo "touch 130 files"
5785 createmany -o $DIR/f59- 130
5787 unlinkmany $DIR/f59- 130
5789 # wait for commitment of removal
5790 wait_delete_completed
5792 run_test 59 "verify cancellation of llog records async ========="
5794 TEST60_HEAD="test_60 run $RANDOM"
5796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5797 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5798 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5799 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5800 skip_env "missing subtest run-llog.sh" && return
5802 log "$TEST60_HEAD - from kernel mode"
5803 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5804 do_facet mgs "sh run-llog.sh" || error "run-llog.sh failed"
5805 do_facet mgs $LCTL dk > $TMP/$tfile
5807 # LU-6388: test llog_reader
5808 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5809 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5810 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5811 skip_env "missing llog_reader" && return
5812 local fstype=$(facet_fstype mgs)
5813 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5814 skip_env "Only for ldiskfs or zfs type mgs" && return
5816 local mntpt=$(facet_mntpt mgs)
5817 local mgsdev=$(mgsdevname 1)
5829 #get fid and record list
5830 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5832 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5834 #remount mgs as ldiskfs or zfs type
5835 stop mgs || error "stop mgs failed"
5836 mount_fstype mgs || error "remount mgs failed"
5837 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5840 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5841 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5846 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5848 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5850 echo "obj_file is $obj_file"
5851 do_facet mgs $llog_reader $obj_file
5853 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5854 awk '{ print $3 }' | sed -e "s/^type=//g")
5855 if [ $rec_type != $rec ]; then
5856 echo "FAILED test_60a wrong record type $rec_type," \
5862 #check obj path if record type is LLOG_LOGID_MAGIC
5863 if [ "$rec" == "1064553b" ]; then
5864 path=$(do_facet mgs $llog_reader $obj_file |
5865 grep "path=" | awk '{ print $NF }' |
5866 sed -e "s/^path=//g")
5867 if [ $obj_file != $mntpt/$path ]; then
5868 echo "FAILED test_60a wrong obj path" \
5869 "$montpt/$path, should be $obj_file"
5876 #restart mgs before "error", otherwise it will block the next test
5877 stop mgs || error "stop mgs failed"
5878 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5879 $pass || error "test failed, see FAILED test_60a messages for specifics"
5881 run_test 60a "llog_test run from kernel module and test llog_reader"
5884 # test old logid format
5885 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
5886 do_facet mgs $LCTL dl | grep MGS
5887 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
5888 error "old llog_print failed"
5891 # test new logid format
5892 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
5893 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
5894 error "new llog_print failed"
5897 run_test 60aa "llog_print works with FIDs and simple names"
5899 test_60b() { # bug 6411
5900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5902 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5914 [[ $LLOG_COUNT -gt 100 ]] &&
5915 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5917 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5921 echo "create 5000 files"
5922 createmany -o $DIR/f60c- 5000
5923 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5924 lctl set_param fail_loc=0x80000137
5925 unlinkmany $DIR/f60c- 5000
5926 lctl set_param fail_loc=0
5928 run_test 60c "unlink file when mds full"
5931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5932 SAVEPRINTK=$(lctl get_param -n printk)
5934 # verify "lctl mark" is even working"
5935 MESSAGE="test message ID $RANDOM $$"
5936 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5937 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5939 lctl set_param printk=0 || error "set lnet.printk failed"
5940 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5941 MESSAGE="new test message ID $RANDOM $$"
5942 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5943 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5944 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5946 lctl set_param -n printk="$SAVEPRINTK"
5948 run_test 60d "test printk console message masking"
5951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5952 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5954 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5955 do_facet mds1 lctl set_param fail_loc=0x15b
5958 run_test 60e "no space while new llog is being created"
5961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5963 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5964 cancel_lru_locks osc
5965 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5968 run_test 61 "mmap() writes don't make sync hang ================"
5970 # bug 2330 - insufficient obd_match error checking causes LBUG
5972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5975 cancel_lru_locks osc
5976 lctl set_param fail_loc=0x405
5977 cat $f && error "cat succeeded, expect -EIO"
5978 lctl set_param fail_loc=0
5980 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5981 # match every page all of the time.
5982 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5984 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5985 # Though this test is irrelevant anymore, it helped to reveal some
5986 # other grant bugs (LU-4482), let's keep it.
5987 test_63a() { # was test_63
5988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5989 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5990 for i in `seq 10` ; do
5991 dd if=/dev/zero of=$DIR/f63 bs=8k &
5997 rm -f $DIR/f63 || true
5999 run_test 63a "Verify oig_wait interruption does not crash ======="
6001 # bug 2248 - async write errors didn't return to application on sync
6002 # bug 3677 - async write errors left page locked
6004 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6006 lctl set_param debug=-1
6008 # ensure we have a grant to do async writes
6009 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6012 sync # sync lest earlier test intercept the fail_loc
6014 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6015 lctl set_param fail_loc=0x80000406
6016 $MULTIOP $DIR/$tfile Owy && \
6017 error "sync didn't return ENOMEM"
6018 sync; sleep 2; sync # do a real sync this time to flush page
6019 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6020 error "locked page left in cache after async error" || true
6023 run_test 63b "async write errors should be returned to fsync ==="
6026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6028 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6030 run_test 64a "verify filter grant calculations (in kernel) ====="
6033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6034 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6036 run_test 64b "check out-of-space detection on client"
6039 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6041 run_test 64c "verify grant shrink"
6043 # this does exactly what osc_request.c:osc_announce_cached() does in
6044 # order to calculate max amount of grants to ask from server
6048 local page_size=$(get_page_size client)
6050 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6051 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6053 ((rpc_in_flight ++));
6054 nrpages=$((nrpages * rpc_in_flight))
6056 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6058 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size))
6060 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6061 local undirty=$((nrpages * page_size))
6063 local max_extent_pages
6064 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6065 grep grant_max_extent_size | awk '{print $2}')
6066 max_extent_pages=$((max_extent_pages / page_size))
6067 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6068 local grant_extent_tax
6069 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6070 grep grant_extent_tax | awk '{print $2}')
6072 undirty=$((undirty + nrextents * grant_extent_tax))
6077 # this is size of unit for grant allocation. It should be equal to
6078 # what tgt_grant.c:tgt_grant_chunk() calculates
6082 local grant_extent_tax
6084 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6085 grep max_brw_size | awk '{print $2}')
6087 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6088 grep grant_extent_tax | awk '{print $2}')
6090 echo $(((max_brw_size + grant_extent_tax) * 2))
6094 [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
6095 skip "OST < 2.10.55 doesn't limit grants enough" && return 0
6097 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6099 [[ $($LCTL get_param osc.${tgt}.import |
6100 grep "connect_flags:.*grant_param") ]] || \
6101 { skip "no grant_param connect flag"; return; }
6103 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6105 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6107 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6109 $SETSTRIPE $DIR/$tfile -i 0 -c 1
6110 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
6115 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6116 if [[ $cur_grant -gt $max_cur_granted ]]
6119 error "cur_grant $cur_grant > $max_cur_granted"
6122 [[ $? -ne 0 ]] && break;
6125 $LCTL set_param debug="$olddebug" 2> /dev/null || true
6127 run_test 64d "check grant limit exceed"
6129 # bug 1414 - set/get directories' stripe info
6131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6132 test_mkdir $DIR/$tdir
6134 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
6136 run_test 65a "directory with no stripe info"
6139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6140 test_mkdir $DIR/$tdir
6141 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6143 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6146 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
6148 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
6151 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6152 [ $OSTCOUNT -lt 2 ] && skip "need at least 2 OSTs" && return
6153 test_mkdir $DIR/$tdir
6154 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
6156 $LFS setstripe -S $((stripesize * 4)) -i 1 \
6157 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
6159 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
6161 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
6164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6165 test_mkdir $DIR/$tdir
6166 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
6167 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6169 if [[ $STRIPECOUNT -le 0 ]]; then
6171 elif [[ $STRIPECOUNT -gt 2000 ]]; then
6172 #LOV_MAX_STRIPE_COUNT is 2000
6173 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
6175 sc=$(($STRIPECOUNT - 1))
6177 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
6178 touch $DIR/$tdir/f4 $DIR/$tdir/f5
6179 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
6180 error "lverify failed"
6182 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
6185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6186 test_mkdir $DIR/$tdir
6188 $SETSTRIPE $DIR/$tdir || error "setstripe"
6189 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
6190 error "no stripe info failed"
6192 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
6194 run_test 65e "directory setstripe defaults"
6197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6198 test_mkdir $DIR/${tdir}f
6199 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
6201 run_test 65f "dir setstripe permission (should return error) ==="
6204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6205 test_mkdir $DIR/$tdir
6206 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6208 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6209 error "setstripe -S failed"
6210 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
6211 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6212 error "delete default stripe failed"
6214 run_test 65g "directory setstripe -d"
6217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6218 test_mkdir $DIR/$tdir
6219 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6221 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6222 error "setstripe -S failed"
6223 test_mkdir $DIR/$tdir/dd1
6224 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
6225 error "stripe info inherit failed"
6227 run_test 65h "directory stripe info inherit ===================="
6229 test_65i() { # bug6367
6230 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6231 $SETSTRIPE -S 65536 -c -1 $MOUNT
6233 run_test 65i "set non-default striping on root directory (bug 6367)="
6235 test_65ia() { # bug12836
6236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6237 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
6239 run_test 65ia "getstripe on -1 default directory striping"
6241 test_65ib() { # bug12836
6242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6243 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
6245 run_test 65ib "getstripe -v on -1 default directory striping"
6247 test_65ic() { # bug12836
6248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6249 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
6251 run_test 65ic "new find on -1 default directory striping"
6253 test_65j() { # bug6367
6254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6255 [ $($LFS getstripe --component-count $MOUNT) -gt 1 ] &&
6256 skip "don't delete default PFL layout" && return
6258 # if we aren't already remounting for each test, do so for this test
6259 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
6260 cleanup || error "failed to unmount"
6263 $SETSTRIPE -d $MOUNT || error "setstripe failed"
6265 run_test 65j "set default striping on root directory (bug 6367)="
6267 test_65k() { # bug11679
6268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6269 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
6270 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6272 local disable_precreate=true
6273 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
6274 disable_precreate=false
6276 echo "Check OST status: "
6277 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
6278 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
6280 for OSC in $MDS_OSCS; do
6281 echo $OSC "is active"
6282 do_facet $SINGLEMDS lctl --device %$OSC activate
6285 for INACTIVE_OSC in $MDS_OSCS; do
6286 local ost=$(osc_to_ost $INACTIVE_OSC)
6287 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
6288 lov.*md*.target_obd |
6289 awk -F: /$ost/'{ print $1 }' | head -n 1)
6292 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
6293 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
6295 echo "Deactivate: " $INACTIVE_OSC
6296 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
6298 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
6299 osp.$ost*MDT0000.create_count")
6300 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
6301 osp.$ost*MDT0000.max_create_count")
6302 $disable_precreate &&
6303 do_facet $SINGLEMDS "lctl set_param -n \
6304 osp.$ost*MDT0000.max_create_count=0"
6306 for idx in $(seq 0 $((OSTCOUNT - 1))); do
6307 [ -f $DIR/$tdir/$idx ] && continue
6308 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
6309 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
6310 error "setstripe $idx should succeed"
6311 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
6313 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
6316 do_facet $SINGLEMDS "lctl set_param -n \
6317 osp.$ost*MDT0000.max_create_count=$max_count"
6318 do_facet $SINGLEMDS "lctl set_param -n \
6319 osp.$ost*MDT0000.create_count=$count"
6320 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6321 echo $INACTIVE_OSC "is Activate"
6323 wait_osc_import_state mds ost$ostnum FULL
6326 run_test 65k "validate manual striping works properly with deactivated OSCs"
6328 test_65l() { # bug 12836
6329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6330 test_mkdir -p $DIR/$tdir/test_dir
6331 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
6332 $LFS find -mtime -1 $DIR/$tdir >/dev/null
6334 run_test 65l "lfs find on -1 stripe dir ========================"
6337 $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
6340 run_test 65m "normal user can't set filesystem default stripe"
6342 # bug 2543 - update blocks count on client
6344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6346 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6347 sync; sync_all_data; sync; sync_all_data
6348 cancel_lru_locks osc
6349 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6350 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6352 run_test 66 "update inode blocks count on client ==============="
6355 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6359 swapon -s | awk '($1 == "'$1'") { print $4 }'
6362 # bug5265, obdfilter oa2dentry return -ENOENT
6363 # #define OBD_FAIL_SRV_ENOENT 0x217
6365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6366 remote_ost_nodsh && skip "remote OST with nodsh" && return
6369 $SETSTRIPE -c 1 -i 0 $f
6371 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6373 do_facet ost1 lctl set_param fail_loc=0x217
6374 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6375 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6377 do_facet ost1 lctl set_param fail_loc=0
6378 $DIRECTIO write $f 0 2 || error "write error"
6380 cancel_lru_locks osc
6381 $DIRECTIO read $f 0 1 || error "read error"
6383 do_facet ost1 lctl set_param fail_loc=0x217
6384 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6386 do_facet ost1 lctl set_param fail_loc=0
6389 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6392 test_mkdir $DIR/$tdir
6393 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6394 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6396 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6398 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6400 [ "$RUNAS_ID" = "$UID" ] &&
6401 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6403 # Check that testing environment is properly set up. Skip if not
6404 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
6405 skip_env "User $RUNAS_ID does not exist - skipping"
6409 chmod 777 $DIR/$tfile
6410 chmod ug+s $DIR/$tfile
6411 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6412 error "$RUNAS dd $DIR/$tfile failed"
6413 # See if we are still setuid/sgid
6414 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6415 error "S/gid is not dropped on write"
6416 # Now test that MDS is updated too
6417 cancel_lru_locks mdc
6418 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6419 error "S/gid is not dropped on MDS"
6422 run_test 72a "Test that remove suid works properly (bug5695) ===="
6424 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6427 [ "$RUNAS_ID" = "$UID" ] && \
6428 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6429 [ "$RUNAS_ID" -eq 0 ] && \
6430 skip_env "RUNAS_ID = 0 -- skipping" && return
6432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6433 # Check that testing environment is properly set up. Skip if not
6434 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
6435 skip_env "User $RUNAS_ID does not exist - skipping"
6438 touch $DIR/${tfile}-f{g,u}
6439 test_mkdir $DIR/${tfile}-dg
6440 test_mkdir $DIR/${tfile}-du
6441 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6442 chmod g+s $DIR/${tfile}-{f,d}g
6443 chmod u+s $DIR/${tfile}-{f,d}u
6444 for perm in 777 2777 4777; do
6445 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6446 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6447 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6448 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6452 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6454 # bug 3462 - multiple simultaneous MDC requests
6456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6457 test_mkdir $DIR/d73-1
6458 test_mkdir $DIR/d73-2
6459 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6462 lctl set_param fail_loc=0x80000129
6463 $MULTIOP $DIR/d73-1/f73-2 Oc &
6465 lctl set_param fail_loc=0
6467 $MULTIOP $DIR/d73-2/f73-3 Oc &
6471 wait $pid1 || return 1
6475 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6476 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6477 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6481 run_test 73 "multiple MDC requests (should not deadlock)"
6483 test_74a() { # bug 6149, 6184
6484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6485 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6487 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6488 # will spin in a tight reconnection loop
6490 $LCTL set_param fail_loc=0x8000030e
6491 # get any lock that won't be difficult - lookup works.
6493 $LCTL set_param fail_loc=0
6497 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6499 test_74b() { # bug 13310
6500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6501 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6503 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6504 # will spin in a tight reconnection loop
6505 $LCTL set_param fail_loc=0x8000030e
6506 # get a "difficult" lock
6508 $LCTL set_param fail_loc=0
6512 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6516 #define OBD_FAIL_LDLM_NEW_LOCK
6517 $LCTL set_param fail_loc=0x319
6518 touch $DIR/$tfile && error "touch successful"
6519 $LCTL set_param fail_loc=0
6522 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6525 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6528 test_76() { # Now for bug 20433, added originally in bug 1443
6529 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6530 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6531 cancel_lru_locks osc
6532 BEFORE_INODES=$(num_inodes)
6533 echo "before inodes: $BEFORE_INODES"
6535 [ "$SLOW" = "no" ] && COUNT=100
6536 for i in $(seq $COUNT); do
6540 cancel_lru_locks osc
6541 AFTER_INODES=$(num_inodes)
6542 echo "after inodes: $AFTER_INODES"
6544 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6546 AFTER_INODES=$(num_inodes)
6548 echo "wait $wait seconds inodes: $AFTER_INODES"
6549 if [ $wait -gt 30 ]; then
6550 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6554 run_test 76 "confirm clients recycle inodes properly ===="
6560 # Note: in sptlrpc modes which enable its own bulk checksum, the
6561 # original crc32_le bulk checksum will be automatically disabled,
6562 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6563 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6564 # In this case set_checksums() will not be no-op, because sptlrpc
6565 # bulk checksum will be enabled all through the test.
6567 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6568 lctl set_param -n osc.*.checksums $1
6572 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6573 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6574 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
6575 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
6578 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6579 log "set checksum type to $1"
6582 F77_TMP=$TMP/f77-temp
6585 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6586 error "error writing to $F77_TMP"
6589 test_77a() { # bug 10889
6590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6591 $GSS && skip "could not run with gss" && return
6592 [ ! -f $F77_TMP ] && setup_f77
6594 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6598 run_test 77a "normal checksum read/write operation"
6600 test_77b() { # bug 10889
6601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6602 $GSS && skip "could not run with gss" && return
6603 [ ! -f $F77_TMP ] && setup_f77
6604 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6605 $LCTL set_param fail_loc=0x80000409
6608 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6609 error "dd error: $?"
6610 $LCTL set_param fail_loc=0
6612 for algo in $CKSUM_TYPES; do
6613 cancel_lru_locks osc
6614 set_checksum_type $algo
6615 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6616 $LCTL set_param fail_loc=0x80000408
6617 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6618 $LCTL set_param fail_loc=0
6621 set_checksum_type $ORIG_CSUM_TYPE
6624 run_test 77b "checksum error on client write, read"
6629 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6631 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6632 [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
6633 $check_ost && [ -n $ost_file_prefix ] &&
6634 do_facet ost1 rm -f ${ost_file_prefix}\*
6638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6639 $GSS && skip "could not run with gss" && return
6642 local osc_file_prefix
6644 local check_ost=false
6645 local ost_file_prefix
6651 # ensure corruption will occur on first OSS/OST
6652 $LFS setstripe -i 0 $DIR/$tfile
6654 [ ! -f $F77_TMP ] && setup_f77
6655 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
6656 error "dd write error: $?"
6657 fid=$($LFS path2fid $DIR/$tfile)
6659 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
6662 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
6663 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
6665 echo "OSS do not support bulk pages dump upon error"
6668 osc_file_prefix=$($LCTL get_param -n debug_path)
6669 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6671 trap cleanup_77c EXIT
6674 # enable bulk pages dump upon error on Client
6675 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
6676 # enable bulk pages dump upon error on OSS
6678 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
6680 # flush Client cache to allow next read to reach OSS
6681 cancel_lru_locks osc
6683 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6684 $LCTL set_param fail_loc=0x80000408
6685 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
6686 $LCTL set_param fail_loc=0
6690 # check cksum dump on Client
6691 osc_file=$(ls ${osc_file_prefix}*)
6692 [ -n "$osc_file" ] || error "no checksum dump file on Client"
6693 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
6694 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
6695 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
6696 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
6698 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
6699 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6700 error "dump content does not match on Client"
6702 $check_ost || { skip "No need to check cksum dump on OSS"; return 0; }
6704 # check cksum dump on OSS
6705 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
6706 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
6707 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
6708 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
6709 [[ "$orig_cksum" == "$dump_cksum" ]] ||
6710 error "dump content does not match on OSS"
6714 run_test 77c "checksum error on client read with debug"
6716 test_77d() { # bug 10889
6717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6718 $GSS && skip "could not run with gss" && return
6719 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6720 $LCTL set_param fail_loc=0x80000409
6722 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6723 error "direct write: rc=$?"
6724 $LCTL set_param fail_loc=0
6727 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
6728 $LCTL set_param fail_loc=0x80000408
6730 cancel_lru_locks osc
6731 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
6732 error "direct read: rc=$?"
6733 $LCTL set_param fail_loc=0
6736 run_test 77d "checksum error on OST direct write, read"
6738 test_77f() { # bug 10889
6739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6740 $GSS && skip "could not run with gss" && return
6742 for algo in $CKSUM_TYPES; do
6743 cancel_lru_locks osc
6744 set_checksum_type $algo
6745 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
6746 $LCTL set_param fail_loc=0x409
6747 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
6748 error "direct write succeeded"
6749 $LCTL set_param fail_loc=0
6751 set_checksum_type $ORIG_CSUM_TYPE
6754 run_test 77f "repeat checksum error on write (expect error)"
6756 test_77g() { # bug 10889
6757 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6758 $GSS && skip "could not run with gss" && return
6759 remote_ost_nodsh && skip "remote OST with nodsh" && return
6761 [ ! -f $F77_TMP ] && setup_f77
6763 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6764 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6765 do_facet ost1 lctl set_param fail_loc=0x8000021a
6767 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6768 error "write error: rc=$?"
6769 do_facet ost1 lctl set_param fail_loc=0
6772 cancel_lru_locks osc
6773 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6774 do_facet ost1 lctl set_param fail_loc=0x8000021b
6776 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6777 do_facet ost1 lctl set_param fail_loc=0
6780 run_test 77g "checksum error on OST write, read"
6782 test_77j() { # bug 13805
6783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6784 $GSS && skip "could not run with gss" && return
6785 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6786 lctl set_param fail_loc=0x40c
6787 remount_client $MOUNT
6788 lctl set_param fail_loc=0
6789 # wait async osc connect to finish and reflect updated state value
6791 for (( i=0; i < OSTCOUNT; i++ )) ; do
6792 wait_osc_import_state client ost$((i+1)) FULL
6795 for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
6796 PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
6797 algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
6798 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6800 remount_client $MOUNT
6802 run_test 77j "client only supporting ADLER32"
6804 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6813 test_78() { # bug 10901
6814 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6815 remote_ost || { skip_env "local OST" && return; }
6818 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6819 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6820 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6821 echo "MemTotal: $MEMTOTAL"
6823 # reserve 256MB of memory for the kernel and other running processes,
6824 # and then take 1/2 of the remaining memory for the read/write buffers.
6825 if [ $MEMTOTAL -gt 512 ] ;then
6826 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6828 # for those poor memory-starved high-end clusters...
6829 MEMTOTAL=$((MEMTOTAL / 2))
6831 echo "Mem to use for directio: $MEMTOTAL"
6833 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6834 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6835 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6836 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6838 echo "Smallest OST: $SMALLESTOST"
6839 [[ $SMALLESTOST -lt 10240 ]] &&
6840 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6842 trap cleanup_test_78 EXIT
6844 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6845 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6847 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6848 echo "File size: $F78SIZE"
6849 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6850 for i in $(seq 1 $NSEQ); do
6851 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6852 echo directIO rdwr round $i of $NSEQ
6853 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6858 run_test 78 "handle large O_DIRECT writes correctly ============"
6860 test_79() { # bug 12743
6861 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6862 wait_delete_completed
6864 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6865 BKFREE=$(calc_osc_kbytes kbytesfree)
6866 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6868 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6869 DFTOTAL=`echo $STRING | cut -d, -f1`
6870 DFUSED=`echo $STRING | cut -d, -f2`
6871 DFAVAIL=`echo $STRING | cut -d, -f3`
6872 DFFREE=$(($DFTOTAL - $DFUSED))
6874 ALLOWANCE=$((64 * $OSTCOUNT))
6876 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6877 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6878 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6880 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6881 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6882 error "df free($DFFREE) mismatch OST free($BKFREE)"
6884 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6885 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6886 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6889 run_test 79 "df report consistency check ======================="
6891 test_80() { # bug 10718
6892 remote_ost_nodsh && skip "remote OST with nodsh" && return
6893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6894 # relax strong synchronous semantics for slow backends like ZFS
6895 local soc="obdfilter.*.sync_on_lock_cancel"
6896 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6898 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6899 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6900 facet_active_host $host; done | sort -u)
6901 do_nodes $hosts lctl set_param $soc=never
6904 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6906 local BEFORE=`date +%s`
6907 cancel_lru_locks osc
6908 local AFTER=`date +%s`
6909 local DIFF=$((AFTER-BEFORE))
6910 if [ $DIFF -gt 1 ] ; then
6911 error "elapsed for 1M@1T = $DIFF"
6914 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6918 run_test 80 "Page eviction is equally fast at high offsets too ===="
6920 test_81a() { # LU-456
6921 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6922 remote_ost_nodsh && skip "remote OST with nodsh" && return
6923 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6924 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6925 do_facet ost1 lctl set_param fail_loc=0x80000228
6927 # write should trigger a retry and success
6928 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6929 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6931 if [ $RC -ne 0 ] ; then
6932 error "write should success, but failed for $RC"
6935 run_test 81a "OST should retry write when get -ENOSPC ==============="
6937 test_81b() { # LU-456
6938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6939 remote_ost_nodsh && skip "remote OST with nodsh" && return
6940 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6941 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6942 do_facet ost1 lctl set_param fail_loc=0x228
6944 # write should retry several times and return -ENOSPC finally
6945 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6946 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6949 if [ $RC -ne $ENOSPC ] ; then
6950 error "dd should fail for -ENOSPC, but succeed."
6953 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6955 test_82() { # LU-1031
6956 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6960 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6962 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6964 kill -USR1 $MULTIPID2
6966 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6967 error "First grouplock does not block second one"
6969 echo "Second grouplock blocks first one"
6971 kill -USR1 $MULTIPID1
6975 run_test 82 "Basic grouplock test"
6978 local sfile="/boot/System.map-$(uname -r)"
6979 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
6980 $LCTL set_param fail_loc=0x140d
6981 cp $sfile $DIR/$tfile || error "write failed"
6982 diff -c $sfile $DIR/$tfile || error "files are different"
6983 $LCTL set_param fail_loc=0
6986 run_test 83 "Short write in ptask ==============================="
6989 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6991 test_mkdir $DIR/$tdir.cvsroot
6992 chown $RUNAS_ID $DIR/$tdir.cvsroot
6995 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
6998 # some versions of cvs import exit(1) when asked to import links or
6999 # files they can't read. ignore those files.
7000 local toignore=$(find . -type l -printf '-I %f\n' -o \
7001 ! -perm /4 -printf '-I %f\n')
7002 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
7003 $tdir.reposname vtag rtag
7006 test_mkdir $DIR/$tdir.reposname
7007 chown $RUNAS_ID $DIR/$tdir.reposname
7008 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
7010 cd $DIR/$tdir.reposname
7012 $RUNAS cvs add -m 'addmsg' foo99
7014 $RUNAS cvs commit -m 'nomsg' foo99
7015 rm -fr $DIR/$tdir.cvsroot
7017 run_test 99 "cvs strange file/directory operations"
7020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7021 [[ "$NETTYPE" =~ tcp ]] ||
7022 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
7025 remote_ost_nodsh && skip "remote OST with nodsh" && return
7026 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7028 { skip "useless for local single node setup" && return; }
7030 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
7031 [ "$PROT" != "tcp" ] && continue
7032 RPORT=$(echo $REMOTE | cut -d: -f2)
7033 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
7036 LPORT=`echo $LOCAL | cut -d: -f2`
7037 if [ $LPORT -ge 1024 ]; then
7038 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
7040 error_exit "local: $LPORT > 1024, remote: $RPORT"
7043 [ "$rc" = 0 ] || error_exit "privileged port not found" )
7045 run_test 100 "check local port using privileged port ==========="
7047 function get_named_value()
7056 echo $line | sed "s/^$tag[ ]*//"
7063 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
7064 awk '/^max_cached_mb/ { print $2 }')
7067 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
7072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7073 [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
7077 local cache_limit=32
7079 $LCTL set_param -n osc.*-osc*.rpc_stats 0
7080 trap cleanup_101a EXIT
7081 $LCTL set_param -n llite.*.read_ahead_stats 0
7082 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
7085 # randomly read 10000 of 64K chunks from file 3x 32MB in size
7087 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
7088 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
7091 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
7092 get_named_value 'read but discarded' | cut -d" " -f1); do
7093 discard=$(($discard + $s))
7097 if [[ $(($discard * 10)) -gt $nreads ]]; then
7098 $LCTL get_param osc.*-osc*.rpc_stats
7099 $LCTL get_param llite.*.read_ahead_stats
7100 error "too many ($discard) discarded pages"
7102 rm -f $DIR/$tfile || true
7104 run_test 101a "check read-ahead for random reads"
7107 test_mkdir $DIR/$tdir
7108 local STRIPE_SIZE=$1
7109 local FILE_LENGTH=$2
7112 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
7114 local list=$(comma_list $(osts_nodes))
7115 set_osd_param $list '' read_cache_enable 0
7116 set_osd_param $list '' writethrough_cache_enable 0
7118 trap cleanup_test101bc EXIT
7119 # prepare the read-ahead file
7120 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
7122 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
7123 count=$FILE_SIZE_MB 2> /dev/null
7127 cleanup_test101bc() {
7132 local list=$(comma_list $(osts_nodes))
7133 set_osd_param $list '' read_cache_enable 1
7134 set_osd_param $list '' writethrough_cache_enable 1
7138 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
7143 local STRIPE_SIZE=$2
7144 local FILE_LENGTH=$3
7145 local RA_INC=1048576
7146 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
7147 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
7148 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
7149 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
7150 get_named_value 'read but discarded' |
7151 cut -d" " -f1 | calc_total)
7152 if [[ $DISCARD -gt $discard_limit ]]; then
7153 $LCTL get_param llite.*.read_ahead_stats
7154 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
7156 echo "Read-ahead success for size ${READ_SIZE}"
7161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7162 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7163 local STRIPE_SIZE=1048576
7164 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
7165 if [ $SLOW == "yes" ]; then
7166 local FILE_LENGTH=$((STRIDE_SIZE * 64))
7168 local FILE_LENGTH=$((STRIDE_SIZE * 8))
7171 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
7173 # prepare the read-ahead file
7174 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7175 cancel_lru_locks osc
7176 for BIDX in 2 4 8 16 32 64 128 256
7178 local BSIZE=$((BIDX*4096))
7179 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
7180 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
7181 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
7182 $LCTL set_param -n llite.*.read_ahead_stats 0
7183 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
7184 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
7185 cancel_lru_locks osc
7186 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
7191 run_test 101b "check stride-io mode read-ahead ================="
7194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7195 local STRIPE_SIZE=1048576
7196 local FILE_LENGTH=$((STRIPE_SIZE*100))
7200 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7202 cancel_lru_locks osc
7203 $LCTL set_param osc.*.rpc_stats 0
7204 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
7205 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
7206 local stats=$($LCTL get_param -n $osc_rpc_stats)
7207 local lines=$(echo "$stats" | awk 'END {print NR;}')
7210 if [ $lines -le 20 ]; then
7213 for size in 1 2 4 8; do
7214 local rpc=$(echo "$stats" |
7215 awk '($1 == "'$size':") {print $2; exit; }')
7217 error "Small $((size*4))k read IO $rpc !"
7219 echo "$osc_rpc_stats check passed!"
7224 run_test 101c "check stripe_size aligned read-ahead ================="
7227 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
7228 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
7232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7233 local file=$DIR/$tfile
7234 local sz_MB=${FILESIZE_101d:-500}
7235 local ra_MB=${READAHEAD_MB:-40}
7237 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
7238 [ $free_MB -lt $sz_MB ] &&
7239 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
7241 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
7242 $SETSTRIPE -c -1 $file || error "setstripe failed"
7244 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
7245 echo Cancel LRU locks on lustre client to flush the client cache
7246 cancel_lru_locks osc
7248 echo Disable read-ahead
7249 local old_READAHEAD=$(set_read_ahead 0)
7251 echo Reading the test file $file with read-ahead disabled
7252 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7254 echo Cancel LRU locks on lustre client to flush the client cache
7255 cancel_lru_locks osc
7256 echo Enable read-ahead with ${ra_MB}MB
7257 set_read_ahead $ra_MB
7259 echo Reading the test file $file with read-ahead enabled
7260 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7262 echo "read-ahead disabled time read $raOFF"
7263 echo "read-ahead enabled time read $raON"
7265 set_read_ahead $old_READAHEAD
7267 wait_delete_completed
7269 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
7270 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
7272 run_test 101d "file read with and without read-ahead enabled"
7275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7276 local file=$DIR/$tfile
7277 local size_KB=500 #KB
7281 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
7282 local need_KB=$((count * size_KB))
7283 [[ $free_KB -le $need_KB ]] &&
7284 skip_env "Need free space $need_KB, have $free_KB" && return
7286 echo "Creating $count ${size_KB}K test files"
7287 for ((i = 0; i < $count; i++)); do
7288 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
7291 echo "Cancel LRU locks on lustre client to flush the client cache"
7292 cancel_lru_locks $OSC
7294 echo "Reset readahead stats"
7295 $LCTL set_param -n llite.*.read_ahead_stats 0
7297 for ((i = 0; i < $count; i++)); do
7298 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
7301 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7302 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7304 for ((i = 0; i < $count; i++)); do
7305 rm -rf $file.$i 2>/dev/null
7308 #10000 means 20% reads are missing in readahead
7309 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7311 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7314 which iozone || { skip "no iozone installed" && return; }
7316 local old_debug=$($LCTL get_param debug)
7317 old_debug=${old_debug#*=}
7318 $LCTL set_param debug="reada mmap"
7320 # create a test file
7321 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7323 echo Cancel LRU locks on lustre client to flush the client cache
7324 cancel_lru_locks osc
7326 echo Reset readahead stats
7327 $LCTL set_param -n llite.*.read_ahead_stats 0
7329 echo mmap read the file with small block size
7330 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7333 echo checking missing pages
7334 $LCTL get_param llite.*.read_ahead_stats
7335 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7336 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7338 $LCTL set_param debug="$old_debug"
7339 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7342 run_test 101f "check mmap read performance"
7344 test_101g_brw_size_test() {
7346 local pages=$((mb * 1048576 / $(page_size)))
7348 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7349 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7350 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7351 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7355 $LCTL set_param -n osc.*.rpc_stats=0
7357 # 10 RPCs should be enough for the test
7359 dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
7360 { error "dd write ${mb} MB blocks failed"; return 3; }
7361 cancel_lru_locks osc
7362 dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
7363 { error "dd write ${mb} MB blocks failed"; return 4; }
7365 # calculate number of full-sized read and write RPCs
7366 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7367 sed -n '/pages per rpc/,/^$/p' |
7368 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7369 END { print reads,writes }'))
7370 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7372 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7380 local osts=$(get_facets OST)
7381 local list=$(comma_list $(osts_nodes))
7382 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7383 local brw_size="obdfilter.*.brw_size"
7384 local ostver=$(lustre_version_code ost1)
7385 local cliver=$(lustre_version_code client)
7387 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7389 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7390 if [ $ostver -ge $(version_code 2.8.52) -o \
7391 \( $ostver -ge $(version_code 2.7.17) -a \
7392 $ostver -lt $(version_code 2.7.50) \) ] &&
7393 [ $cliver -ge $(version_code 2.8.52) -o \
7394 \( $cliver -ge $(version_code 2.7.17) -a \
7395 $cliver -lt $(version_code 2.7.50) \) ]; then
7396 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7397 if [[ $orig_mb -lt 16 ]]; then
7398 save_lustre_params $osts "$brw_size" > $p
7399 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7400 error "set 16MB RPC size failed"
7402 echo "remount client to enable new RPC size"
7403 remount_client $MOUNT || error "remount_client failed"
7406 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7407 # should be able to set brw_size=12, but no rpc_stats for that
7408 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7411 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7413 if [[ $orig_mb -lt 16 ]]; then
7414 restore_lustre_params < $p
7415 remount_client $MOUNT || error "remount_client restore failed"
7418 rm -f $p $DIR/$tfile
7420 run_test 101g "Big bulk(4/16 MiB) readahead"
7423 test_mkdir $DIR/$tdir
7424 chown $RUNAS_ID $DIR/$tdir
7427 STRIPE_COUNT=$OSTCOUNT
7428 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7430 trap cleanup_test102 EXIT
7432 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7434 for num in 1 2 3 4; do
7435 for count in $(seq 1 $STRIPE_COUNT); do
7436 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7437 local size=`expr $STRIPE_SIZE \* $num`
7438 local file=file"$num-$idx-$count"
7439 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7445 $1 tar cf $TMP/f102.tar $tdir --xattrs
7451 rm -rf $DIR/d0.sanity/d102
7455 local testfile=$DIR/$tfile
7459 [ "$UID" != 0 ] && skip_env "must run as root" && return
7460 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7461 skip_env "must have user_xattr" && return
7463 [ -z "$(which setfattr 2>/dev/null)" ] &&
7464 skip_env "could not find setfattr" && return
7466 echo "set/get xattr..."
7467 setfattr -n trusted.name1 -v value1 $testfile ||
7468 error "setfattr -n trusted.name1=value1 $testfile failed"
7469 getfattr -n trusted.name1 $testfile 2> /dev/null |
7470 grep "trusted.name1=.value1" ||
7471 error "$testfile missing trusted.name1=value1"
7473 setfattr -n user.author1 -v author1 $testfile ||
7474 error "setfattr -n user.author1=author1 $testfile failed"
7475 getfattr -n user.author1 $testfile 2> /dev/null |
7476 grep "user.author1=.author1" ||
7477 error "$testfile missing trusted.author1=author1"
7480 setfattr -n trusted.name2 -v value2 $testfile ||
7481 error "$testfile unable to set trusted.name2"
7482 setfattr -n trusted.name3 -v value3 $testfile ||
7483 error "$testfile unable to set trusted.name3"
7484 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7485 grep "trusted.name" | wc -l) -eq 3 ] ||
7486 error "$testfile missing 3 trusted.name xattrs"
7488 setfattr -n user.author2 -v author2 $testfile ||
7489 error "$testfile unable to set user.author2"
7490 setfattr -n user.author3 -v author3 $testfile ||
7491 error "$testfile unable to set user.author3"
7492 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7493 grep "user.author" | wc -l) -eq 3 ] ||
7494 error "$testfile missing 3 user.author xattrs"
7496 echo "remove xattr..."
7497 setfattr -x trusted.name1 $testfile ||
7498 error "$testfile error deleting trusted.name1"
7499 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7500 error "$testfile did not delete trusted.name1 xattr"
7502 setfattr -x user.author1 $testfile ||
7503 error "$testfile error deleting user.author1"
7504 echo "set lustre special xattr ..."
7505 $LFS setstripe -c1 $testfile
7506 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7507 awk -F "=" '/trusted.lov/ { print $2 }' )
7508 setfattr -n "trusted.lov" -v $lovea $testfile ||
7509 error "$testfile doesn't ignore setting trusted.lov again"
7510 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7511 error "$testfile allow setting invalid trusted.lov"
7514 run_test 102a "user xattr test =================================="
7517 [ -z "$(which setfattr 2>/dev/null)" ] &&
7518 skip_env "could not find setfattr" && return
7520 # b10930: get/set/list trusted.lov xattr
7521 echo "get/set/list trusted.lov xattr ..."
7522 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7523 local testfile=$DIR/$tfile
7524 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7525 error "setstripe failed"
7526 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7527 error "getstripe failed"
7528 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7529 error "can't get trusted.lov from $testfile"
7531 local testfile2=${testfile}2
7532 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7533 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7536 setfattr -n trusted.lov -v $value $testfile2
7537 local stripe_size=$($GETSTRIPE -S $testfile2)
7538 local stripe_count=$($GETSTRIPE -c $testfile2)
7539 [[ $stripe_size -eq 65536 ]] ||
7540 error "stripe size $stripe_size != 65536"
7541 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7542 error "stripe count $stripe_count != $STRIPECOUNT"
7545 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7548 [ -z "$(which setfattr 2>/dev/null)" ] &&
7549 skip_env "could not find setfattr" && return
7551 # b10930: get/set/list lustre.lov xattr
7552 echo "get/set/list lustre.lov xattr ..."
7553 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7554 test_mkdir $DIR/$tdir
7555 chown $RUNAS_ID $DIR/$tdir
7556 local testfile=$DIR/$tdir/$tfile
7557 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7558 error "setstripe failed"
7559 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7560 error "getstripe failed"
7561 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7562 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
7564 local testfile2=${testfile}2
7565 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
7566 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
7568 $RUNAS $MCREATE $testfile2
7569 $RUNAS setfattr -n lustre.lov -v $value $testfile2
7570 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
7571 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
7572 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
7573 [ $stripe_count -eq $STRIPECOUNT ] ||
7574 error "stripe count $stripe_count != $STRIPECOUNT"
7576 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
7578 compare_stripe_info1() {
7579 local stripe_index_all_zero=true
7581 for num in 1 2 3 4; do
7582 for count in $(seq 1 $STRIPE_COUNT); do
7583 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
7584 local size=$((STRIPE_SIZE * num))
7585 local file=file"$num-$offset-$count"
7586 stripe_size=$($LFS getstripe -S $PWD/$file)
7587 [[ $stripe_size -ne $size ]] &&
7588 error "$file: size $stripe_size != $size"
7589 stripe_count=$($LFS getstripe -c $PWD/$file)
7590 # allow fewer stripes to be created, ORI-601
7591 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
7592 error "$file: count $stripe_count != $count"
7593 stripe_index=$($LFS getstripe -i $PWD/$file)
7594 [[ $stripe_index -ne 0 ]] &&
7595 stripe_index_all_zero=false
7599 $stripe_index_all_zero &&
7600 error "all files are being extracted starting from OST index 0"
7604 have_xattrs_include() {
7605 tar --help | grep -q xattrs-include &&
7606 echo --xattrs-include="lustre.*"
7610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7611 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7612 XINC=$(have_xattrs_include)
7614 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7616 compare_stripe_info1
7618 run_test 102d "tar restore stripe info from tarfile,not keep osts"
7621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7622 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7623 XINC=$(have_xattrs_include)
7625 test_mkdir $DIR/$tdir.restore
7627 tar cf - --xattrs $tdir | tar xf - \
7628 -C $DIR/$tdir.restore --xattrs $XINC
7629 cd $DIR/$tdir.restore/$tdir
7630 compare_stripe_info1
7632 run_test 102f "tar copy files, not keep osts"
7635 local xsize=${1:-1024} # in bytes
7636 local file=$DIR/$tfile
7638 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
7639 skip "must have user_xattr" && return 0
7640 [ -z "$(which setfattr 2>/dev/null)" ] &&
7641 skip_env "could not find setfattr" && return 0
7642 [ -z "$(which getfattr 2>/dev/null)" ] &&
7643 skip_env "could not find getfattr" && return 0
7647 local value="$(generate_string $xsize)"
7649 local xbig=trusted.big
7650 log "save $xbig on $file"
7651 setfattr -n $xbig -v $value $file ||
7652 error "saving $xbig on $file failed"
7654 local orig=$(get_xattr_value $xbig $file)
7655 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
7657 local xsml=trusted.sml
7658 log "save $xsml on $file"
7659 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
7661 local new=$(get_xattr_value $xbig $file)
7662 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
7664 log "grow $xsml on $file"
7665 setfattr -n $xsml -v "$value" $file ||
7666 error "growing $xsml on $file failed"
7668 new=$(get_xattr_value $xbig $file)
7669 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
7670 log "$xbig still valid after growing $xsml"
7675 test_102h() { # bug 15777
7678 run_test 102h "grow xattr from inside inode to external block"
7681 large_xattr_enabled || { skip "large_xattr disabled" && return; }
7682 grow_xattr $(max_xattr_size)
7684 run_test 102ha "grow xattr from inside inode to external inode"
7686 test_102i() { # bug 17038
7687 [ -z "$(which getfattr 2>/dev/null)" ] &&
7688 skip "could not find getfattr" && return
7690 ln -s $DIR/$tfile $DIR/${tfile}link
7691 getfattr -n trusted.lov $DIR/$tfile ||
7692 error "lgetxattr on $DIR/$tfile failed"
7693 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
7694 grep -i "no such attr" ||
7695 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
7696 rm -f $DIR/$tfile $DIR/${tfile}link
7698 run_test 102i "lgetxattr test on symbolic link ============"
7701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7702 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
7703 XINC=$(have_xattrs_include)
7704 setup_test102 "$RUNAS"
7705 chown $RUNAS_ID $DIR/$tdir
7706 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
7708 compare_stripe_info1 "$RUNAS"
7710 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
7713 [ -z "$(which setfattr 2>/dev/null)" ] &&
7714 skip "could not find setfattr" && return
7716 # b22187 just check that does not crash for regular file.
7717 setfattr -n trusted.lov $DIR/$tfile
7718 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
7719 local test_kdir=$DIR/$tdir
7720 test_mkdir $test_kdir
7721 local default_size=$($LFS getstripe -S $test_kdir)
7722 local default_count=$($LFS getstripe -c $test_kdir)
7723 local default_offset=$($LFS getstripe -i $test_kdir)
7724 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
7725 error 'dir setstripe failed'
7726 setfattr -n trusted.lov $test_kdir
7727 local stripe_size=$($LFS getstripe -S $test_kdir)
7728 local stripe_count=$($LFS getstripe -c $test_kdir)
7729 local stripe_offset=$($LFS getstripe -i $test_kdir)
7730 [ $stripe_size -eq $default_size ] ||
7731 error "stripe size $stripe_size != $default_size"
7732 [ $stripe_count -eq $default_count ] ||
7733 error "stripe count $stripe_count != $default_count"
7734 [ $stripe_offset -eq $default_offset ] ||
7735 error "stripe offset $stripe_offset != $default_offset"
7736 rm -rf $DIR/$tfile $test_kdir
7738 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
7741 [ -z "$(which getfattr 2>/dev/null)" ] &&
7742 skip "could not find getfattr" && return
7744 # LU-532 trusted. xattr is invisible to non-root
7745 local testfile=$DIR/$tfile
7749 echo "listxattr as user..."
7750 chown $RUNAS_ID $testfile
7751 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
7752 grep -q "trusted" &&
7753 error "$testfile trusted xattrs are user visible"
7757 run_test 102l "listxattr size test =================================="
7759 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
7760 local path=$DIR/$tfile
7763 listxattr_size_check $path || error "listattr_size_check $path failed"
7765 run_test 102m "Ensure listxattr fails on small bufffer ========"
7769 getxattr() { # getxattr path name
7770 # Return the base64 encoding of the value of xattr name on path.
7774 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
7776 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7778 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
7780 getfattr --absolute-names --encoding=base64 --name=$name $path |
7781 awk -F= -v name=$name '$1 == name {
7782 print substr($0, index($0, "=") + 1);
7786 test_102n() { # LU-4101 mdt: protect internal xattrs
7787 [ -z "$(which setfattr 2>/dev/null)" ] &&
7788 skip "could not find setfattr" && return
7789 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
7791 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
7795 local file0=$DIR/$tfile.0
7796 local file1=$DIR/$tfile.1
7797 local xattr0=$TMP/$tfile.0
7798 local xattr1=$TMP/$tfile.1
7799 local namelist="lov lma lmv link fid version som hsm"
7803 rm -rf $file0 $file1 $xattr0 $xattr1
7806 # Get 'before' xattrs of $file1.
7807 getfattr --absolute-names --dump --match=- $file1 > $xattr0
7809 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
7810 namelist+=" lfsck_namespace"
7811 for name in $namelist; do
7812 # Try to copy xattr from $file0 to $file1.
7813 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7815 setfattr --name=trusted.$name --value="$value" $file1 ||
7816 error "setxattr 'trusted.$name' failed"
7818 # Try to set a garbage xattr.
7819 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7821 if [[ x$name == "xlov" ]]; then
7822 setfattr --name=trusted.lov --value="$value" $file1 &&
7823 error "setxattr invalid 'trusted.lov' success"
7825 setfattr --name=trusted.$name --value="$value" $file1 ||
7826 error "setxattr invalid 'trusted.$name' failed"
7829 # Try to remove the xattr from $file1. We don't care if this
7830 # appears to succeed or fail, we just don't want there to be
7831 # any changes or crashes.
7832 setfattr --remove=$trusted.$name $file1 2> /dev/null
7835 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7838 # Try to copy xattr from $file0 to $file1.
7839 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7841 setfattr --name=trusted.$name --value="$value" $file1 ||
7842 error "setxattr 'trusted.$name' failed"
7844 # Try to set a garbage xattr.
7845 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7847 setfattr --name=trusted.$name --value="$value" $file1 ||
7848 error "setxattr 'trusted.$name' failed"
7850 # Try to remove the xattr from $file1. We don't care if this
7851 # appears to succeed or fail, we just don't want there to be
7852 # any changes or crashes.
7853 setfattr --remove=$trusted.$name $file1 2> /dev/null
7856 # Get 'after' xattrs of file1.
7857 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7859 if ! diff $xattr0 $xattr1; then
7860 error "before and after xattrs of '$file1' differ"
7863 rm -rf $file0 $file1 $xattr0 $xattr1
7867 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7869 test_102p() { # LU-4703 setxattr did not check ownership
7870 local testfile=$DIR/$tfile
7872 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7873 skip "MDS needs to be at least 2.5.56" && return
7877 echo "setfacl as user..."
7878 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7879 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7881 echo "setfattr as user..."
7882 setfacl -m "u:$RUNAS_ID:---" $testfile
7883 $RUNAS setfattr -x system.posix_acl_access $testfile
7884 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7886 run_test 102p "check setxattr(2) correctly fails without permission"
7889 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7890 skip "MDS needs to be at least 2.6.92" && return
7891 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7893 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7896 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7897 skip "MDS needs to be at least 2.6.93" && return
7898 touch $DIR/$tfile || error "touch"
7899 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7900 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7901 rm $DIR/$tfile || error "rm"
7904 mkdir -p $DIR/$tdir || error "mkdir"
7905 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7906 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7907 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7908 error "$testfile error deleting user.author1"
7909 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7910 grep "user.$(basename $tdir)" &&
7911 error "$tdir did not delete user.$(basename $tdir)"
7912 rmdir $DIR/$tdir || error "rmdir"
7915 test_mkdir $DIR/$tdir
7916 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7917 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7918 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7919 error "$testfile error deleting user.author1"
7920 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7921 grep "user.$(basename $tdir)" &&
7922 error "$tdir did not delete user.$(basename $tdir)"
7923 rmdir $DIR/$tdir || error "rm striped dir"
7925 run_test 102r "set EAs with empty values"
7929 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7934 [ "$UID" != 0 ] && skip_env "must run as root" && return
7935 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7936 skip "must have acl enabled" && return
7937 [ -z "$(which setfacl 2>/dev/null)" ] &&
7938 skip_env "could not find setfacl" && return
7939 $GSS && skip "could not run under gss" && return
7940 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7942 gpasswd -a daemon bin # LU-5641
7943 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7945 declare -a identity_old
7947 for num in $(seq $MDSCOUNT); do
7948 switch_identity $num true || identity_old[$num]=$?
7956 echo "performing cp ..."
7957 run_acl_subtest cp || error "run_acl_subtest cp failed"
7958 echo "performing getfacl-noacl..."
7959 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7960 echo "performing misc..."
7961 run_acl_subtest misc || error "misc test failed"
7962 echo "performing permissions..."
7963 run_acl_subtest permissions || error "permissions failed"
7964 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
7965 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
7966 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
7967 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
7969 echo "performing permissions xattr..."
7970 run_acl_subtest permissions_xattr ||
7971 error "permissions_xattr failed"
7973 echo "performing setfacl..."
7974 run_acl_subtest setfacl || error "setfacl test failed"
7976 # inheritance test got from HP
7977 echo "performing inheritance..."
7978 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7979 chmod +x make-tree || error "chmod +x failed"
7980 run_acl_subtest inheritance || error "inheritance test failed"
7983 echo "LU-974 ignore umask when acl is enabled..."
7984 run_acl_subtest 974 || error "LU-974 umask test failed"
7985 if [ $MDSCOUNT -ge 2 ]; then
7986 run_acl_subtest 974_remote ||
7987 error "LU-974 umask test failed under remote dir"
7990 echo "LU-2561 newly created file is same size as directory..."
7991 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7992 run_acl_subtest 2561 || error "LU-2561 test failed"
7994 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7997 run_acl_subtest 4924 || error "LU-4924 test failed"
8002 for num in $(seq $MDSCOUNT); do
8003 if [ "${identity_old[$num]}" = 1 ]; then
8004 switch_identity $num false || identity_old[$num]=$?
8008 run_test 103a "acl test ========================================="
8012 cp -rp $DIR/$tdir $DIR/$tdir.bak
8014 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
8015 error "$DIR/$tdir shouldn't contain default ACL"
8016 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
8017 error "$DIR/$tdir.bak shouldn't contain default ACL"
8020 run_test 103c "'cp -rp' won't set empty acl"
8023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8025 lfs df || error "lfs df failed"
8026 lfs df -ih || error "lfs df -ih failed"
8027 lfs df -h $DIR || error "lfs df -h $DIR failed"
8028 lfs df -i $DIR || error "lfs df -i $DIR failed"
8029 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
8030 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
8032 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
8033 lctl --device %$OSC deactivate
8034 lfs df || error "lfs df with deactivated OSC failed"
8035 lctl --device %$OSC activate
8036 # wait the osc back to normal
8037 wait_osc_import_state client ost FULL
8039 lfs df || error "lfs df with reactivated OSC failed"
8042 run_test 104a "lfs df [-ih] [path] test ========================="
8045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8046 [ $RUNAS_ID -eq $UID ] &&
8047 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
8049 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
8050 grep "Permission denied" | wc -l)))
8051 if [ $denied_cnt -ne 0 ]; then
8052 error "lfs check servers test failed"
8055 run_test 104b "$RUNAS lfs check servers test ===================="
8058 # doesn't work on 2.4 kernels
8060 if $(flock_is_enabled); then
8061 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
8063 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
8067 run_test 105a "flock when mounted without -o flock test ========"
8071 if $(flock_is_enabled); then
8072 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
8074 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
8078 run_test 105b "fcntl when mounted without -o flock test ========"
8082 if $(flock_is_enabled); then
8083 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
8085 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
8089 run_test 105c "lockf when mounted without -o flock test"
8091 test_105d() { # bug 15924
8092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8093 test_mkdir $DIR/$tdir
8094 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
8095 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
8096 $LCTL set_param fail_loc=0x80000315
8097 flocks_test 2 $DIR/$tdir
8099 run_test 105d "flock race (should not freeze) ========"
8101 test_105e() { # bug 22660 && 22040
8102 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
8104 flocks_test 3 $DIR/$tfile
8106 run_test 105e "Two conflicting flocks from same process"
8108 test_106() { #bug 10921
8109 test_mkdir $DIR/$tdir
8110 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
8111 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
8113 run_test 106 "attempt exec of dir followed by chown of that dir"
8116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8123 local save_pattern=$(sysctl -n kernel.core_pattern)
8124 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
8125 sysctl -w kernel.core_pattern=$file
8126 sysctl -w kernel.core_uses_pid=0
8134 kill -s 11 $SLEEPPID
8136 if [ -e $file ]; then
8137 size=`stat -c%s $file`
8138 [ $size -eq 0 ] && error "Fail to create core file $file"
8140 error "Fail to create core file $file"
8143 sysctl -w kernel.core_pattern=$save_pattern
8144 sysctl -w kernel.core_uses_pid=$save_uses_pid
8147 run_test 107 "Coredump on SIG"
8150 test_mkdir $DIR/$tdir
8151 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
8152 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
8153 error "mkdir with 256 char should fail, but did not"
8154 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
8155 error "create with 255 char failed"
8156 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
8157 error "create with 256 char should fail, but did not"
8162 run_test 110 "filename length checking"
8165 # Purpose: To verify dynamic thread (OSS) creation.
8168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8169 remote_ost_nodsh && skip "remote OST with nodsh" && return
8171 # Lustre does not stop service threads once they are started.
8172 # Reset number of running threads to default.
8177 local save_params="$TMP/sanity-$TESTNAME.parameters"
8179 # Get ll_ost_io count before I/O
8180 OSTIO_pre=$(do_facet ost1 \
8181 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
8182 # Exit if lustre is not running (ll_ost_io not running).
8183 [ -z "$OSTIO_pre" ] && error "no OSS threads"
8185 echo "Starting with $OSTIO_pre threads"
8186 local thread_max=$((OSTIO_pre * 2))
8187 local rpc_in_flight=$((thread_max * 2))
8188 # Number of I/O Process proposed to be started.
8190 local facets=$(get_facets OST)
8192 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
8193 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
8195 # Set in_flight to $rpc_in_flight
8196 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
8197 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
8198 nfiles=${rpc_in_flight}
8199 # Set ost thread_max to $thread_max
8200 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
8202 # 5 Minutes should be sufficient for max number of OSS
8203 # threads(thread_max) to be created.
8207 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
8208 test_mkdir $DIR/$tdir
8209 for i in $(seq $nfiles); do
8210 local file=$DIR/$tdir/${tfile}-$i
8211 $LFS setstripe -c -1 -i 0 $file
8212 ($WTL $file $timeout)&
8215 # I/O Started - Wait for thread_started to reach thread_max or report
8216 # error if thread_started is more than thread_max.
8217 echo "Waiting for thread_started to reach thread_max"
8218 local thread_started=0
8219 local end_time=$((SECONDS + timeout))
8221 while [ $SECONDS -le $end_time ] ; do
8223 # Get ost i/o thread_started count.
8224 thread_started=$(do_facet ost1 \
8226 ost.OSS.ost_io.threads_started | cut -d= -f2")
8227 # Break out if thread_started is equal/greater than thread_max
8228 if [[ $thread_started -ge $thread_max ]]; then
8229 echo ll_ost_io thread_started $thread_started, \
8230 equal/greater than thread_max $thread_max
8236 # Cleanup - We have the numbers, Kill i/o jobs if running.
8237 jobcount=($(jobs -p))
8238 for i in $(seq 0 $((${#jobcount[@]}-1)))
8240 kill -9 ${jobcount[$i]}
8241 if [ $? -ne 0 ] ; then
8243 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8247 # Cleanup files left by WTL binary.
8248 for i in $(seq $nfiles); do
8249 local file=$DIR/$tdir/${tfile}-$i
8251 if [ $? -ne 0 ] ; then
8252 echo "Warning: Failed to delete file $file"
8256 restore_lustre_params <$save_params
8257 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8259 # Error out if no new thread has started or Thread started is greater
8261 if [[ $thread_started -le $OSTIO_pre ||
8262 $thread_started -gt $thread_max ]]; then
8263 error "ll_ost_io: thread_started $thread_started" \
8264 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
8265 "No new thread started or thread started greater " \
8269 run_test 115 "verify dynamic thread creation===================="
8272 wait_delete_completed
8273 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8274 echo "OST kbytes available: ${AVAIL[@]}"
8279 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8280 #echo OST $i: ${AVAIL[i]}kb
8281 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8285 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8290 echo "Min free space: OST $MINI: $MINV"
8291 echo "Max free space: OST $MAXI: $MAXV"
8294 test_116a() { # was previously test_116()
8295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8296 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8298 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8300 echo -n "Free space priority "
8301 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
8306 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
8307 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
8309 trap simple_cleanup_common EXIT
8312 # Check if we need to generate uneven OSTs
8313 test_mkdir -p $DIR/$tdir/OST${MINI}
8314 local FILL=$((MINV / 4))
8315 local DIFF=$((MAXV - MINV))
8316 local DIFF2=$((DIFF * 100 / MINV))
8318 local threshold=$(do_facet $SINGLEMDS \
8319 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
8320 threshold=${threshold%%%}
8321 echo -n "Check for uneven OSTs: "
8322 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
8324 if [[ $DIFF2 -gt $threshold ]]; then
8326 echo "Don't need to fill OST$MINI"
8328 # generate uneven OSTs. Write 2% over the QOS threshold value
8330 DIFF=$((threshold - DIFF2 + 2))
8331 DIFF2=$((MINV * DIFF / 100))
8332 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
8333 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
8334 error "setstripe failed"
8335 DIFF=$((DIFF2 / 2048))
8337 while [ $i -lt $DIFF ]; do
8339 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8340 bs=2M count=1 2>/dev/null
8349 DIFF=$((MAXV - MINV))
8350 DIFF2=$((DIFF * 100 / MINV))
8351 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8352 if [ $DIFF2 -gt $threshold ]; then
8355 echo "failed - QOS mode won't be used"
8356 skip "QOS imbalance criteria not met"
8357 simple_cleanup_common
8366 # now fill using QOS
8367 $SETSTRIPE -c 1 $DIR/$tdir
8368 FILL=$((FILL / 200))
8369 if [ $FILL -gt 600 ]; then
8372 echo "writing $FILL files to QOS-assigned OSTs"
8374 while [ $i -lt $FILL ]; do
8376 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8380 echo "wrote $i 200k files"
8384 echo "Note: free space may not be updated, so measurements might be off"
8386 DIFF2=$((MAXV - MINV))
8387 echo "free space delta: orig $DIFF final $DIFF2"
8388 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8389 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8390 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8391 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8392 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8393 if [[ $DIFF -gt 0 ]]; then
8394 FILL=$((DIFF2 * 100 / DIFF - 100))
8395 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8398 # Figure out which files were written where
8399 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8400 awk '/'$MINI1': / {print $2; exit}')
8402 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8403 echo "$MINC files created on smaller OST $MINI1"
8404 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8405 awk '/'$MAXI1': / {print $2; exit}')
8407 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8408 echo "$MAXC files created on larger OST $MAXI1"
8409 if [[ $MINC -gt 0 ]]; then
8410 FILL=$((MAXC * 100 / MINC - 100))
8411 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8413 [[ $MAXC -gt $MINC ]] ||
8414 error_ignore LU-9 "stripe QOS didn't balance free space"
8415 simple_cleanup_common
8417 run_test 116a "stripe QOS: free space balance ==================="
8419 test_116b() { # LU-2093
8420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8421 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8423 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8424 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8425 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8426 [ -z "$old_rr" ] && skip "no QOS" && return 0
8427 do_facet $SINGLEMDS lctl set_param \
8428 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8430 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8431 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8432 do_facet $SINGLEMDS lctl set_param fail_loc=0
8434 do_facet $SINGLEMDS lctl set_param \
8435 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8437 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8439 test_117() # bug 10891
8441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8442 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8443 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8444 lctl set_param fail_loc=0x21e
8445 > $DIR/$tfile || error "truncate failed"
8446 lctl set_param fail_loc=0
8447 echo "Truncate succeeded."
8450 run_test 117 "verify osd extend =========="
8452 NO_SLOW_RESENDCOUNT=4
8453 export OLD_RESENDCOUNT=""
8454 set_resend_count () {
8455 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8456 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8457 lctl set_param -n $PROC_RESENDCOUNT $1
8458 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8461 # for reduce test_118* time (b=14842)
8462 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8464 # Reset async IO behavior after error case
8466 FILE=$DIR/reset_async
8468 # Ensure all OSCs are cleared
8469 $SETSTRIPE -c -1 $FILE
8470 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8475 test_118a() #bug 11710
8477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8480 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8481 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8482 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8484 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8485 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8490 run_test 118a "verify O_SYNC works =========="
8494 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8495 remote_ost_nodsh && skip "remote OST with nodsh" && return
8499 #define OBD_FAIL_SRV_ENOENT 0x217
8500 set_nodes_failloc "$(osts_nodes)" 0x217
8501 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8503 set_nodes_failloc "$(osts_nodes)" 0
8504 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8505 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8508 if [[ $RC -eq 0 ]]; then
8509 error "Must return error due to dropped pages, rc=$RC"
8513 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8514 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8518 echo "Dirty pages not leaked on ENOENT"
8520 # Due to the above error the OSC will issue all RPCs syncronously
8521 # until a subsequent RPC completes successfully without error.
8522 $MULTIOP $DIR/$tfile Ow4096yc
8527 run_test 118b "Reclaim dirty pages on fatal error =========="
8531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8533 # for 118c, restore the original resend count, LU-1940
8534 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
8535 set_resend_count $OLD_RESENDCOUNT
8536 remote_ost_nodsh && skip "remote OST with nodsh" && return
8540 #define OBD_FAIL_OST_EROFS 0x216
8541 set_nodes_failloc "$(osts_nodes)" 0x216
8543 # multiop should block due to fsync until pages are written
8544 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8548 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8549 error "Multiop failed to block on fsync, pid=$MULTIPID"
8552 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8554 if [[ $WRITEBACK -eq 0 ]]; then
8555 error "No page in writeback, writeback=$WRITEBACK"
8558 set_nodes_failloc "$(osts_nodes)" 0
8561 if [[ $RC -ne 0 ]]; then
8562 error "Multiop fsync failed, rc=$RC"
8565 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8566 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8568 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8569 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8573 echo "Dirty pages flushed via fsync on EROFS"
8576 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
8578 # continue to use small resend count to reduce test_118* time (b=14842)
8579 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8584 remote_ost_nodsh && skip "remote OST with nodsh" && return
8588 #define OBD_FAIL_OST_BRW_PAUSE_BULK
8589 set_nodes_failloc "$(osts_nodes)" 0x214
8590 # multiop should block due to fsync until pages are written
8591 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8595 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
8596 error "Multiop failed to block on fsync, pid=$MULTIPID"
8599 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8601 if [[ $WRITEBACK -eq 0 ]]; then
8602 error "No page in writeback, writeback=$WRITEBACK"
8605 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
8606 set_nodes_failloc "$(osts_nodes)" 0
8608 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8609 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8611 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8612 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8616 echo "Dirty pages gaurenteed flushed via fsync"
8619 run_test 118d "Fsync validation inject a delay of the bulk =========="
8622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8625 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
8626 lctl set_param fail_loc=0x8000040a
8628 # Should simulate EINVAL error which is fatal
8629 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8631 if [[ $RC -eq 0 ]]; then
8632 error "Must return error due to dropped pages, rc=$RC"
8635 lctl set_param fail_loc=0x0
8637 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8638 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8639 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8641 if [[ $LOCKED -ne 0 ]]; then
8642 error "Locked pages remain in cache, locked=$LOCKED"
8645 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8646 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8650 echo "No pages locked after fsync"
8655 run_test 118f "Simulate unrecoverable OSC side error =========="
8658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8661 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
8662 lctl set_param fail_loc=0x406
8664 # simulate local -ENOMEM
8665 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8668 lctl set_param fail_loc=0
8669 if [[ $RC -eq 0 ]]; then
8670 error "Must return error due to dropped pages, rc=$RC"
8673 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8674 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8675 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8677 if [[ $LOCKED -ne 0 ]]; then
8678 error "Locked pages remain in cache, locked=$LOCKED"
8681 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8682 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8686 echo "No pages locked after fsync"
8691 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
8694 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8695 remote_ost_nodsh && skip "remote OST with nodsh" && return
8699 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8700 set_nodes_failloc "$(osts_nodes)" 0x20e
8701 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8702 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8705 set_nodes_failloc "$(osts_nodes)" 0
8706 if [[ $RC -eq 0 ]]; then
8707 error "Must return error due to dropped pages, rc=$RC"
8710 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8711 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8712 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
8714 if [[ $LOCKED -ne 0 ]]; then
8715 error "Locked pages remain in cache, locked=$LOCKED"
8718 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8719 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8723 echo "No pages locked after fsync"
8727 run_test 118h "Verify timeout in handling recoverables errors =========="
8729 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8733 remote_ost_nodsh && skip "remote OST with nodsh" && return
8737 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8738 set_nodes_failloc "$(osts_nodes)" 0x20e
8740 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
8741 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
8744 set_nodes_failloc "$(osts_nodes)" 0
8748 if [[ $RC -ne 0 ]]; then
8749 error "got error, but should be not, rc=$RC"
8752 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8753 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8754 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8755 if [[ $LOCKED -ne 0 ]]; then
8756 error "Locked pages remain in cache, locked=$LOCKED"
8759 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8760 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8764 echo "No pages locked after fsync"
8768 run_test 118i "Fix error before timeout in recoverable error =========="
8770 [ "$SLOW" = "no" ] && set_resend_count 4
8773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8774 remote_ost_nodsh && skip "remote OST with nodsh" && return
8778 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
8779 set_nodes_failloc "$(osts_nodes)" 0x220
8781 # return -EIO from OST
8782 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8784 set_nodes_failloc "$(osts_nodes)" 0x0
8785 if [[ $RC -eq 0 ]]; then
8786 error "Must return error due to dropped pages, rc=$RC"
8789 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
8790 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8791 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8792 if [[ $LOCKED -ne 0 ]]; then
8793 error "Locked pages remain in cache, locked=$LOCKED"
8796 # in recoverable error on OST we want resend and stay until it finished
8797 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8798 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8802 echo "No pages locked after fsync"
8806 run_test 118j "Simulate unrecoverable OST side error =========="
8810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8811 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8813 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
8814 set_nodes_failloc "$(osts_nodes)" 0x20e
8815 test_mkdir $DIR/$tdir
8817 for ((i=0;i<10;i++)); do
8818 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
8819 error "dd to $DIR/$tdir/$tfile-$i failed" )&
8826 set_nodes_failloc "$(osts_nodes)" 0
8829 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
8833 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8835 test_mkdir $DIR/$tdir
8836 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
8839 run_test 118l "fsync dir"
8841 test_118m() # LU-3066
8843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8844 test_mkdir $DIR/$tdir
8845 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
8848 run_test 118m "fdatasync dir ========="
8850 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
8857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8858 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
8860 # Sleep to avoid a cached response.
8861 #define OBD_STATFS_CACHE_SECONDS 1
8864 # Inject a 10 second delay in the OST_STATFS handler.
8865 #define OBD_FAIL_OST_STATFS_DELAY 0x242
8866 set_nodes_failloc "$(osts_nodes)" 0x242
8869 stat --file-system $MOUNT > /dev/null
8872 set_nodes_failloc "$(osts_nodes)" 0
8874 if ((end - begin > 20)); then
8875 error "statfs took $((end - begin)) seconds, expected 10"
8878 run_test 118n "statfs() sends OST_STATFS requests in parallel"
8880 test_119a() # bug 11737
8882 BSIZE=$((512 * 1024))
8883 directio write $DIR/$tfile 0 1 $BSIZE
8884 # We ask to read two blocks, which is more than a file size.
8885 # directio will indicate an error when requested and actual
8886 # sizes aren't equeal (a normal situation in this case) and
8887 # print actual read amount.
8888 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
8889 if [ "$NOB" != "$BSIZE" ]; then
8890 error "read $NOB bytes instead of $BSIZE"
8894 run_test 119a "Short directIO read must return actual read amount"
8896 test_119b() # bug 11737
8898 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
8900 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
8901 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
8903 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
8904 error "direct read failed"
8907 run_test 119b "Sparse directIO read must return actual read amount"
8909 test_119c() # bug 13099
8912 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8913 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8916 run_test 119c "Testing for direct read hitting hole"
8918 test_119d() # bug 15950
8920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8921 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8922 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8924 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8925 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8926 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8927 lctl set_param fail_loc=0x40d
8928 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8931 cat $DIR/$tfile > /dev/null &
8932 lctl set_param fail_loc=0
8935 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8937 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8938 error "the read rpcs have not completed in 2s"
8940 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8942 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8946 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8947 test_mkdir $DIR/$tdir
8948 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8949 { skip "no early lock cancel on server"; return 0; }
8951 lru_resize_disable mdc
8952 lru_resize_disable osc
8953 cancel_lru_locks mdc
8954 # asynchronous object destroy at MDT could cause bl ast to client
8955 cancel_lru_locks osc
8957 stat $DIR/$tdir > /dev/null
8958 can1=$(do_facet $SINGLEMDS \
8959 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8960 awk '/ldlm_cancel/ {print $2}')
8961 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8962 awk '/ldlm_bl_callback/ {print $2}')
8963 test_mkdir -c1 $DIR/$tdir/d1
8964 can2=$(do_facet $SINGLEMDS \
8965 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8966 awk '/ldlm_cancel/ {print $2}')
8967 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8968 awk '/ldlm_bl_callback/ {print $2}')
8969 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8970 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8971 lru_resize_enable mdc
8972 lru_resize_enable osc
8974 run_test 120a "Early Lock Cancel: mkdir test"
8977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8978 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8979 test_mkdir $DIR/$tdir
8980 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
8981 { skip "no early lock cancel on server"; return 0; }
8982 lru_resize_disable mdc
8983 lru_resize_disable osc
8984 cancel_lru_locks mdc
8985 stat $DIR/$tdir > /dev/null
8986 can1=$(do_facet $SINGLEMDS \
8987 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8988 awk '/ldlm_cancel/ {print $2}')
8989 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8990 awk '/ldlm_bl_callback/ {print $2}')
8992 can2=$(do_facet $SINGLEMDS \
8993 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8994 awk '/ldlm_cancel/ {print $2}')
8995 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8996 awk '/ldlm_bl_callback/ {print $2}')
8997 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8998 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8999 lru_resize_enable mdc
9000 lru_resize_enable osc
9002 run_test 120b "Early Lock Cancel: create test"
9005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9006 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9007 test_mkdir -c1 $DIR/$tdir
9008 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9009 { skip "no early lock cancel on server"; return 0; }
9010 lru_resize_disable mdc
9011 lru_resize_disable osc
9012 test_mkdir -c1 $DIR/$tdir/d1
9013 test_mkdir -c1 $DIR/$tdir/d2
9014 touch $DIR/$tdir/d1/f1
9015 cancel_lru_locks mdc
9016 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
9017 can1=$(do_facet $SINGLEMDS \
9018 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9019 awk '/ldlm_cancel/ {print $2}')
9020 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9021 awk '/ldlm_bl_callback/ {print $2}')
9022 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9023 can2=$(do_facet $SINGLEMDS \
9024 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9025 awk '/ldlm_cancel/ {print $2}')
9026 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9027 awk '/ldlm_bl_callback/ {print $2}')
9028 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9029 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9030 lru_resize_enable mdc
9031 lru_resize_enable osc
9033 run_test 120c "Early Lock Cancel: link test"
9036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9037 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9038 test_mkdir -c1 $DIR/$tdir
9039 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9040 { skip "no early lock cancel on server"; return 0; }
9041 lru_resize_disable mdc
9042 lru_resize_disable osc
9044 cancel_lru_locks mdc
9045 stat $DIR/$tdir > /dev/null
9046 can1=$(do_facet $SINGLEMDS \
9047 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9048 awk '/ldlm_cancel/ {print $2}')
9049 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9050 awk '/ldlm_bl_callback/ {print $2}')
9051 chmod a+x $DIR/$tdir
9052 can2=$(do_facet $SINGLEMDS \
9053 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9054 awk '/ldlm_cancel/ {print $2}')
9055 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9056 awk '/ldlm_bl_callback/ {print $2}')
9057 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9058 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9059 lru_resize_enable mdc
9060 lru_resize_enable osc
9062 run_test 120d "Early Lock Cancel: setattr test"
9065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9066 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9067 { skip "no early lock cancel on server"; return 0; }
9068 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9069 local dlmtrace_set=false
9071 test_mkdir -c1 $DIR/$tdir
9072 lru_resize_disable mdc
9073 lru_resize_disable osc
9074 ! $LCTL get_param debug | grep -q dlmtrace &&
9075 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
9076 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
9077 cancel_lru_locks mdc
9078 cancel_lru_locks osc
9079 dd if=$DIR/$tdir/f1 of=/dev/null
9080 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
9081 # XXX client can not do early lock cancel of OST lock
9082 # during unlink (LU-4206), so cancel osc lock now.
9084 cancel_lru_locks osc
9085 can1=$(do_facet $SINGLEMDS \
9086 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9087 awk '/ldlm_cancel/ {print $2}')
9088 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9089 awk '/ldlm_bl_callback/ {print $2}')
9090 unlink $DIR/$tdir/f1
9092 can2=$(do_facet $SINGLEMDS \
9093 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9094 awk '/ldlm_cancel/ {print $2}')
9095 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9096 awk '/ldlm_bl_callback/ {print $2}')
9097 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
9098 $LCTL dk $TMP/cancel.debug.txt
9099 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
9100 $LCTL dk $TMP/blocking.debug.txt
9101 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
9102 lru_resize_enable mdc
9103 lru_resize_enable osc
9105 run_test 120e "Early Lock Cancel: unlink test"
9108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9109 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9110 { skip "no early lock cancel on server"; return 0; }
9111 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9112 test_mkdir -c1 $DIR/$tdir
9113 lru_resize_disable mdc
9114 lru_resize_disable osc
9115 test_mkdir -c1 $DIR/$tdir/d1
9116 test_mkdir -c1 $DIR/$tdir/d2
9117 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
9118 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
9119 cancel_lru_locks mdc
9120 cancel_lru_locks osc
9121 dd if=$DIR/$tdir/d1/f1 of=/dev/null
9122 dd if=$DIR/$tdir/d2/f2 of=/dev/null
9123 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
9124 # XXX client can not do early lock cancel of OST lock
9125 # during rename (LU-4206), so cancel osc lock now.
9127 cancel_lru_locks osc
9128 can1=$(do_facet $SINGLEMDS \
9129 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9130 awk '/ldlm_cancel/ {print $2}')
9131 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9132 awk '/ldlm_bl_callback/ {print $2}')
9133 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9135 can2=$(do_facet $SINGLEMDS \
9136 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9137 awk '/ldlm_cancel/ {print $2}')
9138 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9139 awk '/ldlm_bl_callback/ {print $2}')
9140 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9141 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9142 lru_resize_enable mdc
9143 lru_resize_enable osc
9145 run_test 120f "Early Lock Cancel: rename test"
9148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9149 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9150 { skip "no early lock cancel on server"; return 0; }
9151 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9152 lru_resize_disable mdc
9153 lru_resize_disable osc
9155 echo create $count files
9156 test_mkdir $DIR/$tdir
9157 cancel_lru_locks mdc
9158 cancel_lru_locks osc
9161 can0=$(do_facet $SINGLEMDS \
9162 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9163 awk '/ldlm_cancel/ {print $2}')
9164 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9165 awk '/ldlm_bl_callback/ {print $2}')
9166 createmany -o $DIR/$tdir/f $count
9168 can1=$(do_facet $SINGLEMDS \
9169 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9170 awk '/ldlm_cancel/ {print $2}')
9171 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9172 awk '/ldlm_bl_callback/ {print $2}')
9174 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
9175 echo rm $count files
9178 can2=$(do_facet $SINGLEMDS \
9179 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9180 awk '/ldlm_cancel/ {print $2}')
9181 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9182 awk '/ldlm_bl_callback/ {print $2}')
9184 echo total: $count removes in $((t2-t1))
9185 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
9187 # wait for commitment of removal
9188 lru_resize_enable mdc
9189 lru_resize_enable osc
9191 run_test 120g "Early Lock Cancel: performance test"
9193 test_121() { #bug #10589
9194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9196 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
9197 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
9198 lctl set_param fail_loc=0x310
9199 cancel_lru_locks osc > /dev/null
9200 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
9201 lctl set_param fail_loc=0
9202 [[ $reads -eq $writes ]] ||
9203 error "read $reads blocks, must be $writes blocks"
9205 run_test 121 "read cancel race ========="
9207 test_123a() { # was test 123, statahead(bug 11401)
9208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9210 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
9211 log "testing UP system. Performance may be lower than expected."
9216 test_mkdir $DIR/$tdir
9217 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
9218 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
9220 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
9221 createmany -o $DIR/$tdir/$tfile $j $((i - j))
9223 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9224 lctl set_param -n llite.*.statahead_max 0
9225 lctl get_param llite.*.statahead_max
9226 cancel_lru_locks mdc
9227 cancel_lru_locks osc
9229 time ls -l $DIR/$tdir | wc -l
9231 delta=$((etime - stime))
9232 log "ls $i files without statahead: $delta sec"
9233 lctl set_param llite.*.statahead_max=$max
9235 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9236 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
9237 cancel_lru_locks mdc
9238 cancel_lru_locks osc
9240 time ls -l $DIR/$tdir | wc -l
9242 delta_sa=$((etime - stime))
9243 log "ls $i files with statahead: $delta_sa sec"
9244 lctl get_param -n llite.*.statahead_stats
9245 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9247 [[ $swrong -lt $ewrong ]] &&
9248 log "statahead was stopped, maybe too many locks held!"
9249 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
9251 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9252 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9253 lctl set_param -n llite.*.statahead_max 0
9254 lctl get_param llite.*.statahead_max
9255 cancel_lru_locks mdc
9256 cancel_lru_locks osc
9258 time ls -l $DIR/$tdir | wc -l
9260 delta=$((etime - stime))
9261 log "ls $i files again without statahead: $delta sec"
9262 lctl set_param llite.*.statahead_max=$max
9263 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9264 if [ $SLOWOK -eq 0 ]; then
9265 error "ls $i files is slower with statahead!"
9267 log "ls $i files is slower with statahead!"
9273 [ $delta -gt 20 ] && break
9274 [ $delta -gt 8 ] && MULT=$((50 / delta))
9275 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
9283 delta=$((etime - stime))
9284 log "rm -r $DIR/$tdir/: $delta seconds"
9286 lctl get_param -n llite.*.statahead_stats
9288 run_test 123a "verify statahead work"
9290 test_123b () { # statahead(bug 15027)
9291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9292 test_mkdir $DIR/$tdir
9293 createmany -o $DIR/$tdir/$tfile-%d 1000
9295 cancel_lru_locks mdc
9296 cancel_lru_locks osc
9298 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
9299 lctl set_param fail_loc=0x80000803
9300 ls -lR $DIR/$tdir > /dev/null
9302 lctl set_param fail_loc=0x0
9303 lctl get_param -n llite.*.statahead_stats
9308 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
9311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9312 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9313 { skip "no lru resize on server"; return 0; }
9315 test_mkdir $DIR/$tdir
9317 log "create $NR files at $DIR/$tdir"
9318 createmany -o $DIR/$tdir/f $NR ||
9319 error "failed to create $NR files in $DIR/$tdir"
9321 cancel_lru_locks mdc
9322 ls -l $DIR/$tdir > /dev/null
9326 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
9327 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
9328 LRU_SIZE=$($LCTL get_param -n $PARAM)
9329 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
9330 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
9332 log "NS=$(basename $NSDIR)"
9337 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9338 skip "Not enough cached locks created!"
9345 # We know that lru resize allows one client to hold $LIMIT locks
9346 # for 10h. After that locks begin to be killed by client.
9348 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9350 if [ $LIMIT -lt $LRU_SIZE ]; then
9351 skip "Limit is too small $LIMIT"
9355 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9356 # killing locks. Some time was spent for creating locks. This means
9357 # that up to the moment of sleep finish we must have killed some of
9358 # them (10-100 locks). This depends on how fast ther were created.
9359 # Many of them were touched in almost the same moment and thus will
9360 # be killed in groups.
9361 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9363 # Use $LRU_SIZE_B here to take into account real number of locks
9364 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9365 local LRU_SIZE_B=$LRU_SIZE
9367 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9368 log "OLD_LVF=$OLD_LVF"
9369 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9371 # Let's make sure that we really have some margin. Client checks
9372 # cached locks every 10 sec.
9374 log "Sleep ${SLEEP} sec"
9376 while ((SEC<$SLEEP)); do
9380 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9384 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9385 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9387 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9388 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9389 unlinkmany $DIR/$tdir/f $NR
9393 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9394 log "unlink $NR files at $DIR/$tdir"
9395 unlinkmany $DIR/$tdir/f $NR
9397 run_test 124a "lru resize ======================================="
9399 get_max_pool_limit()
9401 local limit=$($LCTL get_param \
9402 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9405 if [[ $l -gt $max ]]; then
9413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9414 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9415 { skip "no lru resize on server"; return 0; }
9417 LIMIT=$(get_max_pool_limit)
9419 NR=$(($(default_lru_size)*20))
9420 if [[ $NR -gt $LIMIT ]]; then
9421 log "Limit lock number by $LIMIT locks"
9425 IFree=$(mdsrate_inodes_available)
9426 if [ $IFree -lt $NR ]; then
9427 log "Limit lock number by $IFree inodes"
9431 lru_resize_disable mdc
9432 test_mkdir -p $DIR/$tdir/disable_lru_resize
9434 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9435 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9436 cancel_lru_locks mdc
9439 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9442 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9445 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9449 nolruresize_delta=$((etime-stime))
9450 log "ls -la time: $nolruresize_delta seconds"
9451 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9452 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9454 lru_resize_enable mdc
9455 test_mkdir -p $DIR/$tdir/enable_lru_resize
9457 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9458 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9459 cancel_lru_locks mdc
9462 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9465 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9468 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9472 lruresize_delta=$((etime-stime))
9473 log "ls -la time: $lruresize_delta seconds"
9474 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9476 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9477 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9478 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9479 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9481 log "lru resize performs the same with no lru resize"
9483 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9485 run_test 124b "lru resize (performance test) ======================="
9488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9489 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9490 { skip "no lru resize on server"; return 0; }
9492 # cache ununsed locks on client
9494 cancel_lru_locks mdc
9495 test_mkdir $DIR/$tdir
9496 createmany -o $DIR/$tdir/f $nr ||
9497 error "failed to create $nr files in $DIR/$tdir"
9498 ls -l $DIR/$tdir > /dev/null
9500 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9501 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9502 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
9503 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
9504 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
9506 # set lru_max_age to 1 sec
9507 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
9508 echo "sleep $((recalc_p * 2)) seconds..."
9509 sleep $((recalc_p * 2))
9511 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
9512 # restore lru_max_age
9513 $LCTL set_param -n $nsdir.lru_max_age $max_age
9514 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
9515 unlinkmany $DIR/$tdir/f $nr
9517 run_test 124c "LRUR cancel very aged locks"
9519 test_125() { # 13358
9520 $LCTL get_param -n llite.*.client_type | grep -q local ||
9521 { skip "must run as local client"; return; }
9522 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
9523 { skip "must have acl enabled"; return; }
9524 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9525 test_mkdir $DIR/$tdir
9526 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
9527 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
9528 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
9530 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
9532 test_126() { # bug 12829/13455
9533 $LCTL get_param -n llite.*.client_type | grep -q local ||
9534 { skip "must run as local client"; return; }
9535 [ "$UID" != 0 ] && skip_env "$TESTNAME (must run as root)" && return
9536 $GSS && skip "must run as gss disabled" && return
9538 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
9539 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
9541 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
9543 run_test 126 "check that the fsgid provided by the client is taken into account"
9545 test_127a() { # bug 15521
9546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9547 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
9548 $LCTL set_param osc.*.stats=0
9549 FSIZE=$((2048 * 1024))
9550 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9551 cancel_lru_locks osc
9552 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
9554 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
9555 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9556 echo "got $COUNT $NAME"
9557 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
9558 eval $NAME=$COUNT || error "Wrong proc format"
9561 read_bytes|write_bytes)
9562 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
9563 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
9564 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
9565 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
9566 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
9567 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
9568 error "sumsquare is too small: $SUMSQ"
9569 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
9570 error "sumsquare is too big: $SUMSQ"
9574 done < $DIR/${tfile}.tmp
9576 #check that we actually got some stats
9577 [ "$read_bytes" ] || error "Missing read_bytes stats"
9578 [ "$write_bytes" ] || error "Missing write_bytes stats"
9579 [ "$read_bytes" != 0 ] || error "no read done"
9580 [ "$write_bytes" != 0 ] || error "no write done"
9582 run_test 127a "verify the client stats are sane"
9584 test_127b() { # bug LU-333
9585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9586 $LCTL set_param llite.*.stats=0
9587 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
9588 # perform 2 reads and writes so MAX is different from SUM.
9589 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9590 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
9591 cancel_lru_locks osc
9592 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9593 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
9595 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
9596 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
9597 echo "got $COUNT $NAME"
9598 eval $NAME=$COUNT || error "Wrong proc format"
9602 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9603 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9604 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9605 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9608 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
9609 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
9610 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
9611 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
9615 done < $TMP/${tfile}.tmp
9617 #check that we actually got some stats
9618 [ "$read_bytes" ] || error "Missing read_bytes stats"
9619 [ "$write_bytes" ] || error "Missing write_bytes stats"
9620 [ "$read_bytes" != 0 ] || error "no read done"
9621 [ "$write_bytes" != 0 ] || error "no write done"
9623 rm -f $TMP/${tfile}.tmp
9625 run_test 127b "verify the llite client stats are sane"
9627 test_128() { # bug 15212
9629 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
9634 result=$(grep error $TMP/$tfile.log)
9635 rm -f $DIR/$tfile $TMP/$tfile.log
9637 error "consecutive find's under interactive lfs failed"
9639 run_test 128 "interactive lfs for 2 consecutive find's"
9646 local ldproc=/proc/fs/ldiskfs
9647 local facets=$(get_facets MDS)
9649 for facet in ${facets//,/ }; do
9650 canondev=$(ldiskfs_canon \
9651 *.$(convert_facet2label $facet).mntdev $facet)
9652 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
9653 ldproc=/sys/fs/ldiskfs
9654 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
9655 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
9660 local facets=$(get_facets MDS)
9661 for facet in ${facets//,/ }; do
9662 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
9668 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
9669 { skip "Need MDS version with at least 2.5.56"; return 0; }
9671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9672 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
9673 skip "ldiskfs only test"
9676 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9679 local has_warning=false
9684 # block size of mds1
9685 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
9686 set_dir_limits $maxsize $maxsize
9687 local dirsize=$(stat -c%s "$DIR/$tdir")
9689 while [[ $dirsize -le $maxsize ]]; do
9690 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
9692 if ! $has_warning; then
9693 check_mds_dmesg '"is approaching"' && has_warning=true
9696 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
9697 # EFBIG for previous versions included in ldiskfs series
9698 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
9700 echo "return code $rc received as expected"
9702 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
9703 error_exit "create failed w/o dir size limit"
9705 check_mds_dmesg '"has reached"' ||
9706 error_exit "reached message should be output"
9708 [ $has_warning = "false" ] &&
9709 error_exit "warning message should be output"
9711 dirsize=$(stat -c%s "$DIR/$tdir")
9713 [[ $dirsize -ge $maxsize ]] && return 0
9714 error_exit "current dir size $dirsize, " \
9715 "previous limit $maxsize"
9716 elif [ $rc -ne 0 ]; then
9718 error_exit "return $rc received instead of expected " \
9719 "$EFBIG or $ENOSPC, files in dir $dirsize"
9721 nfiles=$((nfiles + 1))
9722 dirsize=$(stat -c%s "$DIR/$tdir")
9726 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
9728 run_test 129 "test directory size limit ========================"
9737 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9738 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9741 trap cleanup_130 EXIT RETURN
9743 local fm_file=$DIR/$tfile
9744 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
9745 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
9746 error "dd failed for $fm_file"
9748 # LU-1795: test filefrag/FIEMAP once, even if unsupported
9749 filefrag -ves $fm_file
9751 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9752 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9753 [ $RC != 0 ] && error "filefrag $fm_file failed"
9755 filefrag_op=$(filefrag -ve -k $fm_file |
9756 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9757 lun=$($GETSTRIPE -i $fm_file)
9759 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
9762 for line in $filefrag_op
9764 frag_lun=`echo $line | cut -d: -f5`
9765 ext_len=`echo $line | cut -d: -f4`
9766 if (( $frag_lun != $lun )); then
9768 error "FIEMAP on 1-stripe file($fm_file) failed"
9771 (( tot_len += ext_len ))
9774 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
9776 error "FIEMAP on 1-stripe file($fm_file) failed;"
9782 echo "FIEMAP on single striped file succeeded"
9784 run_test 130a "FIEMAP (1-stripe file)"
9787 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
9789 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9790 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
9793 trap cleanup_130 EXIT RETURN
9795 local fm_file=$DIR/$tfile
9796 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9797 error "setstripe on $fm_file"
9798 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9799 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9801 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
9802 error "dd failed on $fm_file"
9804 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9805 filefrag_op=$(filefrag -ve -k $fm_file |
9806 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9808 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9809 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9814 for line in $filefrag_op
9816 frag_lun=$(echo $line | cut -d: -f5 |
9817 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9818 ext_len=$(echo $line | cut -d: -f4)
9819 if (( $frag_lun != $last_lun )); then
9820 if (( tot_len != 1024 )); then
9822 error "FIEMAP on $fm_file failed; returned " \
9823 "len $tot_len for OST $last_lun instead of 1024"
9830 (( tot_len += ext_len ))
9833 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
9835 error "FIEMAP on $fm_file failed; returned wrong number of " \
9836 "luns or wrong len for OST $last_lun"
9842 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
9844 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
9847 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9849 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9850 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9853 trap cleanup_130 EXIT RETURN
9855 local fm_file=$DIR/$tfile
9856 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
9857 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9858 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9860 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
9861 error "dd failed on $fm_file"
9863 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9864 filefrag_op=$(filefrag -ve -k $fm_file |
9865 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9867 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9868 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9873 for line in $filefrag_op
9875 frag_lun=$(echo $line | cut -d: -f5 |
9876 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9877 ext_len=$(echo $line | cut -d: -f4)
9878 if (( $frag_lun != $last_lun )); then
9879 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
9880 if (( logical != 512 )); then
9882 error "FIEMAP on $fm_file failed; returned " \
9883 "logical start for lun $logical instead of 512"
9886 if (( tot_len != 512 )); then
9888 error "FIEMAP on $fm_file failed; returned " \
9889 "len $tot_len for OST $last_lun instead of 1024"
9896 (( tot_len += ext_len ))
9899 if (( num_luns != 2 || tot_len != 512 )); then
9901 error "FIEMAP on $fm_file failed; returned wrong number of " \
9902 "luns or wrong len for OST $last_lun"
9908 echo "FIEMAP on 2-stripe file with hole succeeded"
9910 run_test 130c "FIEMAP (2-stripe file with hole)"
9913 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
9915 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9916 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
9919 trap cleanup_130 EXIT RETURN
9921 local fm_file=$DIR/$tfile
9922 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9923 error "setstripe on $fm_file"
9924 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9925 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9927 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
9928 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
9929 error "dd failed on $fm_file"
9931 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9932 filefrag_op=$(filefrag -ve -k $fm_file |
9933 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9935 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9936 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9941 for line in $filefrag_op
9943 frag_lun=$(echo $line | cut -d: -f5 |
9944 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9945 ext_len=$(echo $line | cut -d: -f4)
9946 if (( $frag_lun != $last_lun )); then
9947 if (( tot_len != 1024 )); then
9949 error "FIEMAP on $fm_file failed; returned " \
9950 "len $tot_len for OST $last_lun instead of 1024"
9957 (( tot_len += ext_len ))
9960 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
9962 error "FIEMAP on $fm_file failed; returned wrong number of " \
9963 "luns or wrong len for OST $last_lun"
9969 echo "FIEMAP on N-stripe file succeeded"
9971 run_test 130d "FIEMAP (N-stripe file)"
9974 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
9976 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9977 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9979 trap cleanup_130 EXIT RETURN
9981 local fm_file=$DIR/$tfile
9982 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9983 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9984 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9987 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9988 for ((i = 0; i < $NUM_BLKS; i++))
9990 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9993 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9994 filefrag_op=$(filefrag -ve -k $fm_file |
9995 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9997 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9998 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10003 for line in $filefrag_op
10005 frag_lun=$(echo $line | cut -d: -f5 |
10006 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10007 ext_len=$(echo $line | cut -d: -f4)
10008 if (( $frag_lun != $last_lun )); then
10009 if (( tot_len != $EXPECTED_LEN )); then
10011 error "FIEMAP on $fm_file failed; returned " \
10012 "len $tot_len for OST $last_lun instead " \
10016 (( num_luns += 1 ))
10020 (( tot_len += ext_len ))
10023 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
10025 error "FIEMAP on $fm_file failed; returned wrong number " \
10026 "of luns or wrong len for OST $last_lun"
10032 echo "FIEMAP with continuation calls succeeded"
10034 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
10036 # Test for writev/readv
10038 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
10039 error "writev test failed"
10040 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
10041 error "readv failed"
10044 run_test 131a "test iov's crossing stripe boundary for writev/readv"
10047 local fsize=$((524288 + 1048576 + 1572864))
10048 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
10049 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10050 error "append writev test failed"
10052 ((fsize += 1572864 + 1048576))
10053 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
10054 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10055 error "append writev test failed"
10058 run_test 131b "test append writev"
10061 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
10064 run_test 131c "test read/write on file w/o objects"
10067 rwv -f $DIR/$tfile -w -n 1 1572864
10068 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
10069 if [ "$NOB" != 1572864 ]; then
10070 error "Short read filed: read $NOB bytes instead of 1572864"
10074 run_test 131d "test short read"
10077 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
10078 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
10079 error "read hitting hole failed"
10082 run_test 131e "test read hitting hole"
10091 mds*) res=$(do_facet $facet \
10092 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
10094 ost*) res=$(do_facet $facet \
10095 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
10097 *) error "Wrong facet '$facet'" ;;
10100 [ "$res" ] || error "The counter for $op on $facet was not incremented"
10101 # if the argument $3 is zero, it means any stat increment is ok.
10102 if [[ $want -gt 0 ]]; then
10103 local count=$(echo $res | awk '{ print $2 }')
10104 [[ $count -ne $want ]] &&
10105 error "The $op counter on $facet is $count, not $want"
10110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10111 remote_ost_nodsh && skip "remote OST with nodsh" && return
10112 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10114 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10115 { skip "MDS doesn't support rename stats"; return; }
10116 local testdir=$DIR/${tdir}/stats_testdir
10117 mkdir -p $DIR/${tdir}
10120 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10121 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10123 # verify mdt stats first.
10124 mkdir ${testdir} || error "mkdir failed"
10125 check_stats $SINGLEMDS "mkdir" 1
10126 touch ${testdir}/${tfile} || error "touch failed"
10127 check_stats $SINGLEMDS "open" 1
10128 check_stats $SINGLEMDS "close" 1
10129 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
10130 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
10131 check_stats $SINGLEMDS "mknod" 2
10133 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
10134 check_stats $SINGLEMDS "unlink" 1
10135 rm -f ${testdir}/${tfile} || error "file remove failed"
10136 check_stats $SINGLEMDS "unlink" 2
10138 # remove working dir and check mdt stats again.
10139 rmdir ${testdir} || error "rmdir failed"
10140 check_stats $SINGLEMDS "rmdir" 1
10142 local testdir1=$DIR/${tdir}/stats_testdir1
10143 mkdir -p ${testdir}
10144 mkdir -p ${testdir1}
10145 touch ${testdir1}/test1
10146 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
10147 check_stats $SINGLEMDS "crossdir_rename" 1
10149 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
10150 check_stats $SINGLEMDS "samedir_rename" 1
10152 rm -rf $DIR/${tdir}
10154 run_test 133a "Verifying MDT stats ========================================"
10157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10158 remote_ost_nodsh && skip "remote OST with nodsh" && return
10159 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10160 local testdir=$DIR/${tdir}/stats_testdir
10161 mkdir -p ${testdir} || error "mkdir failed"
10162 touch ${testdir}/${tfile} || error "touch failed"
10163 cancel_lru_locks mdc
10166 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10167 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10169 # extra mdt stats verification.
10170 chmod 444 ${testdir}/${tfile} || error "chmod failed"
10171 check_stats $SINGLEMDS "setattr" 1
10172 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10173 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
10175 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
10176 check_stats $SINGLEMDS "getattr" 1
10178 $LFS df || error "lfs failed"
10179 check_stats $SINGLEMDS "statfs" 1
10181 rm -rf $DIR/${tdir}
10183 run_test 133b "Verifying extra MDT stats =================================="
10186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10187 remote_ost_nodsh && skip "remote OST with nodsh" && return
10188 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10189 local testdir=$DIR/$tdir/stats_testdir
10190 test_mkdir -p $testdir
10192 # verify obdfilter stats.
10193 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
10195 cancel_lru_locks osc
10196 wait_delete_completed
10199 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10200 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10202 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
10205 cancel_lru_locks osc
10206 check_stats ost1 "write" 1
10208 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
10209 check_stats ost1 "read" 1
10211 > $testdir/$tfile || error "truncate failed"
10212 check_stats ost1 "punch" 1
10214 rm -f $testdir/$tfile || error "file remove failed"
10215 wait_delete_completed
10216 check_stats ost1 "destroy" 1
10220 run_test 133c "Verifying OST stats ========================================"
10227 while [ $value -ge 2 ]; do
10232 if [ $orig -gt $order ]; then
10240 local size=('K' 'M' 'G' 'T');
10242 local size_string=$value
10244 while [ $value -ge 1024 ]; do
10245 if [ $i -gt 3 ]; then
10246 #T is the biggest unit we get here, if that is bigger,
10248 size_string=${value}T
10251 value=$((value >> 10))
10252 if [ $value -lt 1024 ]; then
10253 size_string=${value}${size[$i]}
10262 get_rename_size() {
10264 local context=${2:-.}
10265 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
10266 grep -A1 $context |
10267 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
10272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10273 remote_ost_nodsh && skip "remote OST with nodsh" && return
10274 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10275 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10276 { skip "MDS doesn't support rename stats"; return; }
10278 local testdir1=$DIR/${tdir}/stats_testdir1
10279 local testdir2=$DIR/${tdir}/stats_testdir2
10281 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10283 mkdir -p ${testdir1} || error "mkdir failed"
10284 mkdir -p ${testdir2} || error "mkdir failed"
10286 createmany -o $testdir1/test 512 || error "createmany failed"
10288 # check samedir rename size
10289 mv ${testdir1}/test0 ${testdir1}/test_0
10291 local testdir1_size=$(ls -l $DIR/${tdir} |
10292 awk '/stats_testdir1/ {print $5}')
10293 local testdir2_size=$(ls -l $DIR/${tdir} |
10294 awk '/stats_testdir2/ {print $5}')
10296 testdir1_size=$(order_2 $testdir1_size)
10297 testdir2_size=$(order_2 $testdir2_size)
10299 testdir1_size=$(size_in_KMGT $testdir1_size)
10300 testdir2_size=$(size_in_KMGT $testdir2_size)
10302 echo "source rename dir size: ${testdir1_size}"
10303 echo "target rename dir size: ${testdir2_size}"
10305 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
10306 eval $cmd || error "$cmd failed"
10307 local samedir=$($cmd | grep 'same_dir')
10308 local same_sample=$(get_rename_size $testdir1_size)
10309 [ -z "$samedir" ] && error "samedir_rename_size count error"
10310 [[ $same_sample -eq 1 ]] ||
10311 error "samedir_rename_size error $same_sample"
10312 echo "Check same dir rename stats success"
10314 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10316 # check crossdir rename size
10317 mv ${testdir1}/test_0 ${testdir2}/test_0
10319 testdir1_size=$(ls -l $DIR/${tdir} |
10320 awk '/stats_testdir1/ {print $5}')
10321 testdir2_size=$(ls -l $DIR/${tdir} |
10322 awk '/stats_testdir2/ {print $5}')
10324 testdir1_size=$(order_2 $testdir1_size)
10325 testdir2_size=$(order_2 $testdir2_size)
10327 testdir1_size=$(size_in_KMGT $testdir1_size)
10328 testdir2_size=$(size_in_KMGT $testdir2_size)
10330 echo "source rename dir size: ${testdir1_size}"
10331 echo "target rename dir size: ${testdir2_size}"
10333 eval $cmd || error "$cmd failed"
10334 local crossdir=$($cmd | grep 'crossdir')
10335 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10336 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10337 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10338 [[ $src_sample -eq 1 ]] ||
10339 error "crossdir_rename_size error $src_sample"
10340 [[ $tgt_sample -eq 1 ]] ||
10341 error "crossdir_rename_size error $tgt_sample"
10342 echo "Check cross dir rename stats success"
10343 rm -rf $DIR/${tdir}
10345 run_test 133d "Verifying rename_stats ========================================"
10348 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10349 remote_ost_nodsh && skip "remote OST with nodsh" && return
10350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10351 local testdir=$DIR/${tdir}/stats_testdir
10352 local ctr f0 f1 bs=32768 count=42 sum
10354 mkdir -p ${testdir} || error "mkdir failed"
10356 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10358 for ctr in {write,read}_bytes; do
10360 cancel_lru_locks osc
10362 do_facet ost1 $LCTL set_param -n \
10363 "obdfilter.*.exports.clear=clear"
10365 if [ $ctr = write_bytes ]; then
10367 f1=${testdir}/${tfile}
10369 f0=${testdir}/${tfile}
10373 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10376 cancel_lru_locks osc
10378 sum=$(do_facet ost1 $LCTL get_param \
10379 "obdfilter.*.exports.*.stats" |
10380 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10381 $1 == ctr { sum += $7 }
10382 END { printf("%0.0f", sum) }')
10384 if ((sum != bs * count)); then
10385 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10389 rm -rf $DIR/${tdir}
10391 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10393 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10396 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10397 remote_ost_nodsh && skip "remote OST with nodsh" && return
10398 # First without trusting modes.
10399 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10400 echo "proc_dirs='$proc_dirs'"
10401 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10402 find $proc_dirs -exec cat '{}' \; &> /dev/null
10404 # Second verifying readability.
10405 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10407 # eventually, this can also be replaced with "lctl get_param -R",
10408 # but not until that option is always available on the server
10410 for facet in mds1 ost1; do
10411 local facet_proc_dirs=$(do_facet $facet \
10412 \\\ls -d $proc_regexp 2>/dev/null)
10413 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10414 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10415 do_facet $facet find $facet_proc_dirs \
10416 ! -name req_history \
10417 -exec cat '{}' \\\; &> /dev/null
10419 do_facet $facet find $facet_proc_dirs \
10420 ! -name req_history \
10422 -exec cat '{}' \\\; &> /dev/null ||
10423 error "proc file read failed"
10426 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
10429 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10430 remote_ost_nodsh && skip "remote OST with nodsh" && return
10431 # Second verifying writability.
10432 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10433 echo "proc_dirs='$proc_dirs'"
10434 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10436 -ignore_readdir_race \
10438 -not -name force_lbug \
10439 -not -name changelog_mask \
10440 -exec badarea_io '{}' \; ||
10441 error "find $proc_dirs failed"
10444 for facet in mds1 ost1; do
10445 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10446 skip "Too old lustre on $facet" && continue
10447 local facet_proc_dirs=$(do_facet $facet \
10448 \\\ls -d $proc_regexp 2> /dev/null)
10449 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10450 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10451 do_facet $facet find $facet_proc_dirs \
10452 -ignore_readdir_race \
10454 -not -name force_lbug \
10455 -not -name changelog_mask \
10456 -exec badarea_io '{}' \\\; ||
10457 error "$facet find $facet_proc_dirs failed"
10460 # remount the FS in case writes/reads /proc break the FS
10461 cleanup || error "failed to unmount"
10462 setup || error "failed to setup"
10465 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
10468 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10469 remote_ost_nodsh && skip "remote OST with nodsh" && return
10470 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
10471 skip "Need MDS version at least 2.9.54" && return
10474 for facet in client mds1 ost1; do
10475 local facet_proc_dirs=$(do_facet $facet \
10476 \\\ls -d $proc_regexp 2> /dev/null)
10477 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10478 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10479 # Get the list of files that are missing the terminating newline
10480 local missing=($(do_facet $facet \
10481 find ${facet_proc_dirs} -type f \| \
10482 while read F\; do \
10483 awk -v FS='\v' -v RS='\v\v' \
10484 "'END { if(NR>0 && \
10485 \\\$NF !~ /.*\\\n\$/) \
10486 print FILENAME}'" \
10489 [ ${#missing[*]} -eq 0 ] ||
10490 error "files do not end with newline: ${missing[*]}"
10493 run_test 133h "Proc files should end with newlines"
10496 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10497 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10498 skip "Need MDS version at least 2.7.54" && return
10500 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10501 cancel_lru_locks mdc
10503 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10504 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10505 [ $unused -eq 0 ] || error "$unused locks are not cleared"
10508 createmany -o $DIR/$tdir/f $nr ||
10509 error "failed to create $nr files in $DIR/$tdir"
10510 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10512 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
10513 do_facet mds1 $LCTL set_param fail_loc=0x327
10514 do_facet mds1 $LCTL set_param fail_val=500
10517 echo "sleep 10 seconds ..."
10519 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
10521 do_facet mds1 $LCTL set_param fail_loc=0
10522 do_facet mds1 $LCTL set_param fail_val=0
10523 [ $lck_cnt -lt $unused ] ||
10524 error "No locks reclaimed, before:$unused, after:$lck_cnt"
10527 unlinkmany $DIR/$tdir/f $nr
10529 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
10532 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10533 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
10534 skip "Need MDS version at least 2.7.54" && return
10536 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
10537 cancel_lru_locks mdc
10539 local low_wm=$(do_facet mds1 $LCTL get_param -n \
10540 ldlm.lock_reclaim_threshold_mb)
10541 # disable reclaim temporarily
10542 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
10544 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
10545 do_facet mds1 $LCTL set_param fail_loc=0x328
10546 do_facet mds1 $LCTL set_param fail_val=500
10548 $LCTL set_param debug=+trace
10551 createmany -o $DIR/$tdir/f $nr &
10552 local create_pid=$!
10554 echo "Sleep $TIMEOUT seconds ..."
10556 if ! ps -p $create_pid > /dev/null 2>&1; then
10557 do_facet mds1 $LCTL set_param fail_loc=0
10558 do_facet mds1 $LCTL set_param fail_val=0
10559 do_facet mds1 $LCTL set_param \
10560 ldlm.lock_reclaim_threshold_mb=${low_wm}m
10561 error "createmany finished incorrectly!"
10563 do_facet mds1 $LCTL set_param fail_loc=0
10564 do_facet mds1 $LCTL set_param fail_val=0
10565 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
10566 wait $create_pid || return 1
10568 unlinkmany $DIR/$tdir/f $nr
10570 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
10572 test_140() { #bug-17379
10573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10574 test_mkdir $DIR/$tdir
10575 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
10576 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
10578 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
10579 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
10581 while i=$((i + 1)); do
10583 cd $i || error "Changing to $i"
10584 ln -s ../stat stat || error "Creating stat symlink"
10585 # Read the symlink until ELOOP present,
10586 # not LBUGing the system is considered success,
10587 # we didn't overrun the stack.
10588 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
10589 if [ $ret -ne 0 ]; then
10590 if [ $ret -eq 40 ]; then
10593 error "Open stat symlink"
10599 echo "The symlink depth = $i"
10600 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
10601 error "Invalid symlink depth"
10603 # Test recursive symlink
10604 ln -s symlink_self symlink_self
10605 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
10606 echo "open symlink_self returns $ret"
10607 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
10609 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
10612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10613 local TF="$TMP/$tfile"
10615 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10617 cancel_lru_locks $OSC
10618 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
10619 remount_client $MOUNT
10621 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
10624 $TRUNCATE $DIR/$tfile 6000
10625 cancel_lru_locks $OSC
10626 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
10629 echo "12345" >>$DIR/$tfile
10630 cancel_lru_locks $OSC
10631 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
10634 echo "12345" >>$DIR/$tfile
10635 cancel_lru_locks $OSC
10636 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
10641 run_test 150 "truncate/append tests"
10643 #LU-2902 roc_hit was not able to read all values from lproc
10644 function roc_hit_init() {
10645 local list=$(comma_list $(osts_nodes))
10646 local dir=$DIR/$tdir-check
10647 local file=$dir/$tfile
10653 #use setstripe to do a write to every ost
10654 for i in $(seq 0 $((OSTCOUNT-1))); do
10655 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
10656 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
10657 idx=$(printf %04x $i)
10658 BEFORE=$(get_osd_param $list *OST*$idx stats |
10659 awk '$1 == "cache_access" {sum += $7}
10660 END { printf("%0.0f", sum) }')
10662 cancel_lru_locks osc
10663 cat $file >/dev/null
10665 AFTER=$(get_osd_param $list *OST*$idx stats |
10666 awk '$1 == "cache_access" {sum += $7}
10667 END { printf("%0.0f", sum) }')
10669 echo BEFORE:$BEFORE AFTER:$AFTER
10670 if ! let "AFTER - BEFORE == 4"; then
10672 error "roc_hit is not safe to use"
10680 function roc_hit() {
10681 local list=$(comma_list $(osts_nodes))
10682 echo $(get_osd_param $list '' stats |
10683 awk '$1 == "cache_hit" {sum += $7}
10684 END { printf("%0.0f", sum) }')
10687 function set_cache() {
10690 if [ "$2" == "off" ]; then
10693 local list=$(comma_list $(osts_nodes))
10694 set_osd_param $list '' $1_cache_enable $on
10696 cancel_lru_locks osc
10700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10701 remote_ost_nodsh && skip "remote OST with nodsh" && return
10704 local list=$(comma_list $(osts_nodes))
10706 # check whether obdfilter is cache capable at all
10707 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
10708 echo "not cache-capable obdfilter"
10712 # check cache is enabled on all obdfilters
10713 if get_osd_param $list '' read_cache_enable | grep 0; then
10714 echo "oss cache is disabled"
10718 set_osd_param $list '' writethrough_cache_enable 1
10720 # check write cache is enabled on all obdfilters
10721 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
10722 echo "oss write cache is NOT enabled"
10728 #define OBD_FAIL_OBD_NO_LRU 0x609
10729 do_nodes $list $LCTL set_param fail_loc=0x609
10731 # pages should be in the case right after write
10732 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
10735 local BEFORE=$(roc_hit)
10736 cancel_lru_locks osc
10737 cat $DIR/$tfile >/dev/null
10738 local AFTER=$(roc_hit)
10740 do_nodes $list $LCTL set_param fail_loc=0
10742 if ! let "AFTER - BEFORE == CPAGES"; then
10743 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10746 # the following read invalidates the cache
10747 cancel_lru_locks osc
10748 set_osd_param $list '' read_cache_enable 0
10749 cat $DIR/$tfile >/dev/null
10751 # now data shouldn't be found in the cache
10753 cancel_lru_locks osc
10754 cat $DIR/$tfile >/dev/null
10756 if let "AFTER - BEFORE != 0"; then
10757 error "IN CACHE: before: $BEFORE, after: $AFTER"
10760 set_osd_param $list '' read_cache_enable 1
10763 run_test 151 "test cache on oss and controls ==============================="
10766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10767 local TF="$TMP/$tfile"
10769 # simulate ENOMEM during write
10770 #define OBD_FAIL_OST_NOMEM 0x226
10771 lctl set_param fail_loc=0x80000226
10772 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
10774 sync || error "sync failed"
10775 lctl set_param fail_loc=0
10777 # discard client's cache
10778 cancel_lru_locks osc
10780 # simulate ENOMEM during read
10781 lctl set_param fail_loc=0x80000226
10782 cmp $TF $DIR/$tfile || error "cmp failed"
10783 lctl set_param fail_loc=0
10787 run_test 152 "test read/write with enomem ============================"
10790 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
10792 run_test 153 "test if fdatasync does not crash ======================="
10794 dot_lustre_fid_permission_check() {
10796 local ffid=$MOUNT/.lustre/fid/$fid
10799 echo "stat fid $fid"
10800 stat $ffid > /dev/null || error "stat $ffid failed."
10801 echo "touch fid $fid"
10802 touch $ffid || error "touch $ffid failed."
10803 echo "write to fid $fid"
10804 cat /etc/hosts > $ffid || error "write $ffid failed."
10805 echo "read fid $fid"
10806 diff /etc/hosts $ffid || error "read $ffid failed."
10807 echo "append write to fid $fid"
10808 cat /etc/hosts >> $ffid || error "append write $ffid failed."
10809 echo "rename fid $fid"
10810 mv $ffid $test_dir/$tfile.1 &&
10811 error "rename $ffid to $tfile.1 should fail."
10812 touch $test_dir/$tfile.1
10813 mv $test_dir/$tfile.1 $ffid &&
10814 error "rename $tfile.1 to $ffid should fail."
10815 rm -f $test_dir/$tfile.1
10816 echo "truncate fid $fid"
10817 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
10818 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
10819 echo "link fid $fid"
10820 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
10822 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
10823 echo "setfacl fid $fid"
10824 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
10825 echo "getfacl fid $fid"
10826 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
10828 echo "unlink fid $fid"
10829 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
10830 echo "mknod fid $fid"
10831 mknod $ffid c 1 3 && error "mknod $ffid should fail."
10833 fid=[0xf00000400:0x1:0x0]
10834 ffid=$MOUNT/.lustre/fid/$fid
10836 echo "stat non-exist fid $fid"
10837 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
10838 echo "write to non-exist fid $fid"
10839 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
10840 echo "link new fid $fid"
10841 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
10843 mkdir -p $test_dir/$tdir
10844 touch $test_dir/$tdir/$tfile
10845 fid=$($LFS path2fid $test_dir/$tdir)
10848 error "error: could not get fid for $test_dir/$dir/$tfile."
10850 ffid=$MOUNT/.lustre/fid/$fid
10853 ls $ffid > /dev/null || error "ls $ffid failed."
10854 echo "touch $fid/$tfile.1"
10855 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
10857 echo "touch $MOUNT/.lustre/fid/$tfile"
10858 touch $MOUNT/.lustre/fid/$tfile && \
10859 error "touch $MOUNT/.lustre/fid/$tfile should fail."
10861 echo "setxattr to $MOUNT/.lustre/fid"
10862 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
10864 echo "listxattr for $MOUNT/.lustre/fid"
10865 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
10867 echo "delxattr from $MOUNT/.lustre/fid"
10868 setfattr -x trusted.name1 $MOUNT/.lustre/fid
10870 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
10871 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
10872 error "touch invalid fid should fail."
10874 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
10875 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
10876 error "touch non-normal fid should fail."
10878 echo "rename $tdir to $MOUNT/.lustre/fid"
10879 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
10880 error "rename to $MOUNT/.lustre/fid should fail."
10882 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
10884 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
10885 local new_obf_mode=777
10887 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
10888 chmod $new_obf_mode $DIR/.lustre/fid ||
10889 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
10891 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
10892 [ $obf_mode -eq $new_obf_mode ] ||
10893 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
10895 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
10896 chmod $old_obf_mode $DIR/.lustre/fid ||
10897 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
10900 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
10901 fid=$($LFS path2fid $test_dir/$tfile-2)
10903 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
10905 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
10906 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
10907 error "create lov data thru .lustre failed"
10909 echo "cp /etc/passwd $test_dir/$tfile-2"
10910 cp /etc/passwd $test_dir/$tfile-2 ||
10911 error "copy to $test_dir/$tfile-2 failed."
10912 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
10913 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
10914 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
10916 rm -rf $test_dir/tfile.lnk
10917 rm -rf $test_dir/$tfile-2
10921 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10922 skip "Need MDS version at least 2.4.1" && return
10924 local tf=$DIR/$tfile
10927 local fid=$($LFS path2fid $tf)
10928 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
10930 # check that we get the same pathname back
10931 local found=$($LFS fid2path $MOUNT "$fid")
10932 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
10933 [ "$found" == "$tf" ] ||
10934 error "fid2path($fid=path2fid($tf)) = $found != $tf"
10936 run_test 154A "lfs path2fid and fid2path basic checks"
10939 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10940 skip "Need MDS version at least 2.4.1" && return
10942 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
10943 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
10944 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
10945 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
10947 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
10948 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
10950 # check that we get the same pathname
10951 echo "PFID: $PFID, name: $name"
10952 local FOUND=$($LFS fid2path $MOUNT "$PFID")
10953 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
10954 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
10955 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
10957 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
10959 run_test 154B "verify the ll_decode_linkea tool"
10962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10963 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10964 { skip "Need MDS version at least 2.2.51"; return 0; }
10965 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
10966 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10968 cp /etc/hosts $DIR/$tfile
10970 fid=$($LFS path2fid $DIR/$tfile)
10972 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
10974 dot_lustre_fid_permission_check "$fid" $DIR ||
10975 error "dot lustre permission check $fid failed"
10977 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
10979 touch $MOUNT/.lustre/file &&
10980 error "creation is not allowed under .lustre"
10982 mkdir $MOUNT/.lustre/dir &&
10983 error "mkdir is not allowed under .lustre"
10987 run_test 154a "Open-by-FID"
10990 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10991 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
10992 { skip "Need MDS version at least 2.2.51"; return 0; }
10993 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10997 local remote_dir=$DIR/$tdir/remote_dir
11001 mkdir -p $DIR/$tdir
11002 $LFS mkdir -i $MDTIDX $remote_dir ||
11003 error "create remote directory failed"
11005 cp /etc/hosts $remote_dir/$tfile
11007 fid=$($LFS path2fid $remote_dir/$tfile)
11009 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
11011 dot_lustre_fid_permission_check "$fid" $remote_dir ||
11012 error "dot lustre permission check $fid failed"
11015 run_test 154b "Open-by-FID for remote directory"
11018 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11019 skip "Need MDS version at least 2.4.1" && return
11021 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
11022 local FID1=$($LFS path2fid $DIR/$tfile.1)
11023 local FID2=$($LFS path2fid $DIR/$tfile.2)
11024 local FID3=$($LFS path2fid $DIR/$tfile.3)
11027 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
11028 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
11029 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
11031 [ "$FID" = "${!want}" ] ||
11032 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
11036 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
11038 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
11039 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
11043 run_test 154c "lfs path2fid and fid2path multiple arguments"
11046 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11047 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
11048 skip "Need MDS version at least 2.5.53" && return
11050 if remote_mds; then
11051 nid=$($LCTL list_nids | sed "s/\./\\\./g")
11055 local proc_ofile="mdt.*.exports.'$nid'.open_files"
11062 local fid=$($LFS path2fid $DIR/$tfile)
11065 cmd="exec $fd<$DIR/$tfile"
11067 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
11068 echo "$fid_list" | grep "$fid"
11071 cmd="exec $fd>/dev/null"
11073 if [ $rc -ne 0 ]; then
11074 error "FID $fid not found in open files list $fid_list"
11077 run_test 154d "Verify open file fid"
11081 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
11082 skip "Need MDS version at least 2.6.50" && return
11084 if ls -a $MOUNT | grep -q '^\.lustre$'; then
11085 error ".lustre returned by readdir"
11088 run_test 154e ".lustre is not returned by readdir"
11091 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11092 # create parent directory on a single MDT to avoid cross-MDT hardlinks
11093 test_mkdir -p -c1 $DIR/$tdir/d
11094 # test dirs inherit from its stripe
11095 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
11096 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
11097 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
11098 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
11101 # get fid of parents
11102 local FID0=$($LFS path2fid $DIR/$tdir/d)
11103 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
11104 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
11105 local FID3=$($LFS path2fid $DIR)
11107 # check that path2fid --parents returns expected <parent_fid>/name
11108 # 1) test for a directory (single parent)
11109 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
11110 [ "$parent" == "$FID0/foo1" ] ||
11111 error "expected parent: $FID0/foo1, got: $parent"
11113 # 2) test for a file with nlink > 1 (multiple parents)
11114 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
11115 echo "$parent" | grep -F "$FID1/$tfile" ||
11116 error "$FID1/$tfile not returned in parent list"
11117 echo "$parent" | grep -F "$FID2/link" ||
11118 error "$FID2/link not returned in parent list"
11120 # 3) get parent by fid
11121 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
11122 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11123 echo "$parent" | grep -F "$FID1/$tfile" ||
11124 error "$FID1/$tfile not returned in parent list (by fid)"
11125 echo "$parent" | grep -F "$FID2/link" ||
11126 error "$FID2/link not returned in parent list (by fid)"
11128 # 4) test for entry in root directory
11129 parent=$($LFS path2fid --parents $DIR/f)
11130 echo "$parent" | grep -F "$FID3/f" ||
11131 error "$FID3/f not returned in parent list"
11133 # 5) test it on root directory
11134 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
11135 error "$MOUNT should not have parents"
11137 # enable xattr caching and check that linkea is correctly updated
11138 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11139 save_lustre_params client "llite.*.xattr_cache" > $save
11140 lctl set_param llite.*.xattr_cache 1
11142 # 6.1) linkea update on rename
11143 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
11145 # get parents by fid
11146 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11147 # foo1 should no longer be returned in parent list
11148 echo "$parent" | grep -F "$FID1" &&
11149 error "$FID1 should no longer be in parent list"
11150 # the new path should appear
11151 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
11152 error "$FID2/$tfile.moved is not in parent list"
11154 # 6.2) linkea update on unlink
11155 rm -f $DIR/$tdir/d/foo2/link
11156 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11157 # foo2/link should no longer be returned in parent list
11158 echo "$parent" | grep -F "$FID2/link" &&
11159 error "$FID2/link should no longer be in parent list"
11163 restore_lustre_params < $save
11166 run_test 154f "get parent fids by reading link ea"
11170 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
11171 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
11172 { skip "Need MDS version at least 2.6.92"; return 0; }
11173 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11175 mkdir -p $DIR/$tdir
11176 llapi_fid_test -d $DIR/$tdir
11178 run_test 154g "various llapi FID tests"
11180 test_155_small_load() {
11181 local temp=$TMP/$tfile
11182 local file=$DIR/$tfile
11184 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
11185 error "dd of=$temp bs=6096 count=1 failed"
11187 cancel_lru_locks $OSC
11188 cmp $temp $file || error "$temp $file differ"
11190 $TRUNCATE $temp 6000
11191 $TRUNCATE $file 6000
11192 cmp $temp $file || error "$temp $file differ (truncate1)"
11194 echo "12345" >>$temp
11195 echo "12345" >>$file
11196 cmp $temp $file || error "$temp $file differ (append1)"
11198 echo "12345" >>$temp
11199 echo "12345" >>$file
11200 cmp $temp $file || error "$temp $file differ (append2)"
11206 test_155_big_load() {
11207 remote_ost_nodsh && skip "remote OST with nodsh" && return
11208 local temp=$TMP/$tfile
11209 local file=$DIR/$tfile
11212 local cache_size=$(do_facet ost$((MAXI+1)) \
11213 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
11214 local large_file_size=$((cache_size * 2))
11216 echo "OSS cache size: $cache_size KB"
11217 echo "Large file size: $large_file_size KB"
11219 [ $MAXV -le $large_file_size ] && \
11220 skip_env "max available OST size needs > $large_file_size KB" && \
11223 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
11225 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
11226 error "dd of=$temp bs=$large_file_size count=1k failed"
11229 cancel_lru_locks osc
11230 cmp $temp $file || error "$temp $file differ"
11236 save_writethrough() {
11237 local facets=$(get_facets OST)
11239 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
11240 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
11244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11245 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11246 save_writethrough $p
11249 set_cache writethrough on
11250 test_155_small_load
11251 restore_lustre_params < $p
11254 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
11257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11258 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11259 save_writethrough $p
11262 set_cache writethrough off
11263 test_155_small_load
11264 restore_lustre_params < $p
11267 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
11270 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11271 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11272 save_writethrough $p
11275 set_cache writethrough on
11276 test_155_small_load
11277 restore_lustre_params < $p
11280 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
11283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11284 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11285 save_writethrough $p
11288 set_cache writethrough off
11289 test_155_small_load
11290 restore_lustre_params < $p
11293 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
11296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11297 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11298 save_writethrough $p
11301 set_cache writethrough on
11303 restore_lustre_params < $p
11306 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11310 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11311 save_writethrough $p
11314 set_cache writethrough off
11316 restore_lustre_params < $p
11319 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11323 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11324 save_writethrough $p
11327 set_cache writethrough on
11329 restore_lustre_params < $p
11332 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11336 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11337 save_writethrough $p
11340 set_cache writethrough off
11342 restore_lustre_params < $p
11345 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11348 remote_ost_nodsh && skip "remote OST with nodsh" && return
11349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11353 local file="$DIR/$tfile"
11354 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11356 [ "$(facet_fstype ost1)" = "zfs" -a \
11357 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11358 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
11361 save_writethrough $p
11364 log "Turn on read and write cache"
11366 set_cache writethrough on
11368 log "Write data and read it back."
11369 log "Read should be satisfied from the cache."
11370 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11372 cancel_lru_locks osc
11373 cat $file >/dev/null
11375 if ! let "AFTER - BEFORE == CPAGES"; then
11376 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11378 log "cache hits:: before: $BEFORE, after: $AFTER"
11381 log "Read again; it should be satisfied from the cache."
11383 cancel_lru_locks osc
11384 cat $file >/dev/null
11386 if ! let "AFTER - BEFORE == CPAGES"; then
11387 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11389 log "cache hits:: before: $BEFORE, after: $AFTER"
11392 log "Turn off the read cache and turn on the write cache"
11394 set_cache writethrough on
11396 log "Read again; it should be satisfied from the cache."
11398 cancel_lru_locks osc
11399 cat $file >/dev/null
11401 if ! let "AFTER - BEFORE == CPAGES"; then
11402 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11404 log "cache hits:: before: $BEFORE, after: $AFTER"
11407 log "Read again; it should not be satisfied from the cache."
11409 cancel_lru_locks osc
11410 cat $file >/dev/null
11412 if ! let "AFTER - BEFORE == 0"; then
11413 error "IN CACHE: before: $BEFORE, after: $AFTER"
11415 log "cache hits:: before: $BEFORE, after: $AFTER"
11418 log "Write data and read it back."
11419 log "Read should be satisfied from the cache."
11420 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11422 cancel_lru_locks osc
11423 cat $file >/dev/null
11425 if ! let "AFTER - BEFORE == CPAGES"; then
11426 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11428 log "cache hits:: before: $BEFORE, after: $AFTER"
11431 log "Read again; it should not be satisfied from the cache."
11433 cancel_lru_locks osc
11434 cat $file >/dev/null
11436 if ! let "AFTER - BEFORE == 0"; then
11437 error "IN CACHE: before: $BEFORE, after: $AFTER"
11439 log "cache hits:: before: $BEFORE, after: $AFTER"
11442 log "Turn off read and write cache"
11444 set_cache writethrough off
11446 log "Write data and read it back"
11447 log "It should not be satisfied from the cache."
11449 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11450 cancel_lru_locks osc
11452 cat $file >/dev/null
11454 if ! let "AFTER - BEFORE == 0"; then
11455 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11457 log "cache hits:: before: $BEFORE, after: $AFTER"
11460 log "Turn on the read cache and turn off the write cache"
11462 set_cache writethrough off
11464 log "Write data and read it back"
11465 log "It should not be satisfied from the cache."
11467 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11469 cancel_lru_locks osc
11470 cat $file >/dev/null
11472 if ! let "AFTER - BEFORE == 0"; then
11473 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
11475 log "cache hits:: before: $BEFORE, after: $AFTER"
11478 log "Read again; it should be satisfied from the cache."
11480 cancel_lru_locks osc
11481 cat $file >/dev/null
11483 if ! let "AFTER - BEFORE == CPAGES"; then
11484 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11486 log "cache hits:: before: $BEFORE, after: $AFTER"
11489 restore_lustre_params < $p
11492 run_test 156 "Verification of tunables"
11495 cleanup_changelog () {
11497 echo "Deregistering changelog client $CL_USER"
11498 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11502 if [[ $MDSCOUNT -gt 1 ]]; then
11503 error_ignore bz17935 $*
11511 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11513 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
11515 if [ $MASK -eq 1 ]; then
11516 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
11518 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
11522 changelog_extract_field() {
11526 local identifier=$4
11528 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
11529 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
11534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11535 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11536 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11537 { skip "Need MDS version at least 2.2.0"; return; }
11539 local CL_USERS="mdd.$MDT0.changelog_users"
11540 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11541 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11542 changelog_register -n)
11543 echo "Registered as changelog user $CL_USER"
11544 trap cleanup_changelog EXIT
11545 $GET_CL_USERS | grep -q $CL_USER ||
11546 error "User $CL_USER not found in changelog_users"
11549 test_mkdir -p $DIR/$tdir/pics/2008/zachy
11550 touch $DIR/$tdir/pics/2008/zachy/timestamp
11551 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
11552 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
11553 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
11554 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
11555 rm $DIR/$tdir/pics/desktop.jpg
11557 $LFS changelog $MDT0 | tail -5
11559 echo "verifying changelog mask"
11560 changelog_chmask "MKDIR"
11561 changelog_chmask "CLOSE"
11563 test_mkdir -p $DIR/$tdir/pics/zach/sofia
11564 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11566 changelog_chmask "MKDIR"
11567 changelog_chmask "CLOSE"
11569 test_mkdir -p $DIR/$tdir/pics/2008/sofia
11570 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
11572 $LFS changelog $MDT0
11573 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
11574 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
11575 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
11576 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
11579 echo "verifying target fid"
11580 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
11581 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
11582 [ "$fidc" == "$fidf" ] ||
11583 err17935 "fid in changelog $fidc != file fid $fidf"
11584 echo "verifying parent fid"
11585 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
11586 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
11587 [ "$fidc" == "$fidf" ] ||
11588 err17935 "pfid in changelog $fidc != dir fid $fidf"
11590 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11591 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
11592 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11593 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
11594 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
11595 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
11597 MIN_REC=$($GET_CL_USERS |
11598 awk 'min == "" || $2 < min {min = $2}; END {print min}')
11599 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11600 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
11601 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
11602 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
11604 # LU-3446 changelog index reset on MDT restart
11605 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11606 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11607 $LFS changelog_clear $MDT0 $CL_USER 0
11608 stop $SINGLEMDS || error "Fail to stop MDT."
11609 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11610 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11611 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
11612 [ $CUR_REC1 == $CUR_REC2 ] ||
11613 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
11615 echo "verifying user deregister"
11617 $GET_CL_USERS | grep -q $CL_USER &&
11618 error "User $CL_USER still in changelog_users"
11620 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
11621 if [ $CL_USER -eq 0 ]; then
11622 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11623 touch $DIR/$tdir/chloe
11624 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
11625 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
11626 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
11628 echo "$CL_USER other changelog users; can't verify off"
11631 run_test 160a "changelog sanity"
11633 test_160b() { # LU-3587
11634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11635 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11636 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
11637 { skip "Need MDS version at least 2.2.0"; return; }
11639 local CL_USERS="mdd.$MDT0.changelog_users"
11640 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11641 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11642 changelog_register -n)
11643 echo "Registered as changelog user $CL_USER"
11644 trap cleanup_changelog EXIT
11645 $GET_CL_USERS | grep -q $CL_USER ||
11646 error "User $CL_USER not found in changelog_users"
11648 local LONGNAME1=$(str_repeat a 255)
11649 local LONGNAME2=$(str_repeat b 255)
11652 echo "creating very long named file"
11653 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
11654 echo "moving very long named file"
11655 mv $LONGNAME1 $LONGNAME2
11657 $LFS changelog $MDT0 | grep RENME
11661 run_test 160b "Verify that very long rename doesn't crash in changelog"
11664 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11667 local server_version=$(lustre_version_code $SINGLEMDS)
11669 [[ $server_version -gt $(version_code 2.5.57) ]] ||
11670 [[ $server_version -gt $(version_code 2.5.1) &&
11671 $server_version -lt $(version_code 2.5.50) ]] ||
11672 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
11673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11675 # Registration step
11676 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11677 changelog_register -n)
11678 trap cleanup_changelog EXIT
11681 mkdir -p $DIR/$tdir
11682 $MCREATE $DIR/$tdir/foo_160c
11683 changelog_chmask "TRUNC"
11684 $TRUNCATE $DIR/$tdir/foo_160c 200
11685 changelog_chmask "TRUNC"
11686 $TRUNCATE $DIR/$tdir/foo_160c 199
11687 $LFS changelog $MDT0
11688 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
11689 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
11690 $LFS changelog_clear $MDT0 $CL_USER 0
11692 # Deregistration step
11695 run_test 160c "verify that changelog log catch the truncate event"
11698 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11699 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11701 local server_version=$(lustre_version_code mds1)
11702 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
11704 [[ $server_version -ge $(version_code 2.7.60) ]] ||
11705 { skip "Need MDS version at least 2.7.60+"; return; }
11706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11708 # Registration step
11709 CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
11710 changelog_register -n)
11712 trap cleanup_changelog EXIT
11713 mkdir -p $DIR/$tdir/migrate_dir
11714 $LFS changelog_clear $MDT0 $CL_USER 0
11716 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
11717 $LFS changelog $MDT0
11718 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
11719 $LFS changelog_clear $MDT0 $CL_USER 0
11720 [ $MIGRATES -eq 1 ] ||
11721 error "MIGRATE changelog mask count $MIGRATES != 1"
11723 # Deregistration step
11726 run_test 160d "verify that changelog log catch the migrate event"
11729 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11732 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11733 changelog_register -n)
11734 echo "Registered as changelog user $CL_USER"
11735 trap cleanup_changelog EXIT
11737 # Delete a future user (expect fail)
11738 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
11741 if [ $rc -eq 0 ]; then
11742 error "Deleted non-existant user cl77"
11743 elif [ $rc -ne 2 ]; then
11744 error "changelog_deregister failed with $rc, " \
11745 "expected 2 (ENOENT)"
11748 # Clear to a bad index (1 billion should be safe)
11749 $LFS changelog_clear $MDT0 $CL_USER 1000000000
11752 if [ $rc -eq 0 ]; then
11753 error "Successfully cleared to invalid CL index"
11754 elif [ $rc -ne 22 ]; then
11755 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
11758 run_test 160e "changelog negative testing"
11762 do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
11763 echo "Deregistering changelog client $CL_USER"
11764 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
11765 echo "Deregistering changelog client $CL_USER2"
11766 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER2
11767 restore_lustre_params < $save_params
11772 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11773 # should be set by default
11775 local CL_USERS="mdd.$MDT0.changelog_users"
11776 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11777 local save_params="$TMP/sanity-$TESTNAME.parameters"
11779 save_lustre_params $SINGLEMDS \
11780 "mdd.$MDT0.changelog_max_idle_time" > $save_params
11781 save_lustre_params $SINGLEMDS \
11782 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11783 save_lustre_params $SINGLEMDS \
11784 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11786 trap cleanup_160f EXIT
11789 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11790 changelog_register -n)
11791 echo "Registered as changelog user $CL_USER"
11792 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11793 changelog_register -n)
11794 echo "Registered as changelog user $CL_USER2"
11795 $GET_CL_USERS | grep -q $CL_USER ||
11796 error "User $CL_USER not found in changelog_users"
11797 $GET_CL_USERS | grep -q $CL_USER2 ||
11798 error "User $CL_USER2 not found in changelog_users"
11800 # generate some changelogs to accumulate
11801 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11802 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11803 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11804 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11806 # check changelogs have been generated
11807 nbcl=$($LFS changelog $MDT0 | wc -l)
11808 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11810 do_facet $SINGLEMDS $LCTL set_param \
11811 mdd.$MDT0.changelog_max_idle_time=10
11812 do_facet $SINGLEMDS $LCTL set_param \
11813 mdd.$MDT0.changelog_min_gc_interval=2
11814 do_facet $SINGLEMDS $LCTL set_param \
11815 mdd.$MDT0.changelog_min_free_cat_entries=3
11817 # simulate changelog catalog almost full
11818 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11819 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11820 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11823 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11824 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 2))
11825 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11826 echo "verifying user clear: $(( $USER_REC1 + 2 )) == $USER_REC2"
11827 [ $USER_REC2 == $(($USER_REC1 + 2)) ] ||
11828 error "user index expected $(($USER_REC1 + 2)) is $USER_REC2"
11831 # generate one more changelog to trigger fail_loc
11832 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11834 # ensure gc thread is done
11835 wait_update_facet $SINGLEMDS \
11836 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11838 # check user still registered
11839 $GET_CL_USERS | grep -q $CL_USER ||
11840 error "User $CL_USER not found in changelog_users"
11841 # check user2 unregistered
11842 $GET_CL_USERS | grep -q $CL_USER2 &&
11843 error "User $CL_USER2 still found in changelog_users"
11845 # check changelogs are present and starting at $USER_REC2 + 1
11846 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11847 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11848 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11849 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11853 run_test 160f "changelog garbage collect (timestamped users)"
11856 # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
11857 # should be set by default
11859 local CL_USERS="mdd.$MDT0.changelog_users"
11860 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
11861 local save_params="$TMP/sanity-$TESTNAME.parameters"
11863 save_lustre_params $SINGLEMDS \
11864 "mdd.$MDT0.changelog_max_idle_indexes" > $save_params
11865 save_lustre_params $SINGLEMDS \
11866 "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
11867 save_lustre_params $SINGLEMDS \
11868 "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
11870 trap cleanup_160f EXIT
11872 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
11873 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1314
11876 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11877 changelog_register -n)
11878 echo "Registered as changelog user $CL_USER"
11879 CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11880 changelog_register -n)
11881 echo "Registered as changelog user $CL_USER2"
11882 $GET_CL_USERS | grep -q $CL_USER ||
11883 error "User $CL_USER not found in changelog_users"
11884 $GET_CL_USERS | grep -q $CL_USER2 ||
11885 error "User $CL_USER2 not found in changelog_users"
11887 # generate some changelogs to accumulate
11888 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11889 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11890 touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
11891 rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
11893 # check changelogs have been generated
11894 nbcl=$($LFS changelog $MDT0 | wc -l)
11895 [[ $nbcl -eq 0 ]] && error "no changelogs found"
11897 do_facet $SINGLEMDS $LCTL set_param \
11898 mdd.$MDT0.changelog_max_idle_indexes=$((nbcl - 1))
11899 do_facet $SINGLEMDS $LCTL set_param \
11900 mdd.$MDT0.changelog_min_gc_interval=2
11901 do_facet $SINGLEMDS $LCTL set_param \
11902 mdd.$MDT0.changelog_min_free_cat_entries=3
11904 # simulate changelog catalog almost full
11905 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
11906 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
11907 do_facet $SINGLEMDS $LCTL set_param fail_val=3
11909 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11910 $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 3))
11911 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
11912 echo "verifying user clear: $(( $USER_REC1 + 3 )) == $USER_REC2"
11913 [ $USER_REC2 == $(($USER_REC1 + 3)) ] ||
11914 error "user index expected $(($USER_REC1 + 3)) is $USER_REC2"
11916 # generate one more changelog to trigger fail_loc
11917 rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
11919 # ensure gc thread is done
11920 wait_update_facet $SINGLEMDS \
11921 "ps -e -o comm= | grep chlg_gc_thread" "" 20
11923 # check user still registered
11924 $GET_CL_USERS | grep -q $CL_USER ||
11925 error "User $CL_USER not found in changelog_users"
11926 # check user2 unregistered
11927 $GET_CL_USERS | grep -q $CL_USER2 &&
11928 error "User $CL_USER2 still found in changelog_users"
11930 # check changelogs are present and starting at $USER_REC2 + 1
11931 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
11932 echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
11933 [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
11934 error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
11938 run_test 160g "changelog garbage collect (old users)"
11941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11942 test_mkdir -c1 $DIR/$tdir
11943 cp /etc/hosts $DIR/$tdir/$tfile
11944 test_mkdir -c1 $DIR/$tdir/foo1
11945 test_mkdir -c1 $DIR/$tdir/foo2
11946 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
11947 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
11948 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
11949 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
11950 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
11951 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
11952 $LFS fid2path $DIR $FID
11953 err17935 "bad link ea"
11956 rm $DIR/$tdir/foo2/zachary
11958 rm $DIR/$tdir/foo2/thor
11960 rm $DIR/$tdir/$tfile
11962 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
11963 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
11965 $LFS fid2path $DIR $FID
11966 err17935 "bad link rename"
11968 rm $DIR/$tdir/foo2/maggie
11971 local longname=filename_avg_len_is_thirty_two_
11972 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
11973 error "failed to hardlink many files"
11974 links=$($LFS fid2path $DIR $FID | wc -l)
11975 echo -n "${links}/1000 links in link EA"
11976 [[ $links -gt 60 ]] ||
11977 err17935 "expected at least 60 links in link EA"
11978 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
11979 error "failed to unlink many hardlinks"
11981 run_test 161a "link ea sanity"
11984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11985 [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
11987 local remote_dir=$DIR/$tdir/remote_dir
11989 mkdir -p $DIR/$tdir
11990 $LFS mkdir -i $MDTIDX $remote_dir ||
11991 error "create remote directory failed"
11993 cp /etc/hosts $remote_dir/$tfile
11994 mkdir -p $remote_dir/foo1
11995 mkdir -p $remote_dir/foo2
11996 ln $remote_dir/$tfile $remote_dir/foo1/sofia
11997 ln $remote_dir/$tfile $remote_dir/foo2/zachary
11998 ln $remote_dir/$tfile $remote_dir/foo1/luna
11999 ln $remote_dir/$tfile $remote_dir/foo2/thor
12001 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
12003 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12004 $LFS fid2path $DIR $FID
12005 err17935 "bad link ea"
12008 rm $remote_dir/foo2/zachary
12010 rm $remote_dir/foo2/thor
12012 rm $remote_dir/$tfile
12014 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
12015 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
12016 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
12017 $LFS fid2path $DIR $FID
12018 err17935 "bad link rename"
12020 rm $remote_dir/foo2/maggie
12023 local longname=filename_avg_len_is_thirty_two_
12024 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
12025 error "failed to hardlink many files"
12026 links=$($LFS fid2path $DIR $FID | wc -l)
12027 echo -n "${links}/1000 links in link EA"
12028 [[ ${links} -gt 60 ]] ||
12029 err17935 "expected at least 60 links in link EA"
12030 unlinkmany $remote_dir/foo2/$longname 1000 ||
12031 error "failed to unlink many hardlinks"
12033 run_test 161b "link ea sanity under remote directory"
12036 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12038 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
12039 skip "Need MDS version at least 2.1.5" && return
12041 # define CLF_RENAME_LAST 0x0001
12042 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
12043 CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
12044 changelog_register -n)
12046 trap cleanup_changelog EXIT
12048 mkdir -p $DIR/$tdir
12049 touch $DIR/$tdir/foo_161c
12050 touch $DIR/$tdir/bar_161c
12051 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12052 $LFS changelog $MDT0 | grep RENME
12053 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
12055 $LFS changelog_clear $MDT0 $CL_USER 0
12056 if [ x$flags != "x0x1" ]; then
12057 error "flag $flags is not 0x1"
12059 echo "rename overwrite a target having nlink = 1," \
12060 "changelog record has flags of $flags"
12062 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
12063 touch $DIR/$tdir/foo_161c
12064 touch $DIR/$tdir/bar_161c
12065 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12066 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12067 $LFS changelog $MDT0 | grep RENME
12068 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
12069 $LFS changelog_clear $MDT0 $CL_USER 0
12070 if [ x$flags != "x0x0" ]; then
12071 error "flag $flags is not 0x0"
12073 echo "rename overwrite a target having nlink > 1," \
12074 "changelog record has flags of $flags"
12076 # rename doesn't overwrite a target (changelog flag 0x0)
12077 touch $DIR/$tdir/foo_161c
12078 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
12079 $LFS changelog $MDT0 | grep RENME
12080 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
12081 $LFS changelog_clear $MDT0 $CL_USER 0
12082 if [ x$flags != "x0x0" ]; then
12083 error "flag $flags is not 0x0"
12085 echo "rename doesn't overwrite a target," \
12086 "changelog record has flags of $flags"
12088 # define CLF_UNLINK_LAST 0x0001
12089 # unlink a file having nlink = 1 (changelog flag 0x1)
12090 rm -f $DIR/$tdir/foo2_161c
12091 $LFS changelog $MDT0 | grep UNLNK
12092 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
12093 $LFS changelog_clear $MDT0 $CL_USER 0
12094 if [ x$flags != "x0x1" ]; then
12095 error "flag $flags is not 0x1"
12097 echo "unlink a file having nlink = 1," \
12098 "changelog record has flags of $flags"
12100 # unlink a file having nlink > 1 (changelog flag 0x0)
12101 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12102 rm -f $DIR/$tdir/foobar_161c
12103 $LFS changelog $MDT0 | grep UNLNK
12104 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
12105 $LFS changelog_clear $MDT0 $CL_USER 0
12106 if [ x$flags != "x0x0" ]; then
12107 error "flag $flags is not 0x0"
12109 echo "unlink a file having nlink > 1," \
12110 "changelog record has flags of $flags"
12113 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
12120 # cleanup previous run
12121 rm -rf $DIR/$tdir/$tfile
12123 user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
12124 changelog_register -n)
12125 [[ $? -eq 0 ]] || error "changelog_register failed"
12127 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
12128 # interfer with $MOUNT/.lustre/fid/ access
12130 [[ $? -eq 0 ]] || error "mkdir failed"
12132 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
12133 $LCTL set_param fail_loc=0x8000140c
12135 $LCTL set_param fail_val=5
12138 echo foofoo > $DIR/$tdir/$tfile &
12141 # wait for create to be delayed
12145 [[ $? -eq 0 ]] || error "create should be blocked"
12147 local tempfile=$(mktemp)
12148 fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
12149 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
12150 # some delay may occur during ChangeLog publishing and file read just
12151 # above, that could allow file write to happen finally
12152 [[ -s $tempfile ]] && echo "file should be empty"
12154 $LCTL set_param fail_loc=0
12157 [[ $? -eq 0 ]] || error "create failed"
12159 $LFS changelog_clear $MDT0 $user 0
12160 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
12162 run_test 161d "create with concurrent .lustre/fid access"
12169 local path=$(${LFS} fid2path $*)
12170 # Remove the '//' indicating a remote directory
12171 path=$(echo $path | sed 's#//#/#g')
12174 if [ $RC -ne 0 ]; then
12175 err17935 "path looked up of $expected failed. Error $RC"
12177 elif [ "${path}" != "${expected}" ]; then
12178 err17935 "path looked up \"${path}\" instead of \"${expected}\""
12181 echo "fid $fid resolves to path $path (expected $expected)"
12184 test_162a() { # was test_162
12185 # Make changes to filesystem
12186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12187 test_mkdir -p -c1 $DIR/$tdir/d2
12188 touch $DIR/$tdir/d2/$tfile
12189 touch $DIR/$tdir/d2/x1
12190 touch $DIR/$tdir/d2/x2
12191 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
12192 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
12194 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
12195 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
12196 error "check path $tdir/d2/$tfile failed"
12199 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
12200 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
12201 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
12202 error "check path $tdir/d2/p/q/r/slink failed"
12204 # softlink to wrong file
12205 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
12206 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
12207 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
12208 error "check path $tdir/d2/p/q/r/slink.wrong failed"
12211 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
12212 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
12213 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
12214 # fid2path dir/fsname should both work
12215 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
12216 error "check path $tdir/d2/a/b/c/new_file failed"
12217 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
12218 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
12220 # hardlink count: check that there are 2 links
12221 # Doesnt work with CMD yet: 17935
12222 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
12223 err17935 "expected 2 links"
12225 # hardlink indexing: remove the first link
12226 rm $DIR/$tdir/d2/p/q/r/hlink
12227 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
12228 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
12232 run_test 162a "path lookup sanity"
12235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12236 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12239 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12240 error "create striped dir failed"
12242 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
12243 tail -n 1 | awk '{print $2}')
12244 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
12246 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
12247 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
12250 for ((i=0;i<5;i++)); do
12251 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
12252 error "get fid for f$i failed"
12253 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
12254 error "check path $tdir/striped_dir/f$i failed"
12256 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
12257 error "get fid for d$i failed"
12258 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
12259 error "check path $tdir/striped_dir/d$i failed"
12264 run_test 162b "striped directory path lookup sanity"
12266 # LU-4239: Verify fid2path works with paths 100 or more directories deep
12268 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
12269 skip "Need MDS version at least 2.7.51" && return
12270 test_mkdir $DIR/$tdir.local
12271 test_mkdir $DIR/$tdir.remote
12272 local lpath=$tdir.local
12273 local rpath=$tdir.remote
12275 for ((i = 0; i <= 101; i++)); do
12278 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
12279 error "get fid for local directory $DIR/$lpath failed"
12280 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
12281 error "check path for local directory $DIR/$lpath failed"
12284 test_mkdir $DIR/$rpath
12285 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
12286 error "get fid for remote directory $DIR/$rpath failed"
12287 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
12288 error "check path for remote directory $DIR/$rpath failed"
12293 run_test 162c "fid2path works with paths 100 or more directories deep"
12296 # do directio so as not to populate the page cache
12297 log "creating a 10 Mb file"
12298 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12299 log "starting reads"
12300 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12301 log "truncating the file"
12302 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12304 kill %+ || true # reads might have finished
12305 echo "wait until dd is finished"
12307 log "removing the temporary file"
12308 rm -rf $DIR/$tfile || error "tmp file removal failed"
12310 run_test 169 "parallel read and truncate should not deadlock"
12313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12314 $LCTL clear # bug 18514
12315 $LCTL debug_daemon start $TMP/${tfile}_log_good
12317 $LCTL debug_daemon stop
12318 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
12319 error "sed failed to read log_good"
12321 $LCTL debug_daemon start $TMP/${tfile}_log_good
12323 $LCTL debug_daemon stop
12325 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
12326 error "lctl df log_bad failed"
12328 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12329 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12331 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
12332 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
12334 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
12335 error "bad_line good_line1 good_line2 are empty"
12337 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12338 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
12339 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
12341 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
12342 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
12343 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
12345 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
12346 error "bad_line_new good_line_new are empty"
12348 local expected_good=$((good_line1 + good_line2*2))
12350 rm -f $TMP/${tfile}*
12351 # LU-231, short malformed line may not be counted into bad lines
12352 if [ $bad_line -ne $bad_line_new ] &&
12353 [ $bad_line -ne $((bad_line_new - 1)) ]; then
12354 error "expected $bad_line bad lines, but got $bad_line_new"
12358 if [ $expected_good -ne $good_line_new ]; then
12359 error "expected $expected_good good lines, but got $good_line_new"
12364 run_test 170 "test lctl df to handle corrupted log ====================="
12366 test_171() { # bug20592
12367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12368 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
12369 $LCTL set_param fail_loc=0x50e
12370 $LCTL set_param fail_val=3000
12371 multiop_bg_pause $DIR/$tfile O_s || true
12373 kill -USR1 $MULTIPID
12377 if dmesg | grep "recursive fault"; then
12378 error "caught a recursive fault"
12380 $LCTL set_param fail_loc=0
12383 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
12385 # it would be good to share it with obdfilter-survey/iokit-libecho code
12386 setup_obdecho_osc () {
12389 local obdfilter_name=$2
12390 echo "Creating new osc for $obdfilter_name on $ost_nid"
12391 # make sure we can find loopback nid
12392 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
12394 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
12395 ${obdfilter_name}_osc_UUID || rc=2; }
12396 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
12397 ${obdfilter_name}_UUID $ost_nid || rc=3; }
12401 cleanup_obdecho_osc () {
12402 local obdfilter_name=$1
12403 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
12404 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
12411 local pages=${3:-64}
12416 local obd_size=$(get_obd_size $node $OBD)
12417 local page_size=$(get_page_size $node)
12418 if [[ -n "$obd_size" ]]; then
12419 local new_count=$((obd_size / (pages * page_size / 1024)))
12420 [[ $new_count -ge $count ]] || count=$new_count
12423 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
12424 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
12426 if [ $rc -eq 0 ]; then
12427 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
12428 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
12430 echo "New object id is $id"
12431 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
12433 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
12434 "test_brw $count w v $pages $id" || rc=4; }
12435 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
12437 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
12438 "cleanup" || rc=5; }
12439 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
12440 "detach" || rc=6; }
12441 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
12446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12447 remote_ost_nodsh && skip "remote OST with nodsh" && return
12449 local rmmod_local=0
12451 if ! module_loaded obdecho; then
12452 load_module obdecho/obdecho
12456 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
12457 local host=$(lctl get_param -n osc.$osc.import |
12458 awk '/current_connection:/ {print $2}' )
12459 local target=$(lctl get_param -n osc.$osc.import |
12460 awk '/target:/ {print $2}' )
12461 target=${target%_UUID}
12463 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
12464 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
12465 [[ -n $target ]] && cleanup_obdecho_osc $target
12466 [ $rmmod_local -eq 1 ] && rmmod obdecho
12469 run_test 180a "test obdecho on osc"
12472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12473 remote_ost_nodsh && skip "remote OST with nodsh" && return
12475 local rmmod_remote=0
12477 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12478 rmmod_remote=true || error "failed to load module obdecho"
12479 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
12480 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
12481 $rmmod_remote && do_facet ost1 "rmmod obdecho"
12484 run_test 180b "test obdecho directly on obdfilter"
12486 test_180c() { # LU-2598
12487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12488 remote_ost_nodsh && skip "remote OST with nodsh" && return
12489 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
12490 skip "Need MDS version at least 2.4.0" && return
12493 local rmmod_remote=false
12494 local pages=16384 # 64MB bulk I/O RPC size
12497 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
12498 rmmod_remote=true || error "failed to load module obdecho"
12500 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
12502 if [ -n "$target" ]; then
12503 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
12505 echo "there is no obdfilter target on ost1"
12508 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
12511 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
12513 test_181() { # bug 22177
12514 test_mkdir $DIR/$tdir
12515 # create enough files to index the directory
12516 createmany -o $DIR/$tdir/foobar 4000
12517 # print attributes for debug purpose
12520 multiop_bg_pause $DIR/$tdir D_Sc || return 1
12522 # remove the files & current working dir
12523 unlinkmany $DIR/$tdir/foobar 4000
12525 kill -USR1 $MULTIPID
12527 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
12530 run_test 181 "Test open-unlinked dir ========================"
12536 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12538 $LCTL set_param mdc.*.rpc_stats=clear
12540 for (( i = 0; i < $tcount; i++ )) ; do
12541 mkdir $DIR/$tdir/$i
12544 for (( i = 0; i < $tcount; i++ )) ; do
12545 createmany -o $DIR/$tdir/$i/f- $fcount &
12549 for (( i = 0; i < $tcount; i++ )) ; do
12550 unlinkmany $DIR/$tdir/$i/f- $fcount &
12554 $LCTL get_param mdc.*.rpc_stats
12558 run_test 182 "Test parallel modify metadata operations ================"
12560 test_183() { # LU-2275
12561 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12562 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
12563 skip "Need MDS version at least 2.3.56" && return
12565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12566 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12567 echo aaa > $DIR/$tdir/$tfile
12569 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
12570 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
12572 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
12573 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
12575 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
12577 # Flush negative dentry cache
12578 touch $DIR/$tdir/$tfile
12580 # We are not checking for any leaked references here, they'll
12581 # become evident next time we do cleanup with module unload.
12584 run_test 183 "No crash or request leak in case of strange dispositions ========"
12586 # test suite 184 is for LU-2016, LU-2017
12588 check_swap_layouts_support && return 0
12590 dir0=$DIR/$tdir/$testnum
12591 test_mkdir -p -c1 $dir0
12596 $SETSTRIPE -c1 $file1
12598 $SETSTRIPE -c2 $file2
12600 gen1=$($GETSTRIPE -g $file1)
12601 gen2=$($GETSTRIPE -g $file2)
12603 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
12604 gen=$($GETSTRIPE -g $file1)
12605 [[ $gen1 != $gen ]] ||
12606 "Layout generation on $file1 does not change"
12607 gen=$($GETSTRIPE -g $file2)
12608 [[ $gen2 != $gen ]] ||
12609 "Layout generation on $file2 does not change"
12611 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
12612 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12614 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
12616 run_test 184a "Basic layout swap"
12619 check_swap_layouts_support && return 0
12621 dir0=$DIR/$tdir/$testnum
12622 mkdir -p $dir0 || error "creating dir $dir0"
12629 $SETSTRIPE -c1 $file1
12630 $SETSTRIPE -c2 $file2
12631 $SETSTRIPE -c1 $file3
12632 chown $RUNAS_ID $file3
12633 gen1=$($GETSTRIPE -g $file1)
12634 gen2=$($GETSTRIPE -g $file2)
12636 $LFS swap_layouts $dir1 $dir2 &&
12637 error "swap of directories layouts should fail"
12638 $LFS swap_layouts $dir1 $file1 &&
12639 error "swap of directory and file layouts should fail"
12640 $RUNAS $LFS swap_layouts $file1 $file2 &&
12641 error "swap of file we cannot write should fail"
12642 $LFS swap_layouts $file1 $file3 &&
12643 error "swap of file with different owner should fail"
12644 /bin/true # to clear error code
12646 run_test 184b "Forbidden layout swap (will generate errors)"
12649 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
12650 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
12651 check_swap_layouts_support && return 0
12653 local dir0=$DIR/$tdir/$testnum
12654 mkdir -p $dir0 || error "creating dir $dir0"
12656 local ref1=$dir0/ref1
12657 local ref2=$dir0/ref2
12658 local file1=$dir0/file1
12659 local file2=$dir0/file2
12660 # create a file large enough for the concurrent test
12661 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
12662 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
12663 echo "ref file size: ref1($(stat -c %s $ref1))," \
12664 "ref2($(stat -c %s $ref2))"
12667 dd if=$ref1 of=$file1 bs=16k &
12670 # Make sure dd starts to copy file
12671 while [ ! -f $file1 ]; do sleep 0.1; done
12673 $LFS swap_layouts $file1 $file2
12676 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
12677 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
12679 # how many bytes copied before swapping layout
12680 local copied=$(stat -c %s $file2)
12681 local remaining=$(stat -c %s $ref1)
12682 remaining=$((remaining - copied))
12683 echo "Copied $copied bytes before swapping layout..."
12685 cmp -n $copied $file1 $ref2 | grep differ &&
12686 error "Content mismatch [0, $copied) of ref2 and file1"
12687 cmp -n $copied $file2 $ref1 ||
12688 error "Content mismatch [0, $copied) of ref1 and file2"
12689 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
12690 error "Content mismatch [$copied, EOF) of ref1 and file1"
12693 rm -f $ref1 $ref2 $file1 $file2
12695 run_test 184c "Concurrent write and layout swap"
12698 check_swap_layouts_support && return 0
12699 [ -z "$(which getfattr 2>/dev/null)" ] &&
12700 skip "no getfattr command" && return 0
12702 local file1=$DIR/$tdir/$tfile-1
12703 local file2=$DIR/$tdir/$tfile-2
12704 local file3=$DIR/$tdir/$tfile-3
12708 mkdir -p $DIR/$tdir
12709 touch $file1 || error "create $file1 failed"
12710 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12711 error "create $file2 failed"
12712 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12713 error "create $file3 failed"
12714 lovea1=$(get_layout_param $file1)
12716 $LFS swap_layouts $file2 $file3 ||
12717 error "swap $file2 $file3 layouts failed"
12718 $LFS swap_layouts $file1 $file2 ||
12719 error "swap $file1 $file2 layouts failed"
12721 lovea2=$(get_layout_param $file2)
12724 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
12726 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12727 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
12729 run_test 184d "allow stripeless layouts swap"
12732 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
12733 { skip "Need MDS version at least 2.6.94"; return 0; }
12734 check_swap_layouts_support && return 0
12735 [ -z "$(which getfattr 2>/dev/null)" ] &&
12736 skip "no getfattr command" && return 0
12738 local file1=$DIR/$tdir/$tfile-1
12739 local file2=$DIR/$tdir/$tfile-2
12740 local file3=$DIR/$tdir/$tfile-3
12743 mkdir -p $DIR/$tdir
12744 touch $file1 || error "create $file1 failed"
12745 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
12746 error "create $file2 failed"
12747 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
12748 error "create $file3 failed"
12750 $LFS swap_layouts $file1 $file2 ||
12751 error "swap $file1 $file2 layouts failed"
12753 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
12754 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
12756 echo 123 > $file1 || error "Should be able to write into $file1"
12758 $LFS swap_layouts $file1 $file3 ||
12759 error "swap $file1 $file3 layouts failed"
12761 echo 123 > $file1 || error "Should be able to write into $file1"
12763 rm -rf $file1 $file2 $file3
12765 run_test 184e "Recreate layout after stripeless layout swaps"
12767 test_185() { # LU-2441
12768 # LU-3553 - no volatile file support in old servers
12769 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
12770 { skip "Need MDS version at least 2.3.60"; return 0; }
12772 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
12773 touch $DIR/$tdir/spoo
12774 local mtime1=$(stat -c "%Y" $DIR/$tdir)
12775 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
12776 error "cannot create/write a volatile file"
12777 [ "$FILESET" == "" ] &&
12778 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
12779 error "FID is still valid after close"
12781 multiop_bg_pause $DIR/$tdir vVw4096_c
12788 # assume that the next FID for this client is sequential, since stdout
12789 # is unfortunately eaten by multiop_bg_pause
12790 local n=$((${fidv[1]} + 1))
12791 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
12792 if [ "$FILESET" == "" ]; then
12793 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
12794 error "FID is missing before close"
12796 kill -USR1 $multi_pid
12797 # 1 second delay, so if mtime change we will see it
12799 local mtime2=$(stat -c "%Y" $DIR/$tdir)
12800 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
12802 run_test 185 "Volatile file support"
12805 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12806 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12807 skip "Need MDS version at least 2.3.0" && return
12809 local dir0=$DIR/$tdir/$testnum
12810 mkdir -p $dir0 || error "creating dir $dir0"
12812 local file=$dir0/file1
12813 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
12814 local dv1=$($LFS data_version $file)
12815 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
12816 local dv2=$($LFS data_version $file)
12817 [[ $dv1 != $dv2 ]] ||
12818 error "data version did not change on write $dv1 == $dv2"
12823 run_test 187a "Test data version change"
12826 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12827 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
12828 skip "Need MDS version at least 2.3.0" && return
12830 local dir0=$DIR/$tdir/$testnum
12831 mkdir -p $dir0 || error "creating dir $dir0"
12833 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
12834 [[ ${DV[0]} != ${DV[1]} ]] ||
12835 error "data version did not change on write"\
12836 " ${DV[0]} == ${DV[1]}"
12841 run_test 187b "Test data version change on volatile file"
12844 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12845 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12846 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
12848 local POOL=${POOL:-cea1}
12849 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
12850 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
12853 local last_ost=$(($OSTCOUNT - 1))
12855 local ost_list=$(seq $first_ost $ost_step $last_ost)
12856 local ost_range="$first_ost $last_ost $ost_step"
12857 local test_path=$POOL_ROOT/$POOL_DIR_NAME
12858 local file_dir=$POOL_ROOT/file_tst
12859 local subdir=$test_path/subdir
12862 if ! combined_mgs_mds ; then
12867 # former test_200a test_200b
12868 pool_add $POOL || { rc=$? ; break; }
12869 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
12870 # former test_200c test_200d
12871 mkdir -p $test_path
12872 pool_set_dir $POOL $test_path || { rc=$? ; break; }
12873 pool_check_dir $POOL $test_path || { rc=$? ; break; }
12875 pool_check_dir $POOL $subdir || { rc=$? ; break; }
12876 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
12877 || { rc=$? ; break; }
12878 # former test_200e test_200f
12879 local files=$((OSTCOUNT*3))
12880 pool_alloc_files $POOL $test_path $files "$ost_list" \
12881 || { rc=$? ; break; }
12882 pool_create_files $POOL $file_dir $files "$ost_list" \
12883 || { rc=$? ; break; }
12884 # former test_200g test_200h
12885 pool_lfs_df $POOL || { rc=$? ; break; }
12886 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
12888 # former test_201a test_201b test_201c
12889 pool_remove_first_target $POOL || { rc=$? ; break; }
12891 local f=$test_path/$tfile
12892 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
12893 pool_remove $POOL $f || { rc=$? ; break; }
12899 if ! combined_mgs_mds ; then
12904 run_test 200 "OST pools"
12906 # usage: default_attr <count | size | offset>
12908 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
12911 # usage: check_default_stripe_attr
12912 check_default_stripe_attr() {
12913 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
12916 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
12918 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
12922 error "unknown getstripe attr '$1'"
12925 [ $ACTUAL == $EXPECTED ] ||
12926 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
12930 test_mkdir $DIR/$tdir
12931 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
12933 check_default_stripe_attr --stripe-count
12934 check_default_stripe_attr --stripe-size
12935 check_default_stripe_attr --stripe-index
12937 run_test 204a "Print default stripe attributes"
12940 test_mkdir $DIR/$tdir
12941 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12943 check_default_stripe_attr --stripe-size
12944 check_default_stripe_attr --stripe-index
12946 run_test 204b "Print default stripe size and offset"
12949 test_mkdir $DIR/$tdir
12950 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12952 check_default_stripe_attr --stripe-count
12953 check_default_stripe_attr --stripe-index
12955 run_test 204c "Print default stripe count and offset"
12958 test_mkdir $DIR/$tdir
12959 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12961 check_default_stripe_attr --stripe-count
12962 check_default_stripe_attr --stripe-size
12964 run_test 204d "Print default stripe count and size"
12967 test_mkdir $DIR/$tdir
12968 $SETSTRIPE -d $DIR/$tdir
12970 check_default_stripe_attr --stripe-count --raw
12971 check_default_stripe_attr --stripe-size --raw
12972 check_default_stripe_attr --stripe-index --raw
12974 run_test 204e "Print raw stripe attributes"
12977 test_mkdir $DIR/$tdir
12978 $SETSTRIPE --stripe-count 1 $DIR/$tdir
12980 check_default_stripe_attr --stripe-size --raw
12981 check_default_stripe_attr --stripe-index --raw
12983 run_test 204f "Print raw stripe size and offset"
12986 test_mkdir $DIR/$tdir
12987 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
12989 check_default_stripe_attr --stripe-count --raw
12990 check_default_stripe_attr --stripe-index --raw
12992 run_test 204g "Print raw stripe count and offset"
12995 test_mkdir $DIR/$tdir
12996 $SETSTRIPE --stripe-index 0 $DIR/$tdir
12998 check_default_stripe_attr --stripe-count --raw
12999 check_default_stripe_attr --stripe-size --raw
13001 run_test 204h "Print raw stripe count and size"
13003 # Figure out which job scheduler is being used, if any,
13004 # or use a fake one
13005 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
13006 JOBENV=SLURM_JOB_ID
13007 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
13009 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
13011 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
13012 JOBENV=LOADL_STEP_ID
13013 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
13016 $LCTL list_param jobid_name > /dev/null 2>&1
13017 if [ $? -eq 0 ]; then
13024 verify_jobstats() {
13029 # we don't really need to clear the stats for this test to work, since each
13030 # command has a unique jobid, but it makes debugging easier if needed.
13031 # for facet in $facets; do
13032 # local dev=$(convert_facet2label $facet)
13033 # # clear old jobstats
13034 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
13037 # use a new JobID for each test, or we might see an old one
13038 [ "$JOBENV" = "FAKE_JOBID" ] &&
13039 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13043 [ "$JOBENV" = "nodelocal" ] && {
13044 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13045 $LCTL set_param jobid_name=$FAKE_JOBID
13049 log "Test: ${cmd[*]}"
13050 log "Using JobID environment variable $JOBENV=$JOBVAL"
13052 if [ $JOBENV = "FAKE_JOBID" ]; then
13053 FAKE_JOBID=$JOBVAL ${cmd[*]}
13058 # all files are created on OST0000
13059 for facet in $facets; do
13060 local stats="*.$(convert_facet2label $facet).job_stats"
13061 if [ $(do_facet $facet lctl get_param $stats |
13062 grep -c $JOBVAL) -ne 1 ]; then
13063 do_facet $facet lctl get_param $stats
13064 error "No jobstats for $JOBVAL found on $facet::$stats"
13071 NEW_JOBENV=${1:-$OLD_JOBENV}
13072 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
13073 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
13078 do_facet $SINGLEMDS \
13079 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
13080 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
13084 test_205() { # Job stats
13085 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
13086 { skip "Need MDS version with at least 2.7.1"; return 0; }
13088 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13089 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13090 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13091 remote_ost_nodsh && skip "remote OST with nodsh" && return
13093 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
13094 skip "Server doesn't support jobstats" && return 0
13095 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
13097 OLD_JOBENV=$($LCTL get_param -n jobid_var)
13098 if [ $OLD_JOBENV != $JOBENV ]; then
13099 jobstats_set $JOBENV
13100 trap cleanup_205 EXIT
13103 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
13104 echo "Registered as changelog user $CL_USER"
13106 OLD_INTERVAL=$(do_facet $SINGLEMDS \
13107 lctl get_param -n mdt.*.job_cleanup_interval)
13108 local interval_new=5
13109 do_facet $SINGLEMDS \
13110 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
13111 local start=$SECONDS
13115 cmd="mkdir $DIR/$tdir"
13116 verify_jobstats "$cmd" "$SINGLEMDS"
13118 cmd="rmdir $DIR/$tdir"
13119 verify_jobstats "$cmd" "$SINGLEMDS"
13120 # mkdir on secondary MDT
13121 if [ $MDSCOUNT -gt 1 ]; then
13122 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
13123 verify_jobstats "$cmd" "mds2"
13126 cmd="mknod $DIR/$tfile c 1 3"
13127 verify_jobstats "$cmd" "$SINGLEMDS"
13129 cmd="rm -f $DIR/$tfile"
13130 verify_jobstats "$cmd" "$SINGLEMDS"
13131 # create all files on OST0000 so verify_jobstats can find OST stats
13133 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
13134 verify_jobstats "$cmd" "$SINGLEMDS"
13136 cmd="touch $DIR/$tfile"
13137 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13139 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
13140 verify_jobstats "$cmd" "ost1"
13142 cancel_lru_locks osc
13143 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
13144 verify_jobstats "$cmd" "ost1"
13146 cmd="$TRUNCATE $DIR/$tfile 0"
13147 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13149 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
13150 verify_jobstats "$cmd" "$SINGLEMDS"
13151 # jobstats expiry - sleep until old stats should be expired
13152 local left=$((interval_new + 5 - (SECONDS - start)))
13153 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
13154 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
13156 cmd="mkdir $DIR/$tdir.expire"
13157 verify_jobstats "$cmd" "$SINGLEMDS"
13158 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
13159 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
13161 # Ensure that jobid are present in changelog (if supported by MDS)
13162 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
13164 $LFS changelog $MDT0 | tail -9
13165 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
13166 [ $jobids -eq 9 ] ||
13167 error "Wrong changelog jobid count $jobids != 9"
13171 jobstats_set $JOBENV
13173 $LFS changelog $MDT0 | tail -1
13174 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
13175 [ $jobids -eq 0 ] ||
13176 error "Unexpected jobids when jobid_var=$JOBENV"
13181 run_test 205 "Verify job stats"
13183 # LU-1480, LU-1773 and LU-1657
13185 mkdir -p $DIR/$tdir
13186 $SETSTRIPE -c -1 $DIR/$tdir
13187 #define OBD_FAIL_LOV_INIT 0x1403
13188 $LCTL set_param fail_loc=0xa0001403
13189 $LCTL set_param fail_val=1
13190 touch $DIR/$tdir/$tfile || true
13192 run_test 206 "fail lov_init_raid0() doesn't lbug"
13195 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13196 local fsz=`stat -c %s $DIR/$tfile`
13197 cancel_lru_locks mdc
13199 # do not return layout in getattr intent
13200 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
13201 $LCTL set_param fail_loc=0x170
13202 local sz=`stat -c %s $DIR/$tfile`
13204 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
13208 run_test 207a "can refresh layout at glimpse"
13211 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13212 local cksum=`md5sum $DIR/$tfile`
13213 local fsz=`stat -c %s $DIR/$tfile`
13214 cancel_lru_locks mdc
13215 cancel_lru_locks osc
13217 # do not return layout in getattr intent
13218 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
13219 $LCTL set_param fail_loc=0x171
13221 # it will refresh layout after the file is opened but before read issues
13222 echo checksum is "$cksum"
13223 echo "$cksum" |md5sum -c --quiet || error "file differs"
13227 run_test 207b "can refresh layout at open"
13230 # FIXME: in this test suite, only RD lease is used. This is okay
13231 # for now as only exclusive open is supported. After generic lease
13232 # is done, this test suite should be revised. - Jinshan
13234 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13235 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
13236 { skip "Need MDS version at least 2.4.52"; return 0; }
13238 echo "==== test 1: verify get lease work"
13239 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
13241 echo "==== test 2: verify lease can be broken by upcoming open"
13242 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13246 $MULTIOP $DIR/$tfile oO_RDONLY:c
13247 kill -USR1 $PID && wait $PID || error "break lease error"
13249 echo "==== test 3: verify lease can't be granted if an open already exists"
13250 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
13254 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
13255 kill -USR1 $PID && wait $PID || error "open file error"
13257 echo "==== test 4: lease can sustain over recovery"
13258 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
13264 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
13266 echo "==== test 5: lease broken can't be regained by replay"
13267 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13271 # open file to break lease and then recovery
13272 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
13275 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
13279 run_test 208 "Exclusive open"
13282 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
13283 skip_env "must have disp_stripe" && return
13286 sync; sleep 5; sync;
13288 echo 3 > /proc/sys/vm/drop_caches
13289 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13291 # open/close 500 times
13292 for i in $(seq 500); do
13296 echo 3 > /proc/sys/vm/drop_caches
13297 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
13299 echo "before: $req_before, after: $req_after"
13300 [ $((req_after - req_before)) -ge 300 ] &&
13301 error "open/close requests are not freed"
13304 run_test 209 "read-only open/close requests should be freed promptly"
13308 size=$((size % 8192 + 1))
13309 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
13310 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
13311 rm -f $DIR/f212 $DIR/f212.xyz
13313 run_test 212 "Sendfile test ============================================"
13316 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
13317 cancel_lru_locks osc
13318 lctl set_param fail_loc=0x8000040f
13319 # generate a read lock
13320 cat $DIR/$tfile > /dev/null
13321 # write to the file, it will try to cancel the above read lock.
13322 cat /etc/hosts >> $DIR/$tfile
13324 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
13326 test_214() { # for bug 20133
13327 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
13328 for (( i=0; i < 340; i++ )) ; do
13329 touch $DIR/$tdir/d214c/a$i
13332 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
13333 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
13334 ls $DIR/d214c || error "ls $DIR/d214c failed"
13335 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
13336 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
13338 run_test 214 "hash-indexed directory test - bug 20133"
13340 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
13341 create_lnet_proc_files() {
13342 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
13345 # counterpart of create_lnet_proc_files
13346 remove_lnet_proc_files() {
13347 rm -f $TMP/lnet_$1.sys
13350 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13351 # 3rd arg as regexp for body
13352 check_lnet_proc_stats() {
13353 local l=$(cat "$TMP/lnet_$1" |wc -l)
13354 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
13356 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
13359 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
13360 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
13361 # optional and can be regexp for 2nd line (lnet.routes case)
13362 check_lnet_proc_entry() {
13363 local blp=2 # blp stands for 'position of 1st line of body'
13364 [ -z "$5" ] || blp=3 # lnet.routes case
13366 local l=$(cat "$TMP/lnet_$1" |wc -l)
13367 # subtracting one from $blp because the body can be empty
13368 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
13370 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
13371 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
13373 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
13374 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
13376 # bail out if any unexpected line happened
13377 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
13378 [ "$?" != 0 ] || error "$2 misformatted"
13381 test_215() { # for bugs 18102, 21079, 21517
13382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13383 local N='(0|[1-9][0-9]*)' # non-negative numeric
13384 local P='[1-9][0-9]*' # positive numeric
13385 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
13386 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
13387 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
13388 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
13390 local L1 # regexp for 1st line
13391 local L2 # regexp for 2nd line (optional)
13392 local BR # regexp for the rest (body)
13394 # lnet.stats should look as 11 space-separated non-negative numerics
13395 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
13396 create_lnet_proc_files "stats"
13397 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
13398 remove_lnet_proc_files "stats"
13400 # lnet.routes should look like this:
13401 # Routing disabled/enabled
13402 # net hops priority state router
13403 # where net is a string like tcp0, hops > 0, priority >= 0,
13404 # state is up/down,
13405 # router is a string like 192.168.1.1@tcp2
13406 L1="^Routing (disabled|enabled)$"
13407 L2="^net +hops +priority +state +router$"
13408 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
13409 create_lnet_proc_files "routes"
13410 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
13411 remove_lnet_proc_files "routes"
13413 # lnet.routers should look like this:
13414 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
13415 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
13416 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
13417 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
13418 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
13419 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
13420 create_lnet_proc_files "routers"
13421 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
13422 remove_lnet_proc_files "routers"
13424 # lnet.peers should look like this:
13425 # nid refs state last max rtr min tx min queue
13426 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
13427 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
13428 # numeric (0 or >0 or <0), queue >= 0.
13429 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
13430 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
13431 create_lnet_proc_files "peers"
13432 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
13433 remove_lnet_proc_files "peers"
13435 # lnet.buffers should look like this:
13436 # pages count credits min
13437 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
13438 L1="^pages +count +credits +min$"
13439 BR="^ +$N +$N +$I +$I$"
13440 create_lnet_proc_files "buffers"
13441 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
13442 remove_lnet_proc_files "buffers"
13444 # lnet.nis should look like this:
13445 # nid status alive refs peer rtr max tx min
13446 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
13447 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
13448 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
13449 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
13450 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
13451 create_lnet_proc_files "nis"
13452 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
13453 remove_lnet_proc_files "nis"
13455 # can we successfully write to lnet.stats?
13456 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
13458 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
13460 test_216() { # bug 20317
13461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13462 remote_ost_nodsh && skip "remote OST with nodsh" && return
13465 local facets=$(get_facets OST)
13466 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13468 save_lustre_params client "osc.*.contention_seconds" > $p
13469 save_lustre_params $facets \
13470 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
13471 save_lustre_params $facets \
13472 "ldlm.namespaces.filter-*.contended_locks" >> $p
13473 save_lustre_params $facets \
13474 "ldlm.namespaces.filter-*.contention_seconds" >> $p
13475 clear_stats osc.*.osc_stats
13477 # agressive lockless i/o settings
13478 do_nodes $(comma_list $(osts_nodes)) \
13479 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
13480 ldlm.namespaces.filter-*.contended_locks=0 \
13481 ldlm.namespaces.filter-*.contention_seconds=60"
13482 lctl set_param -n osc.*.contention_seconds=60
13484 $DIRECTIO write $DIR/$tfile 0 10 4096
13485 $CHECKSTAT -s 40960 $DIR/$tfile
13487 # disable lockless i/o
13488 do_nodes $(comma_list $(osts_nodes)) \
13489 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
13490 ldlm.namespaces.filter-*.contended_locks=32 \
13491 ldlm.namespaces.filter-*.contention_seconds=0"
13492 lctl set_param -n osc.*.contention_seconds=0
13493 clear_stats osc.*.osc_stats
13495 dd if=/dev/zero of=$DIR/$tfile count=0
13496 $CHECKSTAT -s 0 $DIR/$tfile
13498 restore_lustre_params <$p
13502 run_test 216 "check lockless direct write updates file size and kms correctly"
13504 test_217() { # bug 22430
13505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13509 for node in $(nodes_list); do
13510 nid=$(host_nids_address $node $NETTYPE)
13511 if [[ $nid = *-* ]] ; then
13512 echo "lctl ping $(h2nettype $nid)"
13513 lctl ping $(h2nettype $nid)
13515 echo "skipping $node (no hyphen detected)"
13519 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
13522 # do directio so as not to populate the page cache
13523 log "creating a 10 Mb file"
13524 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13525 log "starting reads"
13526 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13527 log "truncating the file"
13528 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13530 kill %+ || true # reads might have finished
13531 echo "wait until dd is finished"
13533 log "removing the temporary file"
13534 rm -rf $DIR/$tfile || error "tmp file removal failed"
13536 run_test 218 "parallel read and truncate should not deadlock ======================="
13539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13540 # write one partial page
13541 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
13542 # set no grant so vvp_io_commit_write will do sync write
13543 $LCTL set_param fail_loc=0x411
13544 # write a full page at the end of file
13545 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
13547 $LCTL set_param fail_loc=0
13548 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
13549 $LCTL set_param fail_loc=0x411
13550 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
13553 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
13554 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
13556 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
13558 test_220() { #LU-325
13559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13560 remote_ost_nodsh && skip "remote OST with nodsh" && return
13561 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13562 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
13565 # create on MDT0000 so the last_id and next_id are correct
13567 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
13571 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
13572 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
13573 osc.$mdtosc_proc1.prealloc_last_id)
13574 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
13575 osc.$mdtosc_proc1.prealloc_next_id)
13579 if ! combined_mgs_mds ; then
13583 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
13584 #define OBD_FAIL_OST_ENOINO 0x229
13585 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
13586 create_pool $FSNAME.$TESTNAME || return 1
13587 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
13589 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
13591 MDSOBJS=$((last_id - next_id))
13592 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
13594 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
13595 echo "OST still has $count kbytes free"
13597 echo "create $MDSOBJS files @next_id..."
13598 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
13600 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13601 osc.$mdtosc_proc1.prealloc_last_id)
13602 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
13603 osc.$mdtosc_proc1.prealloc_next_id)
13605 echo "after creation, last_id=$last_id2, next_id=$next_id2"
13610 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
13611 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
13613 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
13614 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
13615 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
13616 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
13617 echo "unlink $MDSOBJS files @$next_id..."
13618 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
13620 if ! combined_mgs_mds ; then
13624 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
13627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13628 dd if=`which date` of=$MOUNT/date oflag=sync
13629 chmod +x $MOUNT/date
13631 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
13632 $LCTL set_param fail_loc=0x80001401
13634 $MOUNT/date > /dev/null
13637 run_test 221 "make sure fault and truncate race to not cause OOM"
13640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13642 test_mkdir $DIR/$tdir
13643 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13644 createmany -o $DIR/$tdir/$tfile 10
13645 cancel_lru_locks mdc
13646 cancel_lru_locks osc
13647 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13648 $LCTL set_param fail_loc=0x31a
13649 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
13650 $LCTL set_param fail_loc=0
13653 run_test 222a "AGL for ls should not trigger CLIO lock failure"
13656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13658 test_mkdir $DIR/$tdir
13659 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13660 createmany -o $DIR/$tdir/$tfile 10
13661 cancel_lru_locks mdc
13662 cancel_lru_locks osc
13663 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
13664 $LCTL set_param fail_loc=0x31a
13665 rm -r $DIR/$tdir || error "AGL for rmdir failed"
13666 $LCTL set_param fail_loc=0
13668 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
13671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13673 test_mkdir $DIR/$tdir
13674 $LFS setstripe -c 1 -i 0 $DIR/$tdir
13675 createmany -o $DIR/$tdir/$tfile 10
13676 cancel_lru_locks mdc
13677 cancel_lru_locks osc
13678 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
13679 $LCTL set_param fail_loc=0x31b
13680 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
13681 $LCTL set_param fail_loc=0
13684 run_test 223 "osc reenqueue if without AGL lock granted ======================="
13686 test_224a() { # LU-1039, MRP-303
13687 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13688 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
13689 $LCTL set_param fail_loc=0x508
13690 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
13691 $LCTL set_param fail_loc=0
13694 run_test 224a "Don't panic on bulk IO failure"
13696 test_224b() { # LU-1039, MRP-303
13697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13698 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
13699 cancel_lru_locks osc
13700 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
13701 $LCTL set_param fail_loc=0x515
13702 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
13703 $LCTL set_param fail_loc=0
13706 run_test 224b "Don't panic on bulk IO failure"
13708 test_224c() { # LU-6441
13709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13710 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13712 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13713 save_writethrough $p
13714 set_cache writethrough on
13716 local pages_per_rpc=$($LCTL get_param \
13717 osc.*.max_pages_per_rpc)
13718 local at_max=$($LCTL get_param -n at_max)
13719 local timeout=$($LCTL get_param -n timeout)
13720 local test_at="$LCTL get_param -n at_max"
13721 local param_at="$FSNAME.sys.at_max"
13722 local test_timeout="$LCTL get_param -n timeout"
13723 local param_timeout="$FSNAME.sys.timeout"
13725 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
13727 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
13728 error "conf_param at_max=0 failed"
13729 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
13730 error "conf_param timeout=5 failed"
13732 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
13733 do_facet ost1 $LCTL set_param fail_loc=0x520
13734 $LFS setstripe -c 1 -i 0 $DIR/$tfile
13735 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
13737 do_facet ost1 $LCTL set_param fail_loc=0
13739 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
13740 error "conf_param at_max=$at_max failed"
13741 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
13742 $timeout || error "conf_param timeout=$timeout failed"
13744 $LCTL set_param -n $pages_per_rpc
13745 restore_lustre_params < $p
13748 run_test 224c "Don't hang if one of md lost during large bulk RPC"
13750 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
13752 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13753 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13754 if [ -z ${MDSSURVEY} ]; then
13755 skip_env "mds-survey not found" && return
13758 [ $MDSCOUNT -ge 2 ] &&
13759 skip "skipping now for more than one MDT" && return
13761 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13762 { skip "Need MDS version at least 2.2.51"; return; }
13764 local mds=$(facet_host $SINGLEMDS)
13765 local target=$(do_nodes $mds 'lctl dl' | \
13766 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13768 local cmd1="file_count=1000 thrhi=4"
13769 local cmd2="dir_count=2 layer=mdd stripe_count=0"
13770 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13771 local cmd="$cmd1 $cmd2 $cmd3"
13773 rm -f ${TMP}/mds_survey*
13775 eval $cmd || error "mds-survey with zero-stripe failed"
13776 cat ${TMP}/mds_survey*
13777 rm -f ${TMP}/mds_survey*
13779 run_test 225a "Metadata survey sanity with zero-stripe"
13782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13783 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13784 if [ -z ${MDSSURVEY} ]; then
13785 skip_env "mds-survey not found" && return
13787 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
13788 { skip "Need MDS version at least 2.2.51"; return; }
13790 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
13791 skip_env "Need to mount OST to test" && return
13794 local mds=$(facet_host $SINGLEMDS)
13795 local target=$(do_nodes $mds 'lctl dl' | \
13796 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
13798 local cmd1="file_count=1000 thrhi=4"
13799 local cmd2="dir_count=2 layer=mdd stripe_count=1"
13800 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
13801 local cmd="$cmd1 $cmd2 $cmd3"
13803 rm -f ${TMP}/mds_survey*
13805 eval $cmd || error "mds-survey with stripe_count failed"
13806 cat ${TMP}/mds_survey*
13807 rm -f ${TMP}/mds_survey*
13809 run_test 225b "Metadata survey sanity with stripe_count = 1"
13811 mcreate_path2fid () {
13817 local path=$DIR/$tdir/$name
13822 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
13823 error "cannot create $desc"
13825 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
13827 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
13829 fid_path=$($LFS fid2path $MOUNT $fid)
13831 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
13833 [ "$path" == "$fid_path" ] ||
13834 error "fid2path returned $fid_path, expected $path"
13836 echo "pass with $path and $fid"
13841 mkdir -p $DIR/$tdir
13843 mcreate_path2fid 0010666 0 0 fifo "FIFO"
13844 mcreate_path2fid 0020666 1 3 null "character special file (null)"
13845 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
13846 mcreate_path2fid 0040666 0 0 dir "directory"
13847 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
13848 mcreate_path2fid 0100666 0 0 file "regular file"
13849 mcreate_path2fid 0120666 0 0 link "symbolic link"
13850 mcreate_path2fid 0140666 0 0 sock "socket"
13852 run_test 226a "call path2fid and fid2path on files of all type"
13855 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13859 mkdir -p $DIR/$tdir
13860 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
13861 error "create remote directory failed"
13862 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
13863 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
13864 "character special file (null)"
13865 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
13866 "character special file (no device)"
13867 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
13868 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
13869 "block special file (loop)"
13870 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
13871 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
13872 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
13874 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
13876 # LU-1299 Executing or running ldd on a truncated executable does not
13877 # cause an out-of-memory condition.
13879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13880 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
13881 dd if=$(which date) of=$MOUNT/date bs=1k count=1
13882 chmod +x $MOUNT/date
13884 $MOUNT/date > /dev/null
13885 ldd $MOUNT/date > /dev/null
13888 run_test 227 "running truncated executable does not cause OOM"
13890 # LU-1512 try to reuse idle OI blocks
13892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13893 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13894 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13895 skip "ldiskfs only test" && return
13897 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13898 local myDIR=$DIR/$tdir
13901 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13902 $LCTL set_param fail_loc=0x80001002
13903 createmany -o $myDIR/t- 10000
13904 $LCTL set_param fail_loc=0
13905 # The guard is current the largest FID holder
13907 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13909 local IDX=$(($SEQ % 64))
13911 do_facet $SINGLEMDS sync
13912 # Make sure journal flushed.
13914 local blk1=$(do_facet $SINGLEMDS \
13915 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13916 grep Blockcount | awk '{print $4}')
13918 # Remove old files, some OI blocks will become idle.
13919 unlinkmany $myDIR/t- 10000
13920 # Create new files, idle OI blocks should be reused.
13921 createmany -o $myDIR/t- 2000
13922 do_facet $SINGLEMDS sync
13923 # Make sure journal flushed.
13925 local blk2=$(do_facet $SINGLEMDS \
13926 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13927 grep Blockcount | awk '{print $4}')
13929 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13931 run_test 228a "try to reuse idle OI blocks"
13934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13935 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13936 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13937 skip "ldiskfs only test" && return
13939 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13940 local myDIR=$DIR/$tdir
13943 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13944 $LCTL set_param fail_loc=0x80001002
13945 createmany -o $myDIR/t- 10000
13946 $LCTL set_param fail_loc=0
13947 # The guard is current the largest FID holder
13949 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
13951 local IDX=$(($SEQ % 64))
13953 do_facet $SINGLEMDS sync
13954 # Make sure journal flushed.
13956 local blk1=$(do_facet $SINGLEMDS \
13957 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13958 grep Blockcount | awk '{print $4}')
13960 # Remove old files, some OI blocks will become idle.
13961 unlinkmany $myDIR/t- 10000
13964 stop $SINGLEMDS || error "Fail to stop MDT."
13966 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
13968 df $MOUNT || error "Fail to df."
13969 # Create new files, idle OI blocks should be reused.
13970 createmany -o $myDIR/t- 2000
13971 do_facet $SINGLEMDS sync
13972 # Make sure journal flushed.
13974 local blk2=$(do_facet $SINGLEMDS \
13975 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
13976 grep Blockcount | awk '{print $4}')
13978 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
13980 run_test 228b "idle OI blocks can be reused after MDT restart"
13984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13985 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13986 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
13987 skip "ldiskfs only test" && return
13989 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
13990 local myDIR=$DIR/$tdir
13993 #define OBD_FAIL_SEQ_EXHAUST 0x1002
13994 $LCTL set_param fail_loc=0x80001002
13995 # 20000 files can guarantee there are index nodes in the OI file
13996 createmany -o $myDIR/t- 20000
13997 $LCTL set_param fail_loc=0
13998 # The guard is current the largest FID holder
14000 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14002 local IDX=$(($SEQ % 64))
14004 do_facet $SINGLEMDS sync
14005 # Make sure journal flushed.
14007 local blk1=$(do_facet $SINGLEMDS \
14008 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14009 grep Blockcount | awk '{print $4}')
14011 # Remove old files, some OI blocks will become idle.
14012 unlinkmany $myDIR/t- 20000
14014 # The OI file should become empty now
14016 # Create new files, idle OI blocks should be reused.
14017 createmany -o $myDIR/t- 2000
14018 do_facet $SINGLEMDS sync
14019 # Make sure journal flushed.
14021 local blk2=$(do_facet $SINGLEMDS \
14022 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14023 grep Blockcount | awk '{print $4}')
14025 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14027 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
14029 test_229() { # LU-2482, LU-3448
14030 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
14031 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
14033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14034 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
14038 # Create a file with a released layout and stripe count 2.
14039 $MULTIOP $DIR/$tfile H2c ||
14040 error "failed to create file with released layout"
14042 $GETSTRIPE -v $DIR/$tfile
14044 local pattern=$($GETSTRIPE -L $DIR/$tfile)
14045 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
14047 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
14048 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
14049 stat $DIR/$tfile || error "failed to stat released file"
14051 chown $RUNAS_ID $DIR/$tfile ||
14052 error "chown $RUNAS_ID $DIR/$tfile failed"
14054 chgrp $RUNAS_ID $DIR/$tfile ||
14055 error "chgrp $RUNAS_ID $DIR/$tfile failed"
14057 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
14058 rm $DIR/$tfile || error "failed to remove released file"
14060 run_test 229 "getstripe/stat/rm/attr changes work on released files"
14063 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14064 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14067 test_mkdir $DIR/$tdir
14068 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
14069 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
14070 [ $mdt_idx -ne 0 ] &&
14071 error "create local directory on wrong MDT $mdt_idx"
14073 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
14074 error "create remote directory failed"
14075 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
14076 [ $mdt_idx -ne $MDTIDX ] &&
14077 error "create remote directory on wrong MDT $mdt_idx"
14079 createmany -o $DIR/$tdir/test_230/t- 10 ||
14080 error "create files on remote directory failed"
14081 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
14082 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
14083 rm -r $DIR/$tdir || error "unlink remote directory failed"
14085 run_test 230a "Create remote directory and files under the remote directory"
14088 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14089 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14096 local migrate_dir=$DIR/$tdir/migrate_dir
14097 local other_dir=$DIR/$tdir/other_dir
14099 test_mkdir $DIR/$tdir
14100 test_mkdir -i0 -c1 $migrate_dir
14101 test_mkdir -i0 -c1 $other_dir
14102 for ((i=0; i<10; i++)); do
14103 mkdir -p $migrate_dir/dir_${i}
14104 createmany -o $migrate_dir/dir_${i}/f 10 ||
14105 error "create files under remote dir failed $i"
14108 cp /etc/passwd $migrate_dir/$tfile
14109 cp /etc/passwd $other_dir/$tfile
14110 chattr +SAD $migrate_dir
14111 chattr +SAD $migrate_dir/$tfile
14113 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14114 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14115 local old_dir_mode=$(stat -c%f $migrate_dir)
14116 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
14118 mkdir -p $migrate_dir/dir_default_stripe2
14119 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
14120 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
14122 mkdir -p $other_dir
14123 ln $migrate_dir/$tfile $other_dir/luna
14124 ln $migrate_dir/$tfile $migrate_dir/sofia
14125 ln $other_dir/$tfile $migrate_dir/david
14126 ln -s $migrate_dir/$tfile $other_dir/zachary
14127 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
14128 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
14130 $LFS migrate -m $MDTIDX $migrate_dir ||
14131 error "fails on migrating remote dir to MDT1"
14133 echo "migratate to MDT1, then checking.."
14134 for ((i = 0; i < 10; i++)); do
14135 for file in $(find $migrate_dir/dir_${i}); do
14136 mdt_index=$($LFS getstripe -M $file)
14137 [ $mdt_index == $MDTIDX ] ||
14138 error "$file is not on MDT${MDTIDX}"
14142 # the multiple link file should still in MDT0
14143 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
14144 [ $mdt_index == 0 ] ||
14145 error "$file is not on MDT${MDTIDX}"
14147 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14148 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14149 error " expect $old_dir_flag get $new_dir_flag"
14151 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14152 [ "$old_file_flag" = "$new_file_flag" ] ||
14153 error " expect $old_file_flag get $new_file_flag"
14155 local new_dir_mode=$(stat -c%f $migrate_dir)
14156 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14157 error "expect mode $old_dir_mode get $new_dir_mode"
14159 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14160 [ "$old_file_mode" = "$new_file_mode" ] ||
14161 error "expect mode $old_file_mode get $new_file_mode"
14163 diff /etc/passwd $migrate_dir/$tfile ||
14164 error "$tfile different after migration"
14166 diff /etc/passwd $other_dir/luna ||
14167 error "luna different after migration"
14169 diff /etc/passwd $migrate_dir/sofia ||
14170 error "sofia different after migration"
14172 diff /etc/passwd $migrate_dir/david ||
14173 error "david different after migration"
14175 diff /etc/passwd $other_dir/zachary ||
14176 error "zachary different after migration"
14178 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14179 error "${tfile}_ln different after migration"
14181 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14182 error "${tfile}_ln_other different after migration"
14184 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
14185 [ $stripe_count = 2 ] ||
14186 error "dir strpe_count $d != 2 after migration."
14188 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
14189 [ $stripe_count = 2 ] ||
14190 error "file strpe_count $d != 2 after migration."
14192 #migrate back to MDT0
14195 $LFS migrate -m $MDTIDX $migrate_dir ||
14196 error "fails on migrating remote dir to MDT0"
14198 echo "migrate back to MDT0, checking.."
14199 for file in $(find $migrate_dir); do
14200 mdt_index=$($LFS getstripe -M $file)
14201 [ $mdt_index == $MDTIDX ] ||
14202 error "$file is not on MDT${MDTIDX}"
14205 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14206 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14207 error " expect $old_dir_flag get $new_dir_flag"
14209 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14210 [ "$old_file_flag" = "$new_file_flag" ] ||
14211 error " expect $old_file_flag get $new_file_flag"
14213 local new_dir_mode=$(stat -c%f $migrate_dir)
14214 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14215 error "expect mode $old_dir_mode get $new_dir_mode"
14217 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14218 [ "$old_file_mode" = "$new_file_mode" ] ||
14219 error "expect mode $old_file_mode get $new_file_mode"
14221 diff /etc/passwd ${migrate_dir}/$tfile ||
14222 error "$tfile different after migration"
14224 diff /etc/passwd ${other_dir}/luna ||
14225 error "luna different after migration"
14227 diff /etc/passwd ${migrate_dir}/sofia ||
14228 error "sofia different after migration"
14230 diff /etc/passwd ${other_dir}/zachary ||
14231 error "zachary different after migration"
14233 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14234 error "${tfile}_ln different after migration"
14236 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14237 error "${tfile}_ln_other different after migration"
14239 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
14240 [ $stripe_count = 2 ] ||
14241 error "dir strpe_count $d != 2 after migration."
14243 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
14244 [ $stripe_count = 2 ] ||
14245 error "file strpe_count $d != 2 after migration."
14247 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14249 run_test 230b "migrate directory"
14252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14253 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14254 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14258 local migrate_dir=$DIR/$tdir/migrate_dir
14260 #If migrating directory fails in the middle, all entries of
14261 #the directory is still accessiable.
14262 test_mkdir $DIR/$tdir
14263 test_mkdir -i0 -c1 $migrate_dir
14265 createmany -o $migrate_dir/f 10 ||
14266 error "create files under ${migrate_dir} failed"
14268 #failed after migrating 5 entries
14269 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
14270 do_facet mds1 lctl set_param fail_loc=0x20001801
14271 do_facet mds1 lctl set_param fail_val=5
14272 local t=$(ls $migrate_dir | wc -l)
14273 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
14274 error "migrate should fail after 5 entries"
14276 mkdir $migrate_dir/dir &&
14277 error "mkdir succeeds under migrating directory"
14278 touch $migrate_dir/file &&
14279 error "touch file succeeds under migrating directory"
14281 local u=$(ls $migrate_dir | wc -l)
14282 [ "$u" == "$t" ] || error "$u != $t during migration"
14284 for file in $(find $migrate_dir); do
14285 stat $file || error "stat $file failed"
14288 do_facet mds1 lctl set_param fail_loc=0
14289 do_facet mds1 lctl set_param fail_val=0
14291 $LFS migrate -m $MDTIDX $migrate_dir ||
14292 error "migrate open files should failed with open files"
14294 echo "Finish migration, then checking.."
14295 for file in $(find $migrate_dir); do
14296 mdt_index=$($LFS getstripe -M $file)
14297 [ $mdt_index == $MDTIDX ] ||
14298 error "$file is not on MDT${MDTIDX}"
14301 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14303 run_test 230c "check directory accessiblity if migration is failed"
14306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14307 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14310 local migrate_dir=$DIR/$tdir/migrate_dir
14314 test_mkdir $DIR/$tdir
14315 test_mkdir -i0 -c1 $migrate_dir
14317 for ((i=0; i<100; i++)); do
14318 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
14319 createmany -o $migrate_dir/dir_${i}/f 100 ||
14320 error "create files under remote dir failed $i"
14323 $LFS migrate -m $MDTIDX $migrate_dir ||
14324 error "migrate remote dir error"
14326 echo "Finish migration, then checking.."
14327 for file in $(find $migrate_dir); do
14328 mdt_index=$($LFS getstripe -M $file)
14329 [ $mdt_index == $MDTIDX ] ||
14330 error "$file is not on MDT${MDTIDX}"
14333 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14335 run_test 230d "check migrate big directory"
14338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14339 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14345 mkdir -p $DIR/$tdir
14346 mkdir $DIR/$tdir/migrate_dir
14347 mkdir $DIR/$tdir/other_dir
14348 touch $DIR/$tdir/migrate_dir/a
14349 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
14350 ls $DIR/$tdir/other_dir
14352 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14353 error "migrate dir fails"
14355 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14356 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14358 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14359 [ $mdt_index == 0 ] || error "a is not on MDT0"
14361 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
14362 error "migrate dir fails"
14364 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
14365 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
14367 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14368 [ $mdt_index == 1 ] || error "a is not on MDT1"
14370 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
14371 [ $mdt_index == 1 ] || error "b is not on MDT1"
14373 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14374 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
14376 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
14378 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14380 run_test 230e "migrate mulitple local link files"
14383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14384 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14388 mkdir -p $DIR/$tdir
14389 mkdir $DIR/$tdir/migrate_dir
14390 $LFS mkdir -i1 $DIR/$tdir/other_dir
14391 touch $DIR/$tdir/migrate_dir/a
14392 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
14393 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
14394 ls $DIR/$tdir/other_dir
14396 # a should be migrated to MDT1, since no other links on MDT0
14397 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14398 error "#1 migrate dir fails"
14399 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14400 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
14401 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14402 [ $mdt_index == 1 ] || error "a is not on MDT1"
14404 # a should stay on MDT1, because it is a mulitple link file
14405 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14406 error "#2 migrate dir fails"
14407 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14408 [ $mdt_index == 1 ] || error "a is not on MDT1"
14410 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
14411 error "#3 migrate dir fails"
14413 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
14414 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
14415 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
14417 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
14418 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
14420 # a should be migrated to MDT0, since no other links on MDT1
14421 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
14422 error "#4 migrate dir fails"
14423 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
14424 [ $mdt_index == 0 ] || error "a is not on MDT0"
14426 rm -rf $DIR/$tdir || error "rm dir failed after migration"
14428 run_test 230f "migrate mulitple remote link files"
14431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14432 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14434 mkdir -p $DIR/$tdir/migrate_dir
14436 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
14437 error "migrating dir to non-exist MDT succeeds"
14440 run_test 230g "migrate dir to non-exist MDT"
14443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14444 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14445 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
14446 skip "Need MDS version at least 2.7.64" && return
14449 mkdir -p $DIR/$tdir/migrate_dir
14451 $LFS migrate -m1 $DIR &&
14452 error "migrating mountpoint1 should fail"
14454 $LFS migrate -m1 $DIR/$tdir/.. &&
14455 error "migrating mountpoint2 should fail"
14457 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
14458 error "migrating $tdir fail"
14460 mdt_index=$($LFS getstripe -M $DIR/$tdir)
14461 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14463 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
14464 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
14467 run_test 230h "migrate .. and root"
14470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14471 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14473 mkdir -p $DIR/$tdir/migrate_dir
14475 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
14476 error "migration fails with a tailing slash"
14478 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
14479 error "migration fails with two tailing slashes"
14481 run_test 230i "lfs migrate -m tolerates trailing slashes"
14485 # For simplicity this test assumes that max_pages_per_rpc
14486 # is the same across all OSCs
14487 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
14488 local bulk_size=$((max_pages * 4096))
14489 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
14492 mkdir -p $DIR/$tdir
14493 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
14494 error "failed to set stripe with -S ${brw_size}M option"
14496 # clear the OSC stats
14497 $LCTL set_param osc.*.stats=0 &>/dev/null
14500 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
14501 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
14502 oflag=direct &>/dev/null || error "dd failed"
14504 sync; sleep 1; sync # just to be safe
14505 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
14506 if [ x$nrpcs != "x1" ]; then
14507 $LCTL get_param osc.*.stats
14508 error "found $nrpcs ost_write RPCs, not 1 as expected"
14512 # Drop the OSC cache, otherwise we will read from it
14513 cancel_lru_locks osc
14515 # clear the OSC stats
14516 $LCTL set_param osc.*.stats=0 &>/dev/null
14518 # Client reads $bulk_size.
14519 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
14520 iflag=direct &>/dev/null || error "dd failed"
14522 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
14523 if [ x$nrpcs != "x1" ]; then
14524 $LCTL get_param osc.*.stats
14525 error "found $nrpcs ost_read RPCs, not 1 as expected"
14528 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
14531 mkdir -p $DIR/$tdir
14533 for i in {0..1023}; do
14534 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
14535 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
14536 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
14540 run_test 231b "must not assert on fully utilized OST request buffer"
14543 mkdir -p $DIR/$tdir
14544 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14546 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14547 do_facet ost1 $LCTL set_param fail_loc=0x31c
14549 # ignore dd failure
14550 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
14552 do_facet ost1 $LCTL set_param fail_loc=0
14553 umount_client $MOUNT || error "umount failed"
14554 mount_client $MOUNT || error "mount failed"
14555 stop ost1 || error "cannot stop ost1"
14556 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
14558 run_test 232a "failed lock should not block umount"
14561 mkdir -p $DIR/$tdir
14562 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
14563 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
14565 cancel_lru_locks osc
14567 #define OBD_FAIL_LDLM_OST_LVB 0x31c
14568 do_facet ost1 $LCTL set_param fail_loc=0x31c
14571 $LFS data_version $DIR/$tdir/$tfile || true
14573 do_facet ost1 $LCTL set_param fail_loc=0
14574 umount_client $MOUNT || error "umount failed"
14575 mount_client $MOUNT || error "mount failed"
14576 stop ost1 || error "cannot stop ost1"
14577 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
14579 run_test 232b "failed data version lock should not block umount"
14582 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
14583 { skip "Need MDS version at least 2.3.64"; return; }
14584 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14586 local fid=$($LFS path2fid $MOUNT)
14587 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14588 error "cannot access $MOUNT using its FID '$fid'"
14590 run_test 233a "checking that OBF of the FS root succeeds"
14593 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
14594 { skip "Need MDS version at least 2.5.90"; return; }
14595 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
14597 local fid=$($LFS path2fid $MOUNT/.lustre)
14598 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14599 error "cannot access $MOUNT/.lustre using its FID '$fid'"
14601 fid=$($LFS path2fid $MOUNT/.lustre/fid)
14602 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
14603 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
14605 run_test 233b "checking that OBF of the FS .lustre succeeds"
14608 local p="$TMP/sanityN-$TESTNAME.parameters"
14609 save_lustre_params client "llite.*.xattr_cache" > $p
14610 lctl set_param llite.*.xattr_cache 1 ||
14611 { skip "xattr cache is not supported"; return 0; }
14613 mkdir -p $DIR/$tdir || error "mkdir failed"
14614 touch $DIR/$tdir/$tfile || error "touch failed"
14615 # OBD_FAIL_LLITE_XATTR_ENOMEM
14616 $LCTL set_param fail_loc=0x1405
14617 # output of the form: attr 2 4 44 3 fc13 x86_64
14618 V=($(IFS=".-" rpm -q attr))
14619 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
14620 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
14621 # attr pre-2.4.44-7 had a bug with rc
14622 # LU-3703 - SLES 11 and FC13 clients have older attr
14623 getfattr -n user.attr $DIR/$tdir/$tfile &&
14624 error "getfattr should have failed with ENOMEM"
14626 skip "LU-3703: attr version $(getfattr --version) too old"
14628 $LCTL set_param fail_loc=0x0
14631 restore_lustre_params < $p
14634 run_test 234 "xattr cache should not crash on ENOMEM"
14637 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
14638 skip "Need MDS version at least 2.4.52" && return
14639 flock_deadlock $DIR/$tfile
14644 124) error "process hangs on a deadlock"
14646 *) error "error executing flock_deadlock $DIR/$tfile"
14650 run_test 235 "LU-1715: flock deadlock detection does not work properly"
14654 check_swap_layouts_support && return 0
14655 test_mkdir -c1 $DIR/$tdir
14657 local ref1=/etc/passwd
14658 local ref2=/etc/group
14659 local file1=$DIR/$tdir/f1
14660 local file2=$DIR/$tdir/f2
14662 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
14663 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
14664 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
14665 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
14666 local fd=$(free_fd)
14667 local cmd="exec $fd<>$file2"
14670 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
14671 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
14674 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14679 run_test 236 "Layout swap on open unlinked file"
14681 # test to verify file handle related system calls
14682 # (name_to_handle_at/open_by_handle_at)
14683 # The new system calls are supported in glibc >= 2.14.
14686 echo "Test file_handle syscalls" > $DIR/$tfile ||
14687 error "write failed"
14688 check_fhandle_syscalls $DIR/$tfile ||
14689 error "check_fhandle_syscalls failed"
14691 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
14693 # LU-4659 linkea consistency
14695 local server_version=$(lustre_version_code $SINGLEMDS)
14697 [[ $server_version -gt $(version_code 2.5.57) ]] ||
14698 [[ $server_version -gt $(version_code 2.5.1) &&
14699 $server_version -lt $(version_code 2.5.50) ]] ||
14700 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
14703 ln $DIR/$tfile $DIR/$tfile.lnk
14704 touch $DIR/$tfile.new
14705 mv $DIR/$tfile.new $DIR/$tfile
14706 local fid1=$($LFS path2fid $DIR/$tfile)
14707 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
14708 local path1=$($LFS fid2path $FSNAME "$fid1")
14709 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
14710 local path2=$($LFS fid2path $FSNAME "$fid2")
14711 [ $tfile.lnk == $path2 ] ||
14712 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
14715 run_test 238 "Verify linkea consistency"
14718 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
14719 skip "Need MDS version at least 2.5.60" && return
14720 local list=$(comma_list $(mdts_nodes))
14722 mkdir -p $DIR/$tdir
14723 createmany -o $DIR/$tdir/f- 5000
14724 unlinkmany $DIR/$tdir/f- 5000
14725 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
14726 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
14727 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
14728 osp.*MDT*.sync_in_flight" | calc_sum)
14729 [ "$changes" -eq 0 ] || error "$changes not synced"
14731 run_test 239 "osp_sync test"
14733 test_239a() { #LU-5297
14734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14736 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
14737 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
14738 chgrp $RUNAS_GID $DIR/$tfile
14739 wait_delete_completed
14741 run_test 239a "process invalid osp sync record correctly"
14743 test_239b() { #LU-5297
14744 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14746 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
14747 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
14748 chgrp $RUNAS_GID $DIR/$tfile1
14749 wait_delete_completed
14750 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14752 chgrp $RUNAS_GID $DIR/$tfile2
14753 wait_delete_completed
14755 run_test 239b "process osp sync record with ENOMEM error correctly"
14758 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14759 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14761 mkdir -p $DIR/$tdir
14763 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
14764 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
14765 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
14766 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
14768 umount_client $MOUNT || error "umount failed"
14769 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
14770 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
14771 mount_client $MOUNT || error "failed to mount client"
14773 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
14774 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
14776 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
14779 for LOOP in $(seq $1); do
14780 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
14781 cancel_lru_locks $OSC || true
14786 for LOOP in $(seq $1); do
14787 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
14788 iflag=direct 2>/dev/null
14792 test_241a() { # was test_241
14793 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14795 cancel_lru_locks $OSC
14796 test_241_bio 1000 &
14801 run_test 241a "bio vs dio"
14804 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
14806 test_241_dio 1000 &
14811 run_test 241b "dio vs dio"
14814 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14815 mkdir -p $DIR/$tdir
14816 touch $DIR/$tdir/$tfile
14818 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
14819 do_facet mds1 lctl set_param fail_loc=0x105
14820 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
14822 do_facet mds1 lctl set_param fail_loc=0
14823 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
14825 run_test 242 "mdt_readpage failure should not cause directory unreadable"
14829 test_mkdir $DIR/$tdir
14830 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
14832 run_test 243 "various group lock tests"
14836 test_mkdir $DIR/$tdir
14837 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
14838 sendfile_grouplock $DIR/$tdir/$tfile || \
14839 error "sendfile+grouplock failed"
14842 run_test 244 "sendfile with group lock tests"
14845 local flagname="multi_mod_rpcs"
14846 local connect_data_name="max_mod_rpcs"
14849 # check if multiple modify RPCs flag is set
14850 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
14851 grep "connect_flags:")
14854 echo "$out" | grep -qw $flagname
14855 if [ $? -ne 0 ]; then
14856 echo "connect flag $flagname is not set"
14860 # check if multiple modify RPCs data is set
14861 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
14864 echo "$out" | grep -qw $connect_data_name ||
14865 error "import should have connect data $connect_data_name"
14867 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
14869 test_246() { # LU-7371
14870 remote_ost_nodsh && skip "remote OST with nodsh" && return
14871 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
14872 skip "Need OST version >= 2.7.62" && return 0
14873 do_facet ost1 $LCTL set_param fail_val=4095
14874 #define OBD_FAIL_OST_READ_SIZE 0x234
14875 do_facet ost1 $LCTL set_param fail_loc=0x234
14876 $LFS setstripe $DIR/$tfile -i 0 -c 1
14877 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
14878 cancel_lru_locks $FSNAME-OST0000
14879 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
14881 run_test 246 "Read file of size 4095 should return right length"
14887 umount_client $submount
14892 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14894 { skip "Fileset feature is not supported"; return; }
14896 local submount=${MOUNT}_$tdir
14899 mkdir -p $submount || error "mkdir $submount failed"
14900 FILESET="$FILESET/$tdir" mount_client $submount ||
14901 error "mount $submount failed"
14902 trap "cleanup_247 $submount" EXIT
14903 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
14904 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
14905 error "read $MOUNT/$tdir/$tfile failed"
14906 cleanup_247 $submount
14908 run_test 247a "mount subdir as fileset"
14911 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14912 { skip "Fileset feature is not supported"; return; }
14914 local submount=${MOUNT}_$tdir
14916 rm -rf $MOUNT/$tdir
14917 mkdir -p $submount || error "mkdir $submount failed"
14919 FILESET="$FILESET/$tdir" mount_client $submount &&
14920 error "mount $submount should fail"
14923 run_test 247b "mount subdir that dose not exist"
14926 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14927 { skip "Fileset feature is not supported"; return; }
14929 local submount=${MOUNT}_$tdir
14931 mkdir -p $MOUNT/$tdir/dir1
14932 mkdir -p $submount || error "mkdir $submount failed"
14933 trap "cleanup_247 $submount" EXIT
14934 FILESET="$FILESET/$tdir" mount_client $submount ||
14935 error "mount $submount failed"
14936 local fid=$($LFS path2fid $MOUNT/)
14937 $LFS fid2path $submount $fid && error "fid2path should fail"
14938 cleanup_247 $submount
14940 run_test 247c "running fid2path outside root"
14943 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
14944 { skip "Fileset feature is not supported"; return; }
14946 local submount=${MOUNT}_$tdir
14948 mkdir -p $MOUNT/$tdir/dir1
14949 mkdir -p $submount || error "mkdir $submount failed"
14950 FILESET="$FILESET/$tdir" mount_client $submount ||
14951 error "mount $submount failed"
14952 trap "cleanup_247 $submount" EXIT
14953 local fid=$($LFS path2fid $submount/dir1)
14954 $LFS fid2path $submount $fid || error "fid2path should succeed"
14955 cleanup_247 $submount
14957 run_test 247d "running fid2path inside root"
14961 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
14963 { skip "Fileset feature is not supported"; return; }
14965 local submount=${MOUNT}_$tdir
14968 mkdir -p $submount || error "mkdir $submount failed"
14969 FILESET="$FILESET/.." mount_client $submount &&
14970 error "mount $submount should fail"
14973 run_test 247e "mount .. as fileset"
14976 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
14977 [ -z "$fast_read_sav" ] && skip "no fast read support" && return
14979 # create a large file for fast read verification
14980 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
14982 # make sure the file is created correctly
14983 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
14984 { rm -f $DIR/$tfile; skip "file creation error" && return; }
14986 echo "Test 1: verify that fast read is 4 times faster on cache read"
14988 # small read with fast read enabled
14989 $LCTL set_param -n llite.*.fast_read=1
14990 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14991 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14992 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14993 # small read with fast read disabled
14994 $LCTL set_param -n llite.*.fast_read=0
14995 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
14996 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
14997 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
14999 # verify that fast read is 4 times faster for cache read
15000 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
15001 error_not_in_vm "fast read was not 4 times faster: " \
15002 "$t_fast vs $t_slow"
15004 echo "Test 2: verify the performance between big and small read"
15005 $LCTL set_param -n llite.*.fast_read=1
15007 # 1k non-cache read
15008 cancel_lru_locks osc
15009 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15010 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15011 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15013 # 1M non-cache read
15014 cancel_lru_locks osc
15015 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15016 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15017 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15019 # verify that big IO is not 4 times faster than small IO
15020 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
15021 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
15023 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
15026 run_test 248 "fast read verification"
15028 test_249() { # LU-7890
15030 $SETSTRIPE -c 1 $DIR/$tfile
15032 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
15033 skip "Need at least version 2.8.54"
15035 # Offset 2T == 4k * 512M
15036 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
15037 error "dd to 2T offset failed"
15039 run_test 249 "Write above 2T file size"
15042 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
15043 && skip "no 16TB file size limit on ZFS" && return
15045 $SETSTRIPE -c 1 $DIR/$tfile
15046 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
15047 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
15048 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
15049 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
15050 conv=notrunc,fsync && error "append succeeded"
15053 run_test 250 "Write above 16T limit"
15056 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
15058 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
15059 #Skip once - writing the first stripe will succeed
15060 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15061 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
15062 error "short write happened"
15064 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15065 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
15066 error "short read happened"
15070 run_test 251 "Handling short read and write correctly"
15080 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15081 remote_ost_nodsh && skip "remote OST with nodsh" && return
15082 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
15083 "$(facet_fstype mds1)" != "ldiskfs" ]; then
15084 skip "ldiskfs only test"
15088 # check lr_reader on OST0000
15090 dev=$(facet_device $tgt)
15091 out=$(do_facet $tgt $LR_READER $dev)
15092 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15094 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
15095 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
15096 error "Invalid uuid returned by $LR_READER on target $tgt"
15097 echo -e "uuid returned by $LR_READER is '$uuid'\n"
15099 # check lr_reader -c on MDT0000
15101 dev=$(facet_device $tgt)
15102 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
15103 echo "$LR_READER does not support additional options"
15106 out=$(do_facet $tgt $LR_READER -c $dev)
15107 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15109 num=$(echo "$out" | grep -c "mdtlov")
15110 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
15111 error "Invalid number of mdtlov clients returned by $LR_READER"
15112 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
15114 # check lr_reader -cr on MDT0000
15115 out=$(do_facet $tgt $LR_READER -cr $dev)
15116 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15118 echo "$out" | grep -q "^reply_data:$" ||
15119 error "$LR_READER should have returned 'reply_data' section"
15120 num=$(echo "$out" | grep -c "client_generation")
15121 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
15123 run_test 252 "check lr_reader tool"
15125 test_253_fill_ost() {
15126 local size_mb #how many MB should we write to pass watermark
15127 local lwm=$3 #low watermark
15128 local free_10mb #10% of free space
15130 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15131 size_mb=$((free_kb / 1024 - lwm))
15132 free_10mb=$((free_kb / 10240))
15133 #If 10% of free space cross low watermark use it
15134 if (( free_10mb > size_mb )); then
15137 #At least we need to store 1.1 of difference between
15138 #free space and low watermark
15139 size_mb=$((size_mb + size_mb / 10))
15141 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
15142 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
15143 oflag=append conv=notrunc
15148 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15149 echo "OST still has $((free_kb / 1024)) mbytes free"
15156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15157 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15158 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
15160 local ost_name=$($LFS osts |
15161 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
15163 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
15164 do_facet $SINGLEMDS $LCTL get_param -n \
15165 osp.$mdtosc_proc1.reserved_mb_high ||
15166 { skip "remote MDS does not support reserved_mb_high" &&
15171 wait_delete_completed
15174 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
15175 osp.$mdtosc_proc1.reserved_mb_high)
15176 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
15177 osp.$mdtosc_proc1.reserved_mb_low)
15178 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
15180 if ! combined_mgs_mds ; then
15183 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
15184 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
15185 error "Adding $ost_name to pool failed"
15187 # Wait for client to see a OST at pool
15188 wait_update $HOSTNAME "$LCTL get_param -n
15189 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
15190 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
15191 error "Client can not see the pool"
15192 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
15193 error "Setstripe failed"
15195 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
15196 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
15197 echo "OST still has $((blocks/1024)) mbytes free"
15199 local new_lwm=$((blocks/1024-10))
15200 do_facet $SINGLEMDS $LCTL set_param \
15201 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
15202 do_facet $SINGLEMDS $LCTL set_param \
15203 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
15205 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15207 #First enospc could execute orphan deletion so repeat.
15208 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15210 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15211 osp.$mdtosc_proc1.prealloc_status)
15212 echo "prealloc_status $oa_status"
15214 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
15215 error "File creation should fail"
15216 #object allocation was stopped, but we still able to append files
15217 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
15218 error "Append failed"
15219 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
15221 wait_delete_completed
15225 for i in $(seq 10 12); do
15226 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
15227 error "File creation failed after rm";
15230 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15231 osp.$mdtosc_proc1.prealloc_status)
15232 echo "prealloc_status $oa_status"
15234 if (( oa_status != 0 )); then
15235 error "Object allocation still disable after rm"
15237 do_facet $SINGLEMDS $LCTL set_param \
15238 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
15239 do_facet $SINGLEMDS $LCTL set_param \
15240 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
15243 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
15244 error "Remove $ost_name from pool failed"
15245 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15246 error "Pool destroy fialed"
15248 if ! combined_mgs_mds ; then
15252 run_test 253 "Check object allocation limit"
15257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15258 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15259 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
15260 { skip "MDS does not support changelog_size" && return; }
15262 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15263 echo "Registered as changelog user $cl_user"
15265 $LFS changelog_clear $MDT0 $cl_user 0
15267 local size1=$(do_facet mds1 \
15268 $LCTL get_param -n mdd.$MDT0.changelog_size)
15269 echo "Changelog size $size1"
15272 $LFS mkdir -i 0 $DIR/$tdir
15274 mkdir -p $DIR/$tdir/pics/2008/zachy
15275 touch $DIR/$tdir/pics/2008/zachy/timestamp
15276 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
15277 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
15278 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
15279 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
15280 rm $DIR/$tdir/pics/desktop.jpg
15282 local size2=$(do_facet mds1 \
15283 $LCTL get_param -n mdd.$MDT0.changelog_size)
15284 echo "Changelog size after work $size2"
15286 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15288 if (( size2 <= size1 )); then
15289 error "Changelog size after work should be greater than original"
15293 run_test 254 "Check changelog size"
15300 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
15301 awk -F: '{print $2}' | grep $type > /dev/null
15302 if [ $? -ne 0 ]; then
15312 lfs ladvise -a willread $file > /dev/null 2>&1
15313 if [ $? -eq 0 ]; then
15317 lfs ladvise -a willread $file 2>&1 |
15318 grep "Inappropriate ioctl for device" > /dev/null
15319 if [ $? -eq 0 ]; then
15326 bc <<<"scale=2; ($1 - $2) * 100 / $2"
15329 # run a random read IO workload
15330 # usage: random_read_iops <filename> <filesize> <iosize>
15331 random_read_iops() {
15334 local iosize=${3:-4096}
15336 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
15337 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
15340 drop_file_oss_cache() {
15344 $LFS ladvise -a dontneed $file 2>/dev/null ||
15345 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
15348 ladvise_willread_performance()
15351 local average_origin=0
15352 local average_cache=0
15353 local average_ladvise=0
15355 for ((i = 1; i <= $repeat; i++)); do
15356 echo "Iter $i/$repeat: reading without willread hint"
15357 cancel_lru_locks osc
15358 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15359 local speed_origin=$(random_read_iops $DIR/$tfile $size)
15360 echo "Iter $i/$repeat: uncached speed: $speed_origin"
15361 average_origin=$(bc <<<"$average_origin + $speed_origin")
15363 cancel_lru_locks osc
15364 local speed_cache=$(random_read_iops $DIR/$tfile $size)
15365 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
15366 average_cache=$(bc <<<"$average_cache + $speed_cache")
15368 cancel_lru_locks osc
15369 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
15370 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
15371 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
15372 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
15373 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
15375 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
15376 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
15377 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
15379 speedup_cache=$(percent $average_cache $average_origin)
15380 speedup_ladvise=$(percent $average_ladvise $average_origin)
15382 echo "Average uncached read: $average_origin"
15383 echo "Average speedup with OSS cached read: " \
15384 "$average_cache = +$speedup_cache%"
15385 echo "Average speedup with ladvise willread: " \
15386 "$average_ladvise = +$speedup_ladvise%"
15388 local lowest_speedup=20
15389 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
15390 echo "Speedup with OSS cached read less than $lowest_speedup%," \
15391 "got $average_cache%. Skipping ladvise willread check."
15395 # the test won't work on ZFS until it supports 'ladvise dontneed', but
15396 # it is still good to run until then to exercise 'ladvise willread'
15397 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15398 [ "$(facet_fstype ost1)" = "zfs" ] &&
15399 echo "osd-zfs does not support dontneed or drop_caches" &&
15402 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
15403 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
15404 error_not_in_vm "Speedup with willread is less than " \
15405 "$lowest_speedup%, got $average_ladvise%"
15409 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15410 skip "lustre < 2.8.54 does not support ladvise " && return
15411 remote_ost_nodsh && skip "remote OST with nodsh" && return
15413 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
15415 ladvise_no_type willread $DIR/$tfile &&
15416 skip "willread ladvise is not supported" && return
15418 ladvise_no_ioctl $DIR/$tfile &&
15419 skip "ladvise ioctl is not supported" && return
15422 local size=$((size_mb * 1048576))
15423 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15424 error "dd to $DIR/$tfile failed"
15426 lfs ladvise -a willread $DIR/$tfile ||
15427 error "Ladvise failed with no range argument"
15429 lfs ladvise -a willread -s 0 $DIR/$tfile ||
15430 error "Ladvise failed with no -l or -e argument"
15432 lfs ladvise -a willread -e 1 $DIR/$tfile ||
15433 error "Ladvise failed with only -e argument"
15435 lfs ladvise -a willread -l 1 $DIR/$tfile ||
15436 error "Ladvise failed with only -l argument"
15438 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
15439 error "End offset should not be smaller than start offset"
15441 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
15442 error "End offset should not be equal to start offset"
15444 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
15445 error "Ladvise failed with overflowing -s argument"
15447 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
15448 error "Ladvise failed with overflowing -e argument"
15450 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
15451 error "Ladvise failed with overflowing -l argument"
15453 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
15454 error "Ladvise succeeded with conflicting -l and -e arguments"
15456 echo "Synchronous ladvise should wait"
15458 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
15459 do_nodes $(comma_list $(osts_nodes)) \
15460 $LCTL set_param fail_val=$delay fail_loc=0x237
15462 local start_ts=$SECONDS
15463 lfs ladvise -a willread $DIR/$tfile ||
15464 error "Ladvise failed with no range argument"
15465 local end_ts=$SECONDS
15466 local inteval_ts=$((end_ts - start_ts))
15468 if [ $inteval_ts -lt $(($delay - 1)) ]; then
15469 error "Synchronous advice didn't wait reply"
15472 echo "Asynchronous ladvise shouldn't wait"
15473 local start_ts=$SECONDS
15474 lfs ladvise -a willread -b $DIR/$tfile ||
15475 error "Ladvise failed with no range argument"
15476 local end_ts=$SECONDS
15477 local inteval_ts=$((end_ts - start_ts))
15479 if [ $inteval_ts -gt $(($delay / 2)) ]; then
15480 error "Asynchronous advice blocked"
15483 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
15484 ladvise_willread_performance
15486 run_test 255a "check 'lfs ladvise -a willread'"
15492 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
15496 remote_ost_nodsh && skip "remote OST with nodsh" && return
15498 lfs setstripe -c 1 -i 0 $DIR/$tfile
15500 ladvise_no_type dontneed $DIR/$tfile &&
15501 skip "dontneed ladvise is not supported" && return
15503 ladvise_no_ioctl $DIR/$tfile &&
15504 skip "ladvise ioctl is not supported" && return
15506 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
15507 skip "lustre < 2.8.54 does not support ladvise" && return
15509 ! $LFS ladvise -a dontneed $DIR/$tfile &&
15510 [ "$(facet_fstype ost1)" = "zfs" ] &&
15511 skip "zfs-osd does not support 'ladvise dontneed'" && return
15514 local size=$((size_mb * 1048576))
15515 # In order to prevent disturbance of other processes, only check 3/4
15516 # of the memory usage
15517 local kibibytes=$((size_mb * 1024 * 3 / 4))
15519 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
15520 error "dd to $DIR/$tfile failed"
15522 local total=$(facet_meminfo ost1 MemTotal)
15523 echo "Total memory: $total KiB"
15525 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
15526 local before_read=$(facet_meminfo ost1 Cached)
15527 echo "Cache used before read: $before_read KiB"
15529 lfs ladvise -a willread $DIR/$tfile ||
15530 error "Ladvise willread failed"
15531 local after_read=$(facet_meminfo ost1 Cached)
15532 echo "Cache used after read: $after_read KiB"
15534 lfs ladvise -a dontneed $DIR/$tfile ||
15535 error "Ladvise dontneed again failed"
15536 local no_read=$(facet_meminfo ost1 Cached)
15537 echo "Cache used after dontneed ladvise: $no_read KiB"
15539 if [ $total -lt $((before_read + kibibytes)) ]; then
15540 echo "Memory is too small, abort checking"
15544 if [ $((before_read + kibibytes)) -gt $after_read ]; then
15545 error "Ladvise willread should use more memory" \
15546 "than $kibibytes KiB"
15549 if [ $((no_read + kibibytes)) -gt $after_read ]; then
15550 error "Ladvise dontneed should release more memory" \
15551 "than $kibibytes KiB"
15554 run_test 255b "check 'lfs ladvise -a dontneed'"
15563 [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] &&
15564 skip "lustre < 2.10.53 does not support lockahead" && return
15566 test_mkdir -p $DIR/$tdir
15567 $SETSTRIPE -i 0 $DIR/$tdir
15569 #test 10 returns only success/failure
15571 lockahead_test -d $DIR/$tdir -t $i
15573 if [ $rc -eq 255 ]; then
15574 error "Ladvise test${i} failed, ${rc}"
15577 #test 11 counts lock enqueue requests, all others count new locks
15579 count=$(do_facet ost1 \
15580 $LCTL get_param -n ost.OSS.ost.stats)
15581 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
15583 lockahead_test -d $DIR/$tdir -t $i
15585 if [ $rc -eq 255 ]; then
15586 error "Ladvise test${i} failed, ${rc}"
15589 new_count=$(do_facet ost1 \
15590 $LCTL get_param -n ost.OSS.ost.stats)
15591 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
15592 awk '{ print $2 }')
15594 difference="$((new_count - count))"
15595 if [ $difference -ne $rc ]; then
15596 error "Ladvise test${i}, bad enqueue count, returned " \
15597 "${rc}, actual ${difference}"
15600 for i in $(seq 12 21); do
15601 # If we do not do this, we run the risk of having too many
15602 # locks and starting lock cancellation while we are checking
15604 cancel_lru_locks osc
15606 count=$($LCTL get_param -n \
15607 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15609 lockahead_test -d $DIR/$tdir -t $i
15611 if [ $rc -eq 255 ]; then
15612 error "Ladvise test ${i} failed, ${rc}"
15615 new_count=$($LCTL get_param -n \
15616 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
15617 difference="$((new_count - count))"
15619 # Test 15 output is divided by 100 to map down to valid return
15620 if [ $i -eq 15 ]; then
15624 if [ $difference -ne $rc ]; then
15625 error "Ladvise test ${i}, bad lock count, returned " \
15626 "${rc}, actual ${difference}"
15630 #test 22 returns only success/failure
15632 lockahead_test -d $DIR/$tdir -t $i
15634 if [ $rc -eq 255 ]; then
15635 error "Ladvise test${i} failed, ${rc}"
15639 run_test 255c "suite of ladvise lockahead tests"
15646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
15647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15648 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
15649 skip "ldiskfs only test" && return
15651 mdt_dev=$(mdsdevname 1)
15653 cl_user=$(do_facet mds1 \
15654 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
15655 if [[ -n $cl_user ]]; then
15656 skip "active changelog user"
15660 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
15661 echo "Registered as changelog user $cl_user"
15664 mkdir -p $DIR/$tdir
15666 $LFS changelog_clear $MDT0 $cl_user 0
15669 touch $DIR/$tdir/{1..10}
15672 stop mds1 || error "Fail to stop MDT."
15675 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
15677 #after mount new plainllog is used
15678 touch $DIR/$tdir/{11..19}
15680 local TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
15681 cat_sl=$(do_facet mds1 \
15682 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15683 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15684 do_facet mds1 rm $TEMP256FILE
15686 if (( cat_sl != 2 )); then
15687 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15688 error "Changelog catalog has wrong number of slots $cat_sl"
15691 $LFS changelog_clear $MDT0 $cl_user 0
15694 TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
15695 cat_sl=$(do_facet mds1 \
15696 "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
15697 llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
15698 do_facet mds1 rm $TEMP256FILE
15700 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
15702 if (( cat_sl == 2 )); then
15703 error "Empty plain llog was not deleted from changelog catalog"
15705 if (( cat_sl != 1 )); then
15706 error "Active plain llog shouldn\`t be deleted from catalog"
15709 run_test 256 "Check llog delete for empty and not full state"
15712 remote_mds_nodsh && skip "remote MDS with nodsh" && return
15713 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
15714 skip "Need MDS version at least 2.8.55" && return
15716 test_mkdir $DIR/$tdir
15718 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
15719 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
15722 #define OBD_FAIL_MDS_XATTR_REP 0x161
15723 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
15724 local facet=mds$((mdtidx + 1))
15725 set_nodes_failloc $(facet_active_host $facet) 0x80000161
15726 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
15728 stop $facet || error "stop MDS failed"
15729 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
15730 error "start MDS fail"
15732 run_test 257 "xattr locks are not lost"
15734 # Verify we take the i_mutex when security requires it
15736 #define OBD_FAIL_IMUTEX_SEC 0x141c
15737 $LCTL set_param fail_loc=0x141c
15739 chmod u+s $DIR/$tfile
15740 chmod a+rwx $DIR/$tfile
15741 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15743 if [ $RC -ne 0 ]; then
15744 error "error, failed to take i_mutex, rc=$?"
15750 # Verify we do NOT take the i_mutex in the normal case
15752 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
15753 $LCTL set_param fail_loc=0x141d
15756 chmod a+rw $DIR/$tfile
15757 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
15759 if [ $RC -ne 0 ]; then
15760 error "error, took i_mutex unnecessarily, rc=$?"
15765 run_test 258b "verify i_mutex security behavior"
15768 #define OBD_FAIL_MDC_CLOSE 0x806
15769 $LCTL set_param fail_loc=0x80000806
15773 run_test 260 "Check mdc_close fail"
15775 ### Data-on-MDT sanity tests ###
15778 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15779 skip "Need MDS version at least 2.10.55" && return
15782 local dom=$DIR/$tdir/dom_file
15783 local tmp=$DIR/$tdir/tmp_file
15785 mkdir -p $DIR/$tdir
15787 # basic checks for DoM component creation
15788 $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
15789 error "Can set MDT layout to non-first entry"
15791 $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
15792 error "Can define multiple entries as MDT layout"
15794 $LFS setstripe -E 1M -L mdt $dom ||
15795 error "Can't create DoM layout"
15797 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
15798 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
15799 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
15801 local mdtidx=$($GETSTRIPE -M $dom)
15802 local mdtname=MDT$(printf %04x $mdtidx)
15803 local facet=mds$((mdtidx + 1))
15804 local space_check=1
15806 # Skip free space checks with ZFS
15807 if [ "$(facet_fstype $facet)" == "zfs" ]; then
15813 local mdtfree1=$(do_facet $facet \
15814 lctl get_param -n osd*.*$mdtname.kbytesfree)
15815 dd if=/dev/urandom of=$tmp bs=1024 count=100
15816 # check also direct IO along write
15817 dd if=$tmp of=$dom bs=102400 count=1 oflag=direct
15819 cmp $tmp $dom || error "file data is different"
15820 [ $(stat -c%s $dom) == 102400 ] || error "bad size after write"
15821 if [ $space_check == 1 ]; then
15822 local mdtfree2=$(do_facet $facet \
15823 lctl get_param -n osd*.*$mdtname.kbytesfree)
15824 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15825 error "MDT free space is wrong after write"
15829 $TRUNCATE $dom 10000
15830 [ $(stat -c%s $dom) == 10000 ] || error "bad size after truncate"
15831 if [ $space_check == 1 ]; then
15832 mdtfree1=$(do_facet $facet \
15833 lctl get_param -n osd*.*$mdtname.kbytesfree)
15834 [ $(($mdtfree1 - $mdtfree2)) -ge 92 ] ||
15835 error "MDT free space is wrong after truncate"
15841 [ $(stat -c%s $dom) == 112400 ] || error "bad size after append"
15842 if [ $space_check == 1 ]; then
15843 mdtfree2=$(do_facet $facet \
15844 lctl get_param -n osd*.*$mdtname.kbytesfree)
15845 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
15846 error "MDT free space is wrong after append"
15851 if [ $space_check == 1 ]; then
15852 mdtfree1=$(do_facet $facet \
15853 lctl get_param -n osd*.*$mdtname.kbytesfree)
15854 [ $(($mdtfree1 - $mdtfree2)) -ge 112 ] ||
15855 error "MDT free space is wrong after removal"
15858 # combined striping
15859 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
15860 error "Can't create DoM + OST striping"
15862 dd if=/dev/urandom of=$tmp bs=1024 count=2000
15863 # check also direct IO along write
15864 dd if=$tmp of=$dom bs=102400 count=20 oflag=direct
15866 cmp $tmp $dom || error "file data is different"
15867 [ $(stat -c%s $dom) == 2048000 ] || error "bad size after write"
15873 run_test 270a "DoM: basic functionality tests"
15876 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15877 skip "Need MDS version at least 2.10.55" && return
15879 local dom=$DIR/$tdir/dom_file
15880 local max_size=1048576
15882 mkdir -p $DIR/$tdir
15883 $LFS setstripe -E $max_size -L mdt $dom
15885 # truncate over the limit
15886 $TRUNCATE $dom $(($max_size + 1)) &&
15887 error "successful truncate over the maximum size"
15888 # write over the limit
15889 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
15890 error "successful write over the maximum size"
15891 # append over the limit
15892 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
15893 echo "12345" >> $dom && error "successful append over the maximum size"
15898 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
15901 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15902 skip "Need MDS version at least 2.10.55" && return
15904 mkdir -p $DIR/$tdir
15905 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15907 # check files inherit DoM EA
15908 touch $DIR/$tdir/first
15909 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
15910 error "bad pattern"
15911 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
15912 error "bad stripe count"
15913 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
15914 error "bad stripe size"
15916 # check directory inherits DoM EA and uses it as default
15917 mkdir $DIR/$tdir/subdir
15918 touch $DIR/$tdir/subdir/second
15919 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
15920 error "bad pattern in sub-directory"
15921 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
15922 error "bad stripe count in sub-directory"
15923 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
15924 error "bad stripe size in sub-directory"
15927 run_test 270c "DoM: DoM EA inheritance tests"
15930 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15931 skip "Need MDS version at least 2.10.55" && return
15933 mkdir -p $DIR/$tdir
15934 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
15936 # inherit default DoM striping
15937 mkdir $DIR/$tdir/subdir
15938 touch $DIR/$tdir/subdir/f1
15940 # change default directory striping
15941 $LFS setstripe -c 1 $DIR/$tdir/subdir
15942 touch $DIR/$tdir/subdir/f2
15943 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
15944 error "wrong default striping in file 2"
15945 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
15946 error "bad pattern in file 2"
15949 run_test 270d "DoM: change striping from DoM to RAID0"
15952 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15953 skip "Need MDS version at least 2.10.55" && return
15955 mkdir -p $DIR/$tdir/dom
15956 mkdir -p $DIR/$tdir/norm
15959 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
15960 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
15962 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
15963 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
15965 # find DoM files by layout
15966 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
15967 [ $NUM -eq $DOMFILES ] ||
15968 error "lfs find -L: found $NUM, expected $DOMFILES"
15969 echo "Test 1: lfs find 20 DOM files by layout: OK"
15971 # there should be 1 dir with default DOM striping
15972 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
15974 error "lfs find -L: found $NUM, expected 1 dir"
15975 echo "Test 2: lfs find 1 DOM dir by layout: OK"
15977 # find DoM files by stripe size
15978 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
15979 [ $NUM -eq $DOMFILES ] ||
15980 error "lfs find -S: found $NUM, expected $DOMFILES"
15981 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
15983 # find files by stripe offset except DoM files
15984 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
15985 [ $NUM -eq $NORMFILES ] ||
15986 error "lfs find -i: found $NUM, expected $NORMFILES"
15987 echo "Test 5: lfs find no DOM files by stripe index: OK"
15990 run_test 270e "DoM: lfs find with DoM files test"
15993 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
15994 skip "Need MDS version at least 2.10.55" && return
15996 local mdtname=${FSNAME}-MDT0000-mdtlov
15997 local dom=$DIR/$tdir/dom_file
15998 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
15999 lod.$mdtname.dom_stripesize)
16000 local dom_limit=131072
16002 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
16003 local dom_current=$(do_facet mds1 $LCTL get_param -n \
16004 lod.$mdtname.dom_stripesize)
16005 [ ${dom_limit} -eq ${dom_current} ] ||
16006 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
16008 $LFS mkdir -i 0 -c 1 $DIR/$tdir
16009 $LFS setstripe -d $DIR/$tdir
16010 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
16011 error "Can't set directory default striping"
16013 # exceed maximum stripe size
16014 $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
16015 error "Able to create DoM component size more than LOD limit"
16017 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
16018 dom_current=$(do_facet mds1 $LCTL get_param -n \
16019 lod.$mdtname.dom_stripesize)
16020 [ 0 -eq ${dom_current} ] ||
16021 error "Can't set zero DoM stripe limit"
16023 # too low values to be aligned with smallest stripe size 64K
16024 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
16025 dom_current=$(do_facet mds1 $LCTL get_param -n \
16026 lod.$mdtname.dom_stripesize)
16027 [ 30000 -eq ${dom_current} ] &&
16028 error "Can set too small DoM stripe limit"
16030 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
16031 dom_current=$(do_facet mds1 $LCTL get_param -n \
16032 lod.$mdtname.dom_stripesize)
16034 [ 2147483648 -eq ${dom_current} ] &&
16035 error "Can set too large DoM stripe limit"
16037 do_facet mds1 $LCTL set_param -n \
16038 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
16039 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
16040 error "Can't create DoM component size after limit change"
16041 do_facet mds1 $LCTL set_param -n \
16042 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
16043 $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
16044 error "Can create big DoM component after limit decrease"
16045 touch ${dom}_def ||
16046 error "Can't create file with old default layout"
16048 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
16051 run_test 270f "DoM: maximum DoM stripe size checks"
16054 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16055 skip "Need MDS version at least 2.10.55" && return
16057 local dom=$DIR/$tdir/dom
16059 mkdir -p $DIR/$tdir
16061 $LFS setstripe -E 1024K -L mdt $dom
16063 lctl set_param -n mdc.*.stats=clear
16064 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16065 cat $dom > /dev/null
16066 local reads=$(lctl get_param -n mdc.*.stats |
16067 awk '/ost_read/ {print $2}')
16068 [ -z $reads ] || error "Unexpected $reads READ RPCs"
16072 run_test 271a "DoM: data is cached for read after write"
16075 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16076 skip "Need MDS version at least 2.10.55" && return
16078 local dom=$DIR/$tdir/dom
16080 mkdir -p $DIR/$tdir
16082 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16084 lctl set_param -n mdc.*.stats=clear
16085 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16086 cancel_lru_locks mdc
16087 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
16088 # second stat to check size is cached on client
16089 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
16090 local gls=$(lctl get_param -n mdc.*.stats |
16091 awk '/ldlm_glimpse/ {print $2}')
16092 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16095 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
16098 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16099 skip "Need MDS version at least 2.10.55" && return
16101 local dom=$DIR/$tdir/dom
16103 mkdir -p $DIR/$tdir
16105 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16107 lctl set_param -n mdc.*.stats=clear
16108 lctl set_param -n osc.*.stats=clear
16109 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
16110 cancel_lru_locks mdc
16111 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16112 # second stat to check size is cached on client
16113 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16114 local gls=$(lctl get_param -n mdc.*.stats |
16115 awk '/ldlm_glimpse/ {print $2}')
16116 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16117 local gls=$(lctl get_param -n osc.*.stats |
16118 awk '/ldlm_glimpse/ {print $2}')
16119 [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
16122 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
16125 # test to be enabled with lock_convert
16126 skip "skipped until lock convert will be implemented" && return
16128 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16129 skip "Need MDS version at least 2.10.55" && return
16131 local dom=$DIR/$tdir/dom
16133 mkdir -p $DIR/$tdir
16135 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16137 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
16138 local facet=mds$((mdtidx + 1))
16140 cancel_lru_locks mdc
16141 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
16142 createmany -o $dom 1000
16143 lctl set_param -n mdc.*.stats=clear
16144 smalliomany -w $dom 1000 200
16145 lctl get_param -n mdc.*.stats
16146 local enq=$(lctl get_param -n mdc.*.stats |
16147 awk '/ldlm_ibits_enqueue/ {print $2}')
16148 # Each file has 1 open, 1 IO enqueues, total 2000
16149 # but now we have also +1 getxattr for security.capability, total 3000
16150 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
16151 unlinkmany $dom 1000
16153 cancel_lru_locks mdc
16154 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
16155 createmany -o $dom 1000
16156 lctl set_param -n mdc.*.stats=clear
16157 smalliomany -w $dom 1000 200
16158 lctl get_param -n mdc.*.stats
16159 local enq_2=$(lctl get_param -n mdc.*.stats |
16160 awk '/ldlm_ibits_enqueue/ {print $2}')
16161 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
16162 # for OPEN and IO lock.
16163 [ $((enq - enq_2)) -ge 1000 ] ||
16164 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
16165 unlinkmany $dom 1000
16168 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
16170 cleanup_test_300() {
16174 test_striped_dir() {
16179 mkdir -p $DIR/$tdir
16181 SAVE_UMASK=$(umask)
16182 trap cleanup_test_300 RETURN EXIT
16184 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
16185 $DIR/$tdir/striped_dir ||
16186 error "set striped dir error"
16188 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
16189 [ "$mode" = "755" ] || error "expect 755 got $mode"
16191 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
16192 error "getdirstripe failed"
16193 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
16194 if [ "$stripe_count" != "2" ]; then
16195 error "1:stripe_count is $stripe_count, expect 2"
16197 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
16198 if [ "$stripe_count" != "2" ]; then
16199 error "2:stripe_count is $stripe_count, expect 2"
16202 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
16203 if [ "$stripe_index" != "$mdt_index" ]; then
16204 error "stripe_index is $stripe_index, expect $mdt_index"
16207 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
16208 error "nlink error after create striped dir"
16210 mkdir $DIR/$tdir/striped_dir/a
16211 mkdir $DIR/$tdir/striped_dir/b
16213 stat $DIR/$tdir/striped_dir/a ||
16214 error "create dir under striped dir failed"
16215 stat $DIR/$tdir/striped_dir/b ||
16216 error "create dir under striped dir failed"
16218 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
16219 error "nlink error after mkdir"
16221 rmdir $DIR/$tdir/striped_dir/a
16222 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
16223 error "nlink error after rmdir"
16225 rmdir $DIR/$tdir/striped_dir/b
16226 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
16227 error "nlink error after rmdir"
16229 chattr +i $DIR/$tdir/striped_dir
16230 createmany -o $DIR/$tdir/striped_dir/f 10 &&
16231 error "immutable flags not working under striped dir!"
16232 chattr -i $DIR/$tdir/striped_dir
16234 rmdir $DIR/$tdir/striped_dir ||
16235 error "rmdir striped dir error"
16243 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16244 skip "skipped for lustre < 2.7.0" && return
16245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16246 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16248 test_striped_dir 0 || error "failed on striped dir on MDT0"
16249 test_striped_dir 1 || error "failed on striped dir on MDT0"
16251 run_test 300a "basic striped dir sanity test"
16254 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16255 skip "skipped for lustre < 2.7.0" && return
16256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16257 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16263 test_mkdir $DIR/$tdir
16264 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16265 error "set striped dir error"
16266 for ((i=0; i<10; i++)); do
16267 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
16269 touch $DIR/$tdir/striped_dir/file_$i ||
16270 error "touch error $i"
16271 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
16272 [ $mtime1 -eq $mtime2 ] &&
16273 error "mtime not change after create"
16275 rm -f $DIR/$tdir/striped_dir/file_$i ||
16276 error "unlink error $i"
16277 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
16278 [ $mtime2 -eq $mtime3 ] &&
16279 error "mtime did not change after unlink"
16283 run_test 300b "check ctime/mtime for striped dir"
16286 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16287 skip "skipped for lustre < 2.7.0" && return
16288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16289 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16292 mkdir -p $DIR/$tdir
16293 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
16294 error "set striped dir error"
16296 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
16297 error "chown striped dir failed"
16299 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
16300 error "create 5k files failed"
16302 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
16304 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
16308 run_test 300c "chown && check ls under striped directory"
16311 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
16312 skip "skipped for lustre < 2.7.0" && return
16313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16314 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16318 mkdir -p $DIR/$tdir
16319 $SETSTRIPE -c 2 $DIR/$tdir
16321 #local striped directory
16322 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16323 error "set striped dir error"
16324 createmany -o $DIR/$tdir/striped_dir/f 10 ||
16325 error "create 10 files failed"
16327 #remote striped directory
16328 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
16329 error "set striped dir error"
16330 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
16331 error "create 10 files failed"
16333 for file in $(find $DIR/$tdir); do
16334 stripe_count=$($GETSTRIPE -c $file)
16335 [ $stripe_count -eq 2 ] ||
16336 error "wrong stripe $stripe_count for $file"
16341 run_test 300d "check default stripe under striped directory"
16344 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16345 skip "Need MDS version at least 2.7.55" && return
16346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16347 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16351 mkdir -p $DIR/$tdir
16353 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16354 error "set striped dir error"
16356 touch $DIR/$tdir/striped_dir/a
16357 touch $DIR/$tdir/striped_dir/b
16358 touch $DIR/$tdir/striped_dir/c
16360 mkdir $DIR/$tdir/striped_dir/dir_a
16361 mkdir $DIR/$tdir/striped_dir/dir_b
16362 mkdir $DIR/$tdir/striped_dir/dir_c
16364 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
16365 error "set striped adir under striped dir error"
16367 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
16368 error "set striped bdir under striped dir error"
16370 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
16371 error "set striped cdir under striped dir error"
16373 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
16374 error "rename dir under striped dir fails"
16376 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
16377 error "rename dir under different stripes fails"
16379 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
16380 error "rename file under striped dir should succeed"
16382 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
16383 error "rename dir under striped dir should succeed"
16387 run_test 300e "check rename under striped directory"
16390 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16391 skip "Need MDS version at least 2.7.55" && return
16392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16393 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16398 mkdir -p $DIR/$tdir
16400 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
16401 error "set striped dir error"
16403 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
16404 error "set striped dir error"
16406 touch $DIR/$tdir/striped_dir/a
16407 mkdir $DIR/$tdir/striped_dir/dir_a
16408 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
16409 error "create striped dir under striped dir fails"
16411 touch $DIR/$tdir/striped_dir1/b
16412 mkdir $DIR/$tdir/striped_dir1/dir_b
16413 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
16414 error "create striped dir under striped dir fails"
16416 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
16417 error "rename dir under different striped dir should fail"
16419 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
16420 error "rename striped dir under diff striped dir should fail"
16422 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
16423 error "rename file under diff striped dirs fails"
16427 run_test 300f "check rename cross striped directory"
16429 test_300_check_default_striped_dir()
16432 local default_count=$2
16433 local default_index=$3
16436 local dir_stripe_index
16439 echo "checking $dirname $default_count $default_index"
16440 $LFS setdirstripe -D -c $default_count -i $default_index \
16441 -t all_char $DIR/$tdir/$dirname ||
16442 error "set default stripe on striped dir error"
16443 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
16444 [ $stripe_count -eq $default_count ] ||
16445 error "expect $default_count get $stripe_count for $dirname"
16447 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
16448 [ $stripe_index -eq $default_index ] ||
16449 error "expect $default_index get $stripe_index for $dirname"
16451 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
16452 error "create dirs failed"
16454 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
16455 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
16456 for dir in $(find $DIR/$tdir/$dirname/*); do
16457 stripe_count=$($LFS getdirstripe -c $dir)
16458 [ $stripe_count -eq $default_count ] ||
16459 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
16460 error "stripe count $default_count != $stripe_count for $dir"
16462 stripe_index=$($LFS getdirstripe -i $dir)
16463 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
16464 error "$stripe_index != $default_index for $dir"
16466 #check default stripe
16467 stripe_count=$($LFS getdirstripe -D -c $dir)
16468 [ $stripe_count -eq $default_count ] ||
16469 error "default count $default_count != $stripe_count for $dir"
16471 stripe_index=$($LFS getdirstripe -D -i $dir)
16472 [ $stripe_index -eq $default_index ] ||
16473 error "default index $default_index != $stripe_index for $dir"
16475 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
16479 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16480 skip "Need MDS version at least 2.7.55" && return
16481 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16487 mkdir $DIR/$tdir/normal_dir
16489 #Checking when client cache stripe index
16490 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
16491 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
16492 error "create striped_dir failed"
16494 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
16495 error "create dir0 fails"
16496 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
16497 [ $stripe_index -eq 0 ] ||
16498 error "dir0 expect index 0 got $stripe_index"
16500 mkdir $DIR/$tdir/striped_dir/dir1 ||
16501 error "create dir1 fails"
16502 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
16503 [ $stripe_index -eq 1 ] ||
16504 error "dir1 expect index 1 got $stripe_index"
16506 #check default stripe count/stripe index
16507 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
16508 test_300_check_default_striped_dir normal_dir 1 0
16509 test_300_check_default_striped_dir normal_dir 2 1
16510 test_300_check_default_striped_dir normal_dir 2 -1
16512 #delete default stripe information
16513 echo "delete default stripeEA"
16514 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
16515 error "set default stripe on striped dir error"
16517 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
16518 for dir in $(find $DIR/$tdir/normal_dir/*); do
16519 stripe_count=$($LFS getdirstripe -c $dir)
16520 [ $stripe_count -eq 0 ] ||
16521 error "expect 1 get $stripe_count for $dir"
16522 stripe_index=$($LFS getdirstripe -i $dir)
16523 [ $stripe_index -eq 0 ] ||
16524 error "expect 0 get $stripe_index for $dir"
16527 run_test 300g "check default striped directory for normal directory"
16530 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16531 skip "Need MDS version at least 2.7.55" && return
16532 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16537 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
16538 $DIR/$tdir/striped_dir ||
16539 error "set striped dir error"
16541 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
16542 test_300_check_default_striped_dir striped_dir 1 0
16543 test_300_check_default_striped_dir striped_dir 2 1
16544 test_300_check_default_striped_dir striped_dir 2 -1
16546 #delete default stripe information
16547 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
16548 error "set default stripe on striped dir error"
16550 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
16551 for dir in $(find $DIR/$tdir/striped_dir/*); do
16552 stripe_count=$($LFS getdirstripe -c $dir)
16553 [ $stripe_count -eq 0 ] ||
16554 error "expect 1 get $stripe_count for $dir"
16557 run_test 300h "check default striped directory for striped directory"
16560 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16561 skip "Need MDS version at least 2.7.55" && return
16562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16563 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16569 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
16570 error "set striped dir error"
16572 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16573 error "create files under striped dir failed"
16575 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
16576 error "set striped hashdir error"
16578 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
16579 error "create dir0 under hash dir failed"
16580 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
16581 error "create dir1 under hash dir failed"
16583 # unfortunately, we need to umount to clear dir layout cache for now
16584 # once we fully implement dir layout, we can drop this
16585 umount_client $MOUNT || error "umount failed"
16586 mount_client $MOUNT || error "mount failed"
16588 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
16589 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
16590 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
16592 #set the stripe to be unknown hash type
16593 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
16594 $LCTL set_param fail_loc=0x1901
16595 for ((i = 0; i < 10; i++)); do
16596 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
16597 error "stat f-$i failed"
16598 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
16601 touch $DIR/$tdir/striped_dir/f0 &&
16602 error "create under striped dir with unknown hash should fail"
16604 $LCTL set_param fail_loc=0
16606 umount_client $MOUNT || error "umount failed"
16607 mount_client $MOUNT || error "mount failed"
16611 run_test 300i "client handle unknown hash type striped directory"
16614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16615 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16616 skip "Need MDS version at least 2.7.55" && return
16617 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16623 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
16624 $LCTL set_param fail_loc=0x1702
16625 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
16626 error "set striped dir error"
16628 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
16629 error "create files under striped dir failed"
16631 $LCTL set_param fail_loc=0
16633 rm -rf $DIR/$tdir || error "unlink striped dir fails"
16637 run_test 300j "test large update record"
16640 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16641 skip "Need MDS version at least 2.7.55" && return
16642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16643 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16649 #define OBD_FAIL_LARGE_STRIPE 0x1703
16650 $LCTL set_param fail_loc=0x1703
16651 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
16652 error "set striped dir error"
16653 $LCTL set_param fail_loc=0
16655 $LFS getdirstripe $DIR/$tdir/striped_dir ||
16656 error "getstripeddir fails"
16657 rm -rf $DIR/$tdir/striped_dir ||
16658 error "unlink striped dir fails"
16662 run_test 300k "test large striped directory"
16665 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16666 skip "Need MDS version at least 2.7.55" && return
16667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16668 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16671 test_mkdir -p $DIR/$tdir/striped_dir
16672 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
16673 error "chown $RUNAS_ID failed"
16674 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
16675 error "set default striped dir failed"
16677 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
16678 $LCTL set_param fail_loc=0x80000158
16679 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
16681 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
16682 [ $stripe_index -eq 1 ] ||
16683 error "expect 1 get $stripe_index for $dir"
16685 run_test 300l "non-root user to create dir under striped dir with stale layout"
16688 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16689 skip "Need MDS version at least 2.7.55" && return
16690 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16691 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
16693 mkdir -p $DIR/$tdir/striped_dir
16694 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
16695 error "set default stripes dir error"
16697 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
16699 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
16700 [ $stripe_count -eq 0 ] ||
16701 error "expect 0 get $stripe_count for a"
16703 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
16704 error "set default stripes dir error"
16706 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
16708 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
16709 [ $stripe_count -eq 0 ] ||
16710 error "expect 0 get $stripe_count for b"
16712 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
16713 error "set default stripes dir error"
16715 mkdir $DIR/$tdir/striped_dir/c &&
16716 error "default stripe_index is invalid, mkdir c should fails"
16718 rm -rf $DIR/$tdir || error "rmdir fails"
16720 run_test 300m "setstriped directory on single MDT FS"
16723 local list=$(comma_list $(mdts_nodes))
16726 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16730 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16731 skip "Need MDS version at least 2.7.55" && return
16732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16733 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16737 local list=$(comma_list $(mdts_nodes))
16739 trap cleanup_300n RETURN EXIT
16740 mkdir -p $DIR/$tdir
16741 chmod 777 $DIR/$tdir
16742 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
16743 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16744 error "create striped dir succeeds with gid=0"
16746 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16747 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
16748 error "create striped dir fails with gid=-1"
16750 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16751 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
16752 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
16753 error "set default striped dir succeeds with gid=0"
16756 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
16757 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
16758 error "set default striped dir fails with gid=-1"
16761 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
16762 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
16763 error "create test_dir fails"
16764 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
16765 error "create test_dir1 fails"
16766 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
16767 error "create test_dir2 fails"
16770 run_test 300n "non-root user to create dir under striped dir with default EA"
16773 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
16774 skip "Need MDS version at least 2.7.55" && return
16775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16776 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16780 mkdir -p $DIR/$tdir
16782 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
16783 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
16784 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
16785 skip "not enough free inodes $numfree1 $numfree2"
16789 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
16790 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
16791 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
16792 skip "not enough free space $numfree1 $numfree2"
16796 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
16797 error "setdirstripe fails"
16799 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
16800 error "create dirs fails"
16802 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
16803 ls $DIR/$tdir/striped_dir > /dev/null ||
16804 error "ls striped dir fails"
16805 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
16806 error "unlink big striped dir fails"
16808 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
16811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16812 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16813 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16815 mkdir -p $DIR/$tdir
16817 #define OBD_FAIL_OUT_ENOSPC 0x1704
16818 do_facet mds2 lctl set_param fail_loc=0x80001704
16819 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
16820 error "create striped directory should fail"
16822 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
16824 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
16827 run_test 300p "create striped directory without space"
16830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16831 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
16833 local fd=$(free_fd)
16834 local cmd="exec $fd<$tdir"
16836 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
16839 trap "eval $cmd" EXIT
16840 cd $tdir || error "cd $tdir fails"
16841 rmdir ../$tdir || error "rmdir $tdir fails"
16842 mkdir local_dir && error "create dir succeeds"
16843 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
16847 run_test 300q "create remote directory under orphan directory"
16849 prepare_remote_file() {
16850 mkdir $DIR/$tdir/src_dir ||
16851 error "create remote source failed"
16853 cp /etc/hosts $DIR/$tdir/src_dir/a || error
16854 touch $DIR/$tdir/src_dir/a
16856 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
16857 error "create remote target dir failed"
16859 touch $DIR/$tdir/tgt_dir/b
16861 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
16862 error "rename dir cross MDT failed!"
16864 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
16865 error "src_child still exists after rename"
16867 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
16868 error "missing file(a) after rename"
16870 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
16871 error "diff after rename"
16875 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16877 local remote_file=$DIR/$tdir/tgt_dir/b
16879 mkdir -p $DIR/$tdir
16881 prepare_remote_file || error "prepare remote file failed"
16884 $OPENUNLINK $remote_file $remote_file || error
16885 $CHECKSTAT -a $remote_file || error
16887 run_test 310a "open unlink remote file"
16890 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
16891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16892 local remote_file=$DIR/$tdir/tgt_dir/b
16894 mkdir -p $DIR/$tdir
16896 prepare_remote_file || error "prepare remote file failed"
16898 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16899 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
16900 $CHECKSTAT -t file $remote_file || error "check file failed"
16902 run_test 310b "unlink remote file with multiple links while open"
16905 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
16906 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16907 local remote_file=$DIR/$tdir/tgt_dir/b
16909 mkdir -p $DIR/$tdir
16911 prepare_remote_file || error "prepare remote file failed"
16913 ln $remote_file $DIR/$tfile || error "link failed for remote file"
16914 multiop_bg_pause $remote_file O_uc ||
16915 error "mulitop failed for remote file"
16917 $MULTIOP $DIR/$tfile Ouc
16918 kill -USR1 $MULTIPID
16921 run_test 310c "open-unlink remote file with multiple links"
16925 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
16926 skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
16927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
16928 remote_mds_nodsh && skip "remote MDS with nodsh" && return
16930 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16932 mkdir -p $DIR/$tdir
16933 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
16934 createmany -o $DIR/$tdir/$tfile. 1000
16936 # statfs data is not real time, let's just calculate it
16937 old_iused=$((old_iused + 1000))
16939 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
16940 osp.*OST0000*MDT0000.create_count")
16941 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
16942 osp.*OST0000*MDT0000.max_create_count")
16943 for idx in $(seq $MDSCOUNT); do
16944 do_facet mds$idx "lctl set_param -n \
16945 osp.*OST0000*MDT000?.max_create_count=0"
16948 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
16949 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
16950 [ $index -ne 0 ] || error "$tfile stripe index is 0"
16952 unlinkmany $DIR/$tdir/$tfile. 1000
16954 for idx in $(seq $MDSCOUNT); do
16955 do_facet mds$idx "lctl set_param -n \
16956 osp.*OST0000*MDT000?.max_create_count=$max_count"
16957 do_facet mds$idx "lctl set_param -n \
16958 osp.*OST0000*MDT000?.create_count=$count"
16962 for i in $(seq 120); do
16963 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
16964 # system may be too busy to destroy all objs in time, use
16965 # a somewhat small value to not fail autotest
16966 [ $((old_iused - new_iused)) -gt 400 ] && break
16970 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
16971 [ $((old_iused - new_iused)) -gt 400 ] ||
16972 error "objs not destroyed after unlink"
16974 run_test 311 "disable OSP precreate, and unlink should destroy objs"
16981 local vdevdir=$(dirname $(facet_vdevice $ost))
16982 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
16983 local zfs_zapid=$(do_facet $ost $cmd |
16984 grep -w "/O/0/d$((objid%32))" -C 5 |
16985 awk '/Object/{getline; print $1}')
16986 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
16987 awk "/$objid = /"'{printf $3}')
16992 zfs_object_blksz() {
16996 local vdevdir=$(dirname $(facet_vdevice $ost))
16997 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
16998 local blksz=$(do_facet $ost $cmd $objid |
16999 awk '/dblk/{getline; printf $4}')
17001 case "${blksz: -1}" in
17002 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
17003 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
17010 test_312() { # LU-4856
17011 remote_ost_nodsh && skip "remote OST with nodsh" && return
17013 [ $(facet_fstype ost1) = "zfs" ] ||
17014 { skip "the test only applies to zfs" && return; }
17016 local max_blksz=$(do_facet ost1 \
17017 $ZFS get -p recordsize $(facet_device ost1) |
17018 awk '!/VALUE/{print $3}')
17019 local min_blksz=$(getconf PAGE_SIZE)
17021 # to make life a little bit easier
17022 $LFS mkdir -c 1 -i 0 $DIR/$tdir
17023 $LFS setstripe -c 1 -i 0 $DIR/$tdir
17025 local tf=$DIR/$tdir/$tfile
17027 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17029 # Get ZFS object id
17030 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17032 # block size change by sequential over write
17034 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
17035 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
17037 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17038 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
17042 # block size change by sequential append write
17043 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
17044 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17045 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17047 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
17048 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
17049 oflag=sync conv=notrunc
17051 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17052 [ $blksz -eq $((2 * count * min_blksz)) ] ||
17053 error "blksz error, actual $blksz, " \
17054 "expected: 2 * $count * $min_blksz"
17060 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17061 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17063 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
17064 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17065 [ $blksz -eq $min_blksz ] ||
17066 error "blksz error: $blksz, expected: $min_blksz"
17068 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
17069 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17070 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
17072 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
17073 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17074 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
17076 run_test 312 "make sure ZFS adjusts its block size by write pattern"
17079 remote_ost_nodsh && skip "remote OST with nodsh" && return
17081 local file=$DIR/$tfile
17083 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
17085 # define OBD_FAIL_TGT_RCVD_EIO 0x720
17086 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17087 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
17088 error "write should failed"
17089 do_facet ost1 "$LCTL set_param fail_loc=0"
17092 run_test 313 "io should fail after last_rcvd update fail"
17095 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
17096 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17098 wait_delete_completed
17099 do_facet ost1 "$LCTL set_param fail_loc=0"
17101 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
17103 test_315() { # LU-618
17104 local file=$DIR/$tfile
17107 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
17108 $MULTIOP $file oO_RDONLY:r4096000_c &
17113 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
17116 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
17119 run_test 315 "read should be accounted"
17122 local read_write=$1
17123 if [ "$read_write" = "write" ]; then
17124 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
17125 elif [ "$read_write" = "read" ]; then
17126 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
17128 error "argument error"
17131 # turn off debug for performance testing
17132 local saved_debug=$($LCTL get_param -n debug)
17133 $LCTL set_param debug=0
17135 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
17137 # get ost1 size - lustre-OST0000
17138 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
17139 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
17140 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
17142 if [ "$read_write" = "read" ]; then
17143 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
17146 local start_time=$(date +%s.%N)
17147 $dd_cmd bs=1M count=$blocks oflag=sync ||
17148 error "real dd $read_write error"
17149 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
17151 if [ "$read_write" = "write" ]; then
17155 # define OBD_FAIL_OST_FAKE_RW 0x238
17156 do_facet ost1 $LCTL set_param fail_loc=0x238
17158 local start_time=$(date +%s.%N)
17159 $dd_cmd bs=1M count=$blocks oflag=sync ||
17160 error "fake dd $read_write error"
17161 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
17163 if [ "$read_write" = "write" ]; then
17165 cancel_lru_locks osc
17166 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
17167 error "$tfile size not $blocks MB"
17169 do_facet ost1 $LCTL set_param fail_loc=0
17171 echo "fake $read_write $duration_fake vs. normal $read_write" \
17172 "$duration in seconds"
17173 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
17174 error_not_in_vm "fake write is slower"
17176 $LCTL set_param -n debug="$saved_debug"
17179 test_399a() { # LU-7655 for OST fake write
17180 remote_ost_nodsh && skip "remote OST with nodsh" && return
17184 run_test 399a "fake write should not be slower than normal write"
17186 test_399b() { # LU-8726 for OST fake read
17187 remote_ost_nodsh && skip "remote OST with nodsh" && return
17189 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
17190 skip "ldiskfs only test" && return 0
17194 run_test 399b "fake read should not be slower than normal read"
17196 test_400a() { # LU-1606, was conf-sanity test_74
17197 local extra_flags=''
17198 local out=$TMP/$tfile
17199 local prefix=/usr/include/lustre
17202 if ! which $CC > /dev/null 2>&1; then
17203 skip_env "$CC is not installed"
17207 if ! [[ -d $prefix ]]; then
17208 # Assume we're running in tree and fixup the include path.
17209 extra_flags+=" -I$LUSTRE/include"
17210 extra_flags+=" -L$LUSTRE/utils"
17213 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
17214 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
17215 error "client api broken"
17219 run_test 400a "Lustre client api program can compile and link"
17221 test_400b() { # LU-1606, LU-5011
17223 local out=$TMP/$tfile
17224 local prefix=/usr/include/linux/lustre
17226 # We use a hard coded prefix so that this test will not fail
17227 # when run in tree. There are headers in lustre/include/lustre/
17228 # that are not packaged (like lustre_idl.h) and have more
17229 # complicated include dependencies (like config.h and lnet/types.h).
17230 # Since this test about correct packaging we just skip them when
17231 # they don't exist (see below) rather than try to fixup cppflags.
17233 if ! which $CC > /dev/null 2>&1; then
17234 skip_env "$CC is not installed"
17238 for header in $prefix/*.h; do
17239 if ! [[ -f "$header" ]]; then
17243 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
17244 continue # lustre_ioctl.h is internal header
17247 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
17248 error "cannot compile '$header'"
17252 run_test 400b "packaged headers can be compiled"
17254 test_401a() { #LU-7437
17255 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
17256 [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
17258 #count the number of parameters by "list_param -R"
17259 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
17260 #count the number of parameters by listing proc files
17261 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
17262 echo "proc_dirs='$proc_dirs'"
17263 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
17264 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
17267 [ $params -eq $procs ] ||
17268 error "found $params parameters vs. $procs proc files"
17270 # test the list_param -D option only returns directories
17271 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
17272 #count the number of parameters by listing proc directories
17273 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
17276 [ $params -eq $procs ] ||
17277 error "found $params parameters vs. $procs proc files"
17279 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
17282 local save=$($LCTL get_param -n jobid_var)
17285 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
17286 error "no error returned when setting bad parameters"
17288 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
17289 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
17291 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
17292 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
17293 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
17295 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
17298 local jobid_var_old=$($LCTL get_param -n jobid_var)
17299 local jobid_var_new
17301 $LCTL set_param jobid_var= &&
17302 error "no error returned for 'set_param a='"
17304 jobid_var_new=$($LCTL get_param -n jobid_var)
17305 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
17306 error "jobid_var was changed by setting without value"
17308 $LCTL set_param jobid_var &&
17309 error "no error returned for 'set_param a'"
17311 jobid_var_new=$($LCTL get_param -n jobid_var)
17312 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
17313 error "jobid_var was changed by setting without value"
17315 run_test 401c "Verify 'lctl set_param' without value fails in either format."
17318 local jobid_var_old=$($LCTL get_param -n jobid_var)
17319 local jobid_var_new
17320 local new_value="foo=bar"
17322 $LCTL set_param jobid_var=$new_value ||
17323 error "'set_param a=b' did not accept a value containing '='"
17325 jobid_var_new=$($LCTL get_param -n jobid_var)
17326 [[ "$jobid_var_new" == "$new_value" ]] ||
17327 error "'set_param a=b' failed on a value containing '='"
17329 # Reset the jobid_var to test the other format
17330 $LCTL set_param jobid_var=$jobid_var_old
17331 jobid_var_new=$($LCTL get_param -n jobid_var)
17332 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
17333 error "failed to reset jobid_var"
17335 $LCTL set_param jobid_var $new_value ||
17336 error "'set_param a b' did not accept a value containing '='"
17338 jobid_var_new=$($LCTL get_param -n jobid_var)
17339 [[ "$jobid_var_new" == "$new_value" ]] ||
17340 error "'set_param a b' failed on a value containing '='"
17342 $LCTL set_param jobid_var $jobid_var_old
17343 jobid_var_new=$($LCTL get_param -n jobid_var)
17344 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
17345 error "failed to reset jobid_var"
17347 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
17350 local server_version=$(lustre_version_code $SINGLEMDS)
17351 [[ $server_version -ge $(version_code 2.7.66) ]] ||
17352 [[ $server_version -ge $(version_code 2.7.18.4) &&
17353 $server_version -lt $(version_code 2.7.50) ]] ||
17354 [[ $server_version -ge $(version_code 2.7.2) &&
17355 $server_version -lt $(version_code 2.7.11) ]] ||
17356 { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
17358 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17359 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
17360 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
17361 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
17362 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
17363 echo "Touch failed - OK"
17365 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
17368 local file1=$DIR/$tfile.1
17369 local file2=$DIR/$tfile.2
17370 local tfile=$TMP/$tfile
17372 rm -f $file1 $file2 $tfile
17377 # 30 sec OBD_TIMEOUT in ll_getattr()
17378 # right before populating st_nlink
17379 $LCTL set_param fail_loc=0x80001409
17380 stat -c %h $file1 > $tfile &
17382 # create an alias, drop all locks and reclaim the dentry
17384 cancel_lru_locks mdc
17385 cancel_lru_locks osc
17386 sysctl -w vm.drop_caches=2
17390 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
17392 rm -f $tfile $file1 $file2
17394 run_test 403 "i_nlink should not drop to zero due to aliasing"
17396 test_404() { # LU-6601
17397 local server_version=$(lustre_version_code $SINGLEMDS)
17398 [[ $server_version -ge $(version_code 2.8.53) ]] ||
17399 { skip "Need server version newer than 2.8.52"; return 0; }
17401 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17402 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
17403 awk '/osp .*-osc-MDT/ { print $4}')
17406 for osp in $mosps; do
17407 echo "Deactivate: " $osp
17408 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
17409 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17410 awk -vp=$osp '$4 == p { print $2 }')
17411 [ $stat = IN ] || {
17412 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17413 error "deactivate error"
17415 echo "Activate: " $osp
17416 do_facet $SINGLEMDS $LCTL --device %$osp activate
17417 local stat=$(do_facet $SINGLEMDS $LCTL dl |
17418 awk -vp=$osp '$4 == p { print $2 }')
17419 [ $stat = UP ] || {
17420 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
17421 error "activate error"
17425 run_test 404 "validate manual {de}activated works properly for OSPs"
17428 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
17429 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
17430 skip "Layout swap lock is not supported" && return
17432 check_swap_layouts_support && return 0
17434 test_mkdir $DIR/$tdir
17435 swap_lock_test -d $DIR/$tdir ||
17436 error "One layout swap locked test failed"
17438 run_test 405 "Various layout swap lock tests"
17441 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17442 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
17443 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
17444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17445 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
17446 skip "Need MDS version at least 2.8.50" && return
17448 local def_stripe_count=$($GETSTRIPE -c $MOUNT)
17449 local def_stripe_size=$($GETSTRIPE -S $MOUNT)
17450 local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
17451 local def_pool=$($GETSTRIPE -p $MOUNT)
17452 local test_pool=$TESTNAME
17454 if ! combined_mgs_mds ; then
17457 pool_add $test_pool || error "pool_add failed"
17458 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
17459 error "pool_add_targets failed"
17461 # parent set default stripe count only, child will stripe from both
17462 # parent and fs default
17463 $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
17464 error "setstripe $MOUNT failed"
17465 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
17466 $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
17467 for i in $(seq 10); do
17468 local f=$DIR/$tdir/$tfile.$i
17469 touch $f || error "touch failed"
17470 local count=$($GETSTRIPE -c $f)
17471 [ $count -eq $OSTCOUNT ] ||
17472 error "$f stripe count $count != $OSTCOUNT"
17473 local offset=$($GETSTRIPE -i $f)
17474 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
17475 local size=$($GETSTRIPE -S $f)
17476 [ $size -eq $((def_stripe_size * 2)) ] ||
17477 error "$f stripe size $size != $((def_stripe_size * 2))"
17478 local pool=$($GETSTRIPE -p $f)
17479 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
17482 # change fs default striping, delete parent default striping, now child
17483 # will stripe from new fs default striping only
17484 $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
17485 error "change $MOUNT default stripe failed"
17486 $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
17487 for i in $(seq 11 20); do
17488 local f=$DIR/$tdir/$tfile.$i
17489 touch $f || error "touch $f failed"
17490 local count=$($GETSTRIPE -c $f)
17491 [ $count -eq 1 ] || error "$f stripe count $count != 1"
17492 local offset=$($GETSTRIPE -i $f)
17493 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
17494 local size=$($GETSTRIPE -S $f)
17495 [ $size -eq $def_stripe_size ] ||
17496 error "$f stripe size $size != $def_stripe_size"
17497 local pool=$($GETSTRIPE -p $f)
17498 [ "#$pool" == "#" ] || error "$f pool $pool is set"
17502 unlinkmany $DIR/$tdir/$tfile. 1 20
17504 # restore FS default striping
17505 if [ -z $def_pool ]; then
17506 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
17507 -i $def_stripe_offset $MOUNT ||
17508 error "restore default striping failed"
17510 $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
17511 -i $def_stripe_offset -p $def_pool $MOUNT ||
17512 error "restore default striping with $def_pool failed"
17515 local f=$DIR/$tdir/$tfile
17516 pool_remove_all_targets $test_pool $f
17517 pool_remove $test_pool $f
17519 if ! combined_mgs_mds ; then
17523 run_test 406 "DNE support fs default striping"
17526 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
17527 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
17528 skip "Need MDS version at least 2.8.55" && return
17529 remote_mds_nodsh && skip "remote MDS with nodsh" && return
17531 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
17532 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
17533 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
17534 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
17535 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
17537 #define OBD_FAIL_DT_TXN_STOP 0x2019
17538 for idx in $(seq $MDSCOUNT); do
17539 do_facet mds$idx "lctl set_param fail_loc=0x2019"
17541 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
17542 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
17543 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
17546 run_test 407 "transaction fail should cause operation fail"
17549 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
17551 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
17552 lctl set_param fail_loc=0x8000040a
17553 # let ll_prepare_partial_page() fail
17554 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
17558 # create at least 100 unused inodes so that
17559 # shrink_icache_memory(0) should not return 0
17560 touch $DIR/$tfile-{0..100}
17561 rm -f $DIR/$tfile-{0..100}
17564 echo 2 > /proc/sys/vm/drop_caches
17566 run_test 408 "drop_caches should not hang due to page leaks"
17570 [ $MDSCOUNT -lt 2 ] &&
17571 skip "We need at least 2 MDTs for this test" && return
17573 check_mount_and_prep
17575 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
17576 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
17577 touch $DIR/$tdir/guard || error "(2) Fail to create"
17579 local PREFIX=$(str_repeat 'A' 128)
17580 echo "Create 1K hard links start at $(date)"
17581 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17582 error "(3) Fail to hard link"
17584 echo "Links count should be right although linkEA overflow"
17585 stat $DIR/$tdir/guard || error "(4) Fail to stat"
17586 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
17587 [ $linkcount -eq 1001 ] ||
17588 error "(5) Unexpected hard links count: $linkcount"
17590 echo "List all links start at $(date)"
17591 ls -l $DIR/$tdir/foo > /dev/null ||
17592 error "(6) Fail to list $DIR/$tdir/foo"
17594 echo "Unlink hard links start at $(date)"
17595 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
17596 error "(7) Fail to unlink"
17598 run_test 409 "Large amount of cross-MDTs hard links on the same file"
17602 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
17603 skip "Need client version at least 2.9.59" && return
17605 # Create a file, and stat it from the kernel
17606 local testfile=$DIR/$tfile
17609 local run_id=$RANDOM
17610 local my_ino=$(stat --format "%i" $testfile)
17612 # Try to insert the module. This will always fail as the
17613 # module is designed to not be inserted.
17614 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
17617 # Anything but success is a test failure
17619 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
17620 error "no inode match"
17622 run_test 410 "Test inode number returned from kernel thread"
17624 cleanup_test411_cgroup() {
17630 local cg_basedir=/sys/fs/cgroup/memory
17632 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
17633 { skip "no setup for cgroup"; return; }
17635 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
17636 error "test file creation failed"
17637 cancel_lru_locks osc
17639 # Create a very small memory cgroup to force a slab allocation error
17640 local cgdir=$cg_basedir/osc_slab_alloc
17641 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
17642 trap "cleanup_test411_cgroup $cgdir" EXIT
17643 echo 2M > $cgdir/memory.kmem.limit_in_bytes
17644 echo 1M > $cgdir/memory.limit_in_bytes
17646 # Should not LBUG, just be killed by oom-killer
17647 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
17648 error "fail to trigger a memory allocation error"
17650 cleanup_test411_cgroup $cgdir
17654 run_test 411 "Slab allocation error with cgroup does not LBUG"
17657 [ $MDSCOUNT -lt 2 ] &&
17658 skip "We need at least 2 MDTs for this test" && return
17660 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
17661 skip "Need server version at least 2.10.55" & exit 0
17664 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
17665 error "mkdir failed"
17666 $LFS getdirstripe $DIR/$tdir
17667 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
17668 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
17669 error "expect $((MDSCOUT - 1)) get $stripe_index"
17670 stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
17671 [ $stripe_count -eq 2 ] ||
17672 error "expect 2 get $stripe_count"
17674 run_test 412 "mkdir on specific MDTs"
17677 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17678 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17679 skip "Need server version at least 2.9.55" & exit 0
17680 start_full_debug_logging
17684 stop_full_debug_logging
17688 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17689 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17690 awk '/The barrier for/ { print $7 }')
17693 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
17698 barrier_expired() {
17701 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
17702 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
17703 awk '/will be expired/ { print $7 }')
17705 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
17714 echo "Start barrier_freeze at: $(date)"
17715 #define OBD_FAIL_BARRIER_DELAY 0x2202
17716 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17717 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
17720 local b_status=$(barrier_stat)
17721 echo "Got barrier status at: $(date)"
17722 [ "$b_status" = "'freezing_p1'" ] ||
17723 error "(1) unexpected barrier status $b_status"
17725 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17727 b_status=$(barrier_stat)
17728 [ "$b_status" = "'frozen'" ] ||
17729 error "(2) unexpected barrier status $b_status"
17731 local expired=$(barrier_expired)
17732 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
17733 sleep $((expired + 3))
17735 b_status=$(barrier_stat)
17736 [ "$b_status" = "'expired'" ] ||
17737 error "(3) unexpected barrier status $b_status"
17739 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
17740 error "(4) fail to freeze barrier"
17742 b_status=$(barrier_stat)
17743 [ "$b_status" = "'frozen'" ] ||
17744 error "(5) unexpected barrier status $b_status"
17746 echo "Start barrier_thaw at: $(date)"
17747 #define OBD_FAIL_BARRIER_DELAY 0x2202
17748 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
17749 do_facet mgs $LCTL barrier_thaw $FSNAME &
17752 b_status=$(barrier_stat)
17753 echo "Got barrier status at: $(date)"
17754 [ "$b_status" = "'thawing'" ] ||
17755 error "(6) unexpected barrier status $b_status"
17757 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
17759 b_status=$(barrier_stat)
17760 [ "$b_status" = "'thawed'" ] ||
17761 error "(7) unexpected barrier status $b_status"
17763 #define OBD_FAIL_BARRIER_FAILURE 0x2203
17764 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
17765 do_facet mgs $LCTL barrier_freeze $FSNAME
17767 b_status=$(barrier_stat)
17768 [ "$b_status" = "'failed'" ] ||
17769 error "(8) unexpected barrier status $b_status"
17771 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17772 do_facet mgs $LCTL barrier_thaw $FSNAME
17776 run_test 801a "write barrier user interfaces and stat machine"
17781 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17782 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
17783 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
17784 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
17785 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
17787 cancel_lru_locks mdc
17789 # 180 seconds should be long enough
17790 do_facet mgs $LCTL barrier_freeze $FSNAME 180
17792 local b_status=$(barrier_stat)
17793 [ "$b_status" = "'frozen'" ] ||
17794 error "(6) unexpected barrier status $b_status"
17796 mkdir $DIR/$tdir/d0/d10 &
17799 touch $DIR/$tdir/d1/f13 &
17802 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
17805 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
17808 rm -f $DIR/$tdir/d4/f12 &
17811 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
17813 # To guarantee taht the 'stat' is not blocked
17814 b_status=$(barrier_stat)
17815 [ "$b_status" = "'frozen'" ] ||
17816 error "(8) unexpected barrier status $b_status"
17818 # let above commands to run at background
17821 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
17822 ps -p $touch_pid || error "(10) touch should be blocked"
17823 ps -p $ln_pid || error "(11) link should be blocked"
17824 ps -p $mv_pid || error "(12) rename should be blocked"
17825 ps -p $rm_pid || error "(13) unlink should be blocked"
17827 b_status=$(barrier_stat)
17828 [ "$b_status" = "'frozen'" ] ||
17829 error "(14) unexpected barrier status $b_status"
17831 do_facet mgs $LCTL barrier_thaw $FSNAME
17832 b_status=$(barrier_stat)
17833 [ "$b_status" = "'thawed'" ] ||
17834 error "(15) unexpected barrier status $b_status"
17836 wait $mkdir_pid || error "(16) mkdir should succeed"
17837 wait $touch_pid || error "(17) touch should succeed"
17838 wait $ln_pid || error "(18) link should succeed"
17839 wait $mv_pid || error "(19) rename should succeed"
17840 wait $rm_pid || error "(20) unlink should succeed"
17844 run_test 801b "modification will be blocked by write barrier"
17847 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17851 stop mds2 || error "(1) Fail to stop mds2"
17853 do_facet mgs $LCTL barrier_freeze $FSNAME 30
17855 local b_status=$(barrier_stat)
17856 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
17857 do_facet mgs $LCTL barrier_thaw $FSNAME
17858 error "(2) unexpected barrier status $b_status"
17861 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17862 error "(3) Fail to rescan barrier bitmap"
17864 do_facet mgs $LCTL barrier_freeze $FSNAME 10
17866 b_status=$(barrier_stat)
17867 [ "$b_status" = "'frozen'" ] ||
17868 error "(4) unexpected barrier status $b_status"
17870 do_facet mgs $LCTL barrier_thaw $FSNAME
17871 b_status=$(barrier_stat)
17872 [ "$b_status" = "'thawed'" ] ||
17873 error "(5) unexpected barrier status $b_status"
17875 local devname=$(mdsdevname 2)
17877 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
17879 do_facet mgs $LCTL barrier_rescan $FSNAME ||
17880 error "(7) Fail to rescan barrier bitmap"
17884 run_test 801c "rescan barrier bitmap"
17886 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
17887 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
17888 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
17894 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
17895 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
17896 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
17902 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
17903 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
17904 skip "Need server version at least 2.9.55" & exit 0
17906 mkdir $DIR/$tdir || error "(1) fail to mkdir"
17908 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
17909 error "(2) Fail to copy"
17911 trap cleanup_802 EXIT
17913 # sync by force before remount as readonly
17914 sync; sync_all_data; sleep 3; sync_all_data
17918 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
17919 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
17920 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
17922 echo "Mount the server as read only"
17923 setupall server_only || error "(3) Fail to start servers"
17925 echo "Mount client without ro should fail"
17926 mount_client $MOUNT &&
17927 error "(4) Mount client without 'ro' should fail"
17929 echo "Mount client with ro should succeed"
17930 mount_client $MOUNT ro ||
17931 error "(5) Mount client with 'ro' should succeed"
17933 echo "Modify should be refused"
17934 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
17936 echo "Read should be allowed"
17937 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
17938 error "(7) Read should succeed under ro mode"
17942 run_test 802 "simulate readonly device"
17945 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17946 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
17947 skip "MDS needs to be newer than 2.10.54" && return
17949 mkdir -p $DIR/$tdir
17950 # Create some objects on all MDTs to trigger related logs objects
17951 for idx in $(seq $MDSCOUNT); do
17952 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
17953 $DIR/$tdir/dir${idx} ||
17954 error "Fail to create $DIR/$tdir/dir${idx}"
17958 echo "before create:"
17960 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17962 for ((i=0; i<10; i++)); do
17963 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
17964 error "Fail to create $DIR/$tdir/foo$i"
17968 echo "after create:"
17970 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17972 [ $after_used -ge $((before_used + 10)) ] ||
17973 error "before ($before_used) + 10 > after ($after_used)"
17975 for ((i=0; i<10; i++)); do
17976 rm -rf $DIR/$tdir/foo$i ||
17977 error "Fail to remove $DIR/$tdir/foo$i"
17980 wait_delete_completed
17981 echo "after unlink:"
17983 before_used=$after_used
17984 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
17986 [ $after_used -le $((before_used - 8)) ] ||
17987 error "before ($before_used) - 8 < after ($after_used)"
17989 run_test 803 "verify agent object for remote object"
17992 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
17993 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
17994 skip "MDS needs to be newer than 2.10.54" && return
17996 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
17997 skip "ldiskfs only test" && return 0
17999 mkdir -p $DIR/$tdir
18000 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
18001 error "Fail to create $DIR/$tdir/dir0"
18003 local fid=$($LFS path2fid $DIR/$tdir/dir0)
18004 local dev=$(mdsdevname 2)
18006 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18007 grep ${fid} || error "NOT found agent entry for dir0"
18009 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
18010 error "Fail to create $DIR/$tdir/dir1"
18012 touch $DIR/$tdir/dir1/foo0 ||
18013 error "Fail to create $DIR/$tdir/dir1/foo0"
18014 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
18017 for idx in $(seq $MDSCOUNT); do
18018 dev=$(mdsdevname $idx)
18019 do_facet mds${idx} \
18020 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18021 grep ${fid} && rc=$idx
18024 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
18025 error "Fail to rename foo0 to foo1"
18026 if [ $rc -eq 0 ]; then
18027 for idx in $(seq $MDSCOUNT); do
18028 dev=$(mdsdevname $idx)
18029 do_facet mds${idx} \
18030 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18031 grep ${fid} && rc=$idx
18035 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
18036 error "Fail to rename foo1 to foo2"
18037 if [ $rc -eq 0 ]; then
18038 for idx in $(seq $MDSCOUNT); do
18039 dev=$(mdsdevname $idx)
18040 do_facet mds${idx} \
18041 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18042 grep ${fid} && rc=$idx
18046 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
18048 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
18049 error "Fail to link to $DIR/$tdir/dir1/foo2"
18050 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
18051 error "Fail to rename foo2 to foo0"
18052 unlink $DIR/$tdir/dir1/foo0 ||
18053 error "Fail to unlink $DIR/$tdir/dir1/foo0"
18054 rm -rf $DIR/$tdir/dir0 ||
18055 error "Fail to rm $DIR/$tdir/dir0"
18057 for idx in $(seq $MDSCOUNT); do
18058 dev=$(mdsdevname $idx)
18062 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
18064 start mds${idx} $dev $MDS_MOUNT_OPTS ||
18065 error "mount mds$idx failed"
18066 df $MOUNT > /dev/null 2>&1
18068 # e2fsck should not return error
18070 error "e2fsck detected error on MDT${idx}: rc=$rc"
18073 run_test 804 "verify agent entry for remote entry"
18076 # tests that do cleanup/setup should be run at the end
18080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18082 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
18083 $LCTL set_param fail_loc=0x903
18085 cancel_lru_locks MGC
18087 FAIL_ON_ERROR=true cleanup
18088 FAIL_ON_ERROR=true setup
18090 run_test 900 "umount should not race with any mgc requeue thread"
18093 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
18094 check_and_cleanup_lustre
18095 if [ "$I_MOUNTED" != "yes" ]; then
18096 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true