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: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
21 if [ -r /etc/SuSE-release ]
23 local vers=$(grep VERSION /etc/SuSE-release | awk '{print $3}')
24 local patchlev=$(grep PATCHLEVEL /etc/SuSE-release |
26 if [ $vers -eq 11 ] && [ $patchlev -ge 3 ]; then
33 if is_sles11; then # LU-4341
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
37 SRCDIR=$(cd $(dirname $0); echo $PWD)
38 export PATH=$PATH:/sbin
43 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
44 CREATETEST=${CREATETEST:-createtest}
46 LFIND=${LFIND:-"$LFS find"}
47 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
49 OPENFILE=${OPENFILE:-openfile}
50 OPENUNLINK=${OPENUNLINK:-openunlink}
51 export MULTIOP=${MULTIOP:-multiop}
52 READS=${READS:-"reads"}
53 MUNLINK=${MUNLINK:-munlink}
54 SOCKETSERVER=${SOCKETSERVER:-socketserver}
55 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
56 MEMHOG=${MEMHOG:-memhog}
57 DIRECTIO=${DIRECTIO:-directio}
58 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
73 . $LUSTRE/tests/test-framework.sh
75 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b 300o"
80 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
81 # bug number for skipped test: LU-4536 LU-1957 LU-2805
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
83 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
90 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
91 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
100 check_swap_layouts_support()
102 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
103 { skip "Does not support layout lock."; return 0; }
107 check_and_setup_lustre
111 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
112 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
113 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
115 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
116 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
117 rm -rf $DIR/[Rdfs][0-9]*
119 # $RUNAS_ID may get set incorrectly somewhere else
120 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
122 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
126 if [ "${ONLY}" = "MOUNT" ] ; then
127 echo "Lustre is up, please go on"
131 echo "preparing for tests involving mounts"
132 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
134 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
135 echo # add a newline after mke2fs.
139 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
140 lctl set_param debug=-1 2> /dev/null || true
143 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
145 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
147 run_test 0a "touch; rm ====================="
150 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
151 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
153 run_test 0b "chmod 0755 $DIR ============================="
156 $LCTL get_param mdc.*.import | grep "state: FULL" ||
157 error "import not FULL"
158 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
161 run_test 0c "check import proc ============================="
164 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
165 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
166 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
167 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
170 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
172 run_test 1 "mkdir; remkdir; rmdir =============================="
175 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
176 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
177 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
179 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
181 run_test 2 "mkdir; touch; rmdir; check file ===================="
184 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
185 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
186 touch $DIR/$tdir/$tfile
187 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
189 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
191 run_test 3 "mkdir; touch; rmdir; check dir ====================="
193 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
197 test_mkdir $DIR/$tdir ||
198 error "Create remote directory failed"
200 touch $DIR/$tdir/$tfile ||
201 error "Create file under remote directory failed"
204 error "Expect error removing in-use dir $DIR/$tdir"
206 test -d $DIR/$tdir || error "Remote directory disappeared"
208 rm -rf $DIR/$tdir || error "remove remote dir error"
210 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
213 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
214 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
215 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
216 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
217 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
219 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
222 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
223 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
224 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
225 error "$tfile does not have perm 0666 or UID $UID"
226 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
227 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
228 error "$tfile should be 0666 and owned by UID $UID"
230 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
233 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
235 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
236 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
237 error "$tfile should be owned by UID $RUNAS_ID"
238 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
239 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
240 error "$tfile should be owned by UID $RUNAS_ID"
242 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
245 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
247 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
248 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
249 error "$tfile should be owned by GID $UID"
250 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
251 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
252 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
254 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
257 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
258 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
259 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
260 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
261 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
262 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
263 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
264 error "$tdir/d/subdir should be GID $RUNAS_GID"
266 run_test 6g "Is new dir in sgid dir inheriting group?"
268 test_6h() { # bug 7331
269 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
270 touch $DIR/$tfile || error "touch failed"
271 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
272 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
273 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
274 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
275 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
277 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
280 test_mkdir $DIR/$tdir
281 $MCREATE $DIR/$tdir/$tfile
282 chmod 0666 $DIR/$tdir/$tfile
283 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
284 error "$tdir/$tfile should be mode 0666"
286 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
289 if [ ! -d $DIR/$tdir ]; then
290 test_mkdir $DIR/$tdir
292 $MCREATE $DIR/$tdir/$tfile
293 echo -n foo > $DIR/$tdir/$tfile
294 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
295 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
297 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
300 test_mkdir $DIR/$tdir
301 touch $DIR/$tdir/$tfile
302 chmod 0666 $DIR/$tdir/$tfile
303 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
304 error "$tfile mode not 0666"
306 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
309 test_mkdir $DIR/$tdir
310 test_mkdir $DIR/$tdir/d2
311 test_mkdir $DIR/$tdir/d2/d3
312 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
314 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
317 test_mkdir $DIR/$tdir
318 test_mkdir $DIR/$tdir/d2
319 touch $DIR/$tdir/d2/$tfile
320 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
321 error "$tdir/d2/$tfile not a file"
323 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
326 test_mkdir $DIR/$tdir
327 test_mkdir $DIR/$tdir/d2
328 chmod 0666 $DIR/$tdir/d2
329 chmod 0705 $DIR/$tdir/d2
330 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
331 error "$tdir/d2 mode not 0705"
333 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
336 test_mkdir $DIR/$tdir
337 touch $DIR/$tdir/$tfile
338 chmod 0666 $DIR/$tdir/$tfile
339 chmod 0654 $DIR/$tdir/$tfile
340 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
341 error "$tdir/d2 mode not 0654"
343 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
346 test_mkdir $DIR/$tdir
347 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
349 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
350 error "$tdir/$tfile size not 0 after truncate"
352 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
355 test_mkdir $DIR/$tdir
356 touch $DIR/$tdir/$tfile
358 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
360 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
363 test_mkdir $DIR/$tdir
364 touch $DIR/$tdir/$tfile
365 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
366 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
367 error "$tdir/${tfile_2} not a file after rename"
368 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
370 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
373 test_mkdir $DIR/$tdir
374 touch $DIR/$tdir/$tfile
375 rm -rf $DIR/$tdir/$tfile
376 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
378 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
381 test_mkdir -p $DIR/$tdir
382 touch $DIR/$tdir/$tfile
383 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
385 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
386 error "$tdir/l-exist not a symlink"
387 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
388 error "$tdir/l-exist not referencing a file"
389 rm -f $DIR/$tdir/l-exist
390 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
392 run_test 17a "symlinks: create, remove (real) =================="
395 test_mkdir -p $DIR/$tdir
396 ln -s no-such-file $DIR/$tdir/l-dangle
398 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
399 error "$tdir/l-dangle not referencing no-such-file"
400 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
401 error "$tdir/l-dangle not referencing non-existent file"
402 rm -f $DIR/$tdir/l-dangle
403 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
405 run_test 17b "symlinks: create, remove (dangling) =============="
407 test_17c() { # bug 3440 - don't save failed open RPC for replay
408 test_mkdir -p $DIR/$tdir
409 ln -s foo $DIR/$tdir/$tfile
410 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
412 run_test 17c "symlinks: open dangling (should return error) ===="
415 test_mkdir -p $DIR/$tdir
416 ln -s foo $DIR/$tdir/$tfile
417 touch $DIR/$tdir/$tfile || error "creating to new symlink"
419 run_test 17d "symlinks: create dangling ========================"
422 test_mkdir -p $DIR/$tdir
423 local foo=$DIR/$tdir/$tfile
424 ln -s $foo $foo || error "create symlink failed"
425 ls -l $foo || error "ls -l failed"
426 ls $foo && error "ls not failed" || true
428 run_test 17e "symlinks: create recursive symlink (should return error) ===="
431 test_mkdir -p $DIR/$tdir
432 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
433 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
434 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
437 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
440 run_test 17f "symlinks: long and very long symlink name ========================"
442 # str_repeat(S, N) generate a string that is string S repeated N times
447 while [ $((n -= 1)) -ge 0 ]; do
453 # Long symlinks and LU-2241
455 test_mkdir -p $DIR/$tdir
456 local TESTS="59 60 61 4094 4095"
458 # Fix for inode size boundary in 2.1.4
459 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
462 # Patch not applied to 2.2 or 2.3 branches
463 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
464 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
467 # skip long symlink name for rhel6.5.
468 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
469 grep -q '6.5' /etc/redhat-release &>/dev/null &&
470 TESTS="59 60 61 4062 4063"
473 local SYMNAME=$(str_repeat 'x' $i)
474 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
475 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
478 run_test 17g "symlinks: really long symlink name and inode boundaries"
480 test_17h() { #bug 17378
481 remote_mds_nodsh && skip "remote MDS with nodsh" && return
482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
484 test_mkdir -p $DIR/$tdir
485 if [[ $MDSCOUNT -gt 1 ]]; then
486 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
490 $SETSTRIPE -c -1 $DIR/$tdir
491 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
492 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
493 touch $DIR/$tdir/$tfile || true
495 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
497 test_17i() { #bug 20018
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
500 test_mkdir -c1 $DIR/$tdir
501 local foo=$DIR/$tdir/$tfile
503 if [[ $MDSCOUNT -gt 1 ]]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 ln -s $foo $foo || error "create symlink failed"
509 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
511 ls -l $foo && error "error not detected"
514 run_test 17i "don't panic on short symlink"
516 test_17k() { #bug 22301
517 [[ -z "$(which rsync 2>/dev/null)" ]] &&
518 skip "no rsync command" && return 0
519 rsync --help | grep -q xattr ||
520 skip_env "$(rsync --version | head -n1) does not support xattrs"
521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
522 test_mkdir -p $DIR/$tdir
523 test_mkdir -p $DIR/$tdir.new
524 touch $DIR/$tdir/$tfile
525 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
526 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
527 error "rsync failed with xattrs enabled"
529 run_test 17k "symlinks: rsync with xattrs enabled ========================="
531 test_17l() { # LU-279
532 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
533 skip "no getfattr command" && return 0
534 test_mkdir -p $DIR/$tdir
535 touch $DIR/$tdir/$tfile
536 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
537 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
538 # -h to not follow symlinks. -m '' to list all the xattrs.
539 # grep to remove first line: '# file: $path'.
540 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
542 lgetxattr_size_check $path $xattr ||
543 error "lgetxattr_size_check $path $xattr failed"
547 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
551 local short_sym="0123456789"
552 local WDIR=$DIR/${tdir}m
555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
556 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
557 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
558 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
560 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
561 skip "only for ldiskfs MDT" && return 0
563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
567 # create a long symlink file
568 for ((i = 0; i < 4; ++i)); do
569 long_sym=${long_sym}${long_sym}
572 echo "create 512 short and long symlink files under $WDIR"
573 for ((i = 0; i < 256; ++i)); do
574 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
575 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
581 wait_delete_completed
583 echo "recreate the 512 symlink files with a shorter string"
584 for ((i = 0; i < 512; ++i)); do
585 # rewrite the symlink file with a shorter string
586 ln -sf ${long_sym} $WDIR/long-$i || error "long_sym failed"
587 ln -sf ${short_sym} $WDIR/short-$i || error "short_sym failed"
590 local mds_index=$(($($LFS getstripe -M $WDIR) + 1))
591 local devname=$(mdsdevname $mds_index)
593 echo "stop and checking mds${mds_index}:"
594 # e2fsck should not return error
596 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
599 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
600 df $MOUNT > /dev/null 2>&1
602 error "e2fsck detected error for short/long symlink: rc=$rc"
604 run_test 17m "run e2fsck against MDT which contains short/long symlink"
606 check_fs_consistency_17n() {
610 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
611 # so it only check MDT1/MDT2 instead of all of MDTs.
612 for mdt_index in 1 2; do
613 local devname=$(mdsdevname $mdt_index)
614 # e2fsck should not return error
616 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
619 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
620 error "mount mds$mdt_index failed"
621 df $MOUNT > /dev/null 2>&1
629 remote_mds_nodsh && skip "remote MDS with nodsh" && return
630 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
631 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
632 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
634 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
635 skip "only for ldiskfs MDT" && return 0
637 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
641 test_mkdir $DIR/$tdir
642 for ((i=0; i<10; i++)); do
643 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
644 error "create remote dir error $i"
645 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
646 error "create files under remote dir failed $i"
649 check_fs_consistency_17n ||
650 error "e2fsck report error after create files under remote dir"
652 for ((i = 0; i < 10; i++)); do
653 rm -rf $DIR/$tdir/remote_dir_${i} ||
654 error "destroy remote dir error $i"
657 check_fs_consistency_17n ||
658 error "e2fsck report error after unlink files under remote dir"
660 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
661 skip "lustre < 2.4.50 does not support migrate mv " && return
663 for ((i = 0; i < 10; i++)); do
664 mkdir -p $DIR/$tdir/remote_dir_${i}
665 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
666 error "create files under remote dir failed $i"
667 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
668 error "migrate remote dir error $i"
670 check_fs_consistency_17n || error "e2fsck report error after migration"
672 for ((i = 0; i < 10; i++)); do
673 rm -rf $DIR/$tdir/remote_dir_${i} ||
674 error "destroy remote dir error $i"
677 check_fs_consistency_17n || error "e2fsck report error after unlink"
679 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
682 remote_mds_nodsh && skip "remote MDS with nodsh" && return
683 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
684 skip "Need MDS version at least 2.3.64" && return
686 local WDIR=$DIR/${tdir}o
691 mdt_index=$($LFS getstripe -M $WDIR)
692 mdt_index=$((mdt_index+1))
696 #fail mds will wait the failover finish then set
697 #following fail_loc to avoid interfer the recovery process.
700 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
701 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
702 ls -l $WDIR/$tfile && rc=1
703 do_facet mds${mdt_index} lctl set_param fail_loc=0
704 [[ $rc -ne 0 ]] && error "stat file should fail"
707 run_test 17o "stat file with incompat LMA feature"
710 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
711 ls $DIR || error "Failed to ls $DIR: $?"
713 run_test 18 "touch .../f ; ls ... =============================="
719 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
721 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
724 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
726 run_test 19b "ls -l .../f19 (should return error) =============="
729 [ $RUNAS_ID -eq $UID ] &&
730 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
731 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
733 run_test 19c "$RUNAS touch .../f19 (should return error) =="
736 cat $DIR/f19 && error || true
738 run_test 19d "cat .../f19 (should return error) =============="
750 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
752 run_test 20 "touch .../f ; ls -l ... ==========================="
755 test_mkdir -p $DIR/$tdir
756 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
757 ln -s dangle $DIR/$tdir/link
758 echo foo >> $DIR/$tdir/link
759 cat $DIR/$tdir/dangle
760 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
761 $CHECKSTAT -f -t file $DIR/$tdir/link ||
762 error "$tdir/link not linked to a file"
764 run_test 21 "write to dangling link ============================"
768 test_mkdir -p $DIR/$tdir
769 chown $RUNAS_ID:$RUNAS_GID $WDIR
770 (cd $WDIR || error "cd $WDIR failed";
771 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
773 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
774 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
775 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
777 run_test 22 "unpack tar archive as non-root user ==============="
781 test_mkdir -p $DIR/$tdir
782 local file=$DIR/$tdir/$tfile
784 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
785 openfile -f O_CREAT:O_EXCL $file &&
786 error "$file recreate succeeded" || true
788 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
790 test_23b() { # bug 18988
791 test_mkdir -p $DIR/$tdir
792 local file=$DIR/$tdir/$tfile
795 echo foo > $file || error "write filed"
796 echo bar >> $file || error "append filed"
797 $CHECKSTAT -s 8 $file || error "wrong size"
800 run_test 23b "O_APPEND check =========================="
804 echo '-- same directory rename'
805 test_mkdir $DIR/$tdir
806 touch $DIR/$tdir/$tfile.1
807 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
808 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
810 run_test 24a "rename file to non-existent target"
813 test_mkdir $DIR/$tdir
814 touch $DIR/$tdir/$tfile.{1,2}
815 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
816 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
817 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
819 run_test 24b "rename file to existing target"
822 test_mkdir $DIR/$tdir
823 test_mkdir $DIR/$tdir/d$testnum.1
824 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
825 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
826 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
828 run_test 24c "rename directory to non-existent target"
831 test_mkdir -c1 $DIR/$tdir
832 test_mkdir -c1 $DIR/$tdir/d$testnum.1
833 test_mkdir -c1 $DIR/$tdir/d$testnum.2
834 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
835 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
836 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
838 run_test 24d "rename directory to existing target"
841 echo '-- cross directory renames --'
845 mv $DIR/R5a/f $DIR/R5b/g
846 $CHECKSTAT -a $DIR/R5a/f || error
847 $CHECKSTAT -t file $DIR/R5b/g || error
849 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
854 touch $DIR/R6a/f $DIR/R6b/g
855 mv $DIR/R6a/f $DIR/R6b/g
856 $CHECKSTAT -a $DIR/R6a/f || error
857 $CHECKSTAT -t file $DIR/R6b/g || error
859 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
864 test_mkdir $DIR/R7a/d
865 mv $DIR/R7a/d $DIR/R7b/e
866 $CHECKSTAT -a $DIR/R7a/d || error
867 $CHECKSTAT -t dir $DIR/R7b/e || error
869 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
872 test_mkdir -c1 $DIR/R8a
873 test_mkdir -c1 $DIR/R8b
874 test_mkdir -c1 $DIR/R8a/d
875 test_mkdir -c1 $DIR/R8b/e
876 mrename $DIR/R8a/d $DIR/R8b/e
877 $CHECKSTAT -a $DIR/R8a/d || error
878 $CHECKSTAT -t dir $DIR/R8b/e || error
880 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
883 echo "-- rename error cases"
887 mrename $DIR/R9/f $DIR/R9/a
888 $CHECKSTAT -t file $DIR/R9/f || error
889 $CHECKSTAT -t dir $DIR/R9/a || error
890 $CHECKSTAT -a $DIR/R9/a/f || error
892 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
896 mrename $DIR/R10/f $DIR/R10/g
897 $CHECKSTAT -t dir $DIR/R10 || error
898 $CHECKSTAT -a $DIR/R10/f || error
899 $CHECKSTAT -a $DIR/R10/g || error
901 run_test 24j "source does not exist ============================"
905 test_mkdir $DIR/R11a/d
907 mv $DIR/R11a/f $DIR/R11a/d
908 $CHECKSTAT -a $DIR/R11a/f || error
909 $CHECKSTAT -t file $DIR/R11a/d/f || error
911 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
913 # bug 2429 - rename foo foo foo creates invalid file
916 $MULTIOP $f OcNs || error
918 run_test 24l "Renaming a file to itself ========================"
922 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
923 # on ext3 this does not remove either the source or target files
924 # though the "expected" operation would be to remove the source
925 $CHECKSTAT -t file ${f} || error "${f} missing"
926 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
928 run_test 24m "Renaming a file to a hard link to itself ========="
932 # this stats the old file after it was renamed, so it should fail
936 $CHECKSTAT ${f}.rename
939 run_test 24n "Statting the old file after renaming (Posix rename 2)"
942 test_mkdir -p $DIR/d24o
943 rename_many -s random -v -n 10 $DIR/d24o
945 run_test 24o "rename of files during htree split ==============="
950 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
951 mrename $DIR/R12a $DIR/R12b
952 $CHECKSTAT -a $DIR/R12a || error
953 $CHECKSTAT -t dir $DIR/R12b || error
954 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
955 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
957 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
959 cleanup_multiop_pause() {
965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
968 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
969 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
972 trap cleanup_multiop_pause EXIT
973 mrename $DIR/R13a $DIR/R13b
974 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
975 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
976 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
977 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
978 cleanup_multiop_pause
979 wait $MULTIPID || error "multiop close failed"
981 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
983 test_24r() { #bug 3789
985 test_mkdir $DIR/R14a/b
986 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
987 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
988 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
990 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
994 test_mkdir $DIR/R15a/b
995 test_mkdir $DIR/R15a/b/c
996 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
997 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
998 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1000 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1002 test_mkdir $DIR/R16a
1003 test_mkdir $DIR/R16a/b
1004 test_mkdir $DIR/R16a/b/c
1005 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1006 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1007 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1009 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1011 test_24u() { # bug12192
1012 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1013 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1015 run_test 24u "create stripe file"
1021 simple_cleanup_common() {
1024 wait_delete_completed
1027 max_pages_per_rpc() {
1028 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1032 local NRFILES=100000
1033 local FREE_INODES=$(mdt_free_inodes 0)
1034 [[ $FREE_INODES -lt $NRFILES ]] &&
1035 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1039 trap simple_cleanup_common EXIT
1041 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1042 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1044 test_mkdir -p $DIR/$tdir
1045 createmany -m $DIR/$tdir/$tfile $NRFILES
1047 cancel_lru_locks mdc
1048 lctl set_param mdc.*.stats clear
1050 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1052 # LU-5 large readdir
1053 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1054 # 8 bytes for name(filename is mostly 5 in this test) +
1055 # 8 bytes for luda_type
1056 # take into account of overhead in lu_dirpage header and end mark in
1057 # each page, plus one in RPC_NUM calculation.
1059 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1060 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1061 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1062 awk '/^mds_readpage/ {print $2}')
1063 [[ $mds_readpage -gt $RPC_NUM ]] &&
1064 error "large readdir doesn't take effect"
1066 simple_cleanup_common
1068 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1070 test_24w() { # bug21506
1072 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1073 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1074 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1075 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1076 [[ "$SZ1" -eq "$SZ2" ]] ||
1077 error "Error reading at the end of the file $tfile"
1079 run_test 24w "Reading a file larger than 4Gb"
1082 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1084 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1085 skip "Need MDS version at least 2.7.56" && return
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1089 local remote_dir=$DIR/$tdir/remote_dir
1091 test_mkdir -p $DIR/$tdir
1092 $LFS mkdir -i $MDTIDX $remote_dir ||
1093 error "create remote directory failed"
1095 test_mkdir -p $DIR/$tdir/src_dir
1096 touch $DIR/$tdir/src_file
1097 test_mkdir -p $remote_dir/tgt_dir
1098 touch $remote_dir/tgt_file
1100 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1101 error "rename dir cross MDT failed!"
1103 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1104 error "rename file cross MDT failed!"
1106 touch $DIR/$tdir/ln_file
1107 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1108 error "ln file cross MDT failed"
1110 rm -rf $DIR/$tdir || error "Can not delete directories"
1112 run_test 24x "cross MDT rename/link"
1115 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1118 local remote_dir=$DIR/$tdir/remote_dir
1120 test_mkdir -p $DIR/$tdir
1121 $LFS mkdir -i $MDTIDX $remote_dir ||
1122 error "create remote directory failed"
1124 test_mkdir -p $remote_dir/src_dir
1125 touch $remote_dir/src_file
1126 test_mkdir -p $remote_dir/tgt_dir
1127 touch $remote_dir/tgt_file
1129 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1130 error "rename subdir in the same remote dir failed!"
1132 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1133 error "rename files in the same remote dir failed!"
1135 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1136 error "link files in the same remote dir failed!"
1138 rm -rf $DIR/$tdir || error "Can not delete directories"
1140 run_test 24y "rename/link on the same dir should succeed"
1142 test_24A() { # LU-3182
1146 test_mkdir -p $DIR/$tdir
1147 createmany -m $DIR/$tdir/$tfile $NFILES
1148 local t=$(ls $DIR/$tdir | wc -l)
1149 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1150 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1151 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1152 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1155 rm -rf $DIR/$tdir || error "Can not delete directories"
1157 run_test 24A "readdir() returns correct number of entries."
1159 test_24B() { # LU-4805
1160 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1163 test_mkdir $DIR/$tdir
1164 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1165 error "create striped dir failed"
1167 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1168 [ $count -eq 2 ] || error "Expected 2, got $count"
1170 touch $DIR/$tdir/striped_dir/a
1172 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1173 [ $count -eq 3 ] || error "Expected 3, got $count"
1175 touch $DIR/$tdir/striped_dir/.f
1177 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1178 [ $count -eq 4 ] || error "Expected 4, got $count"
1180 rm -rf $DIR/$tdir || error "Can not delete directories"
1182 run_test 24B "readdir for striped dir return correct number of entries"
1185 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1191 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1192 error "create striped dir failed"
1194 cd $DIR/$tdir/d0/striped_dir
1196 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1197 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1198 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1200 [ "$d0_ino" = "$parent_ino" ] ||
1201 error ".. wrong, expect $d0_ino, get $parent_ino"
1203 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1204 error "mv striped dir failed"
1206 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1208 [ "$d1_ino" = "$parent_ino" ] ||
1209 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1211 run_test 24C "check .. in striped dir"
1213 test_24D() { # LU-6101
1218 createmany -m $DIR/$tdir/$tfile $NFILES
1219 local t=$(ls $DIR/$tdir | wc -l)
1220 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1221 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1222 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1223 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1226 rm -rf $DIR/$tdir || error "Can not delete directories"
1228 run_test 24D "readdir() returns correct number of entries after cursor reload"
1231 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1235 mkdir $DIR/$tdir/src_dir
1236 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1237 error "create remote source failed"
1239 touch $DIR/$tdir/src_dir/src_child/a
1241 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1242 error "create remote target dir failed"
1244 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1245 error "create remote target child failed"
1247 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1248 error "rename dir cross MDT failed!"
1252 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1253 error "src_child still exists after rename"
1255 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1256 error "missing file(a) after rename"
1258 rm -rf $DIR/$tdir || error "Can not delete directories"
1260 run_test 24E "cross MDT rename/link"
1263 echo '== symlink sanity ============================================='
1267 touch $DIR/s25/foo || error
1269 run_test 25a "create file in symlinked directory ==============="
1272 [ ! -d $DIR/d25 ] && test_25a
1273 $CHECKSTAT -t file $DIR/s25/foo || error
1275 run_test 25b "lookup file in symlinked directory ==============="
1279 test_mkdir $DIR/d26/d26-2
1280 ln -s d26/d26-2 $DIR/s26
1281 touch $DIR/s26/foo || error
1283 run_test 26a "multiple component symlink ======================="
1286 test_mkdir -p $DIR/d26b/d26-2
1287 ln -s d26b/d26-2/foo $DIR/s26-2
1288 touch $DIR/s26-2 || error
1290 run_test 26b "multiple component symlink at end of lookup ======"
1293 test_mkdir $DIR/d26.2
1294 touch $DIR/d26.2/foo
1295 ln -s d26.2 $DIR/s26.2-1
1296 ln -s s26.2-1 $DIR/s26.2-2
1297 ln -s s26.2-2 $DIR/s26.2-3
1298 chmod 0666 $DIR/s26.2-3/foo
1300 run_test 26c "chain of symlinks ================================"
1302 # recursive symlinks (bug 439)
1304 ln -s d26-3/foo $DIR/d26-3
1306 run_test 26d "create multiple component recursive symlink ======"
1309 [ ! -h $DIR/d26-3 ] && test_26d
1312 run_test 26e "unlink multiple component recursive symlink ======"
1314 # recursive symlinks (bug 7022)
1316 test_mkdir -p $DIR/$tdir
1317 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1318 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1319 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1320 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1321 cd $tfile || error "cd $tfile failed"
1322 ln -s .. dotdot || error "ln dotdot failed"
1323 ln -s dotdot/lndir lndir || error "ln lndir failed"
1324 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1325 output=`ls $tfile/$tfile/lndir/bar1`
1326 [ "$output" = bar1 ] && error "unexpected output"
1327 rm -r $tfile || error "rm $tfile failed"
1328 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1330 run_test 26f "rm -r of a directory which has recursive symlink ="
1333 echo '== stripe sanity =============================================='
1334 test_mkdir -p $DIR/d27 || error "mkdir failed"
1336 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1337 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1338 log "== test_27a: write to one stripe file ========================="
1339 cp /etc/hosts $DIR/d27/f0 || error
1341 run_test 27a "one stripe file =================================="
1344 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1345 test_mkdir -p $DIR/d27
1346 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1347 $GETSTRIPE -c $DIR/d27/f01
1348 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1349 error "two-stripe file doesn't have two stripes"
1351 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1353 run_test 27b "create and write to two stripe file"
1356 test_mkdir -p $DIR/d27
1357 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1358 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1359 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1361 run_test 27d "create file with default settings ================"
1364 # LU-5839 adds check for existed layout before setting it
1365 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1366 skip "Need MDS version at least 2.7.56" && return
1367 test_mkdir -p $DIR/d27
1368 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1369 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1370 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1372 run_test 27e "setstripe existing file (should return error) ======"
1375 test_mkdir $DIR/$tdir
1376 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1377 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1378 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1379 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1380 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1381 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1383 run_test 27f "setstripe with bad stripe size (should return error)"
1386 test_mkdir -p $DIR/d27
1387 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1388 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1389 error "$DIR/d27/fnone has object"
1391 run_test 27g "$GETSTRIPE with no objects"
1394 test_mkdir $DIR/$tdir
1395 touch $DIR/$tdir/$tfile || error "touch failed"
1396 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1397 error "missing objects"
1399 run_test 27i "$GETSTRIPE with some objects"
1402 test_mkdir -p $DIR/d27
1403 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1405 run_test 27j "setstripe with bad stripe offset (should return error)"
1407 test_27k() { # bug 2844
1408 test_mkdir -p $DIR/d27
1410 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1411 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1412 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1413 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1414 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1415 dd if=/dev/zero of=$FILE bs=4k count=1
1416 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1417 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1419 run_test 27k "limit i_blksize for broken user apps ============="
1422 test_mkdir -p $DIR/d27
1423 mcreate $DIR/f27l || error "creating file"
1424 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1425 error "setstripe should have failed" || true
1427 run_test 27l "check setstripe permissions (should return error)"
1430 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1433 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1435 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1436 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1439 trap simple_cleanup_common EXIT
1440 test_mkdir -p $DIR/$tdir
1441 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1442 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1443 error "dd should fill OST0"
1445 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1447 [ $i -gt 256 ] && break
1450 touch $DIR/$tdir/f27m_$i
1451 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1452 error "OST0 was full but new created file still use it"
1454 touch $DIR/$tdir/f27m_$i
1455 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1456 error "OST0 was full but new created file still use it"
1457 simple_cleanup_common
1459 run_test 27m "create file while OST0 was full =================="
1462 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1466 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1467 # if the OST isn't full anymore.
1469 local OSTIDX=${1:-""}
1471 local list=$(comma_list $(osts_nodes))
1472 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1474 do_nodes $list lctl set_param fail_loc=0
1475 sync # initiate all OST_DESTROYs from MDS to OST
1479 exhaust_precreations() {
1482 local FAILIDX=${3:-$OSTIDX}
1483 local ofacet=ost$((OSTIDX + 1))
1485 test_mkdir -p -c1 $DIR/$tdir
1486 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1487 local mfacet=mds$((mdtidx + 1))
1488 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1490 local OST=$(ostname_from_index $OSTIDX)
1493 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1494 local last_id=$(do_facet $mfacet lctl get_param -n \
1495 osc.$mdtosc_proc1.prealloc_last_id)
1496 local next_id=$(do_facet $mfacet lctl get_param -n \
1497 osc.$mdtosc_proc1.prealloc_next_id)
1499 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1500 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1502 test_mkdir -p $DIR/$tdir/${OST}
1503 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1504 #define OBD_FAIL_OST_ENOSPC 0x215
1505 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1506 echo "Creating to objid $last_id on ost $OST..."
1507 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1508 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1509 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1513 exhaust_all_precreations() {
1515 for (( i=0; i < OSTCOUNT; i++ )) ; do
1516 exhaust_precreations $i $1 -1
1521 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1523 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1524 remote_ost_nodsh && skip "remote OST with nodsh" && return
1527 rm -f $DIR/$tdir/$tfile
1528 exhaust_precreations 0 0x80000215
1529 $SETSTRIPE -c -1 $DIR/$tdir
1530 touch $DIR/$tdir/$tfile || error
1531 $GETSTRIPE $DIR/$tdir/$tfile
1534 run_test 27n "create file with some full OSTs =================="
1537 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1539 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1540 remote_ost_nodsh && skip "remote OST with nodsh" && return
1543 rm -f $DIR/$tdir/$tfile
1544 exhaust_all_precreations 0x215
1546 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1551 run_test 27o "create file with all full OSTs (should error) ===="
1554 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 remote_ost_nodsh && skip "remote OST with nodsh" && return
1560 rm -f $DIR/$tdir/$tfile
1561 test_mkdir -p $DIR/$tdir
1563 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1564 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1565 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1567 exhaust_precreations 0 0x80000215
1568 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1569 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1570 $GETSTRIPE $DIR/$tdir/$tfile
1574 run_test 27p "append to a truncated file with some full OSTs ==="
1577 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1579 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1580 remote_ost_nodsh && skip "remote OST with nodsh" && return
1583 rm -f $DIR/$tdir/$tfile
1585 test_mkdir -p $DIR/$tdir
1586 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1587 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1588 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1590 exhaust_all_precreations 0x215
1592 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1593 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1597 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1600 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1602 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1603 remote_ost_nodsh && skip "remote OST with nodsh" && return
1606 rm -f $DIR/$tdir/$tfile
1607 exhaust_precreations 0 0x80000215
1609 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1613 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1615 test_27s() { # bug 10725
1616 test_mkdir -p $DIR/$tdir
1617 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1618 local stripe_count=0
1619 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1620 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1621 error "stripe width >= 2^32 succeeded" || true
1624 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1626 test_27t() { # bug 10864
1631 $WLFS getstripe $tfile
1634 run_test 27t "check that utils parse path correctly"
1636 test_27u() { # bug 4900
1637 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1638 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1640 local list=$(comma_list $(mdts_nodes))
1642 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1643 do_nodes $list $LCTL set_param fail_loc=0x139
1644 test_mkdir -p $DIR/$tdir
1646 createmany -o $DIR/$tdir/t- 1000
1647 do_nodes $list $LCTL set_param fail_loc=0
1649 TLOG=$DIR/$tfile.getstripe
1650 $GETSTRIPE $DIR/$tdir > $TLOG
1651 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1652 unlinkmany $DIR/$tdir/t- 1000
1653 [[ $OBJS -gt 0 ]] &&
1654 error "$OBJS objects created on OST-0. See $TLOG" || pass
1656 run_test 27u "skip object creation on OSC w/o objects =========="
1658 test_27v() { # bug 4900
1659 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1661 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1662 remote_ost_nodsh && skip "remote OST with nodsh" && return
1664 exhaust_all_precreations 0x215
1667 test_mkdir -p $DIR/$tdir
1668 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1670 touch $DIR/$tdir/$tfile
1671 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1673 for (( i=1; i < OSTCOUNT; i++ )); do
1674 do_facet ost$i lctl set_param fail_loc=0x705
1676 local START=`date +%s`
1677 createmany -o $DIR/$tdir/$tfile 32
1679 local FINISH=`date +%s`
1680 local TIMEOUT=`lctl get_param -n timeout`
1681 local PROCESS=$((FINISH - START))
1682 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1683 error "$FINISH - $START >= $TIMEOUT / 2"
1684 sleep $((TIMEOUT / 2 - PROCESS))
1687 run_test 27v "skip object creation on slow OST ================="
1689 test_27w() { # bug 10997
1690 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1691 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1692 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1693 error "stripe size $size != 65536" || true
1694 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1695 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1697 run_test 27w "check $SETSTRIPE -S option"
1700 [[ $OSTCOUNT -lt 2 ]] &&
1701 skip_env "skipping multiple stripe count/offset test" && return
1703 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1704 for i in $(seq 1 $OSTCOUNT); do
1706 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1707 error "setstripe -c $i -i $offset failed"
1708 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1709 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1710 [ $count -ne $i ] && error "stripe count $count != $i" || true
1711 [ $index -ne $offset ] &&
1712 error "stripe offset $index != $offset" || true
1715 run_test 27wa "check $SETSTRIPE -c -i options"
1718 remote_ost_nodsh && skip "remote OST with nodsh" && return
1719 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1721 OFFSET=$(($OSTCOUNT - 1))
1723 local OST=$(ostname_from_index $OSTIDX)
1725 test_mkdir -p $DIR/$tdir
1726 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1727 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1729 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1730 for i in `seq 0 $OFFSET`; do
1731 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1732 error "OST0 was degraded but new created file still use it"
1734 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1736 run_test 27x "create files while OST0 is degraded"
1739 [[ $OSTCOUNT -lt 2 ]] &&
1740 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1741 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1742 remote_ost_nodsh && skip "remote OST with nodsh" && return
1743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1745 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1746 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1747 osc.$mdtosc.prealloc_last_id)
1748 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1749 osc.$mdtosc.prealloc_next_id)
1750 local fcount=$((last_id - next_id))
1751 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1752 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1754 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1755 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1756 local OST_DEACTIVE_IDX=-1
1761 for OSC in $MDS_OSCS; do
1762 OST=$(osc_to_ost $OSC)
1763 OSTIDX=$(index_from_ostuuid $OST)
1764 if [ $OST_DEACTIVE_IDX == -1 ]; then
1765 OST_DEACTIVE_IDX=$OSTIDX
1767 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1768 echo $OSC "is Deactivated:"
1769 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1773 OSTIDX=$(index_from_ostuuid $OST)
1774 test_mkdir -p $DIR/$tdir
1775 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1777 for OSC in $MDS_OSCS; do
1778 OST=$(osc_to_ost $OSC)
1779 OSTIDX=$(index_from_ostuuid $OST)
1780 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1781 echo $OST "is degraded:"
1782 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1783 obdfilter.$OST.degraded=1
1788 createmany -o $DIR/$tdir/$tfile $fcount
1790 for OSC in $MDS_OSCS; do
1791 OST=$(osc_to_ost $OSC)
1792 OSTIDX=$(index_from_ostuuid $OST)
1793 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1794 echo $OST "is recovered from degraded:"
1795 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1796 obdfilter.$OST.degraded=0
1798 do_facet $SINGLEMDS lctl --device %$OSC activate
1802 # all osp devices get activated, hence -1 stripe count restored
1805 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1806 # devices get activated.
1808 $SETSTRIPE -c -1 $DIR/$tfile
1809 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1811 [ $stripecnt -ne $OSTCOUNT ] &&
1812 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1815 run_test 27y "create files while OST0 is degraded and the rest inactive"
1821 lmm_count=$($GETSTRIPE -c $1)
1822 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1823 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1825 local old_ifs="$IFS"
1827 fid=($($LFS path2fid $1))
1830 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1831 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1833 # compare lmm_seq and lu_fid->f_seq
1834 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1835 # compare lmm_object_id and lu_fid->oid
1836 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1838 # check the trusted.fid attribute of the OST objects of the file
1839 local have_obdidx=false
1841 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1842 # skip lines up to and including "obdidx"
1843 [ -z "$obdidx" ] && break
1844 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1845 $have_obdidx || continue
1847 local ost=$((obdidx + 1))
1848 local dev=$(ostdevname $ost)
1851 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1853 seq=$(echo $seq | sed -e "s/^0x//g")
1854 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1855 oid_hex=$(echo $oid)
1857 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1859 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1863 # Don't unmount/remount the OSTs if we don't need to do that.
1864 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1865 # update too, until that use mount/ll_decode_filter_fid/mount.
1866 # Re-enable when debugfs will understand new filter_fid.
1868 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1869 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1870 $dev 2>/dev/null" | grep "parent=")
1873 mount_fstype ost$ost
1874 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1875 $(facet_mntpt ost$ost)/$obj_file)
1876 unmount_fstype ost$ost
1877 start ost$ost $dev $OST_MOUNT_OPTS
1881 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1883 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1885 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1886 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1887 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1888 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1889 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1891 if echo $ff_parent | grep -q 'stripe='; then
1892 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1895 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1896 # into f_ver in this case. See the comment on
1899 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1903 # compare lmm_seq and filter_fid->ff_parent.f_seq
1904 [ $ff_pseq = $lmm_seq ] ||
1905 error "FF parent SEQ $ff_pseq != $lmm_seq"
1906 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1907 [ $ff_poid = $lmm_oid ] ||
1908 error "FF parent OID $ff_poid != $lmm_oid"
1909 (($ff_pstripe == $stripe_nr)) ||
1910 error "FF stripe $ff_pstripe != $stripe_nr"
1912 stripe_nr=$((stripe_nr + 1))
1917 remote_ost_nodsh && skip "remote OST with nodsh" && return
1918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1919 test_mkdir -p $DIR/$tdir
1921 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1922 { error "setstripe -c -1 failed"; return 1; }
1923 # We need to send a write to every object to get parent FID info set.
1924 # This _should_ also work for setattr, but does not currently.
1925 # touch $DIR/$tdir/$tfile-1 ||
1926 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1927 { error "dd $tfile-1 failed"; return 2; }
1928 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1929 { error "setstripe -c -1 failed"; return 3; }
1930 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1931 { error "dd $tfile-2 failed"; return 4; }
1933 # make sure write RPCs have been sent to OSTs
1936 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1937 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1939 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1941 test_27A() { # b=19102
1942 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1943 local restore_size=$($GETSTRIPE -S $MOUNT)
1944 local restore_count=$($GETSTRIPE -c $MOUNT)
1945 local restore_offset=$($GETSTRIPE -i $MOUNT)
1946 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1947 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1948 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1949 local default_size=$($GETSTRIPE -S $MOUNT)
1950 local default_offset=$($GETSTRIPE -i $MOUNT)
1951 local dsize=$((1024 * 1024))
1952 [ $default_size -eq $dsize ] ||
1953 error "stripe size $default_size != $dsize"
1954 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1955 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1957 run_test 27A "check filesystem-wide default LOV EA values"
1959 test_27B() { # LU-2523
1960 test_mkdir -p $DIR/$tdir
1961 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1963 # open f1 with O_LOV_DELAY_CREATE
1965 # call setstripe ioctl on open file descriptor for f1
1967 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1971 # open f1 with O_LOV_DELAY_CREATE
1973 # call setstripe ioctl on open file descriptor for f1
1975 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1977 # Allow multiop to fail in imitation of NFS's busted semantics.
1980 run_test 27B "call setstripe on open unlinked file/rename victim"
1982 test_27C() { #LU-2871
1983 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1991 test_mkdir -p $DIR/$tdir
1993 for i in $(seq 0 $((OSTCOUNT - 1))); do
1994 # set stripe across all OSTs starting from OST$i
1995 $SETSTRIPE -i $i -c -1 $tfile$i
1996 # get striping information
1997 ost_idx=($($GETSTRIPE $tfile$i |
1998 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2002 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2003 error "${#ost_idx[@]} != $OSTCOUNT"
2005 for index in $(seq 0 $((OSTCOUNT - 1))); do
2007 for j in $(echo ${ost_idx[@]}); do
2008 if [ $index -eq $j ]; then
2014 error "Can not find $index in ${ost_idx[@]}"
2018 run_test 27C "check full striping across all OSTs"
2021 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2022 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2023 local POOL=${POOL:-testpool}
2025 local last_ost=$(($OSTCOUNT - 1))
2027 local ost_list=$(seq $first_ost $ost_step $last_ost)
2028 local ost_range="$first_ost $last_ost $ost_step"
2030 test_mkdir -p $DIR/$tdir
2031 pool_add $POOL || error "pool_add failed"
2032 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2033 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2034 error "llapi_layout_test failed"
2035 cleanup_pools || error "cleanup_pools failed"
2037 run_test 27D "validate llapi_layout API"
2039 # Verify that default_easize is increased from its initial value after
2040 # accessing a widely striped file.
2042 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2044 # 72 bytes is the minimum space required to store striping
2045 # information for a file striped across one OST:
2046 # (sizeof(struct lov_user_md_v3) +
2047 # sizeof(struct lov_user_ost_data_v1))
2049 $LCTL set_param -n llite.*.default_easize $min_easize ||
2050 error "lctl set_param failed"
2051 local easize=$($LCTL get_param -n llite.*.default_easize)
2053 [ $easize -eq $min_easize ] ||
2054 error "failed to set default_easize"
2056 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2057 error "setstripe failed"
2061 easize=$($LCTL get_param -n llite.*.default_easize)
2063 [ $easize -gt $min_easize ] ||
2064 error "default_easize not updated"
2066 run_test 27E "check that default extended attribute size properly increases"
2068 # createtest also checks that device nodes are created and
2069 # then visible correctly (#2091)
2070 test_28() { # bug 2091
2072 $CREATETEST $DIR/d28/ct || error
2074 run_test 28 "create/mknod/mkdir with bad file types ============"
2077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2078 cancel_lru_locks mdc
2084 declare -i LOCKCOUNTORIG=0
2085 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2086 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2088 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2090 declare -i LOCKUNUSEDCOUNTORIG=0
2091 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2092 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2099 declare -i LOCKCOUNTCURRENT=0
2100 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2101 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2104 declare -i LOCKUNUSEDCOUNTCURRENT=0
2105 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2106 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2109 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2110 $LCTL set_param -n ldlm.dump_namespaces ""
2111 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2112 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2113 log "dumped log to $TMP/test_29.dk (bug 5793)"
2116 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2117 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2118 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2119 log "dumped log to $TMP/test_29.dk (bug 5793)"
2123 run_test 29 "IT_GETATTR regression ============================"
2125 test_30a() { # was test_30
2126 cp $(which ls) $DIR || cp /bin/ls $DIR
2130 run_test 30a "execute binary from Lustre (execve) =============="
2133 cp `which ls` $DIR || cp /bin/ls $DIR
2135 $RUNAS $DIR/ls / || error
2138 run_test 30b "execute binary from Lustre as non-root ==========="
2140 test_30c() { # b=22376
2141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2142 cp `which ls` $DIR || cp /bin/ls $DIR
2144 cancel_lru_locks mdc
2145 cancel_lru_locks osc
2146 $RUNAS $DIR/ls / || error
2149 run_test 30c "execute binary from Lustre without read perms ===="
2152 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2153 $CHECKSTAT -a $DIR/f31 || error
2155 run_test 31a "open-unlink file =================================="
2158 touch $DIR/f31 || error
2159 ln $DIR/f31 $DIR/f31b || error
2160 $MULTIOP $DIR/f31b Ouc || error
2161 $CHECKSTAT -t file $DIR/f31 || error
2163 run_test 31b "unlink file with multiple links while open ======="
2166 touch $DIR/f31 || error
2167 ln $DIR/f31 $DIR/f31c || error
2168 multiop_bg_pause $DIR/f31 O_uc || return 1
2170 $MULTIOP $DIR/f31c Ouc
2171 kill -USR1 $MULTIPID
2174 run_test 31c "open-unlink file with multiple links ============="
2177 opendirunlink $DIR/d31d $DIR/d31d || error
2178 $CHECKSTAT -a $DIR/d31d || error
2180 run_test 31d "remove of open directory ========================="
2182 test_31e() { # bug 2904
2183 openfilleddirunlink $DIR/d31e || error
2185 run_test 31e "remove of open non-empty directory ==============="
2187 test_31f() { # bug 4554
2188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2190 test_mkdir $DIR/d31f
2191 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2192 cp /etc/hosts $DIR/d31f
2194 $GETSTRIPE $DIR/d31f/hosts
2195 multiop_bg_pause $DIR/d31f D_c || return 1
2198 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2199 test_mkdir $DIR/d31f
2200 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2201 cp /etc/hosts $DIR/d31f
2203 $GETSTRIPE $DIR/d31f/hosts
2204 multiop_bg_pause $DIR/d31f D_c || return 1
2207 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2208 wait $MULTIPID || error "first opendir $MULTIPID failed"
2212 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2213 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2216 run_test 31f "remove of open directory with open-unlink file ==="
2219 echo "-- cross directory link --"
2220 test_mkdir -c1 $DIR/${tdir}ga
2221 test_mkdir -c1 $DIR/${tdir}gb
2222 touch $DIR/${tdir}ga/f
2223 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2224 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2225 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2226 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2227 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2229 run_test 31g "cross directory link==============="
2232 echo "-- cross directory link --"
2233 test_mkdir -c1 $DIR/${tdir}
2234 test_mkdir -c1 $DIR/${tdir}/dir
2235 touch $DIR/${tdir}/f
2236 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2237 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2238 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2239 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2240 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2242 run_test 31h "cross directory link under child==============="
2245 echo "-- cross directory link --"
2246 test_mkdir -c1 $DIR/$tdir
2247 test_mkdir -c1 $DIR/$tdir/dir
2248 touch $DIR/$tdir/dir/f
2249 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2250 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2251 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2252 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2253 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2255 run_test 31i "cross directory link under parent==============="
2258 test_mkdir -c1 -p $DIR/$tdir
2259 test_mkdir -c1 -p $DIR/$tdir/dir1
2260 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2261 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2262 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2263 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2266 run_test 31j "link for directory==============="
2269 test_mkdir -c1 -p $DIR/$tdir
2271 touch $DIR/$tdir/exist
2272 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2273 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2274 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2275 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2276 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2277 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2278 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2281 run_test 31k "link to file: the same, non-existing, dir==============="
2287 touch $DIR/d31m2/exist
2288 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2289 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2290 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2291 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2292 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2293 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2296 run_test 31m "link to file: the same, non-existing, dir==============="
2299 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2300 nlink=$(stat --format=%h $DIR/$tfile)
2301 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2303 local cmd="exec $fd<$DIR/$tfile"
2306 trap "eval $cmd" EXIT
2307 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2308 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2309 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2310 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2311 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2314 run_test 31n "check link count of unlinked file"
2317 local TEMPNAME=$(mktemp $1_XXXXXX)
2318 mlink $TEMPNAME $1 2> /dev/null &&
2319 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2323 test_31o() { # LU-2901
2324 test_mkdir -p $DIR/$tdir
2325 for LOOP in $(seq 100); do
2326 rm -f $DIR/$tdir/$tfile*
2327 for THREAD in $(seq 8); do
2328 link_one $DIR/$tdir/$tfile.$LOOP &
2331 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2332 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2333 error "$LINKS duplicate links to $tfile.$LOOP" &&
2337 run_test 31o "duplicate hard links with same filename"
2340 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2342 test_mkdir $DIR/$tdir
2343 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2344 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2346 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2347 error "open unlink test1 failed"
2348 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2349 error "open unlink test2 failed"
2351 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2352 error "test1 still exists"
2353 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2354 error "test2 still exists"
2356 run_test 31p "remove of open striped directory"
2358 cleanup_test32_mount() {
2360 $UMOUNT $DIR/$tdir/ext2-mountpoint
2364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2365 echo "== more mountpoints and symlinks ================="
2366 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2367 trap cleanup_test32_mount EXIT
2368 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2369 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2370 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2371 cleanup_test32_mount
2373 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2377 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2378 trap cleanup_test32_mount EXIT
2379 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2380 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2381 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2382 cleanup_test32_mount
2384 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2388 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2389 trap cleanup_test32_mount EXIT
2390 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2391 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2392 test_mkdir -p $DIR/$tdir/d2/test_dir
2393 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2394 cleanup_test32_mount
2396 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2400 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2401 trap cleanup_test32_mount EXIT
2402 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2403 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2404 test_mkdir -p $DIR/$tdir/d2/test_dir
2405 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2406 cleanup_test32_mount
2408 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2411 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2412 test_mkdir -p $DIR/d32e/tmp
2413 TMP_DIR=$DIR/d32e/tmp
2414 ln -s $DIR/d32e $TMP_DIR/symlink11
2415 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2416 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2417 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2419 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2422 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2423 test_mkdir -p $DIR/d32f/tmp
2424 TMP_DIR=$DIR/d32f/tmp
2425 ln -s $DIR/d32f $TMP_DIR/symlink11
2426 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2427 ls $DIR/d32f/tmp/symlink11 || error
2428 ls $DIR/d32f/symlink01 || error
2430 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2433 TMP_DIR=$DIR/$tdir/tmp
2434 test_mkdir -p $DIR/$tdir/tmp
2435 test_mkdir $DIR/${tdir}2
2436 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2437 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2438 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2439 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2440 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2441 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2443 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2446 rm -fr $DIR/$tdir $DIR/${tdir}2
2447 TMP_DIR=$DIR/$tdir/tmp
2448 test_mkdir -p $DIR/$tdir/tmp
2449 test_mkdir $DIR/${tdir}2
2450 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2451 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2452 ls $TMP_DIR/symlink12 || error
2453 ls $DIR/$tdir/symlink02 || error
2455 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2458 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2459 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2460 trap cleanup_test32_mount EXIT
2461 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2462 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2463 touch $DIR/$tdir/test_file
2464 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2465 cleanup_test32_mount
2467 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2471 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2472 trap cleanup_test32_mount EXIT
2473 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2474 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2475 touch $DIR/$tdir/test_file
2476 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2477 cleanup_test32_mount
2479 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
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
2487 test_mkdir -p $DIR/$tdir/d2
2488 touch $DIR/$tdir/d2/test_file || error
2489 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2490 cleanup_test32_mount
2492 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2497 trap cleanup_test32_mount EXIT
2498 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2499 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2500 test_mkdir -p $DIR/$tdir/d2
2501 touch $DIR/$tdir/d2/test_file
2502 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2503 cleanup_test32_mount
2505 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2509 test_mkdir -p $DIR/d32m/tmp
2510 TMP_DIR=$DIR/d32m/tmp
2511 ln -s $DIR $TMP_DIR/symlink11
2512 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2513 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2514 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2516 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2520 test_mkdir -p $DIR/d32n/tmp
2521 TMP_DIR=$DIR/d32n/tmp
2522 ln -s $DIR $TMP_DIR/symlink11
2523 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2524 ls -l $DIR/d32n/tmp/symlink11 || error
2525 ls -l $DIR/d32n/symlink01 || error
2527 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2531 test_mkdir -p $DIR/d32o/tmp
2532 TMP_DIR=$DIR/d32o/tmp
2533 ln -s $DIR/$tfile $TMP_DIR/symlink12
2534 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2535 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2536 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2537 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2538 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2540 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2550 test_mkdir -p $DIR/d32p/tmp
2552 TMP_DIR=$DIR/d32p/tmp
2554 ln -s $DIR/$tfile $TMP_DIR/symlink12
2556 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2558 cat $DIR/d32p/tmp/symlink12 || error
2560 cat $DIR/d32p/symlink02 || error
2563 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2565 cleanup_testdir_mount() {
2571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2572 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2573 trap cleanup_testdir_mount EXIT
2574 test_mkdir -p $DIR/$tdir
2575 touch $DIR/$tdir/under_the_mount
2576 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2577 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2578 cleanup_testdir_mount
2580 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2584 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2585 trap cleanup_testdir_mount EXIT
2586 test_mkdir -p $DIR/$tdir
2587 touch $DIR/$tdir/under_the_mount
2588 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2589 ls $DIR/$tdir | grep -q under_the_mount && error || true
2590 cleanup_testdir_mount
2592 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2597 chmod 444 $DIR/$tfile
2598 chown $RUNAS_ID $DIR/$tfile
2600 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2603 run_test 33aa "write file with mode 444 (should return error) ===="
2607 test_mkdir -p $DIR/d33
2608 chown $RUNAS_ID $DIR/d33
2609 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2610 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2611 error "open RDWR" || true
2613 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2617 test_mkdir -p $DIR/d33
2618 chown $RUNAS_ID $DIR/d33
2619 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2621 run_test 33b "test open file with malformed flags (No panic)"
2624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2630 remote_ost_nodsh && skip "remote OST with nodsh" && return
2633 test_mkdir -p $DIR/d33
2634 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2637 for ostnum in $(seq $OSTCOUNT); do
2638 # test-framework's OST numbering is one-based, while Lustre's
2640 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2641 # Parsing llobdstat's output sucks; we could grep the /proc
2642 # path, but that's likely to not be as portable as using the
2643 # llobdstat utility. So we parse lctl output instead.
2644 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2645 obdfilter/$ostname/stats |
2646 awk '/^write_bytes/ {print $7}' )
2647 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2648 if (( ${write_bytes:-0} > 0 ))
2655 $all_zeros || return 0
2658 echo foo > $DIR/d33/bar
2662 # Total up write_bytes after writing. We'd better find non-zeros.
2663 for ostnum in $(seq $OSTCOUNT); do
2664 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2665 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2666 obdfilter/$ostname/stats |
2667 awk '/^write_bytes/ {print $7}' )
2668 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2669 if (( ${write_bytes:-0} > 0 ))
2678 for ostnum in $(seq $OSTCOUNT); do
2679 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2680 echo "Check that write_bytes is present in obdfilter/*/stats:"
2681 do_facet ost$ostnum lctl get_param -n \
2682 obdfilter/$ostname/stats
2684 error "OST not keeping write_bytes stats (b22312)"
2687 run_test 33c "test llobdstat and write_bytes"
2690 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2691 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2693 local remote_dir=$DIR/$tdir/remote_dir
2695 test_mkdir -p $DIR/$tdir
2696 $LFS mkdir -i $MDTIDX $remote_dir ||
2697 error "create remote directory failed"
2699 touch $remote_dir/$tfile
2700 chmod 444 $remote_dir/$tfile
2701 chown $RUNAS_ID $remote_dir/$tfile
2703 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2705 chown $RUNAS_ID $remote_dir
2706 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2707 error "create" || true
2708 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2709 error "open RDWR" || true
2710 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2712 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2715 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2719 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2720 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2721 mkdir $DIR/$tdir/local_dir
2723 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2724 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2725 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2727 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2728 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2730 rmdir $DIR/$tdir/* || error "rmdir failed"
2733 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2734 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2735 mkdir $DIR/$tdir/local_dir
2737 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2738 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2739 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2741 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2742 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2744 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2747 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2748 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2749 mkdir $DIR/$tdir/local_dir
2751 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2752 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2753 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2755 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2756 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2758 run_test 33e "mkdir and striped directory should have same mode"
2762 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2766 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2769 chmod go+rwx $DIR/$tdir
2770 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2771 trap cleanup_33f EXIT
2773 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2774 error "cannot create striped directory"
2776 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2777 error "cannot create files in striped directory"
2779 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2780 error "cannot remove files in striped directory"
2782 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2783 error "cannot remove striped directory"
2787 run_test 33f "nonroot user can create, access, and remove a striped directory"
2789 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2792 $MCREATE $DIR/f34 || error
2793 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2794 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2795 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2796 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2798 run_test 34a "truncate file that has not been opened ==========="
2801 [ ! -f $DIR/f34 ] && test_34a
2802 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2803 $OPENFILE -f O_RDONLY $DIR/f34
2804 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2805 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2807 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2810 [ ! -f $DIR/f34 ] && test_34a
2811 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2812 $OPENFILE -f O_RDWR $DIR/f34
2813 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2814 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2816 run_test 34c "O_RDWR opening file-with-size works =============="
2819 [ ! -f $DIR/f34 ] && test_34a
2820 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2821 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2824 run_test 34d "write to sparse file ============================="
2828 $MCREATE $DIR/f34e || error
2829 $TRUNCATE $DIR/f34e 1000 || error
2830 $CHECKSTAT -s 1000 $DIR/f34e || error
2831 $OPENFILE -f O_RDWR $DIR/f34e
2832 $CHECKSTAT -s 1000 $DIR/f34e || error
2834 run_test 34e "create objects, some with size and some without =="
2836 test_34f() { # bug 6242, 6243
2837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2840 $MCREATE $DIR/f34f || error
2841 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2842 dd if=$DIR/f34f of=$TMP/f34f
2843 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2844 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2845 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2846 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2847 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2849 run_test 34f "read from a file with no objects until EOF ======="
2852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2853 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2854 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2855 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2856 cancel_lru_locks osc
2857 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2858 error "wrong size after lock cancel"
2860 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2861 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2862 error "expanding truncate failed"
2863 cancel_lru_locks osc
2864 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2865 error "wrong expanded size after lock cancel"
2867 run_test 34g "truncate long file ==============================="
2870 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2874 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2875 sync # Flush the cache so that multiop below does not block on cache
2876 # flush when getting the group lock
2877 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2880 # Since just timed wait is not good enough, let's do a sync write
2881 # that way we are sure enough time for a roundtrip + processing
2882 # passed + 2 seconds of extra margin.
2883 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2887 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2888 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2892 local nsz=`stat -c %s $DIR/$tfile`
2893 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2895 run_test 34h "ftruncate file under grouplock should not block"
2898 cp /bin/sh $DIR/f35a
2900 chown $RUNAS_ID $DIR/f35a
2901 $RUNAS $DIR/f35a && error || true
2904 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2908 utime $DIR/f36 || error
2910 run_test 36a "MDS utime check (mknod, utime) ==================="
2914 utime $DIR/f36 || error
2916 run_test 36b "OST utime check (open, utime) ===================="
2921 chown $RUNAS_ID $DIR/d36
2922 $RUNAS utime $DIR/d36/f36 || error
2924 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2927 [ ! -d $DIR/d36 ] && test_36c
2928 echo "" > $DIR/d36/f36
2929 $RUNAS utime $DIR/d36/f36 || error
2931 run_test 36d "non-root OST utime check (open, utime) ==========="
2934 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2935 test_mkdir -p $DIR/$tdir
2936 touch $DIR/$tdir/$tfile
2937 $RUNAS utime $DIR/$tdir/$tfile && \
2938 error "utime worked, expected failure" || true
2940 run_test 36e "utime on non-owned file (should return error) ===="
2944 local LANG_SAVE=$LANG
2945 local LC_LANG_SAVE=$LC_LANG
2946 export LANG=C LC_LANG=C # for date language
2948 DATESTR="Dec 20 2000"
2949 test_mkdir -p $DIR/$tdir
2950 lctl set_param fail_loc=$fl
2952 cp /etc/hosts $DIR/$tdir/$tfile
2953 sync & # write RPC generated with "current" inode timestamp, but delayed
2955 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2956 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2957 cancel_lru_locks osc
2958 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2960 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2961 echo "BEFORE: $LS_BEFORE" && \
2962 echo "AFTER : $LS_AFTER" && \
2963 echo "WANT : $DATESTR" && \
2964 error "$DIR/$tdir/$tfile timestamps changed" || true
2966 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2971 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2972 subr_36fh "0x80000214"
2974 run_test 36f "utime on file racing with OST BRW write =========="
2977 remote_ost_nodsh && skip "remote OST with nodsh" && return
2978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2983 test_mkdir -p $DIR/$tdir
2984 fmd_max_age=$(do_facet ost1 \
2985 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2988 fmd_before=$(do_facet ost1 \
2989 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2990 touch $DIR/$tdir/$tfile
2991 sleep $((fmd_max_age + 12))
2992 fmd_after=$(do_facet ost1 \
2993 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2995 echo "fmd_before: $fmd_before"
2996 echo "fmd_after: $fmd_after"
2997 [[ $fmd_after -gt $fmd_before ]] &&
2998 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2999 error "fmd didn't expire after ping" || true
3001 run_test 36g "filter mod data cache expiry ====================="
3004 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3005 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3006 subr_36fh "0x80000227"
3008 run_test 36h "utime on file racing with OST BRW write =========="
3011 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3013 test_mkdir $DIR/$tdir
3014 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3016 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3017 local new_mtime=$((mtime + 200))
3019 #change Modify time of striped dir
3020 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3021 error "change mtime failed"
3023 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3025 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3027 run_test 36i "change mtime on striped directory"
3029 # test_37 - duplicate with tests 32q 32r
3032 local file=$DIR/$tfile
3034 openfile -f O_DIRECTORY $file
3037 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3038 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3040 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3044 touch $DIR/${tfile}2
3045 # ls -l $DIR/$tfile $DIR/${tfile}2
3046 # ls -lu $DIR/$tfile $DIR/${tfile}2
3047 # ls -lc $DIR/$tfile $DIR/${tfile}2
3049 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3050 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3052 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3054 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3056 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3057 error "O_TRUNC didn't change timestamps"
3060 run_test 39 "mtime changed on create ==========================="
3063 test_mkdir -p -c1 $DIR/$tdir
3064 cp -p /etc/passwd $DIR/$tdir/fopen
3065 cp -p /etc/passwd $DIR/$tdir/flink
3066 cp -p /etc/passwd $DIR/$tdir/funlink
3067 cp -p /etc/passwd $DIR/$tdir/frename
3068 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3071 echo "aaaaaa" >> $DIR/$tdir/fopen
3072 echo "aaaaaa" >> $DIR/$tdir/flink
3073 echo "aaaaaa" >> $DIR/$tdir/funlink
3074 echo "aaaaaa" >> $DIR/$tdir/frename
3076 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3077 local link_new=`stat -c %Y $DIR/$tdir/flink`
3078 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3079 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3081 cat $DIR/$tdir/fopen > /dev/null
3082 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3083 rm -f $DIR/$tdir/funlink2
3084 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3086 for (( i=0; i < 2; i++ )) ; do
3087 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3088 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3089 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3090 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3092 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3093 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3094 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3095 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3097 cancel_lru_locks osc
3098 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3101 run_test 39b "mtime change on open, link, unlink, rename ======"
3103 # this should be set to past
3104 TEST_39_MTIME=`date -d "1 year ago" +%s`
3110 local mtime0=`stat -c %Y $DIR1/$tfile`
3112 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3113 local mtime1=`stat -c %Y $DIR1/$tfile`
3114 [ "$mtime1" = $TEST_39_MTIME ] || \
3115 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3118 echo hello >> $DIR1/$tfile
3120 local mtime2=`stat -c %Y $DIR1/$tfile`
3121 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3122 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3124 mv $DIR1/$tfile $DIR1/$tfile-1
3126 for (( i=0; i < 2; i++ )) ; do
3127 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3128 [ "$mtime2" = "$mtime3" ] || \
3129 error "mtime ($mtime2) changed (to $mtime3) on rename"
3131 cancel_lru_locks osc
3132 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3135 run_test 39c "mtime change on rename ==========================="
3139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3142 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3144 for (( i=0; i < 2; i++ )) ; do
3145 local mtime=`stat -c %Y $DIR1/$tfile`
3146 [ $mtime = $TEST_39_MTIME ] || \
3147 error "mtime($mtime) is not set to $TEST_39_MTIME"
3149 cancel_lru_locks osc
3150 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3153 run_test 39d "create, utime, stat =============================="
3157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3159 local mtime1=`stat -c %Y $DIR1/$tfile`
3161 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3163 for (( i=0; i < 2; i++ )) ; do
3164 local mtime2=`stat -c %Y $DIR1/$tfile`
3165 [ $mtime2 = $TEST_39_MTIME ] || \
3166 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3168 cancel_lru_locks osc
3169 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3172 run_test 39e "create, stat, utime, stat ========================"
3176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3178 mtime1=`stat -c %Y $DIR1/$tfile`
3181 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3183 for (( i=0; i < 2; i++ )) ; do
3184 local mtime2=`stat -c %Y $DIR1/$tfile`
3185 [ $mtime2 = $TEST_39_MTIME ] || \
3186 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3188 cancel_lru_locks osc
3189 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3192 run_test 39f "create, stat, sleep, utime, stat ================="
3196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3197 echo hello >> $DIR1/$tfile
3198 local mtime1=`stat -c %Y $DIR1/$tfile`
3201 chmod o+r $DIR1/$tfile
3203 for (( i=0; i < 2; i++ )) ; do
3204 local mtime2=`stat -c %Y $DIR1/$tfile`
3205 [ "$mtime1" = "$mtime2" ] || \
3206 error "lost mtime: $mtime2, should be $mtime1"
3208 cancel_lru_locks osc
3209 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3212 run_test 39g "write, chmod, stat ==============================="
3216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3221 echo hello >> $DIR1/$tfile
3222 local mtime1=`stat -c %Y $DIR1/$tfile`
3224 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3226 if [ "$d1" != "$d2" ]; then
3227 echo "write and touch not within one second"
3229 for (( i=0; i < 2; i++ )) ; do
3230 local mtime2=`stat -c %Y $DIR1/$tfile`
3231 [ "$mtime2" = $TEST_39_MTIME ] || \
3232 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3234 cancel_lru_locks osc
3235 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3239 run_test 39h "write, utime within one second, stat ============="
3242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3246 echo hello >> $DIR1/$tfile
3247 local mtime1=`stat -c %Y $DIR1/$tfile`
3249 mv $DIR1/$tfile $DIR1/$tfile-1
3251 for (( i=0; i < 2; i++ )) ; do
3252 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3254 [ "$mtime1" = "$mtime2" ] || \
3255 error "lost mtime: $mtime2, should be $mtime1"
3257 cancel_lru_locks osc
3258 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3261 run_test 39i "write, rename, stat =============================="
3264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3265 start_full_debug_logging
3269 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3270 lctl set_param fail_loc=0x80000412
3271 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3272 error "multiop failed"
3274 local mtime1=`stat -c %Y $DIR1/$tfile`
3276 mv $DIR1/$tfile $DIR1/$tfile-1
3278 kill -USR1 $multipid
3279 wait $multipid || error "multiop close failed"
3281 for (( i=0; i < 2; i++ )) ; do
3282 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3283 [ "$mtime1" = "$mtime2" ] ||
3284 error "mtime is lost on close: $mtime2, " \
3287 cancel_lru_locks osc
3288 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3290 lctl set_param fail_loc=0
3291 stop_full_debug_logging
3293 run_test 39j "write, rename, close, stat ======================="
3296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3300 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3302 local mtime1=`stat -c %Y $DIR1/$tfile`
3304 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3306 kill -USR1 $multipid
3307 wait $multipid || error "multiop close failed"
3309 for (( i=0; i < 2; i++ )) ; do
3310 local mtime2=`stat -c %Y $DIR1/$tfile`
3312 [ "$mtime2" = $TEST_39_MTIME ] || \
3313 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3315 cancel_lru_locks osc
3316 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3319 run_test 39k "write, utime, close, stat ========================"
3321 # this should be set to future
3322 TEST_39_ATIME=`date -d "1 year" +%s`
3325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3326 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3327 local atime_diff=$(do_facet $SINGLEMDS \
3328 lctl get_param -n mdd.*MDT0000*.atime_diff)
3332 # test setting directory atime to future
3333 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3334 local atime=$(stat -c %X $DIR/$tdir)
3335 [ "$atime" = $TEST_39_ATIME ] || \
3336 error "atime is not set to future: $atime, $TEST_39_ATIME"
3338 # test setting directory atime from future to now
3339 local d1=$(date +%s)
3341 local d2=$(date +%s)
3343 cancel_lru_locks mdc
3344 atime=$(stat -c %X $DIR/$tdir)
3345 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3346 error "atime is not updated from future: $atime, $d1<atime<$d2"
3348 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3351 # test setting directory atime when now > dir atime + atime_diff
3355 cancel_lru_locks mdc
3356 atime=$(stat -c %X $DIR/$tdir)
3357 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3358 error "atime is not updated : $atime, should be $d2"
3360 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3363 # test not setting directory atime when now < dir atime + atime_diff
3365 cancel_lru_locks mdc
3366 atime=$(stat -c %X $DIR/$tdir)
3367 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3368 error "atime is updated to $atime, should remain $d1<atime<$d2"
3370 do_facet $SINGLEMDS \
3371 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3373 run_test 39l "directory atime update ==========================="
3376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3379 local far_past_mtime=$(date -d "May 29 1953" +%s)
3380 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3382 touch -m -d @$far_past_mtime $DIR1/$tfile
3383 touch -a -d @$far_past_atime $DIR1/$tfile
3385 for (( i=0; i < 2; i++ )) ; do
3386 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3387 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3388 error "atime or mtime set incorrectly"
3390 cancel_lru_locks osc
3391 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3394 run_test 39m "test atime and mtime before 1970"
3396 test_39n() { # LU-3832
3397 local atime_diff=$(do_facet $SINGLEMDS \
3398 lctl get_param -n mdd.*MDT0000*.atime_diff)
3403 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3406 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3407 atime0=$(stat -c %X $DIR/$tfile)
3410 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3411 atime1=$(stat -c %X $DIR/$tfile)
3414 cancel_lru_locks mdc
3415 cancel_lru_locks osc
3416 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3417 atime2=$(stat -c %X $DIR/$tfile)
3419 do_facet $SINGLEMDS \
3420 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3422 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3423 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3425 run_test 39n "check that O_NOATIME is honored"
3428 TESTDIR=$DIR/$tdir/$tfile
3429 [ -e $TESTDIR ] && rm -rf $TESTDIR
3436 links2=$(stat -c %h .)
3437 [ $(($links1 + 2)) != $links2 ] &&
3438 error "wrong links count $(($links1 + 2)) != $links2"
3440 links3=$(stat -c %h .)
3441 [ $(($links1 + 1)) != $links3 ] &&
3442 error "wrong links count $links1 != $links3"
3445 run_test 39o "directory cached attributes updated after create ========"
3448 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3450 TESTDIR=$DIR/$tdir/$tfile
3451 [ -e $TESTDIR ] && rm -rf $TESTDIR
3452 test_mkdir -p $TESTDIR
3456 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3457 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3459 links2=$(stat -c %h .)
3460 [ $(($links1 + 2)) != $links2 ] &&
3461 error "wrong links count $(($links1 + 2)) != $links2"
3463 links3=$(stat -c %h .)
3464 [ $(($links1 + 1)) != $links3 ] &&
3465 error "wrong links count $links1 != $links3"
3468 run_test 39p "remote directory cached attributes updated after create ========"
3472 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3473 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3474 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3475 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3476 error "$tfile is not 4096 bytes in size"
3478 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3482 small_write $DIR/f41 18
3484 run_test 41 "test small file write + fstat ====================="
3486 count_ost_writes() {
3487 lctl get_param -n osc.*.stats |
3488 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3489 END { printf("%0.0f", writes) }'
3496 BG_DIRTY_RATIO_SAVE=10
3497 MAX_BG_DIRTY_RATIO=25
3501 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3502 # dirty_ratio, dirty_background_ratio
3503 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3504 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3505 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3506 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3508 # if file not here, we are a 2.4 kernel
3509 kill -CONT `pidof kupdated`
3514 # setup the trap first, so someone cannot exit the test at the
3515 # exact wrong time and mess up a machine
3516 trap start_writeback EXIT
3517 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3518 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3519 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3520 sysctl -w vm.dirty_writeback_centisecs=0
3521 sysctl -w vm.dirty_writeback_centisecs=0
3522 # save and increase /proc/sys/vm/dirty_ratio
3523 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3524 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3525 # save and increase /proc/sys/vm/dirty_background_ratio
3526 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3527 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3529 # if file not here, we are a 2.4 kernel
3530 kill -STOP `pidof kupdated`
3534 # ensure that all stripes have some grant before we test client-side cache
3536 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3537 dd if=/dev/zero of=$i bs=4k count=1
3542 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3543 # file truncation, and file removal.
3545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3547 cancel_lru_locks osc
3549 sync; sleep 1; sync # just to be safe
3550 BEFOREWRITES=`count_ost_writes`
3551 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3552 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3553 AFTERWRITES=`count_ost_writes`
3554 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3555 error "$BEFOREWRITES < $AFTERWRITES"
3558 run_test 42a "ensure that we don't flush on close =============="
3561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3563 cancel_lru_locks osc
3566 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3567 BEFOREWRITES=$(count_ost_writes)
3568 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3569 AFTERWRITES=$(count_ost_writes)
3570 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3571 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3573 BEFOREWRITES=$(count_ost_writes)
3574 sync || error "sync: $?"
3575 AFTERWRITES=$(count_ost_writes)
3576 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3577 error "$BEFOREWRITES < $AFTERWRITES on sync"
3579 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3583 run_test 42b "test destroy of file with cached dirty data ======"
3585 # if these tests just want to test the effect of truncation,
3586 # they have to be very careful. consider:
3587 # - the first open gets a {0,EOF}PR lock
3588 # - the first write conflicts and gets a {0, count-1}PW
3589 # - the rest of the writes are under {count,EOF}PW
3590 # - the open for truncate tries to match a {0,EOF}PR
3591 # for the filesize and cancels the PWs.
3592 # any number of fixes (don't get {0,EOF} on open, match
3593 # composite locks, do smarter file size management) fix
3594 # this, but for now we want these tests to verify that
3595 # the cancellation with truncate intent works, so we
3596 # start the file with a full-file pw lock to match against
3597 # until the truncate.
3602 cancel_lru_locks osc
3604 # prime the file with 0,EOF PW to match
3608 # now the real test..
3609 dd if=/dev/zero of=$file bs=1024 count=100
3610 BEFOREWRITES=`count_ost_writes`
3611 $TRUNCATE $file $offset
3612 cancel_lru_locks osc
3613 AFTERWRITES=`count_ost_writes`
3618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3620 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3621 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3624 run_test 42c "test partial truncate of file with cached dirty data"
3627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3629 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3630 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3633 run_test 42d "test complete truncate of file with cached dirty data"
3635 test_42e() { # bug22074
3636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3637 local TDIR=$DIR/${tdir}e
3638 local pagesz=$(page_size)
3639 local pages=16 # hardcoded 16 pages, don't change it.
3640 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3641 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3645 test_mkdir -p $DIR/${tdir}e
3646 $SETSTRIPE -c 1 $TDIR
3647 createmany -o $TDIR/f $files
3649 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3651 # we assume that with $OSTCOUNT files, at least one of them will
3652 # be allocated on OST0.
3653 warmup_files=$((OSTCOUNT * max_dirty_mb))
3654 createmany -o $TDIR/w $warmup_files
3656 # write a large amount of data into one file and sync, to get good
3657 # avail_grant number from OST.
3658 for ((i=0; i<$warmup_files; i++)); do
3659 idx=$($GETSTRIPE -i $TDIR/w$i)
3660 [ $idx -ne 0 ] && continue
3661 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3664 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3666 $LCTL get_param $proc_osc0/cur_dirty_bytes
3667 $LCTL get_param $proc_osc0/cur_grant_bytes
3669 # create as much dirty pages as we can while not to trigger the actual
3670 # RPCs directly. but depends on the env, VFS may trigger flush during this
3671 # period, hopefully we are good.
3672 for ((i=0; i<$warmup_files; i++)); do
3673 idx=$($GETSTRIPE -i $TDIR/w$i)
3674 [ $idx -ne 0 ] && continue
3675 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3677 $LCTL get_param $proc_osc0/cur_dirty_bytes
3678 $LCTL get_param $proc_osc0/cur_grant_bytes
3680 # perform the real test
3681 $LCTL set_param $proc_osc0/rpc_stats 0
3682 for ((;i<$files; i++)); do
3683 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3684 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3687 $LCTL get_param $proc_osc0/rpc_stats
3690 local have_ppr=false
3691 $LCTL get_param $proc_osc0/rpc_stats |
3692 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3693 # skip lines until we are at the RPC histogram data
3694 [ "$PPR" == "pages" ] && have_ppr=true && continue
3695 $have_ppr || continue
3697 # we only want the percent stat for < 16 pages
3698 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3700 percent=$((percent + WPCT))
3701 if [[ $percent -gt 15 ]]; then
3702 error "less than 16-pages write RPCs" \
3709 run_test 42e "verify sub-RPC writes are not done synchronously"
3712 test_mkdir -p $DIR/$tdir
3713 cp -p /bin/ls $DIR/$tdir/$tfile
3714 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3716 # give multiop a chance to open
3719 $DIR/$tdir/$tfile && error || true
3722 run_test 43 "execution of file opened for write should return -ETXTBSY"
3725 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3726 test_mkdir -p $DIR/$tdir
3727 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3728 cp -p multiop $DIR/$tdir/multiop
3729 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3732 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3733 kill -USR1 $MULTIOP_PID || return 2
3734 wait $MULTIOP_PID || return 3
3735 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3737 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3741 test_mkdir -p $DIR/$tdir
3742 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3743 cp -p multiop $DIR/$tdir/multiop
3744 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3747 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3748 kill -USR1 $MULTIOP_PID || return 2
3749 wait $MULTIOP_PID || return 3
3750 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3752 run_test 43b "truncate of file being executed should return -ETXTBSY"
3755 local testdir="$DIR/$tdir"
3756 test_mkdir -p $DIR/$tdir
3758 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3759 ( cd $testdir && md5sum -c)
3761 run_test 43c "md5sum of copy into lustre========================"
3764 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3765 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3766 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3768 run_test 44 "zero length read from a sparse stripe ============="
3771 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3773 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3774 [[ $nstripe -gt $OSTCOUNT ]] &&
3775 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3777 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3779 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3780 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3784 OFFSETS="0 $((stride/2)) $((stride-1))"
3785 for offset in $OFFSETS; do
3786 for i in $(seq 0 $((nstripe-1))); do
3787 local GLOBALOFFSETS=""
3789 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3790 local myfn=$DIR/d44a-$size
3791 echo "--------writing $myfn at $size"
3792 ll_sparseness_write $myfn $size ||
3793 error "ll_sparseness_write"
3794 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3795 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3796 error "ll_sparseness_verify $GLOBALOFFSETS"
3798 for j in $(seq 0 $((nstripe-1))); do
3800 size=$((((j + $nstripe )*$stride + $offset)))
3801 ll_sparseness_write $myfn $size ||
3802 error "ll_sparseness_write"
3803 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3805 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3806 error "ll_sparseness_verify $GLOBALOFFSETS"
3811 run_test 44a "test sparse pwrite ==============================="
3815 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3821 before=`dirty_osc_total`
3822 echo executing "\"$*\""
3824 after=`dirty_osc_total`
3825 echo before $before, after $after
3828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3830 # Obtain grants from OST if it supports it
3831 echo blah > ${f}_grant
3834 do_dirty_record "echo blah > $f"
3835 [[ $before -eq $after ]] && error "write wasn't cached"
3836 do_dirty_record "> $f"
3837 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3838 do_dirty_record "echo blah > $f"
3839 [[ $before -eq $after ]] && error "write wasn't cached"
3840 do_dirty_record "sync"
3841 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3842 do_dirty_record "echo blah > $f"
3843 [[ $before -eq $after ]] && error "write wasn't cached"
3844 do_dirty_record "cancel_lru_locks osc"
3845 [[ $before -gt $after ]] ||
3846 error "lock cancellation didn't lower dirty count"
3849 run_test 45 "osc io page accounting ============================"
3851 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3852 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3853 # objects offset and an assert hit when an rpc was built with 1023's mapped
3854 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3856 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3860 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3862 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3863 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3867 run_test 46 "dirtying a previously written page ================"
3869 # test_47 is removed "Device nodes check" is moved to test_28
3871 test_48a() { # bug 2399
3872 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3873 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3874 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3876 test_mkdir $DIR/$tdir
3878 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3879 test_mkdir $DIR/$tdir || error "recreate directory failed"
3880 touch foo || error "'touch foo' failed after recreating cwd"
3881 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3882 touch .foo || error "'touch .foo' failed after recreating cwd"
3883 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3884 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3885 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3886 cd . || error "'cd .' failed after recreating cwd"
3887 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3888 rmdir . && error "'rmdir .' worked after recreating cwd"
3889 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3890 cd .. || error "'cd ..' failed after recreating cwd"
3892 run_test 48a "Access renamed working dir (should return errors)="
3894 test_48b() { # bug 2399
3896 test_mkdir $DIR/$tdir
3898 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3899 touch foo && error "'touch foo' worked after removing cwd"
3900 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3901 touch .foo && error "'touch .foo' worked after removing cwd"
3902 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3903 ls . > /dev/null && error "'ls .' worked after removing cwd"
3904 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3905 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3906 test_mkdir . && error "'mkdir .' worked after removing cwd"
3907 rmdir . && error "'rmdir .' worked after removing cwd"
3908 ln -s . foo && error "'ln -s .' worked after removing cwd"
3909 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3911 run_test 48b "Access removed working dir (should return errors)="
3913 test_48c() { # bug 2350
3914 #lctl set_param debug=-1
3917 test_mkdir -p $DIR/$tdir/dir
3919 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3920 $TRACE touch foo && error "touch foo worked after removing cwd"
3921 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3922 touch .foo && error "touch .foo worked after removing cwd"
3923 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3924 $TRACE ls . && error "'ls .' worked after removing cwd"
3925 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3926 is_patchless || ( $TRACE cd . &&
3927 error "'cd .' worked after removing cwd" )
3928 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3929 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3930 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3931 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3933 run_test 48c "Access removed working subdir (should return errors)"
3935 test_48d() { # bug 2350
3936 #lctl set_param debug=-1
3939 test_mkdir -p $DIR/$tdir/dir
3941 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3942 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3943 $TRACE touch foo && error "'touch foo' worked after removing parent"
3944 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3945 touch .foo && error "'touch .foo' worked after removing parent"
3946 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3947 $TRACE ls . && error "'ls .' worked after removing parent"
3948 $TRACE ls .. && error "'ls ..' worked after removing parent"
3949 is_patchless || ( $TRACE cd . &&
3950 error "'cd .' worked after recreate parent" )
3951 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3952 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3953 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3954 is_patchless || ( $TRACE cd .. &&
3955 error "'cd ..' worked after removing parent" || true )
3957 run_test 48d "Access removed parent subdir (should return errors)"
3959 test_48e() { # bug 4134
3960 #lctl set_param debug=-1
3963 test_mkdir -p $DIR/$tdir/dir
3965 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3966 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3967 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3968 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3969 # On a buggy kernel addition of "touch foo" after cd .. will
3970 # produce kernel oops in lookup_hash_it
3971 touch ../foo && error "'cd ..' worked after recreate parent"
3973 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3975 run_test 48e "Access to recreated parent subdir (should return errors)"
3977 test_49() { # LU-1030
3978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3979 # get ost1 size - lustre-OST0000
3980 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3982 # write 800M at maximum
3983 [[ $ost1_size -lt 2 ]] && ost1_size=2
3984 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3986 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3987 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3990 # change max_pages_per_rpc while writing the file
3991 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3992 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3993 # loop until dd process exits
3994 while ps ax -opid | grep -wq $dd_pid; do
3995 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3996 sleep $((RANDOM % 5 + 1))
3998 # restore original max_pages_per_rpc
3999 $LCTL set_param $osc1_mppc=$orig_mppc
4000 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4002 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4006 test_mkdir $DIR/$tdir
4008 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4010 run_test 50 "special situations: /proc symlinks ==============="
4012 test_51a() { # was test_51
4013 # bug 1516 - create an empty entry right after ".." then split dir
4014 test_mkdir -c1 $DIR/$tdir
4015 touch $DIR/$tdir/foo
4016 $MCREATE $DIR/$tdir/bar
4018 createmany -m $DIR/$tdir/longfile 201
4020 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4021 $MCREATE $DIR/$tdir/longfile$FNUM
4026 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4028 run_test 51a "special situations: split htree with empty entry =="
4030 export NUMTEST=70000
4032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4033 local BASE=$DIR/d${base}.${TESTSUITE}
4035 # cleanup the directory
4038 test_mkdir -p -c1 $BASE
4042 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4043 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4044 [[ $numfree -lt 21000 ]] &&
4045 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4048 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4049 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4051 # need to check free space for the directories as well
4052 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4053 numfree=$((blkfree / 4))
4054 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4055 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4057 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4061 echo "failed" > $BASE/fnum
4062 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4065 run_test 51b "exceed 64k subdirectory nlink limit"
4067 test_51ba() { # LU-993
4068 local BASE=$DIR/d${base}.${TESTSUITE}
4069 # unlink all but 100 subdirectories, then check it still works
4071 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4073 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4074 local DELETE=$((NUMTEST - LEFT))
4076 # continue on to run this test even if 51b didn't finish,
4077 # just to delete the many subdirectories created.
4078 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4080 # for ldiskfs the nlink count should be 1, but this is OSD specific
4081 # and so this is listed for informational purposes only
4082 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4083 unlinkmany -d $BASE/d $DELETE
4086 if [ $RC -ne 0 ]; then
4087 if [ "$NUMPREV" == "failed" ]; then
4088 skip "previous setup failed"
4091 error "unlink of first $DELETE subdirs failed"
4096 echo "nlink between: $(stat -c %h $BASE)"
4097 # trim the first line of ls output
4098 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4099 [ $FOUND -ne $LEFT ] &&
4100 error "can't find subdirs: found only $FOUND/$LEFT"
4102 unlinkmany -d $BASE/d $DELETE $LEFT ||
4103 error "unlink of second $LEFT subdirs failed"
4104 # regardless of whether the backing filesystem tracks nlink accurately
4105 # or not, the nlink count shouldn't be more than "." and ".." here
4106 local AFTER=$(stat -c %h $BASE)
4107 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4108 echo "nlink after: $AFTER"
4110 run_test 51ba "verify nlink for many subdirectory cleanup"
4113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4114 [[ $OSTCOUNT -lt 3 ]] &&
4115 skip_env "skipping test with few OSTs" && return
4116 test_mkdir -p $DIR/$tdir
4117 createmany -o $DIR/$tdir/t- 1000
4118 $GETSTRIPE $DIR/$tdir > $TMP/files
4119 for N in $(seq 0 $((OSTCOUNT - 1))); do
4120 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4121 END { printf("%0.0f", objs) }' $TMP/files)
4122 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4123 '($1 == '$N') { objs += 1 } \
4124 END { printf("%0.0f", objs) }')
4125 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4127 unlinkmany $DIR/$tdir/t- 1000
4130 for N in $(seq 1 $((OSTCOUNT - 1))); do
4131 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4132 error "OST $N has less objects vs OST $NLAST" \
4133 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4134 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4135 error "OST $N has less objects vs OST $NLAST" \
4136 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4138 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4139 error "OST $N has less #0 objects vs OST $NLAST" \
4140 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4141 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4142 error "OST $N has less #0 objects vs OST $NLAST" \
4143 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4147 run_test 51d "check object distribution ===================="
4150 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4151 skip "Only applicable to ldiskfs-based MDTs"
4155 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4156 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4158 touch $DIR/$tdir/d0/foo
4159 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4160 error "file exceed 65000 nlink limit!"
4161 unlinkmany $DIR/$tdir/d0/f- 65001
4164 run_test 51e "check file nlink limit"
4167 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4168 test_mkdir -p $DIR/$tdir
4169 touch $DIR/$tdir/foo
4170 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4171 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4172 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4173 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4174 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4176 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4177 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4178 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4180 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4181 cp -r $DIR/$tdir /tmp/
4182 rm -fr $DIR/$tdir || error "cleanup rm failed"
4184 run_test 52a "append-only flag test (should return errors) ====="
4187 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4188 test_mkdir -p $DIR/$tdir
4189 touch $DIR/$tdir/foo
4190 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4191 cat test > $DIR/$tdir/foo && error "cat test worked"
4192 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4193 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4194 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4196 echo foo >> $DIR/$tdir/foo && error "echo worked"
4197 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4198 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4199 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4200 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4202 chattr -i $DIR/$tdir/foo || error "chattr failed"
4204 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4206 run_test 52b "immutable flag test (should return errors) ======="
4209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4210 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4211 remote_ost_nodsh && skip "remote OST with nodsh" && return
4224 local support_last_seq=true
4226 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4227 support_last_seq=false
4230 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4232 for value in $(do_facet $SINGLEMDS \
4233 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4234 param=$(echo ${value[0]} | cut -d "=" -f1)
4235 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4237 if $support_last_seq; then
4238 param_seq=$(echo $param |
4239 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4240 mds_last_seq=$(do_facet $SINGLEMDS \
4241 $LCTL get_param -n $param_seq)
4243 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4245 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4246 node=$(facet_active_host ost$((ostnum+1)))
4247 param="obdfilter.$ostname.last_id"
4248 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4249 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4250 ost_last_id=$ost_last
4252 if $support_last_seq; then
4253 ost_last_id=$(echo $ost_last |
4254 awk -F':' '{print $2}' |
4256 ost_last_seq=$(echo $ost_last |
4257 awk -F':' '{print $1}')
4258 [[ $ost_last_seq = $mds_last_seq ]] || continue
4261 if [[ $ost_last_id != $mds_last ]]; then
4262 error "$ost_last_id != $mds_last"
4269 $found || error "can not match last_seq/last_id for $mdtosc"
4272 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4275 $SOCKETSERVER $DIR/socket ||
4276 error "$SOCKETSERVER $DIR/socket failed: $?"
4277 $SOCKETCLIENT $DIR/socket ||
4278 error "$SOCKETCLIENT $DIR/socket failed: $?"
4279 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4281 run_test 54a "unix domain socket test =========================="
4287 dd if=/dev/zero of=$f bs=$(page_size) count=1
4289 run_test 54b "char device works in lustre ======================"
4292 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4293 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4294 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4296 for i in $(seq 3 7); do
4297 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4305 loopdev="$DIR/loop54c"
4308 $UMOUNT $DIR/$tdir || rc=$?
4309 losetup -d $loopdev || true
4310 losetup -d $LOOPDEV || true
4311 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4316 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4317 loopdev="$DIR/loop54c"
4320 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4321 trap cleanup_54c EXIT
4322 mknod $loopdev b 7 $LOOPNUM
4323 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4324 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4325 losetup $loopdev $DIR/$tfile ||
4326 error "can't set up $loopdev for $DIR/$tfile"
4327 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4328 test_mkdir -p $DIR/$tdir
4329 mount -t ext2 $loopdev $DIR/$tdir ||
4330 error "error mounting $loopdev on $DIR/$tdir"
4331 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4334 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4338 run_test 54c "block device works in lustre ====================="
4344 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4346 run_test 54d "fifo device works in lustre ======================"
4351 cp -aL /dev/console $f
4352 echo $string > $f || error "echo $string to $f failed"
4354 run_test 54e "console/tty device works in lustre ======================"
4356 #The test_55 used to be iopen test and it was removed by bz#24037.
4357 #run_test 55 "check iopen_connect_dentry() ======================"
4359 test_56a() { # was test_56
4362 test_mkdir -p $DIR/$tdir/dir
4364 NUMFILESx2=$(($NUMFILES * 2))
4365 for i in $(seq 1 $NUMFILES); do
4366 touch $DIR/$tdir/file$i
4367 touch $DIR/$tdir/dir/file$i
4370 # test lfs getstripe with --recursive
4371 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4372 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4373 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4374 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4375 [[ $FILENUM -eq $NUMFILES ]] ||
4376 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4377 echo "$GETSTRIPE --recursive passed."
4379 # test lfs getstripe with file instead of dir
4380 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4381 [[ $FILENUM -eq 1 ]] ||
4382 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4383 echo "$GETSTRIPE file1 passed."
4385 #test lfs getstripe with --verbose
4386 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4387 grep -c lmm_magic) -eq $NUMFILES ]] ||
4388 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4389 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4390 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4391 echo "$GETSTRIPE --verbose passed."
4393 #test lfs getstripe with --obd
4394 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4395 grep -q "unknown obduuid" ||
4396 error "$GETSTRIPE --obd wrong_uuid should return error message"
4398 [[ $OSTCOUNT -lt 2 ]] &&
4399 skip_env "skipping other $GETSTRIPE --obd test" && return
4402 OBDUUID=$(ostuuid_from_index $OSTIDX)
4403 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4404 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4405 [[ $FOUND -eq $FILENUM ]] ||
4406 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4407 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4408 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4409 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4410 error "$GETSTRIPE --obd: should not show file on other obd"
4411 echo "$GETSTRIPE --obd passed"
4413 run_test 56a "check $GETSTRIPE"
4418 local LOCAL_NUMFILES="$1"
4419 local LOCAL_NUMDIRS="$2"
4420 local MKDIR_PARAMS="$3"
4421 local DIR_STRIPE_PARAMS="$4"
4423 if [ ! -d "$TDIR" ] ; then
4424 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4425 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4426 for i in `seq 1 $LOCAL_NUMFILES` ; do
4429 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4430 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4431 for j in `seq 1 $LOCAL_NUMFILES` ; do
4432 touch $TDIR/dir$i/file$j
4438 setup_56_special() {
4442 if [ ! -e "$TDIR/loop1b" ] ; then
4443 for i in `seq 1 $LOCAL_NUMFILES` ; do
4444 mknod $TDIR/loop${i}b b 7 $i
4445 mknod $TDIR/null${i}c c 1 3
4446 ln -s $TDIR/file1 $TDIR/link${i}l
4448 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4449 mknod $TDIR/dir$i/loop${i}b b 7 $i
4450 mknod $TDIR/dir$i/null${i}c c 1 3
4451 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4460 setup_56 $NUMFILES $NUMDIRS
4462 EXPECTED=$(($NUMDIRS + 2))
4463 # test lfs find with -name
4464 for i in $(seq 1 $NUMFILES) ; do
4465 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4466 [ $NUMS -eq $EXPECTED ] ||
4467 error "lfs find -name \"*$i\" $TDIR wrong: "\
4468 "found $NUMS, expected $EXPECTED"
4471 run_test 56g "check lfs find -name ============================="
4477 setup_56 $NUMFILES $NUMDIRS
4479 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4480 # test lfs find with ! -name
4481 for i in $(seq 1 $NUMFILES) ; do
4482 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4483 [ $NUMS -eq $EXPECTED ] ||
4484 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4485 "found $NUMS, expected $EXPECTED"
4488 run_test 56h "check lfs find ! -name ============================="
4492 test_mkdir -p $DIR/$tdir
4493 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4494 CMD="$LFIND -ost $UUID $DIR/$tdir"
4496 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4498 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4502 setup_56_special $NUMFILES $NUMDIRS
4504 EXPECTED=$((NUMDIRS + 1))
4505 CMD="$LFIND -type d $TDIR"
4506 NUMS=$($CMD | wc -l)
4507 [ $NUMS -eq $EXPECTED ] ||
4508 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4510 run_test 56j "check lfs find -type d ============================="
4514 setup_56_special $NUMFILES $NUMDIRS
4516 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4517 CMD="$LFIND -type f $TDIR"
4518 NUMS=$($CMD | wc -l)
4519 [ $NUMS -eq $EXPECTED ] ||
4520 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4522 run_test 56k "check lfs find -type f ============================="
4526 setup_56_special $NUMFILES $NUMDIRS
4528 EXPECTED=$((NUMDIRS + NUMFILES))
4529 CMD="$LFIND -type b $TDIR"
4530 NUMS=$($CMD | wc -l)
4531 [ $NUMS -eq $EXPECTED ] ||
4532 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4534 run_test 56l "check lfs find -type b ============================="
4538 setup_56_special $NUMFILES $NUMDIRS
4540 EXPECTED=$((NUMDIRS + NUMFILES))
4541 CMD="$LFIND -type c $TDIR"
4542 NUMS=$($CMD | wc -l)
4543 [ $NUMS -eq $EXPECTED ] ||
4544 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4546 run_test 56m "check lfs find -type c ============================="
4550 setup_56_special $NUMFILES $NUMDIRS
4552 EXPECTED=$((NUMDIRS + NUMFILES))
4553 CMD="$LFIND -type l $TDIR"
4554 NUMS=$($CMD | wc -l)
4555 [ $NUMS -eq $EXPECTED ] ||
4556 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4558 run_test 56n "check lfs find -type l ============================="
4562 setup_56 $NUMFILES $NUMDIRS
4563 utime $TDIR/file1 > /dev/null || error "utime (1)"
4564 utime $TDIR/file2 > /dev/null || error "utime (2)"
4565 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4566 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4567 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4568 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4571 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4572 [ $NUMS -eq $EXPECTED ] || \
4573 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4576 CMD="$LFIND -mtime 0 $TDIR"
4577 NUMS=$($CMD | wc -l)
4578 [ $NUMS -eq $EXPECTED ] ||
4579 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4581 run_test 56o "check lfs find -mtime for old files =========================="
4584 [ $RUNAS_ID -eq $UID ] &&
4585 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4588 setup_56 $NUMFILES $NUMDIRS
4590 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4592 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4593 NUMS=$($CMD | wc -l)
4594 [ $NUMS -eq $EXPECTED ] || \
4595 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4597 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4598 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4599 NUMS=$($CMD | wc -l)
4600 [ $NUMS -eq $EXPECTED ] || \
4601 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4603 run_test 56p "check lfs find -uid and ! -uid ==============================="
4606 [ $RUNAS_ID -eq $UID ] &&
4607 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4610 setup_56 $NUMFILES $NUMDIRS
4612 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4615 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4616 NUMS=$($CMD | wc -l)
4617 [ $NUMS -eq $EXPECTED ] ||
4618 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4620 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4621 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4622 NUMS=$($CMD | wc -l)
4623 [ $NUMS -eq $EXPECTED ] ||
4624 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4626 run_test 56q "check lfs find -gid and ! -gid ==============================="
4630 setup_56 $NUMFILES $NUMDIRS
4633 CMD="$LFIND -size 0 -type f $TDIR"
4634 NUMS=$($CMD | wc -l)
4635 [ $NUMS -eq $EXPECTED ] ||
4636 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4638 CMD="$LFIND ! -size 0 -type f $TDIR"
4639 NUMS=$($CMD | wc -l)
4640 [ $NUMS -eq $EXPECTED ] ||
4641 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4642 echo "test" > $TDIR/$tfile
4643 echo "test2" > $TDIR/$tfile.2 && sync
4645 CMD="$LFIND -size 5 -type f $TDIR"
4646 NUMS=$($CMD | wc -l)
4647 [ $NUMS -eq $EXPECTED ] ||
4648 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4650 CMD="$LFIND -size +5 -type f $TDIR"
4651 NUMS=$($CMD | wc -l)
4652 [ $NUMS -eq $EXPECTED ] ||
4653 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4655 CMD="$LFIND -size +0 -type f $TDIR"
4656 NUMS=$($CMD | wc -l)
4657 [ $NUMS -eq $EXPECTED ] ||
4658 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4660 CMD="$LFIND ! -size -5 -type f $TDIR"
4661 NUMS=$($CMD | wc -l)
4662 [ $NUMS -eq $EXPECTED ] ||
4663 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4665 CMD="$LFIND -size -5 -type f $TDIR"
4666 NUMS=$($CMD | wc -l)
4667 [ $NUMS -eq $EXPECTED ] ||
4668 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4670 run_test 56r "check lfs find -size works =========================="
4672 test_56s() { # LU-611
4674 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4676 if [[ $OSTCOUNT -gt 1 ]]; then
4677 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4681 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4685 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4686 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4687 NUMS=$($CMD | wc -l)
4688 [ $NUMS -eq $EXPECTED ] || {
4690 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4693 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4694 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4695 NUMS=$($CMD | wc -l)
4696 [ $NUMS -eq $EXPECTED ] || {
4698 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4702 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4703 NUMS=$($CMD | wc -l)
4704 [ $NUMS -eq $EXPECTED ] || {
4706 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4709 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4710 NUMS=$($CMD | wc -l)
4711 [ $NUMS -eq $EXPECTED ] || {
4713 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4717 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4718 NUMS=$($CMD | wc -l)
4719 [ $NUMS -eq $EXPECTED ] || {
4721 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4724 run_test 56s "check lfs find -stripe-count works"
4726 test_56t() { # LU-611
4728 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4730 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4732 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4733 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4734 NUMS=$($CMD | wc -l)
4735 [ $NUMS -eq $EXPECTED ] ||
4736 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4738 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4739 NUMS=$($CMD | wc -l)
4740 [ $NUMS -eq $EXPECTED ] ||
4741 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4743 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4744 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4745 NUMS=$($CMD | wc -l)
4746 [ $NUMS -eq $EXPECTED ] ||
4747 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4749 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4750 NUMS=$($CMD | wc -l)
4751 [ $NUMS -eq $EXPECTED ] ||
4752 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4755 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4756 NUMS=$($CMD | wc -l)
4757 [ $NUMS -eq $EXPECTED ] ||
4758 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4760 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4761 NUMS=$($CMD | wc -l)
4762 [ $NUMS -eq $EXPECTED ] ||
4763 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4766 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4767 NUMS=$($CMD | wc -l)
4768 [ $NUMS -eq $EXPECTED ] ||
4769 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4771 run_test 56t "check lfs find -stripe-size works"
4773 test_56u() { # LU-611
4775 setup_56 $NUMFILES $NUMDIRS "-i 0"
4777 if [[ $OSTCOUNT -gt 1 ]]; then
4778 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4784 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4785 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4786 NUMS=$($CMD | wc -l)
4787 [ $NUMS -eq $EXPECTED ] ||
4788 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4791 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4792 NUMS=$($CMD | wc -l)
4793 [ $NUMS -eq $EXPECTED ] ||
4794 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4796 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4797 NUMS=$($CMD | wc -l)
4798 [ $NUMS -eq $EXPECTED ] ||
4799 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4802 # This should produce an error and not return any files
4803 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4804 NUMS=$($CMD 2>/dev/null | wc -l)
4805 [ $NUMS -eq $EXPECTED ] ||
4806 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4808 if [[ $OSTCOUNT -gt 1 ]]; then
4809 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4810 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4811 NUMS=$($CMD | wc -l)
4812 [ $NUMS -eq $EXPECTED ] ||
4813 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4816 run_test 56u "check lfs find -stripe-index works"
4823 setup_56 $NUMFILES $NUMDIRS
4825 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4826 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4828 for file in $($LFIND -mdt $UUID $TDIR); do
4829 file_mdt_idx=$($GETSTRIPE -M $file)
4830 [ $file_mdt_idx -eq $MDT_IDX ] ||
4831 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4834 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4837 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4842 rm -rf $TDIR || error "remove $TDIR failed"
4843 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4846 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4847 error "$GETSTRIPE -S -d $TDIR failed"
4848 stripe_size=${stripe_size%% *}
4850 local file_size=$((stripe_size * OSTCOUNT))
4851 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4852 local required_space=$((file_num * file_size))
4854 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
4856 [[ $free_space -le $((required_space / 1024)) ]] &&
4857 skip_env "need at least $required_space bytes free space," \
4858 "have $free_space kbytes" && return
4861 local dd_count=$((file_size / dd_bs))
4863 # write data into the files
4867 for i in $(seq 1 $NUMFILES); do
4869 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4870 error "write data into $file failed"
4872 for i in $(seq 1 $NUMDIRS); do
4873 for j in $(seq 1 $NUMFILES); do
4874 file=$TDIR/dir$i/file$j
4875 yes | dd bs=$dd_bs count=$dd_count of=$file \
4877 error "write data into $file failed"
4882 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4885 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4887 eval $cmd || error "$cmd failed"
4889 check_stripe_count $TDIR/file1 $expected
4891 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4893 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4894 # OST 1 if it is on OST 0. This file is small enough to
4895 # be on only one stripe.
4896 file=$TDIR/migr_1_ost
4897 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4898 error "write data into $file failed"
4899 local obdidx=$($LFS getstripe -i $file)
4900 local oldmd5=$(md5sum $file)
4902 [[ $obdidx -eq 0 ]] && newobdidx=1
4903 cmd="$LFS migrate -i $newobdidx $file"
4905 eval $cmd || error "$cmd failed"
4906 local realobdix=$($LFS getstripe -i $file)
4907 local newmd5=$(md5sum $file)
4908 [[ $newobdidx -ne $realobdix ]] &&
4909 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4910 [[ "$oldmd5" != "$newmd5" ]] &&
4911 error "md5sum differ: $oldmd5, $newmd5"
4915 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4917 eval $cmd || error "$cmd failed"
4919 for j in $(seq 1 $NUMFILES); do
4920 check_stripe_count $TDIR/dir1/file$j $expected
4923 # lfs_migrate works with lfs find
4924 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4925 $LFS_MIGRATE -y -c $expected"
4927 eval $cmd || error "$cmd failed"
4929 for i in $(seq 2 $NUMFILES); do
4930 check_stripe_count $TDIR/file$i $expected
4932 for i in $(seq 2 $NUMDIRS); do
4933 for j in $(seq 1 $NUMFILES); do
4934 check_stripe_count $TDIR/dir$i/file$j $expected
4938 run_test 56w "check lfs_migrate -c stripe_count works"
4941 check_swap_layouts_support && return 0
4942 [[ $OSTCOUNT -lt 2 ]] &&
4943 skip_env "need 2 OST, skipping test" && return
4945 local dir0=$DIR/$tdir/$testnum
4946 test_mkdir -p $dir0 || error "creating dir $dir0"
4948 local ref1=/etc/passwd
4949 local file1=$dir0/file1
4951 $SETSTRIPE -c 2 $file1
4953 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4954 stripe=$($GETSTRIPE -c $file1)
4955 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4956 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4961 run_test 56x "lfs migration support"
4964 check_swap_layouts_support && return 0
4965 [[ $OSTCOUNT -lt 2 ]] &&
4966 skip_env "need 2 OST, skipping test" && return
4968 local dir0=$DIR/$tdir/$testnum
4969 test_mkdir -p $dir0 || error "creating dir $dir0"
4971 local ref1=/etc/passwd
4972 local file1=$dir0/file1
4974 $SETSTRIPE -c 2 $file1
4976 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
4977 local stripe=$($GETSTRIPE -c $file1)
4978 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4979 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4984 run_test 56xa "lfs migration --block support"
4987 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4988 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4992 local dir0=$DIR/$tdir/$testnum
4993 test_mkdir -p $dir0 || error "creating dir $dir0"
4994 local f1=$dir0/file1
4995 local f2=$dir0/file2
4997 touch $f1 || error "creating std file $f1"
4998 $MULTIOP $f2 H2c || error "creating released file $f2"
5000 # a directory can be raid0, so ask only for files
5001 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
5002 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5004 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5005 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5007 # only files can be released, so no need to force file search
5008 res=$($LFIND $dir0 -L released)
5009 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5011 res=$($LFIND $dir0 \! -L released)
5012 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5015 run_test 56y "lfs find -L raid0|released"
5017 test_56z() { # LU-4824
5018 # This checks to make sure 'lfs find' continues after errors
5019 # There are two classes of errors that should be caught:
5020 # - If multiple paths are provided, all should be searched even if one
5022 # - If errors are encountered during the search, it should not terminate
5025 test_mkdir $DIR/$tdir
5026 for i in d{0..9}; do
5027 test_mkdir $DIR/$tdir/$i
5029 touch $DIR/$tdir/d{0..9}/$tfile
5030 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5031 error "$LFS find did not return an error"
5032 # Make a directory unsearchable. This should NOT be the last entry in
5033 # directory order. Arbitrarily pick the 6th entry
5034 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5035 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5036 # The user should be able to see 10 directories and 9 files
5037 [ $count == 19 ] || error "$LFS find did not continue after error"
5039 run_test 56z "lfs find should continue after an error"
5041 test_56aa() { # LU-5937
5042 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5045 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5047 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5048 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5050 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5052 run_test 56aa "lfs find --size under striped dir"
5055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5056 # note test will not do anything if MDS is not local
5057 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5058 skip "Only applicable to ldiskfs-based MDTs"
5062 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5063 local MNTDEV="osd*.*MDT*.mntdev"
5064 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5065 [ -z "$DEV" ] && error "can't access $MNTDEV"
5066 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5067 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5068 error "can't access $DEV"
5069 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5070 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5074 run_test 57a "verify MDS filesystem created with large inodes =="
5077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5078 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5079 skip "Only applicable to ldiskfs-based MDTs"
5083 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5084 local dir=$DIR/$tdir
5088 local FILEN=$dir/f$FILECOUNT
5090 rm -rf $dir || error "removing $dir"
5091 test_mkdir -p -c1 $dir || error "creating $dir"
5092 local mdtidx=$($LFS getstripe -M $dir)
5093 local mdtname=MDT$(printf %04x $mdtidx)
5094 local facet=mds$((mdtidx + 1))
5096 echo "mcreating $FILECOUNT files"
5097 createmany -m $dir/f 1 $FILECOUNT || \
5098 error "creating files in $dir"
5100 # verify that files do not have EAs yet
5101 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5102 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5106 df $dir #make sure we get new statfs data
5107 local MDSFREE=$(do_facet $facet \
5108 lctl get_param -n osd*.*$mdtname.kbytesfree)
5109 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5110 echo "opening files to create objects/EAs"
5112 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5113 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5116 # verify that files have EAs now
5117 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5118 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5120 sleep 1 #make sure we get new statfs data
5122 local MDSFREE2=$(do_facet $facet \
5123 lctl get_param -n osd*.*$mdtname.kbytesfree)
5124 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5125 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5126 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5127 error "MDC before $MDCFREE != after $MDCFREE2"
5129 echo "MDC before $MDCFREE != after $MDCFREE2"
5130 echo "unable to confirm if MDS has large inodes"
5135 run_test 57b "default LOV EAs are stored inside large inodes ==="
5138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5139 [ -z "$(which wiretest 2>/dev/null)" ] &&
5140 skip_env "could not find wiretest" && return
5143 run_test 58 "verify cross-platform wire constants =============="
5146 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5147 echo "touch 130 files"
5148 createmany -o $DIR/f59- 130
5150 unlinkmany $DIR/f59- 130
5152 # wait for commitment of removal
5153 wait_delete_completed
5155 run_test 59 "verify cancellation of llog records async ========="
5157 TEST60_HEAD="test_60 run $RANDOM"
5159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5160 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5161 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5162 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
5163 skip_env "missing subtest run-llog.sh" && return
5165 log "$TEST60_HEAD - from kernel mode"
5166 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
5167 do_facet mgs sh run-llog.sh
5168 do_facet mgs $LCTL dk > $TMP/$tfile
5170 # LU-6388: test llog_reader
5171 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
5172 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
5173 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
5174 skip_env "missing llog_reader" && return
5175 local fstype=$(facet_fstype mgs)
5176 [ $fstype != ldiskfs -a $fstype != zfs ] &&
5177 skip_env "Only for ldiskfs or zfs type mgs" && return
5179 local mntpt=$(facet_mntpt mgs)
5180 local mgsdev=$(mgsdevname 1)
5192 #get fid and record list
5193 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
5195 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
5197 #remount mgs as ldiskfs or zfs type
5198 stop mgs || error "stop mgs failed"
5199 mount_fstype mgs || error "remount mgs failed"
5200 for ((i = 0; i < ${#fid_list[@]}; i++)); do
5203 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
5204 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
5209 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
5211 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
5213 echo "obj_file is $obj_file"
5214 do_facet mgs $llog_reader $obj_file
5216 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
5217 awk '{ print $3 }' | sed -e "s/^type=//g")
5218 if [ $rec_type != $rec ]; then
5219 echo "FAILED test_60a wrong record type $rec_type," \
5225 #check obj path if record type is LLOG_LOGID_MAGIC
5226 if [ "$rec" == "1064553b" ]; then
5227 path=$(do_facet mgs $llog_reader $obj_file |
5228 grep "path=" | awk '{ print $NF }' |
5229 sed -e "s/^path=//g")
5230 if [ $obj_file != $mntpt/$path ]; then
5231 echo "FAILED test_60a wrong obj path" \
5232 "$montpt/$path, should be $obj_file"
5239 #restart mgs before "error", otherwise it will block the next test
5240 stop mgs || error "stop mgs failed"
5241 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
5242 $pass || error "test failed, see FAILED test_60a messages for specifics"
5244 run_test 60a "llog_test run from kernel module and test llog_reader =========="
5246 test_60b() { # bug 6411
5247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5249 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
5261 [[ $LLOG_COUNT -gt 100 ]] &&
5262 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5264 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5268 echo "create 5000 files"
5269 createmany -o $DIR/f60c- 5000
5270 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5271 lctl set_param fail_loc=0x80000137
5272 unlinkmany $DIR/f60c- 5000
5273 lctl set_param fail_loc=0
5275 run_test 60c "unlink file when mds full"
5278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5279 SAVEPRINTK=$(lctl get_param -n printk)
5281 # verify "lctl mark" is even working"
5282 MESSAGE="test message ID $RANDOM $$"
5283 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5284 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5286 lctl set_param printk=0 || error "set lnet.printk failed"
5287 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5288 MESSAGE="new test message ID $RANDOM $$"
5289 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5290 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5291 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5293 lctl set_param -n printk="$SAVEPRINTK"
5295 run_test 60d "test printk console message masking"
5298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5300 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
5301 do_facet mds1 lctl set_param fail_loc=0x15b
5304 run_test 60e "no space while new llog is being created"
5307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5309 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5310 cancel_lru_locks osc
5311 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5314 run_test 61 "mmap() writes don't make sync hang ================"
5316 # bug 2330 - insufficient obd_match error checking causes LBUG
5318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5321 cancel_lru_locks osc
5322 lctl set_param fail_loc=0x405
5323 cat $f && error "cat succeeded, expect -EIO"
5324 lctl set_param fail_loc=0
5326 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5327 # match every page all of the time.
5328 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5330 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5331 # Though this test is irrelevant anymore, it helped to reveal some
5332 # other grant bugs (LU-4482), let's keep it.
5333 test_63a() { # was test_63
5334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5335 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5336 for i in `seq 10` ; do
5337 dd if=/dev/zero of=$DIR/f63 bs=8k &
5343 rm -f $DIR/f63 || true
5345 run_test 63a "Verify oig_wait interruption does not crash ======="
5347 # bug 2248 - async write errors didn't return to application on sync
5348 # bug 3677 - async write errors left page locked
5350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5352 lctl set_param debug=-1
5354 # ensure we have a grant to do async writes
5355 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5358 sync # sync lest earlier test intercept the fail_loc
5360 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5361 lctl set_param fail_loc=0x80000406
5362 $MULTIOP $DIR/$tfile Owy && \
5363 error "sync didn't return ENOMEM"
5364 sync; sleep 2; sync # do a real sync this time to flush page
5365 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5366 error "locked page left in cache after async error" || true
5369 run_test 63b "async write errors should be returned to fsync ==="
5372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5374 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5376 run_test 64a "verify filter grant calculations (in kernel) ====="
5379 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5380 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5382 run_test 64b "check out-of-space detection on client ==========="
5385 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5387 run_test 64c "verify grant shrink ========================------"
5389 # bug 1414 - set/get directories' stripe info
5391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5392 test_mkdir -p $DIR/$tdir
5394 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5396 run_test 65a "directory with no stripe info ===================="
5399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5400 test_mkdir -p $DIR/$tdir
5401 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5403 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5406 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5408 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
5411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5412 if [[ $OSTCOUNT -gt 1 ]]; then
5413 test_mkdir -p $DIR/$tdir
5414 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5416 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5417 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5419 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5422 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
5425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5426 test_mkdir -p $DIR/$tdir
5427 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
5428 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5430 if [[ $STRIPECOUNT -le 0 ]]; then
5432 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5433 #LOV_MAX_STRIPE_COUNT is 2000
5434 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5436 sc=$(($STRIPECOUNT - 1))
5438 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5439 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5440 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5441 error "lverify failed"
5443 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
5446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5447 test_mkdir -p $DIR/$tdir
5449 $SETSTRIPE $DIR/$tdir || error "setstripe"
5450 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5451 error "no stripe info failed"
5453 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5455 run_test 65e "directory setstripe defaults ======================="
5458 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5459 test_mkdir -p $DIR/${tdir}f
5460 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5462 run_test 65f "dir setstripe permission (should return error) ==="
5465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5466 test_mkdir -p $DIR/$tdir
5467 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5469 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5471 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5472 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5473 error "delete default stripe failed"
5475 run_test 65g "directory setstripe -d ==========================="
5478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5479 test_mkdir -p $DIR/$tdir
5480 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
5482 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5484 test_mkdir -p $DIR/$tdir/dd1
5485 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5486 error "stripe info inherit failed"
5488 run_test 65h "directory stripe info inherit ===================="
5490 test_65i() { # bug6367
5491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5492 $SETSTRIPE -S 65536 -c -1 $MOUNT
5494 run_test 65i "set non-default striping on root directory (bug 6367)="
5496 test_65ia() { # bug12836
5497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5498 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5500 run_test 65ia "getstripe on -1 default directory striping"
5502 test_65ib() { # bug12836
5503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5504 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5506 run_test 65ib "getstripe -v on -1 default directory striping"
5508 test_65ic() { # bug12836
5509 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5510 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5512 run_test 65ic "new find on -1 default directory striping"
5514 test_65j() { # bug6367
5515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5517 # if we aren't already remounting for each test, do so for this test
5518 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5519 cleanup || error "failed to unmount"
5522 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5524 run_test 65j "set default striping on root directory (bug 6367)="
5526 test_65k() { # bug11679
5527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5528 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5529 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5531 echo "Check OST status: "
5532 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5533 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5535 for OSC in $MDS_OSCS; do
5536 echo $OSC "is activate"
5537 do_facet $SINGLEMDS lctl --device %$OSC activate
5541 for INACTIVE_OSC in $MDS_OSCS; do
5542 echo "Deactivate: " $INACTIVE_OSC
5543 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5544 for STRIPE_OSC in $MDS_OSCS; do
5545 OST=`osc_to_ost $STRIPE_OSC`
5546 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5547 awk -F: /$OST/'{ print $1 }' | head -n 1`
5549 [ -f $DIR/$tdir/$IDX ] && continue
5550 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5551 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5553 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5556 echo $INACTIVE_OSC "is Activate."
5557 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5560 run_test 65k "validate manual striping works properly with deactivated OSCs"
5562 test_65l() { # bug 12836
5563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5564 test_mkdir -p $DIR/$tdir/test_dir
5565 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5566 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5568 run_test 65l "lfs find on -1 stripe dir ========================"
5570 # bug 2543 - update blocks count on client
5572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5574 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5575 sync; sync_all_data; sync; sync_all_data
5576 cancel_lru_locks osc
5577 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5578 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5580 run_test 66 "update inode blocks count on client ==============="
5585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5587 if [ ! -z "$LLOOP" ]; then
5588 if swapon -s | grep -q $LLOOP; then
5589 swapoff $LLOOP || error "swapoff failed"
5592 $LCTL blockdev_detach $LLOOP || error "detach failed"
5596 if [ ! -z "$LLITELOOPLOAD" ]; then
5604 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5608 swapon -s | awk '($1 == "'$1'") { print $4 }'
5611 # test case for lloop driver, basic function
5613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5614 [ "$UID" != 0 ] && skip_env "must run as root" && return
5615 llite_lloop_enabled || \
5616 { skip_env "llite_lloop module disabled" && return; }
5618 trap cleanup_68 EXIT
5620 if ! module_loaded llite_lloop; then
5621 if load_module llite/llite_lloop; then
5624 skip_env "can't find module llite_lloop"
5629 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5630 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5631 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5633 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5634 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5638 run_test 68a "lloop driver - basic test ========================"
5640 # excercise swapping to lustre by adding a high priority swapfile entry
5641 # and then consuming memory until it is used.
5642 test_68b() { # was test_68
5643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5644 [ "$UID" != 0 ] && skip_env "must run as root" && return
5645 lctl get_param -n devices | grep -q obdfilter && \
5646 skip "local OST" && return
5648 grep -q llite_lloop /proc/modules
5649 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5651 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5652 skip "can't reliably test swap with TCP" && return
5654 MEMTOTAL=`meminfo MemTotal`
5655 NR_BLOCKS=$((MEMTOTAL>>8))
5656 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5658 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5659 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5662 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5664 trap cleanup_68 EXIT
5666 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5668 echo "before: `swapon -s | grep $LLOOP`"
5669 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5670 echo "after: `swapon -s | grep $LLOOP`"
5671 SWAPUSED=`swap_used $LLOOP`
5675 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5677 run_test 68b "support swapping to Lustre ========================"
5679 # bug5265, obdfilter oa2dentry return -ENOENT
5680 # #define OBD_FAIL_SRV_ENOENT 0x217
5682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5683 remote_ost_nodsh && skip "remote OST with nodsh" && return
5686 $SETSTRIPE -c 1 -i 0 $f
5688 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5690 do_facet ost1 lctl set_param fail_loc=0x217
5691 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5692 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5694 do_facet ost1 lctl set_param fail_loc=0
5695 $DIRECTIO write $f 0 2 || error "write error"
5697 cancel_lru_locks osc
5698 $DIRECTIO read $f 0 1 || error "read error"
5700 do_facet ost1 lctl set_param fail_loc=0x217
5701 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5703 do_facet ost1 lctl set_param fail_loc=0
5706 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5709 test_mkdir -p $DIR/$tdir
5710 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5711 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5713 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5715 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5717 [ "$RUNAS_ID" = "$UID" ] &&
5718 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5720 # Check that testing environment is properly set up. Skip if not
5721 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5722 skip_env "User $RUNAS_ID does not exist - skipping"
5726 chmod 777 $DIR/$tfile
5727 chmod ug+s $DIR/$tfile
5728 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5729 error "$RUNAS dd $DIR/$tfile failed"
5730 # See if we are still setuid/sgid
5731 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5732 error "S/gid is not dropped on write"
5733 # Now test that MDS is updated too
5734 cancel_lru_locks mdc
5735 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5736 error "S/gid is not dropped on MDS"
5739 run_test 72a "Test that remove suid works properly (bug5695) ===="
5741 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5744 [ "$RUNAS_ID" = "$UID" ] && \
5745 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5746 [ "$RUNAS_ID" -eq 0 ] && \
5747 skip_env "RUNAS_ID = 0 -- skipping" && return
5749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5750 # Check that testing environment is properly set up. Skip if not
5751 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5752 skip_env "User $RUNAS_ID does not exist - skipping"
5755 touch $DIR/${tfile}-f{g,u}
5756 test_mkdir $DIR/${tfile}-dg
5757 test_mkdir $DIR/${tfile}-du
5758 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5759 chmod g+s $DIR/${tfile}-{f,d}g
5760 chmod u+s $DIR/${tfile}-{f,d}u
5761 for perm in 777 2777 4777; do
5762 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5763 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5764 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5765 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5769 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5771 # bug 3462 - multiple simultaneous MDC requests
5773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5774 test_mkdir $DIR/d73-1
5775 test_mkdir $DIR/d73-2
5776 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5779 lctl set_param fail_loc=0x80000129
5780 $MULTIOP $DIR/d73-1/f73-2 Oc &
5782 lctl set_param fail_loc=0
5784 $MULTIOP $DIR/d73-2/f73-3 Oc &
5788 wait $pid1 || return 1
5792 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5793 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5794 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5798 run_test 73 "multiple MDC requests (should not deadlock)"
5800 test_74a() { # bug 6149, 6184
5801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5802 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5804 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5805 # will spin in a tight reconnection loop
5807 $LCTL set_param fail_loc=0x8000030e
5808 # get any lock that won't be difficult - lookup works.
5810 $LCTL set_param fail_loc=0
5814 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5816 test_74b() { # bug 13310
5817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5818 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5820 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5821 # will spin in a tight reconnection loop
5822 $LCTL set_param fail_loc=0x8000030e
5823 # get a "difficult" lock
5825 $LCTL set_param fail_loc=0
5829 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5833 #define OBD_FAIL_LDLM_NEW_LOCK
5834 $LCTL set_param fail_loc=0x319
5835 touch $DIR/$tfile && error "touch successful"
5836 $LCTL set_param fail_loc=0
5839 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5842 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5845 get_inode_slab_tunables() {
5846 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5849 set_inode_slab_tunables() {
5850 echo "lustre_inode_cache $1" > /proc/slabinfo
5853 test_76() { # Now for bug 20433, added originally in bug 1443
5854 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5855 local SLAB_SETTINGS=`get_inode_slab_tunables`
5856 local CPUS=`getconf _NPROCESSORS_ONLN`
5857 # we cannot set limit below 1 which means 1 inode in each
5858 # per-cpu cache is still allowed
5859 set_inode_slab_tunables "1 1 0"
5860 cancel_lru_locks osc
5861 BEFORE_INODES=$(num_inodes)
5862 echo "before inodes: $BEFORE_INODES"
5864 [ "$SLOW" = "no" ] && COUNT=100
5865 for i in $(seq $COUNT); do
5869 cancel_lru_locks osc
5870 AFTER_INODES=$(num_inodes)
5871 echo "after inodes: $AFTER_INODES"
5873 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5875 AFTER_INODES=$(num_inodes)
5877 echo "wait $wait seconds inodes: $AFTER_INODES"
5878 if [ $wait -gt 30 ]; then
5879 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5882 set_inode_slab_tunables "$SLAB_SETTINGS"
5884 run_test 76 "confirm clients recycle inodes properly ===="
5890 # Note: in sptlrpc modes which enable its own bulk checksum, the
5891 # original crc32_le bulk checksum will be automatically disabled,
5892 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5893 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5894 # In this case set_checksums() will not be no-op, because sptlrpc
5895 # bulk checksum will be enabled all through the test.
5897 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5898 lctl set_param -n osc.*.checksums $1
5902 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5903 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5904 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5905 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5908 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5909 log "set checksum type to $1"
5912 F77_TMP=$TMP/f77-temp
5915 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5916 error "error writing to $F77_TMP"
5919 test_77a() { # bug 10889
5920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5921 $GSS && skip "could not run with gss" && return
5922 [ ! -f $F77_TMP ] && setup_f77
5924 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5928 run_test 77a "normal checksum read/write operation"
5930 test_77b() { # bug 10889
5931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5932 $GSS && skip "could not run with gss" && return
5933 [ ! -f $F77_TMP ] && setup_f77
5934 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5935 $LCTL set_param fail_loc=0x80000409
5938 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5939 error "dd error: $?"
5940 $LCTL set_param fail_loc=0
5942 for algo in $CKSUM_TYPES; do
5943 cancel_lru_locks osc
5944 set_checksum_type $algo
5945 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5946 $LCTL set_param fail_loc=0x80000408
5947 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5948 $LCTL set_param fail_loc=0
5951 set_checksum_type $ORIG_CSUM_TYPE
5954 run_test 77b "checksum error on client write, read"
5956 test_77d() { # bug 10889
5957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5958 $GSS && skip "could not run with gss" && return
5959 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5960 $LCTL set_param fail_loc=0x80000409
5962 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5963 error "direct write: rc=$?"
5964 $LCTL set_param fail_loc=0
5967 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5968 $LCTL set_param fail_loc=0x80000408
5970 cancel_lru_locks osc
5971 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5972 error "direct read: rc=$?"
5973 $LCTL set_param fail_loc=0
5976 run_test 77d "checksum error on OST direct write, read"
5978 test_77f() { # bug 10889
5979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5980 $GSS && skip "could not run with gss" && return
5982 for algo in $CKSUM_TYPES; do
5983 cancel_lru_locks osc
5984 set_checksum_type $algo
5985 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5986 $LCTL set_param fail_loc=0x409
5987 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5988 error "direct write succeeded"
5989 $LCTL set_param fail_loc=0
5991 set_checksum_type $ORIG_CSUM_TYPE
5994 run_test 77f "repeat checksum error on write (expect error)"
5996 test_77g() { # bug 10889
5997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5998 $GSS && skip "could not run with gss" && return
5999 remote_ost_nodsh && skip "remote OST with nodsh" && return
6001 [ ! -f $F77_TMP ] && setup_f77
6003 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
6004 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
6005 do_facet ost1 lctl set_param fail_loc=0x8000021a
6007 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
6008 error "write error: rc=$?"
6009 do_facet ost1 lctl set_param fail_loc=0
6012 cancel_lru_locks osc
6013 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
6014 do_facet ost1 lctl set_param fail_loc=0x8000021b
6016 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
6017 do_facet ost1 lctl set_param fail_loc=0
6020 run_test 77g "checksum error on OST write, read"
6022 test_77i() { # bug 13805
6023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6024 $GSS && skip "could not run with gss" && return
6025 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
6026 lctl set_param fail_loc=0x40b
6027 remount_client $MOUNT
6028 lctl set_param fail_loc=0
6029 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6030 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6031 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6032 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6034 remount_client $MOUNT
6036 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
6038 test_77j() { # bug 13805
6039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6040 $GSS && skip "could not run with gss" && return
6041 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
6042 lctl set_param fail_loc=0x40c
6043 remount_client $MOUNT
6044 lctl set_param fail_loc=0
6045 sleep 2 # wait async osc connect to finish
6046 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
6047 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6048 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
6049 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
6051 remount_client $MOUNT
6053 run_test 77j "client only supporting ADLER32"
6055 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
6059 test_78() { # bug 10901
6060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6061 remote_ost || { skip_env "local OST" && return; }
6064 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
6065 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
6066 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
6067 echo "MemTotal: $MEMTOTAL"
6069 # reserve 256MB of memory for the kernel and other running processes,
6070 # and then take 1/2 of the remaining memory for the read/write buffers.
6071 if [ $MEMTOTAL -gt 512 ] ;then
6072 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
6074 # for those poor memory-starved high-end clusters...
6075 MEMTOTAL=$((MEMTOTAL / 2))
6077 echo "Mem to use for directio: $MEMTOTAL"
6079 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
6080 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
6081 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
6082 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
6084 echo "Smallest OST: $SMALLESTOST"
6085 [[ $SMALLESTOST -lt 10240 ]] &&
6086 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
6088 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
6089 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
6091 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
6092 echo "File size: $F78SIZE"
6093 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
6094 for i in $(seq 1 $NSEQ); do
6095 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
6096 echo directIO rdwr round $i of $NSEQ
6097 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
6102 run_test 78 "handle large O_DIRECT writes correctly ============"
6104 test_79() { # bug 12743
6105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6106 wait_delete_completed
6108 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6109 BKFREE=$(calc_osc_kbytes kbytesfree)
6110 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6112 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6113 DFTOTAL=`echo $STRING | cut -d, -f1`
6114 DFUSED=`echo $STRING | cut -d, -f2`
6115 DFAVAIL=`echo $STRING | cut -d, -f3`
6116 DFFREE=$(($DFTOTAL - $DFUSED))
6118 ALLOWANCE=$((64 * $OSTCOUNT))
6120 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6121 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6122 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6124 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6125 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6126 error "df free($DFFREE) mismatch OST free($BKFREE)"
6128 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6129 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6130 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6133 run_test 79 "df report consistency check ======================="
6135 test_80() { # bug 10718
6136 remote_ost_nodsh && skip "remote OST with nodsh" && return
6137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6138 # relax strong synchronous semantics for slow backends like ZFS
6139 local soc="obdfilter.*.sync_on_lock_cancel"
6140 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6142 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6143 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6144 facet_active_host $host; done | sort -u)
6145 do_nodes $hosts lctl set_param $soc=never
6148 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6150 local BEFORE=`date +%s`
6151 cancel_lru_locks osc
6152 local AFTER=`date +%s`
6153 local DIFF=$((AFTER-BEFORE))
6154 if [ $DIFF -gt 1 ] ; then
6155 error "elapsed for 1M@1T = $DIFF"
6158 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6162 run_test 80 "Page eviction is equally fast at high offsets too ===="
6164 test_81a() { # LU-456
6165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6166 remote_ost_nodsh && skip "remote OST with nodsh" && return
6167 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6168 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6169 do_facet ost1 lctl set_param fail_loc=0x80000228
6171 # write should trigger a retry and success
6172 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6173 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6175 if [ $RC -ne 0 ] ; then
6176 error "write should success, but failed for $RC"
6179 run_test 81a "OST should retry write when get -ENOSPC ==============="
6181 test_81b() { # LU-456
6182 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6183 remote_ost_nodsh && skip "remote OST with nodsh" && return
6184 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6185 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6186 do_facet ost1 lctl set_param fail_loc=0x228
6188 # write should retry several times and return -ENOSPC finally
6189 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6190 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6193 if [ $RC -ne $ENOSPC ] ; then
6194 error "dd should fail for -ENOSPC, but succeed."
6197 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6199 test_82() { # LU-1031
6200 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6204 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6206 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6208 kill -USR1 $MULTIPID2
6210 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6211 error "First grouplock does not block second one"
6213 echo "Second grouplock blocks first one"
6215 kill -USR1 $MULTIPID1
6219 run_test 82 "Basic grouplock test ==============================="
6222 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6224 test_mkdir -p $DIR/d99cvsroot
6225 chown $RUNAS_ID $DIR/d99cvsroot
6226 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6229 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6232 run_test 99a "cvs init ========================================="
6235 [ -z "$(which cvs 2>/dev/null)" ] &&
6236 skip_env "could not find cvs" && return
6237 [ ! -d $DIR/d99cvsroot ] && test_99a
6239 # some versions of cvs import exit(1) when asked to import links or
6240 # files they can't read. ignore those files.
6241 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6242 ! -perm /4 -printf '-I %f\n')
6243 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6244 d99reposname vtag rtag
6246 run_test 99b "cvs import ======================================="
6249 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6250 [ ! -d $DIR/d99cvsroot ] && test_99b
6252 test_mkdir -p $DIR/d99reposname
6253 chown $RUNAS_ID $DIR/d99reposname
6254 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6256 run_test 99c "cvs checkout ====================================="
6259 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6260 [ ! -d $DIR/d99cvsroot ] && test_99c
6261 cd $DIR/d99reposname
6263 $RUNAS cvs add -m 'addmsg' foo99
6265 run_test 99d "cvs add =========================================="
6268 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6269 [ ! -d $DIR/d99cvsroot ] && test_99c
6270 cd $DIR/d99reposname
6273 run_test 99e "cvs update ======================================="
6276 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6277 [ ! -d $DIR/d99cvsroot ] && test_99d
6278 cd $DIR/d99reposname
6279 $RUNAS cvs commit -m 'nomsg' foo99
6280 rm -fr $DIR/d99cvsroot
6282 run_test 99f "cvs commit ======================================="
6285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6286 [ "$NETTYPE" = tcp ] || \
6287 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6290 remote_ost_nodsh && skip "remote OST with nodsh" && return
6291 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6293 { skip "useless for local single node setup" && return; }
6295 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6296 [ "$PROT" != "tcp" ] && continue
6297 RPORT=$(echo $REMOTE | cut -d: -f2)
6298 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6301 LPORT=`echo $LOCAL | cut -d: -f2`
6302 if [ $LPORT -ge 1024 ]; then
6303 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6305 error_exit "local: $LPORT > 1024, remote: $RPORT"
6308 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6310 run_test 100 "check local port using privileged port ==========="
6312 function get_named_value()
6321 echo $line | sed "s/^$tag[ ]*//"
6328 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6329 awk '/^max_cached_mb/ { print $2 }')
6332 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6338 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6342 local cache_limit=32
6344 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6345 trap cleanup_101a EXIT
6346 $LCTL set_param -n llite.*.read_ahead_stats 0
6347 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6350 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6352 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6353 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6356 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6357 get_named_value 'read but discarded' | cut -d" " -f1); do
6358 discard=$(($discard + $s))
6362 if [[ $(($discard * 10)) -gt $nreads ]]; then
6363 $LCTL get_param osc.*-osc*.rpc_stats
6364 $LCTL get_param llite.*.read_ahead_stats
6365 error "too many ($discard) discarded pages"
6367 rm -f $DIR/$tfile || true
6369 run_test 101a "check read-ahead for random reads ================"
6372 test_mkdir -p $DIR/$tdir
6373 local STRIPE_SIZE=$1
6374 local FILE_LENGTH=$2
6377 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6379 local list=$(comma_list $(osts_nodes))
6380 set_osd_param $list '' read_cache_enable 0
6381 set_osd_param $list '' writethrough_cache_enable 0
6383 trap cleanup_test101bc EXIT
6384 # prepare the read-ahead file
6385 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6387 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6388 count=$FILE_SIZE_MB 2> /dev/null
6392 cleanup_test101bc() {
6397 local list=$(comma_list $(osts_nodes))
6398 set_osd_param $list '' read_cache_enable 1
6399 set_osd_param $list '' writethrough_cache_enable 1
6403 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6408 local STRIPE_SIZE=$2
6409 local FILE_LENGTH=$3
6410 local RA_INC=1048576
6411 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6412 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6413 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6414 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6415 get_named_value 'read but discarded' |
6416 cut -d" " -f1 | calc_total)
6417 if [[ $DISCARD -gt $discard_limit ]]; then
6418 $LCTL get_param llite.*.read_ahead_stats
6419 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6421 echo "Read-ahead success for size ${READ_SIZE}"
6426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6427 [[ $OSTCOUNT -lt 2 ]] &&
6428 skip_env "skipping stride IO stride-ahead test" && return
6429 local STRIPE_SIZE=1048576
6430 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6431 if [ $SLOW == "yes" ]; then
6432 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6434 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6437 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6439 # prepare the read-ahead file
6440 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6441 cancel_lru_locks osc
6442 for BIDX in 2 4 8 16 32 64 128 256
6444 local BSIZE=$((BIDX*4096))
6445 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6446 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6447 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6448 $LCTL set_param -n llite.*.read_ahead_stats 0
6449 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6450 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6451 cancel_lru_locks osc
6452 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6457 run_test 101b "check stride-io mode read-ahead ================="
6460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6461 local STRIPE_SIZE=1048576
6462 local FILE_LENGTH=$((STRIPE_SIZE*100))
6466 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6468 cancel_lru_locks osc
6469 $LCTL set_param osc.*.rpc_stats 0
6470 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6471 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6472 local stats=$($LCTL get_param -n $osc_rpc_stats)
6473 local lines=$(echo "$stats" | awk 'END {print NR;}')
6476 if [ $lines -le 20 ]; then
6479 for size in 1 2 4 8; do
6480 local rpc=$(echo "$stats" |
6481 awk '($1 == "'$size':") {print $2; exit; }')
6483 error "Small $((size*4))k read IO $rpc !"
6485 echo "$osc_rpc_stats check passed!"
6490 run_test 101c "check stripe_size aligned read-ahead ================="
6493 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6494 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6499 local file=$DIR/$tfile
6500 local sz_MB=${FILESIZE_101d:-500}
6501 local ra_MB=${READAHEAD_MB:-40}
6503 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6504 [ $free_MB -lt $sz_MB ] &&
6505 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6507 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6508 $SETSTRIPE -c -1 $file || error "setstripe failed"
6510 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6511 echo Cancel LRU locks on lustre client to flush the client cache
6512 cancel_lru_locks osc
6514 echo Disable read-ahead
6515 local old_READAHEAD=$(set_read_ahead 0)
6517 echo Reading the test file $file with read-ahead disabled
6518 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6520 echo Cancel LRU locks on lustre client to flush the client cache
6521 cancel_lru_locks osc
6522 echo Enable read-ahead with ${ra_MB}MB
6523 set_read_ahead $ra_MB
6525 echo Reading the test file $file with read-ahead enabled
6526 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6528 echo "read-ahead disabled time read $raOFF"
6529 echo "read-ahead enabled time read $raON"
6531 set_read_ahead $old_READAHEAD
6533 wait_delete_completed
6535 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6536 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6538 run_test 101d "file read with and without read-ahead enabled"
6541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6542 local file=$DIR/$tfile
6543 local size_KB=500 #KB
6547 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6548 local need_KB=$((count * size_KB))
6549 [[ $free_KB -le $need_KB ]] &&
6550 skip_env "Need free space $need_KB, have $free_KB" && return
6552 echo "Creating $count ${size_KB}K test files"
6553 for ((i = 0; i < $count; i++)); do
6554 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6557 echo "Cancel LRU locks on lustre client to flush the client cache"
6558 cancel_lru_locks osc
6560 echo "Reset readahead stats"
6561 $LCTL set_param -n llite.*.read_ahead_stats 0
6563 for ((i = 0; i < $count; i++)); do
6564 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6567 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6568 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6570 for ((i = 0; i < $count; i++)); do
6571 rm -rf $file.$i 2>/dev/null
6574 #10000 means 20% reads are missing in readahead
6575 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6577 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6580 which iozone || { skip "no iozone installed" && return; }
6582 # create a test file
6583 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
6585 echo Cancel LRU locks on lustre client to flush the client cache
6586 cancel_lru_locks osc
6588 echo Reset readahead stats
6589 $LCTL set_param -n llite.*.read_ahead_stats 0
6591 echo mmap read the file with small block size
6592 iozone -i 1 -+n -r 32k -s 128m -B -f $DIR/$tfile > /dev/null 2>&1
6594 echo checking missing pages
6595 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6596 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6598 [ $miss -lt 3 ] || error "misses too much pages!"
6601 run_test 101f "check mmap read performance"
6604 test_mkdir -p $DIR/$tdir
6605 chown $RUNAS_ID $DIR/$tdir
6608 STRIPE_COUNT=$OSTCOUNT
6609 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6611 trap cleanup_test102 EXIT
6613 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6615 for num in 1 2 3 4; do
6616 for count in $(seq 1 $STRIPE_COUNT); do
6617 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6618 local size=`expr $STRIPE_SIZE \* $num`
6619 local file=file"$num-$idx-$count"
6620 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6626 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6632 rm -rf $DIR/d0.sanity/d102
6636 local testfile=$DIR/$tfile
6640 [ "$UID" != 0 ] && skip_env "must run as root" && return
6641 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6642 skip_env "must have user_xattr" && return
6644 [ -z "$(which setfattr 2>/dev/null)" ] &&
6645 skip_env "could not find setfattr" && return
6647 echo "set/get xattr..."
6648 setfattr -n trusted.name1 -v value1 $testfile ||
6649 error "setfattr -n trusted.name1=value1 $testfile failed"
6650 getfattr -n trusted.name1 $testfile 2> /dev/null |
6651 grep "trusted.name1=.value1" ||
6652 error "$testfile missing trusted.name1=value1"
6654 setfattr -n user.author1 -v author1 $testfile ||
6655 error "setfattr -n user.author1=author1 $testfile failed"
6656 getfattr -n user.author1 $testfile 2> /dev/null |
6657 grep "user.author1=.author1" ||
6658 error "$testfile missing trusted.author1=author1"
6661 setfattr -n trusted.name2 -v value2 $testfile ||
6662 error "$testfile unable to set trusted.name2"
6663 setfattr -n trusted.name3 -v value3 $testfile ||
6664 error "$testfile unable to set trusted.name3"
6665 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6666 grep "trusted.name" | wc -l) -eq 3 ] ||
6667 error "$testfile missing 3 trusted.name xattrs"
6669 setfattr -n user.author2 -v author2 $testfile ||
6670 error "$testfile unable to set user.author2"
6671 setfattr -n user.author3 -v author3 $testfile ||
6672 error "$testfile unable to set user.author3"
6673 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6674 grep "user.author" | wc -l) -eq 3 ] ||
6675 error "$testfile missing 3 user.author xattrs"
6677 echo "remove xattr..."
6678 setfattr -x trusted.name1 $testfile ||
6679 error "$testfile error deleting trusted.name1"
6680 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6681 error "$testfile did not delete trusted.name1 xattr"
6683 setfattr -x user.author1 $testfile ||
6684 error "$testfile error deleting user.author1"
6685 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6686 error "$testfile did not delete trusted.name1 xattr"
6688 # b10667: setting lustre special xattr be silently discarded
6689 echo "set lustre special xattr ..."
6690 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6691 error "$testfile allowed setting trusted.lov"
6693 run_test 102a "user xattr test =================================="
6696 [ -z "$(which setfattr 2>/dev/null)" ] &&
6697 skip_env "could not find setfattr" && return
6699 # b10930: get/set/list trusted.lov xattr
6700 echo "get/set/list trusted.lov xattr ..."
6701 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6702 local testfile=$DIR/$tfile
6703 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6704 error "setstripe failed"
6705 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6706 error "getstripe failed"
6707 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6708 error "can't get trusted.lov from $testfile"
6710 local testfile2=${testfile}2
6711 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6712 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6715 setfattr -n trusted.lov -v $value $testfile2
6716 local stripe_size=$($GETSTRIPE -S $testfile2)
6717 local stripe_count=$($GETSTRIPE -c $testfile2)
6718 [[ $stripe_size -eq 65536 ]] ||
6719 error "stripe size $stripe_size != 65536"
6720 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6721 error "stripe count $stripe_count != $STRIPECOUNT"
6724 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6727 [ -z "$(which setfattr 2>/dev/null)" ] &&
6728 skip_env "could not find setfattr" && return
6730 # b10930: get/set/list lustre.lov xattr
6731 echo "get/set/list lustre.lov xattr ..."
6732 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6733 test_mkdir -p $DIR/$tdir
6734 chown $RUNAS_ID $DIR/$tdir
6735 local testfile=$DIR/$tdir/$tfile
6736 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6737 error "setstripe failed"
6738 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6739 error "getstripe failed"
6740 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6741 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6743 local testfile2=${testfile}2
6744 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6745 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6747 $RUNAS $MCREATE $testfile2
6748 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6749 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6750 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6751 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6752 [ $stripe_count -eq $STRIPECOUNT ] ||
6753 error "stripe count $stripe_count != $STRIPECOUNT"
6755 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6757 compare_stripe_info1() {
6758 local stripe_index_all_zero=true
6760 for num in 1 2 3 4; do
6761 for count in $(seq 1 $STRIPE_COUNT); do
6762 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6763 local size=$((STRIPE_SIZE * num))
6764 local file=file"$num-$offset-$count"
6765 stripe_size=$($LFS getstripe -S $PWD/$file)
6766 [[ $stripe_size -ne $size ]] &&
6767 error "$file: size $stripe_size != $size"
6768 stripe_count=$($LFS getstripe -c $PWD/$file)
6769 # allow fewer stripes to be created, ORI-601
6770 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6771 error "$file: count $stripe_count != $count"
6772 stripe_index=$($LFS getstripe -i $PWD/$file)
6773 [[ $stripe_index -ne 0 ]] &&
6774 stripe_index_all_zero=false
6778 $stripe_index_all_zero &&
6779 error "all files are being extracted starting from OST index 0"
6784 [ -n "$(which tar 2>/dev/null)" ] &&
6785 strings $(which tar) | grep -q "lustre" && echo tar
6789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6790 # b10930: tar test for trusted.lov xattr
6791 TAR=$(find_lustre_tar)
6792 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6793 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6795 test_mkdir -p $DIR/d102d
6796 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6798 compare_stripe_info1
6800 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6803 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6804 # b10930: tar test for trusted.lov xattr
6805 TAR=$(find_lustre_tar)
6806 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6807 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6809 test_mkdir -p $DIR/d102f
6811 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6813 compare_stripe_info1
6815 run_test 102f "tar copy files, not keep osts ==========="
6818 local xsize=${1:-1024} # in bytes
6819 local file=$DIR/$tfile
6821 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6822 skip "must have user_xattr" && return 0
6823 [ -z "$(which setfattr 2>/dev/null)" ] &&
6824 skip_env "could not find setfattr" && return 0
6825 [ -z "$(which getfattr 2>/dev/null)" ] &&
6826 skip_env "could not find getfattr" && return 0
6830 local value="$(generate_string $xsize)"
6832 local xbig=trusted.big
6833 log "save $xbig on $file"
6834 setfattr -n $xbig -v $value $file ||
6835 error "saving $xbig on $file failed"
6837 local orig=$(get_xattr_value $xbig $file)
6838 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6840 local xsml=trusted.sml
6841 log "save $xsml on $file"
6842 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6844 local new=$(get_xattr_value $xbig $file)
6845 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6847 log "grow $xsml on $file"
6848 setfattr -n $xsml -v "$value" $file ||
6849 error "growing $xsml on $file failed"
6851 new=$(get_xattr_value $xbig $file)
6852 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6853 log "$xbig still valid after growing $xsml"
6858 test_102h() { # bug 15777
6861 run_test 102h "grow xattr from inside inode to external block"
6864 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6865 grow_xattr $(max_xattr_size)
6867 run_test 102ha "grow xattr from inside inode to external inode"
6869 test_102i() { # bug 17038
6870 [ -z "$(which getfattr 2>/dev/null)" ] &&
6871 skip "could not find getfattr" && return
6873 ln -s $DIR/$tfile $DIR/${tfile}link
6874 getfattr -n trusted.lov $DIR/$tfile ||
6875 error "lgetxattr on $DIR/$tfile failed"
6876 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6877 grep -i "no such attr" ||
6878 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6879 rm -f $DIR/$tfile $DIR/${tfile}link
6881 run_test 102i "lgetxattr test on symbolic link ============"
6884 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6885 TAR=$(find_lustre_tar)
6886 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6887 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6888 setup_test102 "$RUNAS"
6889 test_mkdir -p $DIR/d102j
6890 chown $RUNAS_ID $DIR/d102j
6891 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6893 compare_stripe_info1 "$RUNAS"
6895 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6898 [ -z "$(which setfattr 2>/dev/null)" ] &&
6899 skip "could not find setfattr" && return
6901 # b22187 just check that does not crash for regular file.
6902 setfattr -n trusted.lov $DIR/$tfile
6903 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6904 local test_kdir=$DIR/d102k
6905 test_mkdir $test_kdir
6906 local default_size=`$GETSTRIPE -S $test_kdir`
6907 local default_count=`$GETSTRIPE -c $test_kdir`
6908 local default_offset=`$GETSTRIPE -i $test_kdir`
6909 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6910 error 'dir setstripe failed'
6911 setfattr -n trusted.lov $test_kdir
6912 local stripe_size=`$GETSTRIPE -S $test_kdir`
6913 local stripe_count=`$GETSTRIPE -c $test_kdir`
6914 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6915 [ $stripe_size -eq $default_size ] ||
6916 error "stripe size $stripe_size != $default_size"
6917 [ $stripe_count -eq $default_count ] ||
6918 error "stripe count $stripe_count != $default_count"
6919 [ $stripe_offset -eq $default_offset ] ||
6920 error "stripe offset $stripe_offset != $default_offset"
6921 rm -rf $DIR/$tfile $test_kdir
6923 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6926 [ -z "$(which getfattr 2>/dev/null)" ] &&
6927 skip "could not find getfattr" && return
6929 # LU-532 trusted. xattr is invisible to non-root
6930 local testfile=$DIR/$tfile
6934 echo "listxattr as user..."
6935 chown $RUNAS_ID $testfile
6936 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6937 grep -q "trusted" &&
6938 error "$testfile trusted xattrs are user visible"
6942 run_test 102l "listxattr size test =================================="
6944 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6945 local path=$DIR/$tfile
6948 listxattr_size_check $path || error "listattr_size_check $path failed"
6950 run_test 102m "Ensure listxattr fails on small bufffer ========"
6954 getxattr() { # getxattr path name
6955 # Return the base64 encoding of the value of xattr name on path.
6959 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6961 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6963 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6965 getfattr --absolute-names --encoding=base64 --name=$name $path |
6966 awk -F= -v name=$name '$1 == name {
6967 print substr($0, index($0, "=") + 1);
6971 test_102n() { # LU-4101 mdt: protect internal xattrs
6972 local file0=$DIR/$tfile.0
6973 local file1=$DIR/$tfile.1
6974 local xattr0=$TMP/$tfile.0
6975 local xattr1=$TMP/$tfile.1
6979 [ -z "$(which setfattr 2>/dev/null)" ] &&
6980 skip "could not find setfattr" && return
6982 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6984 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6988 rm -rf $file0 $file1 $xattr0 $xattr1
6991 # Get 'before' xattrs of $file1.
6992 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6994 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6995 # Try to copy xattr from $file0 to $file1.
6996 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6998 setfattr --name=trusted.$name --value="$value" $file1 ||
6999 error "setxattr 'trusted.$name' failed"
7001 # Try to set a garbage xattr.
7002 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7004 setfattr --name=trusted.$name --value="$value" $file1 ||
7005 error "setxattr 'trusted.$name' failed"
7007 # Try to remove the xattr from $file1. We don't care if this
7008 # appears to succeed or fail, we just don't want there to be
7009 # any changes or crashes.
7010 setfattr --remove=$trusted.$name $file1 2> /dev/null
7013 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
7016 # Try to copy xattr from $file0 to $file1.
7017 value=$(getxattr $file0 trusted.$name 2> /dev/null)
7019 setfattr --name=trusted.$name --value="$value" $file1 ||
7020 error "setxattr 'trusted.$name' failed"
7022 # Try to set a garbage xattr.
7023 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
7025 setfattr --name=trusted.$name --value="$value" $file1 ||
7026 error "setxattr 'trusted.$name' failed"
7028 # Try to remove the xattr from $file1. We don't care if this
7029 # appears to succeed or fail, we just don't want there to be
7030 # any changes or crashes.
7031 setfattr --remove=$trusted.$name $file1 2> /dev/null
7034 # Get 'after' xattrs of file1.
7035 getfattr --absolute-names --dump --match=- $file1 > $xattr1
7037 if ! diff $xattr0 $xattr1; then
7038 error "before and after xattrs of '$file1' differ"
7041 rm -rf $file0 $file1 $xattr0 $xattr1
7045 run_test 102n "silently ignore setxattr on internal trusted xattrs"
7047 test_102p() { # LU-4703 setxattr did not check ownership
7048 local testfile=$DIR/$tfile
7050 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
7051 skip "MDS needs to be at least 2.5.56" && return
7055 echo "setfacl as user..."
7056 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
7057 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
7059 echo "setfattr as user..."
7060 setfacl -m "u:$RUNAS_ID:---" $testfile
7061 $RUNAS setfattr -x system.posix_acl_access $testfile
7062 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
7064 run_test 102p "check setxattr(2) correctly fails without permission"
7067 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
7068 skip "MDS needs to be at least 2.6.92" && return
7069 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
7071 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
7074 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
7075 skip "MDS needs to be at least 2.6.93" && return
7076 touch $DIR/$tfile || error "touch"
7077 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
7078 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
7079 rm $DIR/$tfile || error "rm"
7082 mkdir -p $DIR/$tdir || error "mkdir"
7083 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7084 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7085 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7086 error "$testfile error deleting user.author1"
7087 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7088 grep "user.$(basename $tdir)" &&
7089 error "$tdir did not delete user.$(basename $tdir)"
7090 rmdir $DIR/$tdir || error "rmdir"
7093 test_mkdir -p $DIR/$tdir || error "make striped dir"
7094 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
7095 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
7096 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
7097 error "$testfile error deleting user.author1"
7098 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
7099 grep "user.$(basename $tdir)" &&
7100 error "$tdir did not delete user.$(basename $tdir)"
7101 rmdir $DIR/$tdir || error "rm striped dir"
7103 run_test 102r "set EAs with empty values"
7107 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
7112 [ "$UID" != 0 ] && skip_env "must run as root" && return
7113 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
7114 skip "must have acl enabled" && return
7115 [ -z "$(which setfacl 2>/dev/null)" ] &&
7116 skip_env "could not find setfacl" && return
7117 $GSS && skip "could not run under gss" && return
7119 gpasswd -a daemon bin # LU-5641
7120 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7122 declare -a identity_old
7124 for num in $(seq $MDSCOUNT); do
7125 switch_identity $num true || identity_old[$num]=$?
7132 echo "performing cp ..."
7133 run_acl_subtest cp || error "run_acl_subtest cp failed"
7134 echo "performing getfacl-noacl..."
7135 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7136 echo "performing misc..."
7137 run_acl_subtest misc || error "misc test failed"
7138 echo "performing permissions..."
7139 run_acl_subtest permissions || error "permissions failed"
7140 echo "performing setfacl..."
7141 run_acl_subtest setfacl || error "setfacl test failed"
7143 # inheritance test got from HP
7144 echo "performing inheritance..."
7145 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7146 chmod +x make-tree || error "chmod +x failed"
7147 run_acl_subtest inheritance || error "inheritance test failed"
7150 echo "LU-974 ignore umask when acl is enabled..."
7151 run_acl_subtest 974 || error "LU-974 umask test failed"
7152 if [ $MDSCOUNT -ge 2 ]; then
7153 run_acl_subtest 974_remote ||
7154 error "LU-974 umask test failed under remote dir"
7157 echo "LU-2561 newly created file is same size as directory..."
7158 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7159 run_acl_subtest 2561 || error "LU-2561 test failed"
7161 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7164 run_acl_subtest 4924 || error "LU-4924 test failed"
7169 for num in $(seq $MDSCOUNT); do
7170 if [ "${identity_old[$num]}" = 1 ]; then
7171 switch_identity $num false || identity_old[$num]=$?
7175 run_test 103a "acl test ========================================="
7179 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7180 local mountopts=$MDS_MOUNT_OPTS
7182 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7186 stop $SINGLEMDS || error "failed to stop MDT."
7188 if [ -z "$MDS_MOUNT_OPTS" ]; then
7189 MDS_MOUNT_OPTS="-o noacl"
7191 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7193 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7194 error "failed to start MDT."
7195 MDS_MOUNT_OPTS=$mountopts
7199 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7203 stop $SINGLEMDS || error "failed to stop MDT."
7205 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7206 error "failed to start MDT."
7211 run_test 103b "MDS mount option 'noacl'"
7215 cp -rp $DIR/$tdir $DIR/$tdir.bak
7217 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7218 error "$DIR/$tdir shouldn't contain default ACL"
7219 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7220 error "$DIR/$tdir.bak shouldn't contain default ACL"
7223 run_test 103c "'cp -rp' won't set empty acl"
7226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7228 lfs df || error "lfs df failed"
7229 lfs df -ih || error "lfs df -ih failed"
7230 lfs df -h $DIR || error "lfs df -h $DIR failed"
7231 lfs df -i $DIR || error "lfs df -i $DIR failed"
7232 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7233 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7235 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7236 lctl --device %$OSC deactivate
7237 lfs df || error "lfs df with deactivated OSC failed"
7238 lctl --device %$OSC activate
7239 # wait the osc back to normal
7240 wait_osc_import_state client ost FULL
7242 lfs df || error "lfs df with reactivated OSC failed"
7245 run_test 104a "lfs df [-ih] [path] test ========================="
7248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7249 [ $RUNAS_ID -eq $UID ] &&
7250 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7252 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7253 grep "Permission denied" | wc -l)))
7254 if [ $denied_cnt -ne 0 ]; then
7255 error "lfs check servers test failed"
7258 run_test 104b "$RUNAS lfs check servers test ===================="
7261 # doesn't work on 2.4 kernels
7263 if $(flock_is_enabled); then
7264 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7266 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7270 run_test 105a "flock when mounted without -o flock test ========"
7274 if $(flock_is_enabled); then
7275 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7277 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7281 run_test 105b "fcntl when mounted without -o flock test ========"
7285 if $(flock_is_enabled); then
7286 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7288 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7292 run_test 105c "lockf when mounted without -o flock test ========"
7294 test_105d() { # bug 15924
7295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7296 test_mkdir -p $DIR/$tdir
7297 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7298 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7299 $LCTL set_param fail_loc=0x80000315
7300 flocks_test 2 $DIR/$tdir
7302 run_test 105d "flock race (should not freeze) ========"
7304 test_105e() { # bug 22660 && 22040
7305 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7307 flocks_test 3 $DIR/$tfile
7309 run_test 105e "Two conflicting flocks from same process ======="
7311 test_106() { #bug 10921
7312 test_mkdir -p $DIR/$tdir
7313 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7314 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7316 run_test 106 "attempt exec of dir followed by chown of that dir"
7319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7326 local save_pattern=$(sysctl -n kernel.core_pattern)
7327 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7328 sysctl -w kernel.core_pattern=$file
7329 sysctl -w kernel.core_uses_pid=0
7337 kill -s 11 $SLEEPPID
7339 if [ -e $file ]; then
7340 size=`stat -c%s $file`
7341 [ $size -eq 0 ] && error "Fail to create core file $file"
7343 error "Fail to create core file $file"
7346 sysctl -w kernel.core_pattern=$save_pattern
7347 sysctl -w kernel.core_uses_pid=$save_uses_pid
7350 run_test 107 "Coredump on SIG"
7353 test_mkdir -p $DIR/$tdir
7354 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7355 error "mkdir with 255 char failed"
7356 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7357 error "mkdir with 256 char should fail, but did not"
7358 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7359 error "create with 255 char failed"
7360 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7361 error "create with 256 char should fail, but did not"
7366 run_test 110 "filename length checking"
7369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7370 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7371 tail -1 | cut -c11-20)
7372 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7373 echo "Starting with $OSTIO_pre threads"
7376 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7377 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7378 echo "$NUMTEST creates/unlinks"
7379 test_mkdir -p $DIR/$tdir
7380 createmany -o $DIR/$tdir/$tfile $NUMTEST
7381 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7383 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7384 tail -1 | cut -c11-20)
7386 # don't return an error
7387 [ $OSTIO_post == $OSTIO_pre ] && echo \
7388 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7389 echo "This may be fine, depending on what ran before this test" &&
7390 echo "and how fast this system is." && return
7392 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7394 run_test 115 "verify dynamic thread creation===================="
7397 wait_delete_completed
7398 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7399 echo OST kbytes available: ${AVAIL[@]}
7400 MAXI=0; MAXV=${AVAIL[0]}
7401 MINI=0; MINV=${AVAIL[0]}
7402 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7403 #echo OST $i: ${AVAIL[i]}kb
7404 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7405 MAXV=${AVAIL[i]}; MAXI=$i
7407 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7408 MINV=${AVAIL[i]}; MINI=$i
7411 echo Min free space: OST $MINI: $MINV
7412 echo Max free space: OST $MAXI: $MAXV
7415 test_116a() { # was previously test_116()
7416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7417 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7419 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7421 echo -n "Free space priority "
7422 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7427 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7428 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7430 trap simple_cleanup_common EXIT
7433 # Check if we need to generate uneven OSTs
7434 test_mkdir -p $DIR/$tdir/OST${MINI}
7435 local FILL=$(($MINV / 4))
7436 local DIFF=$(($MAXV - $MINV))
7437 local DIFF2=$(($DIFF * 100 / $MINV))
7439 local threshold=$(do_facet $SINGLEMDS \
7440 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7441 threshold=${threshold%%%}
7442 echo -n "Check for uneven OSTs: "
7443 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7445 if [[ $DIFF2 -gt $threshold ]]; then
7447 echo "Don't need to fill OST$MINI"
7449 # generate uneven OSTs. Write 2% over the QOS threshold value
7451 DIFF=$(($threshold - $DIFF2 + 2))
7452 DIFF2=$(( ($MINV * $DIFF)/100 ))
7453 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7454 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7455 error "setstripe failed"
7456 DIFF=$(($DIFF2 / 2048))
7458 while [ $i -lt $DIFF ]; do
7460 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7461 bs=2M count=1 2>/dev/null
7470 DIFF=$(($MAXV - $MINV))
7471 DIFF2=$(($DIFF * 100 / $MINV))
7472 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7473 if [[ $DIFF2 -gt $threshold ]]; then
7476 echo "failed - QOS mode won't be used"
7477 skip "QOS imbalance criteria not met"
7478 simple_cleanup_common
7482 MINI1=$MINI; MINV1=$MINV
7483 MAXI1=$MAXI; MAXV1=$MAXV
7485 # now fill using QOS
7486 $SETSTRIPE -c 1 $DIR/$tdir
7487 FILL=$(($FILL / 200))
7488 if [ $FILL -gt 600 ]; then
7491 echo "writing $FILL files to QOS-assigned OSTs"
7493 while [ $i -lt $FILL ]; do
7495 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7499 echo "wrote $i 200k files"
7503 echo "Note: free space may not be updated, so measurements might be off"
7505 DIFF2=$(($MAXV - $MINV))
7506 echo "free space delta: orig $DIFF final $DIFF2"
7507 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7508 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7509 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7510 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7511 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7512 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7514 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7516 # Figure out which files were written where
7517 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7518 awk '/'$MINI1': / {print $2; exit}')
7520 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7521 echo "$MINC files created on smaller OST $MINI1"
7522 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7523 awk '/'$MAXI1': / {print $2; exit}')
7525 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7526 echo "$MAXC files created on larger OST $MAXI1"
7527 FILL=$(($MAXC * 100 / $MINC - 100))
7528 [[ $MINC -gt 0 ]] &&
7529 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7530 [[ $MAXC -gt $MINC ]] ||
7531 error_ignore LU-9 "stripe QOS didn't balance free space"
7532 simple_cleanup_common
7534 run_test 116a "stripe QOS: free space balance ==================="
7536 test_116b() { # LU-2093
7537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7538 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7540 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7541 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7542 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7543 [ -z "$old_rr" ] && skip "no QOS" && return 0
7544 do_facet $SINGLEMDS lctl set_param \
7545 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7547 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7548 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7549 do_facet $SINGLEMDS lctl set_param fail_loc=0
7551 do_facet $SINGLEMDS lctl set_param \
7552 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7554 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7556 test_117() # bug 10891
7558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7559 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7560 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7561 lctl set_param fail_loc=0x21e
7562 > $DIR/$tfile || error "truncate failed"
7563 lctl set_param fail_loc=0
7564 echo "Truncate succeeded."
7567 run_test 117 "verify osd extend =========="
7569 NO_SLOW_RESENDCOUNT=4
7570 export OLD_RESENDCOUNT=""
7571 set_resend_count () {
7572 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7573 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7574 lctl set_param -n $PROC_RESENDCOUNT $1
7575 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7578 # for reduce test_118* time (b=14842)
7579 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7581 # Reset async IO behavior after error case
7583 FILE=$DIR/reset_async
7585 # Ensure all OSCs are cleared
7586 $SETSTRIPE -c -1 $FILE
7587 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7592 test_118a() #bug 11710
7594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7597 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7598 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7599 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7601 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7602 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7607 run_test 118a "verify O_SYNC works =========="
7611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7612 remote_ost_nodsh && skip "remote OST with nodsh" && return
7616 #define OBD_FAIL_SRV_ENOENT 0x217
7617 set_nodes_failloc "$(osts_nodes)" 0x217
7618 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7620 set_nodes_failloc "$(osts_nodes)" 0
7621 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7622 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7625 if [[ $RC -eq 0 ]]; then
7626 error "Must return error due to dropped pages, rc=$RC"
7630 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7631 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7635 echo "Dirty pages not leaked on ENOENT"
7637 # Due to the above error the OSC will issue all RPCs syncronously
7638 # until a subsequent RPC completes successfully without error.
7639 $MULTIOP $DIR/$tfile Ow4096yc
7644 run_test 118b "Reclaim dirty pages on fatal error =========="
7648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7650 # for 118c, restore the original resend count, LU-1940
7651 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7652 set_resend_count $OLD_RESENDCOUNT
7653 remote_ost_nodsh && skip "remote OST with nodsh" && return
7657 #define OBD_FAIL_OST_EROFS 0x216
7658 set_nodes_failloc "$(osts_nodes)" 0x216
7660 # multiop should block due to fsync until pages are written
7661 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7665 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7666 error "Multiop failed to block on fsync, pid=$MULTIPID"
7669 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7671 if [[ $WRITEBACK -eq 0 ]]; then
7672 error "No page in writeback, writeback=$WRITEBACK"
7675 set_nodes_failloc "$(osts_nodes)" 0
7678 if [[ $RC -ne 0 ]]; then
7679 error "Multiop fsync failed, rc=$RC"
7682 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7683 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7685 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7686 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7690 echo "Dirty pages flushed via fsync on EROFS"
7693 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7695 # continue to use small resend count to reduce test_118* time (b=14842)
7696 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7701 remote_ost_nodsh && skip "remote OST with nodsh" && return
7705 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7706 set_nodes_failloc "$(osts_nodes)" 0x214
7707 # multiop should block due to fsync until pages are written
7708 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7712 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7713 error "Multiop failed to block on fsync, pid=$MULTIPID"
7716 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7718 if [[ $WRITEBACK -eq 0 ]]; then
7719 error "No page in writeback, writeback=$WRITEBACK"
7722 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7723 set_nodes_failloc "$(osts_nodes)" 0
7725 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7726 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7728 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7729 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7733 echo "Dirty pages gaurenteed flushed via fsync"
7736 run_test 118d "Fsync validation inject a delay of the bulk =========="
7739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7742 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7743 lctl set_param fail_loc=0x8000040a
7745 # Should simulate EINVAL error which is fatal
7746 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7748 if [[ $RC -eq 0 ]]; then
7749 error "Must return error due to dropped pages, rc=$RC"
7752 lctl set_param fail_loc=0x0
7754 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7755 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7756 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7758 if [[ $LOCKED -ne 0 ]]; then
7759 error "Locked pages remain in cache, locked=$LOCKED"
7762 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7763 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7767 echo "No pages locked after fsync"
7772 run_test 118f "Simulate unrecoverable OSC side error =========="
7775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7778 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7779 lctl set_param fail_loc=0x406
7781 # simulate local -ENOMEM
7782 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7785 lctl set_param fail_loc=0
7786 if [[ $RC -eq 0 ]]; then
7787 error "Must return error due to dropped pages, rc=$RC"
7790 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7791 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7792 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7794 if [[ $LOCKED -ne 0 ]]; then
7795 error "Locked pages remain in cache, locked=$LOCKED"
7798 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7799 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7803 echo "No pages locked after fsync"
7808 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7812 remote_ost_nodsh && skip "remote OST with nodsh" && return
7816 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7817 set_nodes_failloc "$(osts_nodes)" 0x20e
7818 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7819 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7822 set_nodes_failloc "$(osts_nodes)" 0
7823 if [[ $RC -eq 0 ]]; then
7824 error "Must return error due to dropped pages, rc=$RC"
7827 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7828 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7829 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7831 if [[ $LOCKED -ne 0 ]]; then
7832 error "Locked pages remain in cache, locked=$LOCKED"
7835 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7836 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7840 echo "No pages locked after fsync"
7844 run_test 118h "Verify timeout in handling recoverables errors =========="
7846 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7850 remote_ost_nodsh && skip "remote OST with nodsh" && return
7854 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7855 set_nodes_failloc "$(osts_nodes)" 0x20e
7857 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7858 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7861 set_nodes_failloc "$(osts_nodes)" 0
7865 if [[ $RC -ne 0 ]]; then
7866 error "got error, but should be not, rc=$RC"
7869 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7870 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7871 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7872 if [[ $LOCKED -ne 0 ]]; then
7873 error "Locked pages remain in cache, locked=$LOCKED"
7876 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7877 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7881 echo "No pages locked after fsync"
7885 run_test 118i "Fix error before timeout in recoverable error =========="
7887 [ "$SLOW" = "no" ] && set_resend_count 4
7890 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7891 remote_ost_nodsh && skip "remote OST with nodsh" && return
7895 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7896 set_nodes_failloc "$(osts_nodes)" 0x220
7898 # return -EIO from OST
7899 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7901 set_nodes_failloc "$(osts_nodes)" 0x0
7902 if [[ $RC -eq 0 ]]; then
7903 error "Must return error due to dropped pages, rc=$RC"
7906 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7907 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7908 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7909 if [[ $LOCKED -ne 0 ]]; then
7910 error "Locked pages remain in cache, locked=$LOCKED"
7913 # in recoverable error on OST we want resend and stay until it finished
7914 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7915 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7919 echo "No pages locked after fsync"
7923 run_test 118j "Simulate unrecoverable OST side error =========="
7927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7928 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7930 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7931 set_nodes_failloc "$(osts_nodes)" 0x20e
7932 test_mkdir -p $DIR/$tdir
7934 for ((i=0;i<10;i++)); do
7935 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7936 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7943 set_nodes_failloc "$(osts_nodes)" 0
7946 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7952 test_mkdir -p $DIR/$tdir
7953 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7956 run_test 118l "fsync dir ========="
7958 test_118m() # LU-3066
7960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7961 test_mkdir -p $DIR/$tdir
7962 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7965 run_test 118m "fdatasync dir ========="
7967 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7969 test_119a() # bug 11737
7971 BSIZE=$((512 * 1024))
7972 directio write $DIR/$tfile 0 1 $BSIZE
7973 # We ask to read two blocks, which is more than a file size.
7974 # directio will indicate an error when requested and actual
7975 # sizes aren't equeal (a normal situation in this case) and
7976 # print actual read amount.
7977 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7978 if [ "$NOB" != "$BSIZE" ]; then
7979 error "read $NOB bytes instead of $BSIZE"
7983 run_test 119a "Short directIO read must return actual read amount"
7985 test_119b() # bug 11737
7987 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7989 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7990 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7992 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7993 error "direct read failed"
7996 run_test 119b "Sparse directIO read must return actual read amount"
7998 test_119c() # bug 13099
8001 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
8002 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
8005 run_test 119c "Testing for direct read hitting hole"
8007 test_119d() # bug 15950
8009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8010 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
8011 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
8013 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
8014 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
8015 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
8016 lctl set_param fail_loc=0x40d
8017 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
8020 cat $DIR/$tfile > /dev/null &
8021 lctl set_param fail_loc=0
8024 log "the DIO writes have completed, now wait for the reads (should not block very long)"
8026 [ -n "`ps h -p $pid_reads -o comm`" ] && \
8027 error "the read rpcs have not completed in 2s"
8029 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
8031 run_test 119d "The DIO path should try to send a new rpc once one is completed"
8034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8035 test_mkdir -p $DIR/$tdir
8036 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8037 skip "no early lock cancel on server" && return 0
8039 lru_resize_disable mdc
8040 lru_resize_disable osc
8041 cancel_lru_locks mdc
8042 # asynchronous object destroy at MDT could cause bl ast to client
8043 cancel_lru_locks osc
8045 stat $DIR/$tdir > /dev/null
8046 can1=$(do_facet $SINGLEMDS \
8047 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8048 awk '/ldlm_cancel/ {print $2}')
8049 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8050 awk '/ldlm_bl_callback/ {print $2}')
8051 test_mkdir -c1 $DIR/$tdir/d1
8052 can2=$(do_facet $SINGLEMDS \
8053 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8054 awk '/ldlm_cancel/ {print $2}')
8055 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8056 awk '/ldlm_bl_callback/ {print $2}')
8057 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8058 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8059 lru_resize_enable mdc
8060 lru_resize_enable osc
8062 run_test 120a "Early Lock Cancel: mkdir test"
8065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8066 test_mkdir $DIR/$tdir
8067 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8068 skip "no early lock cancel on server" && return 0
8069 lru_resize_disable mdc
8070 lru_resize_disable osc
8071 cancel_lru_locks mdc
8072 stat $DIR/$tdir > /dev/null
8073 can1=$(do_facet $SINGLEMDS \
8074 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8075 awk '/ldlm_cancel/ {print $2}')
8076 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8077 awk '/ldlm_bl_callback/ {print $2}')
8079 can2=$(do_facet $SINGLEMDS \
8080 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8081 awk '/ldlm_cancel/ {print $2}')
8082 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8083 awk '/ldlm_bl_callback/ {print $2}')
8084 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8085 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8086 lru_resize_enable mdc
8087 lru_resize_enable osc
8089 run_test 120b "Early Lock Cancel: create test"
8092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8093 test_mkdir -c1 $DIR/$tdir
8094 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8095 skip "no early lock cancel on server" && return 0
8096 lru_resize_disable mdc
8097 lru_resize_disable osc
8098 test_mkdir -p -c1 $DIR/$tdir/d1
8099 test_mkdir -p -c1 $DIR/$tdir/d2
8100 touch $DIR/$tdir/d1/f1
8101 cancel_lru_locks mdc
8102 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
8103 can1=$(do_facet $SINGLEMDS \
8104 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8105 awk '/ldlm_cancel/ {print $2}')
8106 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8107 awk '/ldlm_bl_callback/ {print $2}')
8108 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8109 can2=$(do_facet $SINGLEMDS \
8110 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8111 awk '/ldlm_cancel/ {print $2}')
8112 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8113 awk '/ldlm_bl_callback/ {print $2}')
8114 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8115 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8116 lru_resize_enable mdc
8117 lru_resize_enable osc
8119 run_test 120c "Early Lock Cancel: link test"
8122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8123 test_mkdir -p -c1 $DIR/$tdir
8124 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8125 skip "no early lock cancel on server" && return 0
8126 lru_resize_disable mdc
8127 lru_resize_disable osc
8129 cancel_lru_locks mdc
8130 stat $DIR/$tdir > /dev/null
8131 can1=$(do_facet $SINGLEMDS \
8132 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8133 awk '/ldlm_cancel/ {print $2}')
8134 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8135 awk '/ldlm_bl_callback/ {print $2}')
8136 chmod a+x $DIR/$tdir
8137 can2=$(do_facet $SINGLEMDS \
8138 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8139 awk '/ldlm_cancel/ {print $2}')
8140 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8141 awk '/ldlm_bl_callback/ {print $2}')
8142 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8143 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8144 lru_resize_enable mdc
8145 lru_resize_enable osc
8147 run_test 120d "Early Lock Cancel: setattr test"
8150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8151 ! $($LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_can) &&
8152 skip "no early lock cancel on server" && return 0
8153 local dlmtrace_set=false
8155 test_mkdir -p -c1 $DIR/$tdir
8156 lru_resize_disable mdc
8157 lru_resize_disable osc
8158 ! $LCTL get_param debug | grep -q dlmtrace &&
8159 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
8160 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8161 cancel_lru_locks mdc
8162 cancel_lru_locks osc
8163 dd if=$DIR/$tdir/f1 of=/dev/null
8164 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8165 # XXX client can not do early lock cancel of OST lock
8166 # during unlink (LU-4206), so cancel osc lock now.
8167 cancel_lru_locks osc
8168 can1=$(do_facet $SINGLEMDS \
8169 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8170 awk '/ldlm_cancel/ {print $2}')
8171 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8172 awk '/ldlm_bl_callback/ {print $2}')
8173 unlink $DIR/$tdir/f1
8175 can2=$(do_facet $SINGLEMDS \
8176 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8177 awk '/ldlm_cancel/ {print $2}')
8178 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8179 awk '/ldlm_bl_callback/ {print $2}')
8180 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
8181 $LCTL dk $TMP/cancel.debug.txt
8182 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
8183 $LCTL dk $TMP/blocking.debug.txt
8184 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
8185 lru_resize_enable mdc
8186 lru_resize_enable osc
8188 run_test 120e "Early Lock Cancel: unlink test"
8191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8192 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8193 skip "no early lock cancel on server" && return 0
8194 test_mkdir -p -c1 $DIR/$tdir
8195 lru_resize_disable mdc
8196 lru_resize_disable osc
8197 test_mkdir -p -c1 $DIR/$tdir/d1
8198 test_mkdir -p -c1 $DIR/$tdir/d2
8199 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8200 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8201 cancel_lru_locks mdc
8202 cancel_lru_locks osc
8203 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8204 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8205 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8206 # XXX client can not do early lock cancel of OST lock
8207 # during rename (LU-4206), so cancel osc lock now.
8208 cancel_lru_locks osc
8209 can1=$(do_facet $SINGLEMDS \
8210 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8211 awk '/ldlm_cancel/ {print $2}')
8212 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8213 awk '/ldlm_bl_callback/ {print $2}')
8214 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8216 can2=$(do_facet $SINGLEMDS \
8217 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8218 awk '/ldlm_cancel/ {print $2}')
8219 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8220 awk '/ldlm_bl_callback/ {print $2}')
8221 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8222 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8223 lru_resize_enable mdc
8224 lru_resize_enable osc
8226 run_test 120f "Early Lock Cancel: rename test"
8229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8230 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8231 skip "no early lock cancel on server" && return 0
8232 lru_resize_disable mdc
8233 lru_resize_disable osc
8235 echo create $count files
8236 test_mkdir -p $DIR/$tdir
8237 cancel_lru_locks mdc
8238 cancel_lru_locks osc
8241 can0=$(do_facet $SINGLEMDS \
8242 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8243 awk '/ldlm_cancel/ {print $2}')
8244 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8245 awk '/ldlm_bl_callback/ {print $2}')
8246 createmany -o $DIR/$tdir/f $count
8248 can1=$(do_facet $SINGLEMDS \
8249 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8250 awk '/ldlm_cancel/ {print $2}')
8251 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8252 awk '/ldlm_bl_callback/ {print $2}')
8254 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8255 echo rm $count files
8258 can2=$(do_facet $SINGLEMDS \
8259 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8260 awk '/ldlm_cancel/ {print $2}')
8261 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8262 awk '/ldlm_bl_callback/ {print $2}')
8264 echo total: $count removes in $((t2-t1))
8265 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8267 # wait for commitment of removal
8268 lru_resize_enable mdc
8269 lru_resize_enable osc
8271 run_test 120g "Early Lock Cancel: performance test"
8273 test_121() { #bug #10589
8274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8276 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8277 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8278 lctl set_param fail_loc=0x310
8279 cancel_lru_locks osc > /dev/null
8280 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8281 lctl set_param fail_loc=0
8282 [[ $reads -eq $writes ]] ||
8283 error "read $reads blocks, must be $writes blocks"
8285 run_test 121 "read cancel race ========="
8287 test_123a() { # was test 123, statahead(bug 11401)
8288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8290 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8291 log "testing on UP system. Performance may be not as good as expected."
8296 test_mkdir -p $DIR/$tdir
8297 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8298 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8300 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8301 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8303 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8304 lctl set_param -n llite.*.statahead_max 0
8305 lctl get_param llite.*.statahead_max
8306 cancel_lru_locks mdc
8307 cancel_lru_locks osc
8309 time ls -l $DIR/$tdir | wc -l
8311 delta=$((etime - stime))
8312 log "ls $i files without statahead: $delta sec"
8313 lctl set_param llite.*.statahead_max=$max
8315 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8316 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8317 cancel_lru_locks mdc
8318 cancel_lru_locks osc
8320 time ls -l $DIR/$tdir | wc -l
8322 delta_sa=$((etime - stime))
8323 log "ls $i files with statahead: $delta_sa sec"
8324 lctl get_param -n llite.*.statahead_stats
8325 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8327 [[ $swrong -lt $ewrong ]] &&
8328 log "statahead was stopped, maybe too many locks held!"
8329 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8331 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8332 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8333 lctl set_param -n llite.*.statahead_max 0
8334 lctl get_param llite.*.statahead_max
8335 cancel_lru_locks mdc
8336 cancel_lru_locks osc
8338 time ls -l $DIR/$tdir | wc -l
8340 delta=$((etime - stime))
8341 log "ls $i files again without statahead: $delta sec"
8342 lctl set_param llite.*.statahead_max=$max
8343 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8344 if [ $SLOWOK -eq 0 ]; then
8345 error "ls $i files is slower with statahead!"
8347 log "ls $i files is slower with statahead!"
8353 [ $delta -gt 20 ] && break
8354 [ $delta -gt 8 ] && MULT=$((50 / delta))
8355 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8363 delta=$((etime - stime))
8364 log "rm -r $DIR/$tdir/: $delta seconds"
8366 lctl get_param -n llite.*.statahead_stats
8368 run_test 123a "verify statahead work"
8370 test_123b () { # statahead(bug 15027)
8371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8372 test_mkdir -p $DIR/$tdir
8373 createmany -o $DIR/$tdir/$tfile-%d 1000
8375 cancel_lru_locks mdc
8376 cancel_lru_locks osc
8378 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8379 lctl set_param fail_loc=0x80000803
8380 ls -lR $DIR/$tdir > /dev/null
8382 lctl set_param fail_loc=0x0
8383 lctl get_param -n llite.*.statahead_stats
8388 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8392 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8393 skip "no lru resize on server" && return 0
8395 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8397 log "create $NR files at $DIR/$tdir"
8398 createmany -o $DIR/$tdir/f $NR ||
8399 error "failed to create $NR files in $DIR/$tdir"
8401 cancel_lru_locks mdc
8402 ls -l $DIR/$tdir > /dev/null
8406 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8407 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8408 LRU_SIZE=$($LCTL get_param -n $PARAM)
8409 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8410 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8412 log "NS=$(basename $NSDIR)"
8417 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8418 skip "Not enough cached locks created!"
8425 # We know that lru resize allows one client to hold $LIMIT locks
8426 # for 10h. After that locks begin to be killed by client.
8428 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8430 if [ $LIMIT -lt $LRU_SIZE ]; then
8431 skip "Limit is too small $LIMIT"
8435 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8436 # killing locks. Some time was spent for creating locks. This means
8437 # that up to the moment of sleep finish we must have killed some of
8438 # them (10-100 locks). This depends on how fast ther were created.
8439 # Many of them were touched in almost the same moment and thus will
8440 # be killed in groups.
8441 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8443 # Use $LRU_SIZE_B here to take into account real number of locks
8444 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8445 local LRU_SIZE_B=$LRU_SIZE
8447 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8448 log "OLD_LVF=$OLD_LVF"
8449 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8451 # Let's make sure that we really have some margin. Client checks
8452 # cached locks every 10 sec.
8454 log "Sleep ${SLEEP} sec"
8456 while ((SEC<$SLEEP)); do
8460 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8464 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8465 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8467 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8468 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8469 unlinkmany $DIR/$tdir/f $NR
8473 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8474 log "unlink $NR files at $DIR/$tdir"
8475 unlinkmany $DIR/$tdir/f $NR
8477 run_test 124a "lru resize ======================================="
8479 get_max_pool_limit()
8481 local limit=$($LCTL get_param \
8482 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8485 if [[ $l -gt $max ]]; then
8493 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8494 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8495 skip "no lru resize on server" && return 0
8497 LIMIT=$(get_max_pool_limit)
8499 NR=$(($(default_lru_size)*20))
8500 if [[ $NR -gt $LIMIT ]]; then
8501 log "Limit lock number by $LIMIT locks"
8504 lru_resize_disable mdc
8505 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8506 error "failed to create $DIR/$tdir/disable_lru_resize"
8508 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8509 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8510 cancel_lru_locks mdc
8513 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8516 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8519 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8523 nolruresize_delta=$((etime-stime))
8524 log "ls -la time: $nolruresize_delta seconds"
8525 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8526 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8528 lru_resize_enable mdc
8529 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8530 error "failed to create $DIR/$tdir/enable_lru_resize"
8532 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8533 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8534 cancel_lru_locks mdc
8537 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8540 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8543 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8547 lruresize_delta=$((etime-stime))
8548 log "ls -la time: $lruresize_delta seconds"
8549 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8551 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8552 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8553 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8554 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8556 log "lru resize performs the same with no lru resize"
8558 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8560 run_test 124b "lru resize (performance test) ======================="
8563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8564 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8565 skip "no lru resize on server" && return 0
8567 # cache ununsed locks on client
8569 cancel_lru_locks mdc
8570 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8571 createmany -o $DIR/$tdir/f $nr ||
8572 error "failed to create $nr files in $DIR/$tdir"
8573 ls -l $DIR/$tdir > /dev/null
8575 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8576 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8577 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8578 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8579 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8581 # set lru_max_age to 1 sec
8582 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8583 echo "sleep $((recalc_p * 2)) seconds..."
8584 sleep $((recalc_p * 2))
8586 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8587 # restore lru_max_age
8588 $LCTL set_param -n $nsdir.lru_max_age $max_age
8589 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8590 unlinkmany $DIR/$tdir/f $nr
8592 run_test 124c "LRUR cancel very aged locks"
8594 test_125() { # 13358
8595 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8596 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8597 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8598 test_mkdir -p $DIR/d125 || error "mkdir failed"
8599 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8600 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8601 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8603 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8605 test_126() { # bug 12829/13455
8606 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8607 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8608 $GSS && skip "must run as gss disabled" && return
8610 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8611 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8613 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8615 run_test 126 "check that the fsgid provided by the client is taken into account"
8617 test_127a() { # bug 15521
8618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8619 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8620 $LCTL set_param osc.*.stats=0
8621 FSIZE=$((2048 * 1024))
8622 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8623 cancel_lru_locks osc
8624 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8626 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8627 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8628 echo "got $COUNT $NAME"
8629 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8630 eval $NAME=$COUNT || error "Wrong proc format"
8633 read_bytes|write_bytes)
8634 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8635 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8636 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8637 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8638 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8639 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8640 error "sumsquare is too small: $SUMSQ"
8641 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8642 error "sumsquare is too big: $SUMSQ"
8646 done < $DIR/${tfile}.tmp
8648 #check that we actually got some stats
8649 [ "$read_bytes" ] || error "Missing read_bytes stats"
8650 [ "$write_bytes" ] || error "Missing write_bytes stats"
8651 [ "$read_bytes" != 0 ] || error "no read done"
8652 [ "$write_bytes" != 0 ] || error "no write done"
8654 run_test 127a "verify the client stats are sane"
8656 test_127b() { # bug LU-333
8657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8658 $LCTL set_param llite.*.stats=0
8659 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8660 # perform 2 reads and writes so MAX is different from SUM.
8661 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8662 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8663 cancel_lru_locks osc
8664 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8665 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8667 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8668 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8669 echo "got $COUNT $NAME"
8670 eval $NAME=$COUNT || error "Wrong proc format"
8674 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8675 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8676 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8677 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8680 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8681 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8682 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8683 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8687 done < $TMP/${tfile}.tmp
8689 #check that we actually got some stats
8690 [ "$read_bytes" ] || error "Missing read_bytes stats"
8691 [ "$write_bytes" ] || error "Missing write_bytes stats"
8692 [ "$read_bytes" != 0 ] || error "no read done"
8693 [ "$write_bytes" != 0 ] || error "no write done"
8695 run_test 127b "verify the llite client stats are sane"
8697 test_128() { # bug 15212
8699 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8704 result=$(grep error $TMP/$tfile.log)
8706 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8708 run_test 128 "interactive lfs for 2 consecutive find's"
8715 local LDPROC=/proc/fs/ldiskfs
8716 local facets=$(get_facets MDS)
8718 for facet in ${facets//,/ }; do
8719 canondev=$(ldiskfs_canon \
8720 *.$(convert_facet2label $facet).mntdev $facet)
8721 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8722 LDPROC=/sys/fs/ldiskfs
8723 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8724 do_facet $facet "test -e $LDPROC/$canondev/warning_dir_size" ||
8725 LDPROC=/sys/fs/ldiskfs
8726 do_facet $facet "echo $2 >$LDPROC/$canondev/warning_dir_size"
8731 local facets=$(get_facets MDS)
8732 for facet in ${facets//,/ }; do
8733 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
8739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8740 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8741 skip "Only applicable to ldiskfs-based MDTs"
8744 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8752 # block size of mds1
8753 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8754 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8755 local MAX=$((MDSBLOCKSIZE * 5))
8756 set_dir_limits $MAX $MAX
8757 local I=$(stat -c%s "$DIR/$tdir")
8759 while [[ $I -le $MAX ]]; do
8760 $MULTIOP $DIR/$tdir/$J Oc
8762 if [ $has_warning -eq 0 ]; then
8763 check_mds_dmesg '"is approaching"' &&
8766 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8767 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8768 #and EFBIG for previous versions
8769 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8771 echo "return code $rc received as expected"
8773 createmany -o $DIR/$tdir/$J_file_ 1000 ||
8774 error_exit "create failed w/o dir size limit"
8776 check_mds_dmesg '"has reached"' ||
8777 error_exit "has reached message should be output"
8780 error_exit "warning message should be output"
8782 I=$(stat -c%s "$DIR/$tdir")
8784 if [ $(lustre_version_code $SINGLEMDS) -lt \
8785 $(version_code 2.4.51) ]
8787 [[ $I -eq $MAX ]] && return 0
8789 [[ $I -gt $MAX ]] && return 0
8791 error_exit "current dir size $I, previous limit $MAX"
8792 elif [ $rc -ne 0 ]; then
8794 error_exit "return code $rc received instead of expected " \
8795 "$EFBIG or $ENOSPC, files in dir $I"
8798 I=$(stat -c%s "$DIR/$tdir")
8802 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8804 run_test 129 "test directory size limit ========================"
8813 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8814 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8817 trap cleanup_130 EXIT RETURN
8819 local fm_file=$DIR/$tfile
8820 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8821 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8822 error "dd failed for $fm_file"
8824 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8825 filefrag -ves $fm_file
8827 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8828 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8829 [ $RC != 0 ] && error "filefrag $fm_file failed"
8831 filefrag_op=$(filefrag -ve $fm_file |
8832 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
8833 lun=$($GETSTRIPE -i $fm_file)
8835 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8838 for line in $filefrag_op
8840 frag_lun=`echo $line | cut -d: -f5`
8841 ext_len=`echo $line | cut -d: -f4`
8842 if (( $frag_lun != $lun )); then
8844 error "FIEMAP on 1-stripe file($fm_file) failed"
8847 (( tot_len += ext_len ))
8850 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8852 error "FIEMAP on 1-stripe file($fm_file) failed;"
8858 echo "FIEMAP on single striped file succeeded"
8860 run_test 130a "FIEMAP (1-stripe file)"
8863 [ "$OSTCOUNT" -lt "2" ] &&
8864 skip_env "skipping FIEMAP on $OSTCOUNT-stripe file" && return
8866 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8867 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8870 trap cleanup_130 EXIT RETURN
8872 local fm_file=$DIR/$tfile
8873 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
8874 error "setstripe on $fm_file"
8875 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8876 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8878 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
8879 error "dd failed on $fm_file"
8881 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8882 filefrag_op=$(filefrag -ve $fm_file |
8883 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
8885 last_lun=$(echo $filefrag_op | cut -d: -f5 |
8886 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8891 for line in $filefrag_op
8893 frag_lun=$(echo $line | cut -d: -f5 |
8894 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8895 ext_len=$(echo $line | cut -d: -f4)
8896 if (( $frag_lun != $last_lun )); then
8897 if (( tot_len != 1024 )); then
8899 error "FIEMAP on $fm_file failed; returned " \
8900 "len $tot_len for OST $last_lun instead of 1024"
8907 (( tot_len += ext_len ))
8910 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
8912 error "FIEMAP on $fm_file failed; returned wrong number of " \
8913 "luns or wrong len for OST $last_lun"
8919 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
8921 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
8924 [ "$OSTCOUNT" -lt "2" ] &&
8925 skip_env "skipping FIEMAP on 2-stripe file" && return
8927 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8928 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8931 trap cleanup_130 EXIT RETURN
8933 local fm_file=$DIR/$tfile
8934 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8935 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8936 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8938 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
8939 error "dd failed on $fm_file"
8941 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8942 filefrag_op=$(filefrag -ve $fm_file |
8943 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
8945 last_lun=$(echo $filefrag_op | cut -d: -f5 |
8946 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8951 for line in $filefrag_op
8953 frag_lun=$(echo $line | cut -d: -f5 |
8954 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
8955 ext_len=$(echo $line | cut -d: -f4)
8956 if (( $frag_lun != $last_lun )); then
8957 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8958 if (( logical != 512 )); then
8960 error "FIEMAP on $fm_file failed; returned " \
8961 "logical start for lun $logical instead of 512"
8964 if (( tot_len != 512 )); then
8966 error "FIEMAP on $fm_file failed; returned " \
8967 "len $tot_len for OST $last_lun instead of 1024"
8974 (( tot_len += ext_len ))
8977 if (( num_luns != 2 || tot_len != 512 )); then
8979 error "FIEMAP on $fm_file failed; returned wrong number of " \
8980 "luns or wrong len for OST $last_lun"
8986 echo "FIEMAP on 2-stripe file with hole succeeded"
8988 run_test 130c "FIEMAP (2-stripe file with hole)"
8991 [ "$OSTCOUNT" -lt "3" ] &&
8992 skip_env "skipping FIEMAP on N-stripe file test" && return
8994 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8995 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8998 trap cleanup_130 EXIT RETURN
9000 local fm_file=$DIR/$tfile
9001 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
9002 error "setstripe on $fm_file"
9003 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9004 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9006 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
9007 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
9008 error "dd failed on $fm_file"
9010 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9011 filefrag_op=$(filefrag -ve $fm_file |
9012 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9014 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9015 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9020 for line in $filefrag_op
9022 frag_lun=$(echo $line | cut -d: -f5 |
9023 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9024 ext_len=$(echo $line | cut -d: -f4)
9025 if (( $frag_lun != $last_lun )); then
9026 if (( tot_len != 1024 )); then
9028 error "FIEMAP on $fm_file failed; returned " \
9029 "len $tot_len for OST $last_lun instead of 1024"
9036 (( tot_len += ext_len ))
9039 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
9041 error "FIEMAP on $fm_file failed; returned wrong number of " \
9042 "luns or wrong len for OST $last_lun"
9048 echo "FIEMAP on N-stripe file succeeded"
9050 run_test 130d "FIEMAP (N-stripe file)"
9053 [ "$OSTCOUNT" -lt "2" ] &&
9054 skip_env "skipping continuation FIEMAP test" && return
9056 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
9057 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
9059 trap cleanup_130 EXIT RETURN
9061 local fm_file=$DIR/$tfile
9062 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
9063 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
9064 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
9067 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
9068 for ((i = 0; i < $NUM_BLKS; i++))
9070 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
9073 filefrag -ves $fm_file || error "filefrag $fm_file failed"
9074 filefrag_op=$(filefrag -ve $fm_file |
9075 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
9077 last_lun=$(echo $filefrag_op | cut -d: -f5 |
9078 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9083 for line in $filefrag_op
9085 frag_lun=$(echo $line | cut -d: -f5 |
9086 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
9087 ext_len=$(echo $line | cut -d: -f4)
9088 if (( $frag_lun != $last_lun )); then
9089 if (( tot_len != $EXPECTED_LEN )); then
9091 error "FIEMAP on $fm_file failed; returned " \
9092 "len $tot_len for OST $last_lun instead " \
9100 (( tot_len += ext_len ))
9103 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
9105 error "FIEMAP on $fm_file failed; returned wrong number " \
9106 "of luns or wrong len for OST $last_lun"
9112 echo "FIEMAP with continuation calls succeeded"
9114 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
9116 # Test for writev/readv
9118 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
9119 error "writev test failed"
9120 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
9121 error "readv failed"
9124 run_test 131a "test iov's crossing stripe boundary for writev/readv"
9127 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
9128 error "append writev test failed"
9129 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
9130 error "append writev test failed"
9133 run_test 131b "test append writev"
9136 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
9139 run_test 131c "test read/write on file w/o objects"
9142 rwv -f $DIR/$tfile -w -n 1 1572864
9143 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
9144 if [ "$NOB" != 1572864 ]; then
9145 error "Short read filed: read $NOB bytes instead of 1572864"
9149 run_test 131d "test short read"
9152 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
9153 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
9154 error "read hitting hole failed"
9157 run_test 131e "test read hitting hole"
9163 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9165 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9167 *) error "Wrong argument $1" ;;
9170 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9171 # if the argument $3 is zero, it means any stat increment is ok.
9172 if [[ $3 -gt 0 ]]; then
9173 count=$(echo $res | awk '{ print $2 }')
9174 [[ $count -ne $3 ]] &&
9175 error "The $2 counter on $1 is wrong - expected $3"
9180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9181 remote_ost_nodsh && skip "remote OST with nodsh" && return
9182 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9184 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9185 { skip "MDS doesn't support rename stats"; return; }
9186 local testdir=$DIR/${tdir}/stats_testdir
9187 mkdir -p $DIR/${tdir}
9190 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9191 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9193 # verify mdt stats first.
9194 mkdir ${testdir} || error "mkdir failed"
9195 check_stats $SINGLEMDS "mkdir" 1
9196 touch ${testdir}/${tfile} || "touch failed"
9197 check_stats $SINGLEMDS "open" 1
9198 check_stats $SINGLEMDS "close" 1
9199 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9200 check_stats $SINGLEMDS "mknod" 1
9201 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9202 check_stats $SINGLEMDS "unlink" 1
9203 rm -f ${testdir}/${tfile} || error "file remove failed"
9204 check_stats $SINGLEMDS "unlink" 2
9206 # remove working dir and check mdt stats again.
9207 rmdir ${testdir} || error "rmdir failed"
9208 check_stats $SINGLEMDS "rmdir" 1
9210 local testdir1=$DIR/${tdir}/stats_testdir1
9212 mkdir -p ${testdir1}
9213 touch ${testdir1}/test1
9214 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9215 check_stats $SINGLEMDS "crossdir_rename" 1
9217 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9218 check_stats $SINGLEMDS "samedir_rename" 1
9222 run_test 133a "Verifying MDT stats ========================================"
9225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9226 remote_ost_nodsh && skip "remote OST with nodsh" && return
9227 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9228 local testdir=$DIR/${tdir}/stats_testdir
9229 mkdir -p ${testdir} || error "mkdir failed"
9230 touch ${testdir}/${tfile} || "touch failed"
9231 cancel_lru_locks mdc
9234 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9235 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9237 # extra mdt stats verification.
9238 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9239 check_stats $SINGLEMDS "setattr" 1
9240 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9241 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9243 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9244 check_stats $SINGLEMDS "getattr" 1
9246 $LFS df || error "lfs failed"
9247 check_stats $SINGLEMDS "statfs" 1
9251 run_test 133b "Verifying extra MDT stats =================================="
9254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9255 remote_ost_nodsh && skip "remote OST with nodsh" && return
9256 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9257 local testdir=$DIR/${tdir}/stats_testdir
9258 test_mkdir -p ${testdir} || error "mkdir failed"
9260 # verify obdfilter stats.
9261 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9263 cancel_lru_locks osc
9264 wait_delete_completed
9267 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9268 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9270 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9272 cancel_lru_locks osc
9273 check_stats ost "write" 1
9275 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9276 check_stats ost "read" 1
9278 > ${testdir}/${tfile} || error "truncate failed"
9279 check_stats ost "punch" 1
9281 rm -f ${testdir}/${tfile} || error "file remove failed"
9282 wait_delete_completed
9283 check_stats ost "destroy" 1
9287 run_test 133c "Verifying OST stats ========================================"
9294 while [ $value -ge 2 ]; do
9299 if [ $orig -gt $order ]; then
9307 local size=('K' 'M' 'G' 'T');
9309 local size_string=$value
9311 while [ $value -ge 1024 ]; do
9312 if [ $i -gt 3 ]; then
9313 #T is the biggest unit we get here, if that is bigger,
9315 size_string=${value}T
9318 value=$((value >> 10))
9319 if [ $value -lt 1024 ]; then
9320 size_string=${value}${size[$i]}
9331 local context=${2:-.}
9332 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9334 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9340 remote_ost_nodsh && skip "remote OST with nodsh" && return
9341 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9342 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9343 { skip "MDS doesn't support rename stats"; return; }
9345 local testdir1=$DIR/${tdir}/stats_testdir1
9346 local testdir2=$DIR/${tdir}/stats_testdir2
9348 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9350 mkdir -p ${testdir1} || error "mkdir failed"
9351 mkdir -p ${testdir2} || error "mkdir failed"
9353 createmany -o $testdir1/test 512 || error "createmany failed"
9355 # check samedir rename size
9356 mv ${testdir1}/test0 ${testdir1}/test_0
9358 local testdir1_size=$(ls -l $DIR/${tdir} |
9359 awk '/stats_testdir1/ {print $5}')
9360 local testdir2_size=$(ls -l $DIR/${tdir} |
9361 awk '/stats_testdir2/ {print $5}')
9363 testdir1_size=$(order_2 $testdir1_size)
9364 testdir2_size=$(order_2 $testdir2_size)
9366 testdir1_size=$(size_in_KMGT $testdir1_size)
9367 testdir2_size=$(size_in_KMGT $testdir2_size)
9369 echo "source rename dir size: ${testdir1_size}"
9370 echo "target rename dir size: ${testdir2_size}"
9372 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9373 eval $cmd || error "$cmd failed"
9374 local samedir=$($cmd | grep 'same_dir')
9375 local same_sample=$(get_rename_size $testdir1_size)
9376 [ -z "$samedir" ] && error "samedir_rename_size count error"
9377 [[ $same_sample -eq 1 ]] ||
9378 error "samedir_rename_size error $same_sample"
9379 echo "Check same dir rename stats success"
9381 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9383 # check crossdir rename size
9384 mv ${testdir1}/test_0 ${testdir2}/test_0
9386 testdir1_size=$(ls -l $DIR/${tdir} |
9387 awk '/stats_testdir1/ {print $5}')
9388 testdir2_size=$(ls -l $DIR/${tdir} |
9389 awk '/stats_testdir2/ {print $5}')
9391 testdir1_size=$(order_2 $testdir1_size)
9392 testdir2_size=$(order_2 $testdir2_size)
9394 testdir1_size=$(size_in_KMGT $testdir1_size)
9395 testdir2_size=$(size_in_KMGT $testdir2_size)
9397 echo "source rename dir size: ${testdir1_size}"
9398 echo "target rename dir size: ${testdir2_size}"
9400 eval $cmd || error "$cmd failed"
9401 local crossdir=$($cmd | grep 'crossdir')
9402 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9403 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9404 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9405 [[ $src_sample -eq 1 ]] ||
9406 error "crossdir_rename_size error $src_sample"
9407 [[ $tgt_sample -eq 1 ]] ||
9408 error "crossdir_rename_size error $tgt_sample"
9409 echo "Check cross dir rename stats success"
9412 run_test 133d "Verifying rename_stats ========================================"
9415 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9416 remote_ost_nodsh && skip "remote OST with nodsh" && return
9417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9418 local testdir=$DIR/${tdir}/stats_testdir
9419 local ctr f0 f1 bs=32768 count=42 sum
9421 mkdir -p ${testdir} || error "mkdir failed"
9423 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9425 for ctr in {write,read}_bytes; do
9427 cancel_lru_locks osc
9429 do_facet ost1 $LCTL set_param -n \
9430 "obdfilter.*.exports.clear=clear"
9432 if [ $ctr = write_bytes ]; then
9434 f1=${testdir}/${tfile}
9436 f0=${testdir}/${tfile}
9440 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9443 cancel_lru_locks osc
9445 sum=$(do_facet ost1 $LCTL get_param \
9446 "obdfilter.*.exports.*.stats" |
9447 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9448 $1 == ctr { sum += $7 }
9449 END { printf("%0.0f", sum) }')
9451 if ((sum != bs * count)); then
9452 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9458 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9461 for dir in /proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9462 /sys/fs/lustre/ /sys/fs/lnet/ /sys/kernel/debug/lnet/ \
9463 /sys/kernel/debug/lustre/; do
9464 [[ -d $dir ]] && proc_dirs+=" $dir"
9468 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9469 remote_ost_nodsh && skip "remote OST with nodsh" && return
9470 # First without trusting modes.
9471 find $proc_dirs -exec cat '{}' \; &> /dev/null
9473 # Second verifying readability.
9474 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
9476 # eventually, this can also be replaced with "lctl get_param -R",
9477 # but not until that option is always available on the server
9479 for facet in $SINGLEMDS ost1; do
9480 do_facet $facet find $proc_dirs \
9481 ! -name req_history \
9482 -exec cat '{}' \\\; &> /dev/null
9484 do_facet $facet find $proc_dirs \
9485 ! -name req_history \
9487 -exec cat '{}' \\\; &> /dev/null ||
9488 error "proc file read failed"
9491 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9494 # Second verifying writability.
9497 -not -name force_lbug \
9498 -not -name changelog_mask \
9499 -exec badarea_io '{}' \; &> /dev/null ||
9500 error "find $proc_dirs failed"
9502 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9503 skip "Too old lustre on MDS" && return
9505 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9506 skip "Too old lustre on ost1" && return
9509 for facet in $SINGLEMDS ost1; do
9510 do_facet $facet find $proc_dirs \
9512 -not -name force_lbug \
9513 -not -name changelog_mask \
9514 -exec badarea_io '{}' \\\; &> /dev/null ||
9515 error "$facet find $proc_dirs failed"
9519 # remount the FS in case writes/reads /proc break the FS
9520 cleanup || error "failed to unmount"
9521 setup || error "failed to setup"
9524 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9527 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9528 skip "Need MDS version at least 2.7.54" && return
9530 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9531 cancel_lru_locks mdc
9533 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9534 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9535 [ $unused -eq 0 ] || "$unused locks are not cleared"
9538 createmany -o $DIR/$tdir/f $nr ||
9539 error "failed to create $nr files in $DIR/$tdir"
9540 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9542 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9543 do_facet mds1 $LCTL set_param fail_loc=0x327
9544 do_facet mds1 $LCTL set_param fail_val=500
9547 echo "sleep 10 seconds ..."
9549 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9551 do_facet mds1 $LCTL set_param fail_loc=0
9552 do_facet mds1 $LCTL set_param fail_val=0
9553 [ $lck_cnt -lt $unused ] ||
9554 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9557 unlinkmany $DIR/$tdir/f $nr
9559 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
9562 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9563 skip "Need MDS version at least 2.7.54" && return
9565 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9566 cancel_lru_locks mdc
9568 local low_wm=$(do_facet mds1 $LCTL get_param -n \
9569 ldlm.lock_reclaim_threshold_mb)
9570 # disable reclaim temporarily
9571 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
9573 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9574 do_facet mds1 $LCTL set_param fail_loc=0x328
9575 do_facet mds1 $LCTL set_param fail_val=500
9577 $LCTL set_param debug=+trace
9580 createmany -o $DIR/$tdir/f $nr &
9583 echo "Sleep $TIMEOUT seconds ..."
9585 if ! ps -p $create_pid > /dev/null 2>&1; then
9586 do_facet mds1 $LCTL set_param fail_loc=0
9587 do_facet mds1 $LCTL set_param fail_val=0
9588 do_facet mds1 $LCTL set_param \
9589 ldlm.lock_reclaim_threshold_mb=${low_wm}m
9590 error "createmany finished incorrectly!"
9592 do_facet mds1 $LCTL set_param fail_loc=0
9593 do_facet mds1 $LCTL set_param fail_val=0
9594 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
9595 wait $create_pid || return 1
9597 unlinkmany $DIR/$tdir/f $nr
9599 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
9601 test_140() { #bug-17379
9602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9603 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9604 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9605 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9607 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9608 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9610 while i=`expr $i + 1`; do
9611 test_mkdir -p $i || error "Creating dir $i"
9612 cd $i || error "Changing to $i"
9613 ln -s ../stat stat || error "Creating stat symlink"
9614 # Read the symlink until ELOOP present,
9615 # not LBUGing the system is considered success,
9616 # we didn't overrun the stack.
9617 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9619 if [ $ret -eq 40 ]; then
9622 error "Open stat symlink"
9628 echo "The symlink depth = $i"
9629 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9630 error "Invalid symlink depth"
9632 # Test recursive symlink
9633 ln -s symlink_self symlink_self
9634 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9635 echo "open symlink_self returns $ret"
9636 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9638 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9642 local TF="$TMP/$tfile"
9644 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9646 cancel_lru_locks osc
9647 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9648 remount_client $MOUNT
9650 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9653 $TRUNCATE $DIR/$tfile 6000
9654 cancel_lru_locks osc
9655 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9658 echo "12345" >>$DIR/$tfile
9659 cancel_lru_locks osc
9660 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9663 echo "12345" >>$DIR/$tfile
9664 cancel_lru_locks osc
9665 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9670 run_test 150 "truncate/append tests"
9672 #LU-2902 roc_hit was not able to read all values from lproc
9673 function roc_hit_init() {
9674 local list=$(comma_list $(osts_nodes))
9675 local dir=$DIR/$tdir-check
9676 local file=$dir/file
9682 #use setstripe to do a write to every ost
9683 for i in $(seq 0 $((OSTCOUNT-1))); do
9684 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9685 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9686 idx=$(printf %04x $i)
9687 BEFORE=$(get_osd_param $list *OST*$idx stats |
9688 awk '$1 == "cache_access" {sum += $7}
9689 END { printf("%0.0f", sum) }')
9691 cancel_lru_locks osc
9692 cat $file >/dev/null
9694 AFTER=$(get_osd_param $list *OST*$idx stats |
9695 awk '$1 == "cache_access" {sum += $7}
9696 END { printf("%0.0f", sum) }')
9698 echo BEFORE:$BEFORE AFTER:$AFTER
9699 if ! let "AFTER - BEFORE == 4"; then
9701 error "roc_hit is not safe to use"
9709 function roc_hit() {
9710 local list=$(comma_list $(osts_nodes))
9711 echo $(get_osd_param $list '' stats |
9712 awk '$1 == "cache_hit" {sum += $7}
9713 END { printf("%0.0f", sum) }')
9716 function set_cache() {
9719 if [ "$2" == "off" ]; then
9722 local list=$(comma_list $(osts_nodes))
9723 set_osd_param $list '' $1_cache_enable $on
9725 cancel_lru_locks osc
9729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9730 remote_ost_nodsh && skip "remote OST with nodsh" && return
9733 local list=$(comma_list $(osts_nodes))
9735 # check whether obdfilter is cache capable at all
9736 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9737 echo "not cache-capable obdfilter"
9741 # check cache is enabled on all obdfilters
9742 if get_osd_param $list '' read_cache_enable | grep 0; then
9743 echo "oss cache is disabled"
9747 set_osd_param $list '' writethrough_cache_enable 1
9749 # check write cache is enabled on all obdfilters
9750 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9751 echo "oss write cache is NOT enabled"
9757 #define OBD_FAIL_OBD_NO_LRU 0x609
9758 do_nodes $list $LCTL set_param fail_loc=0x609
9760 # pages should be in the case right after write
9761 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9764 local BEFORE=$(roc_hit)
9765 cancel_lru_locks osc
9766 cat $DIR/$tfile >/dev/null
9767 local AFTER=$(roc_hit)
9769 do_nodes $list $LCTL set_param fail_loc=0
9771 if ! let "AFTER - BEFORE == CPAGES"; then
9772 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9775 # the following read invalidates the cache
9776 cancel_lru_locks osc
9777 set_osd_param $list '' read_cache_enable 0
9778 cat $DIR/$tfile >/dev/null
9780 # now data shouldn't be found in the cache
9782 cancel_lru_locks osc
9783 cat $DIR/$tfile >/dev/null
9785 if let "AFTER - BEFORE != 0"; then
9786 error "IN CACHE: before: $BEFORE, after: $AFTER"
9789 set_osd_param $list '' read_cache_enable 1
9792 run_test 151 "test cache on oss and controls ==============================="
9795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9796 local TF="$TMP/$tfile"
9798 # simulate ENOMEM during write
9799 #define OBD_FAIL_OST_NOMEM 0x226
9800 lctl set_param fail_loc=0x80000226
9801 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9803 sync || error "sync failed"
9804 lctl set_param fail_loc=0
9806 # discard client's cache
9807 cancel_lru_locks osc
9809 # simulate ENOMEM during read
9810 lctl set_param fail_loc=0x80000226
9811 cmp $TF $DIR/$tfile || error "cmp failed"
9812 lctl set_param fail_loc=0
9816 run_test 152 "test read/write with enomem ============================"
9819 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9821 run_test 153 "test if fdatasync does not crash ======================="
9823 dot_lustre_fid_permission_check() {
9825 local ffid=$MOUNT/.lustre/fid/$fid
9828 echo "stat fid $fid"
9829 stat $ffid > /dev/null || error "stat $ffid failed."
9830 echo "touch fid $fid"
9831 touch $ffid || error "touch $ffid failed."
9832 echo "write to fid $fid"
9833 cat /etc/hosts > $ffid || error "write $ffid failed."
9834 echo "read fid $fid"
9835 diff /etc/hosts $ffid || error "read $ffid failed."
9836 echo "append write to fid $fid"
9837 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9838 echo "rename fid $fid"
9839 mv $ffid $test_dir/$tfile.1 &&
9840 error "rename $ffid to $tfile.1 should fail."
9841 touch $test_dir/$tfile.1
9842 mv $test_dir/$tfile.1 $ffid &&
9843 error "rename $tfile.1 to $ffid should fail."
9844 rm -f $test_dir/$tfile.1
9845 echo "truncate fid $fid"
9846 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9847 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9848 echo "link fid $fid"
9849 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9851 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9852 echo "setfacl fid $fid"
9853 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9854 echo "getfacl fid $fid"
9855 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9857 echo "unlink fid $fid"
9858 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9859 echo "mknod fid $fid"
9860 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9862 fid=[0xf00000400:0x1:0x0]
9863 ffid=$MOUNT/.lustre/fid/$fid
9865 echo "stat non-exist fid $fid"
9866 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9867 echo "write to non-exist fid $fid"
9868 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9869 echo "link new fid $fid"
9870 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9872 mkdir -p $test_dir/$tdir
9873 touch $test_dir/$tdir/$tfile
9874 fid=$($LFS path2fid $test_dir/$tdir)
9877 error "error: could not get fid for $test_dir/$dir/$tfile."
9879 ffid=$MOUNT/.lustre/fid/$fid
9882 ls $ffid > /dev/null || error "ls $ffid failed."
9883 echo "touch $fid/$tfile.1"
9884 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9886 echo "touch $MOUNT/.lustre/fid/$tfile"
9887 touch $MOUNT/.lustre/fid/$tfile && \
9888 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9890 echo "setxattr to $MOUNT/.lustre/fid"
9891 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9893 echo "listxattr for $MOUNT/.lustre/fid"
9894 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9896 echo "delxattr from $MOUNT/.lustre/fid"
9897 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9899 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9900 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9901 error "touch invalid fid should fail."
9903 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9904 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9905 error "touch non-normal fid should fail."
9907 echo "rename $tdir to $MOUNT/.lustre/fid"
9908 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9909 error "rename to $MOUNT/.lustre/fid should fail."
9911 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9913 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9914 local new_obf_mode=777
9916 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9917 chmod $new_obf_mode $DIR/.lustre/fid ||
9918 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9920 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9921 [ $obf_mode -eq $new_obf_mode ] ||
9922 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9924 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9925 chmod $old_obf_mode $DIR/.lustre/fid ||
9926 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9929 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9930 fid=$($LFS path2fid $test_dir/$tfile-2)
9932 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9934 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9935 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9936 error "create lov data thru .lustre failed"
9938 echo "cp /etc/passwd $test_dir/$tfile-2"
9939 cp /etc/passwd $test_dir/$tfile-2 ||
9940 error "copy to $test_dir/$tfile-2 failed."
9941 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9942 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9943 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9945 rm -rf $test_dir/tfile.lnk
9946 rm -rf $test_dir/$tfile-2
9950 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9951 skip "Need MDS version at least 2.4.1" && return
9954 local FID=$($LFS path2fid $DIR/$tfile)
9955 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9957 # check that we get the same pathname back
9958 local FOUND=$($LFS fid2path $MOUNT "$FID")
9959 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9960 [ "$FOUND" != "$DIR/$tfile" ] &&
9961 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9965 run_test 154A "lfs path2fid and fid2path basic checks"
9968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9969 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9970 { skip "Need MDS version at least 2.2.51"; return 0; }
9971 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9972 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
9974 cp /etc/hosts $DIR/$tfile
9976 fid=$($LFS path2fid $DIR/$tfile)
9978 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9980 dot_lustre_fid_permission_check "$fid" $DIR ||
9981 error "dot lustre permission check $fid failed"
9983 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9985 touch $MOUNT/.lustre/file &&
9986 error "creation is not allowed under .lustre"
9988 mkdir $MOUNT/.lustre/dir &&
9989 error "mkdir is not allowed under .lustre"
9993 run_test 154a "Open-by-FID"
9996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9997 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9998 { skip "Need MDS version at least 2.2.51"; return 0; }
9999 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10001 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10003 local remote_dir=$DIR/$tdir/remote_dir
10007 mkdir -p $DIR/$tdir
10008 $LFS mkdir -i $MDTIDX $remote_dir ||
10009 error "create remote directory failed"
10011 cp /etc/hosts $remote_dir/$tfile
10013 fid=$($LFS path2fid $remote_dir/$tfile)
10015 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
10017 dot_lustre_fid_permission_check "$fid" $remote_dir ||
10018 error "dot lustre permission check $fid failed"
10021 run_test 154b "Open-by-FID for remote directory"
10024 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
10025 skip "Need MDS version at least 2.4.1" && return
10027 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
10028 local FID1=$($LFS path2fid $DIR/$tfile.1)
10029 local FID2=$($LFS path2fid $DIR/$tfile.2)
10030 local FID3=$($LFS path2fid $DIR/$tfile.3)
10033 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
10034 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
10035 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
10037 [ "$FID" = "${!want}" ] ||
10038 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
10042 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
10044 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
10045 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
10049 run_test 154c "lfs path2fid and fid2path multiple arguments"
10052 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
10053 skip "Need MDS version at least 2.5.53" && return
10055 if remote_mds; then
10056 nid=$($LCTL list_nids | sed "s/\./\\\./g")
10060 local proc_ofile="mdt.*.exports.'$nid'.open_files"
10067 local fid=$($LFS path2fid $DIR/$tfile)
10070 cmd="exec $fd<$DIR/$tfile"
10072 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
10073 echo "$fid_list" | grep "$fid"
10076 cmd="exec $fd>/dev/null"
10078 if [ $rc -ne 0 ]; then
10079 error "FID $fid not found in open files list $fid_list"
10082 run_test 154d "Verify open file fid"
10086 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
10087 skip "Need MDS version at least 2.6.50" && return
10089 if ls -a $MOUNT | grep -q '^\.lustre$'; then
10090 error ".lustre returned by readdir"
10093 run_test 154e ".lustre is not returned by readdir"
10096 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10097 # create parent directory on a single MDT to avoid cross-MDT hardlinks
10098 test_mkdir -p -c1 $DIR/$tdir/d
10099 # test dirs inherit from its stripe
10100 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
10101 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
10102 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
10103 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
10106 # get fid of parents
10107 local FID0=$($LFS path2fid $DIR/$tdir/d)
10108 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
10109 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
10110 local FID3=$($LFS path2fid $DIR)
10112 # check that path2fid --parents returns expected <parent_fid>/name
10113 # 1) test for a directory (single parent)
10114 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
10115 [ "$parent" == "$FID0/foo1" ] ||
10116 error "expected parent: $FID0/foo1, got: $parent"
10118 # 2) test for a file with nlink > 1 (multiple parents)
10119 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
10120 echo "$parent" | grep -F "$FID1/$tfile" ||
10121 error "$FID1/$tfile not returned in parent list"
10122 echo "$parent" | grep -F "$FID2/link" ||
10123 error "$FID2/link not returned in parent list"
10125 # 3) get parent by fid
10126 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
10127 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10128 echo "$parent" | grep -F "$FID1/$tfile" ||
10129 error "$FID1/$tfile not returned in parent list (by fid)"
10130 echo "$parent" | grep -F "$FID2/link" ||
10131 error "$FID2/link not returned in parent list (by fid)"
10133 # 4) test for entry in root directory
10134 parent=$($LFS path2fid --parents $DIR/f)
10135 echo "$parent" | grep -F "$FID3/f" ||
10136 error "$FID3/f not returned in parent list"
10138 # 5) test it on root directory
10139 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
10140 error "$MOUNT should not have parents"
10142 # enable xattr caching and check that linkea is correctly updated
10143 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10144 save_lustre_params client "llite.*.xattr_cache" > $save
10145 lctl set_param llite.*.xattr_cache 1
10147 # 6.1) linkea update on rename
10148 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10150 # get parents by fid
10151 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10152 # foo1 should no longer be returned in parent list
10153 echo "$parent" | grep -F "$FID1" &&
10154 error "$FID1 should no longer be in parent list"
10155 # the new path should appear
10156 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10157 error "$FID2/$tfile.moved is not in parent list"
10159 # 6.2) linkea update on unlink
10160 rm -f $DIR/$tdir/d/foo2/link
10161 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10162 # foo2/link should no longer be returned in parent list
10163 echo "$parent" | grep -F "$FID2/link" &&
10164 error "$FID2/link should no longer be in parent list"
10168 restore_lustre_params < $save
10170 run_test 154f "get parent fids by reading link ea"
10174 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10175 { skip "Need MDS version at least 2.6.92"; return 0; }
10176 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
10178 mkdir -p $DIR/$tdir
10179 llapi_fid_test -d $DIR/$tdir
10181 run_test 154g "various llapi FID tests"
10183 test_155_small_load() {
10184 local temp=$TMP/$tfile
10185 local file=$DIR/$tfile
10187 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10188 error "dd of=$temp bs=6096 count=1 failed"
10190 cancel_lru_locks osc
10191 cmp $temp $file || error "$temp $file differ"
10193 $TRUNCATE $temp 6000
10194 $TRUNCATE $file 6000
10195 cmp $temp $file || error "$temp $file differ (truncate1)"
10197 echo "12345" >>$temp
10198 echo "12345" >>$file
10199 cmp $temp $file || error "$temp $file differ (append1)"
10201 echo "12345" >>$temp
10202 echo "12345" >>$file
10203 cmp $temp $file || error "$temp $file differ (append2)"
10209 test_155_big_load() {
10210 remote_ost_nodsh && skip "remote OST with nodsh" && return
10211 local temp=$TMP/$tfile
10212 local file=$DIR/$tfile
10215 local cache_size=$(do_facet ost$((MAXI+1)) \
10216 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10217 local large_file_size=$((cache_size * 2))
10219 echo "OSS cache size: $cache_size KB"
10220 echo "Large file size: $large_file_size KB"
10222 [ $MAXV -le $large_file_size ] && \
10223 skip_env "max available OST size needs > $large_file_size KB" && \
10226 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10228 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10229 error "dd of=$temp bs=$large_file_size count=1k failed"
10232 cancel_lru_locks osc
10233 cmp $temp $file || error "$temp $file differ"
10240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10242 set_cache writethrough on
10243 test_155_small_load
10245 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10250 set_cache writethrough off
10251 test_155_small_load
10253 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10258 set_cache writethrough on
10259 test_155_small_load
10261 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10266 set_cache writethrough off
10267 test_155_small_load
10269 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10274 set_cache writethrough on
10277 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10282 set_cache writethrough off
10285 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10290 set_cache writethrough on
10293 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10298 set_cache writethrough off
10301 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10304 remote_ost_nodsh && skip "remote OST with nodsh" && return
10305 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10309 local file="$DIR/$tfile"
10311 [ "$(facet_fstype ost1)" = "zfs" -a \
10312 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10313 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10318 log "Turn on read and write cache"
10320 set_cache writethrough on
10322 log "Write data and read it back."
10323 log "Read should be satisfied from the cache."
10324 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10326 cancel_lru_locks osc
10327 cat $file >/dev/null
10329 if ! let "AFTER - BEFORE == CPAGES"; then
10330 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10332 log "cache hits:: before: $BEFORE, after: $AFTER"
10335 log "Read again; it should be satisfied from the cache."
10337 cancel_lru_locks osc
10338 cat $file >/dev/null
10340 if ! let "AFTER - BEFORE == CPAGES"; then
10341 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10343 log "cache hits:: before: $BEFORE, after: $AFTER"
10346 log "Turn off the read cache and turn on the write cache"
10348 set_cache writethrough on
10350 log "Read again; it should be satisfied from the cache."
10352 cancel_lru_locks osc
10353 cat $file >/dev/null
10355 if ! let "AFTER - BEFORE == CPAGES"; then
10356 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10358 log "cache hits:: before: $BEFORE, after: $AFTER"
10361 log "Read again; it should not be satisfied from the cache."
10363 cancel_lru_locks osc
10364 cat $file >/dev/null
10366 if ! let "AFTER - BEFORE == 0"; then
10367 error "IN CACHE: before: $BEFORE, after: $AFTER"
10369 log "cache hits:: before: $BEFORE, after: $AFTER"
10372 log "Write data and read it back."
10373 log "Read should be satisfied from the cache."
10374 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10376 cancel_lru_locks osc
10377 cat $file >/dev/null
10379 if ! let "AFTER - BEFORE == CPAGES"; then
10380 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10382 log "cache hits:: before: $BEFORE, after: $AFTER"
10385 log "Read again; it should not be satisfied from the cache."
10387 cancel_lru_locks osc
10388 cat $file >/dev/null
10390 if ! let "AFTER - BEFORE == 0"; then
10391 error "IN CACHE: before: $BEFORE, after: $AFTER"
10393 log "cache hits:: before: $BEFORE, after: $AFTER"
10396 log "Turn off read and write cache"
10398 set_cache writethrough off
10400 log "Write data and read it back"
10401 log "It should not be satisfied from the cache."
10403 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10404 cancel_lru_locks osc
10406 cat $file >/dev/null
10408 if ! let "AFTER - BEFORE == 0"; then
10409 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10411 log "cache hits:: before: $BEFORE, after: $AFTER"
10414 log "Turn on the read cache and turn off the write cache"
10416 set_cache writethrough off
10418 log "Write data and read it back"
10419 log "It should not be satisfied from the cache."
10421 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10423 cancel_lru_locks osc
10424 cat $file >/dev/null
10426 if ! let "AFTER - BEFORE == 0"; then
10427 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10429 log "cache hits:: before: $BEFORE, after: $AFTER"
10432 log "Read again; it should be satisfied from the cache."
10434 cancel_lru_locks osc
10435 cat $file >/dev/null
10437 if ! let "AFTER - BEFORE == CPAGES"; then
10438 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10440 log "cache hits:: before: $BEFORE, after: $AFTER"
10445 run_test 156 "Verification of tunables"
10449 if [[ $MDSCOUNT -gt 1 ]]; then
10450 error_ignore bz17935 $*
10458 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10460 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10462 if [ $MASK -eq 1 ]; then
10463 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10465 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10469 changelog_extract_field() {
10473 local identifier=$4
10475 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10476 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10482 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10483 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10484 { skip "Need MDS version at least 2.2.0"; return; }
10486 local CL_USERS="mdd.$MDT0.changelog_users"
10487 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10488 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10489 echo "Registered as changelog user $USER"
10490 $GET_CL_USERS | grep -q $USER ||
10491 error "User $USER not found in changelog_users"
10494 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10495 touch $DIR/$tdir/pics/2008/zachy/timestamp
10496 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10497 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10498 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10499 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10500 rm $DIR/$tdir/pics/desktop.jpg
10502 $LFS changelog $MDT0 | tail -5
10504 echo "verifying changelog mask"
10505 changelog_chmask "MKDIR"
10506 changelog_chmask "CLOSE"
10508 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10509 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10511 changelog_chmask "MKDIR"
10512 changelog_chmask "CLOSE"
10514 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10515 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10517 $LFS changelog $MDT0
10518 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10519 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10520 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10521 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10524 echo "verifying target fid"
10525 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10526 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10527 [ "$fidc" == "$fidf" ] ||
10528 err17935 "fid in changelog $fidc != file fid $fidf"
10529 echo "verifying parent fid"
10530 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10531 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10532 [ "$fidc" == "$fidf" ] ||
10533 err17935 "pfid in changelog $fidc != dir fid $fidf"
10535 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10536 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10537 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10538 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10539 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10540 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10542 MIN_REC=$($GET_CL_USERS |
10543 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10544 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10545 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10546 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10547 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10549 # LU-3446 changelog index reset on MDT restart
10550 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10551 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10552 $LFS changelog_clear $MDT0 $USER 0
10553 stop $SINGLEMDS || error "Fail to stop MDT."
10554 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10555 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10556 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10557 [ $CUR_REC1 == $CUR_REC2 ] ||
10558 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10560 echo "verifying user deregister"
10561 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10562 $GET_CL_USERS | grep -q $USER &&
10563 error "User $USER still in changelog_users"
10565 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10566 if [ $USERS -eq 0 ]; then
10567 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10568 touch $DIR/$tdir/chloe
10569 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10570 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10571 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10573 echo "$USERS other changelog users; can't verify off"
10576 run_test 160a "changelog sanity"
10578 test_160b() { # LU-3587
10579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10580 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10581 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10582 { skip "Need MDS version at least 2.2.0"; return; }
10584 local CL_USERS="mdd.$MDT0.changelog_users"
10585 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10586 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10587 echo "Registered as changelog user $USER"
10588 $GET_CL_USERS | grep -q $USER ||
10589 error "User $USER not found in changelog_users"
10591 local LONGNAME1=$(str_repeat a 255)
10592 local LONGNAME2=$(str_repeat b 255)
10595 echo "creating very long named file"
10596 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10597 echo "moving very long named file"
10598 mv $LONGNAME1 $LONGNAME2
10600 $LFS changelog $MDT0 | grep RENME
10602 echo "deregistering $USER"
10603 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10607 run_test 160b "Verify that very long rename doesn't crash in changelog"
10610 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10613 local server_version=$(lustre_version_code $SINGLEMDS)
10615 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10616 [[ $server_version -gt $(version_code 2.5.1) &&
10617 $server_version -lt $(version_code 2.5.50) ]] ||
10618 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10621 # Registration step
10622 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10623 changelog_register -n)
10626 mkdir -p $DIR/$tdir
10627 $MCREATE $DIR/$tdir/foo_160c
10628 changelog_chmask "TRUNC"
10629 $TRUNCATE $DIR/$tdir/foo_160c 200
10630 changelog_chmask "TRUNC"
10631 $TRUNCATE $DIR/$tdir/foo_160c 199
10632 $LFS changelog $MDT0
10633 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10634 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10635 $LFS changelog_clear $MDT0 $USER 0
10637 # Deregistration step
10638 echo "deregistering $USER"
10639 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10641 run_test 160c "verify that changelog log catch the truncate event"
10644 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10647 local server_version=$(lustre_version_code mds1)
10648 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10650 [[ $server_version -ge $(version_code 2.7.60) ]] ||
10651 { skip "Need MDS version at least 2.7.60+"; return; }
10652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10654 # Registration step
10655 local USER=$(do_facet mds1 $LCTL --device $MDT0 \
10656 changelog_register -n)
10658 mkdir -p $DIR/$tdir/migrate_dir
10659 $LFS changelog_clear $MDT0 $USER 0
10661 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
10662 $LFS changelog $MDT0
10663 MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
10664 $LFS changelog_clear $MDT0 $USER 0
10665 [ $MIGRATES -eq 1 ] ||
10666 error "MIGRATE changelog mask count $MIGRATES != 1"
10668 # Deregistration step
10669 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $USER
10671 run_test 160d "verify that changelog log catch the migrate event"
10674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10675 test_mkdir -p -c1 $DIR/$tdir
10676 cp /etc/hosts $DIR/$tdir/$tfile
10677 test_mkdir -c1 $DIR/$tdir/foo1
10678 test_mkdir -c1 $DIR/$tdir/foo2
10679 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10680 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10681 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10682 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10683 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10684 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10685 $LFS fid2path $DIR $FID
10686 err17935 "bad link ea"
10689 rm $DIR/$tdir/foo2/zachary
10691 rm $DIR/$tdir/foo2/thor
10693 rm $DIR/$tdir/$tfile
10695 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10696 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10698 $LFS fid2path $DIR $FID
10699 err17935 "bad link rename"
10701 rm $DIR/$tdir/foo2/maggie
10704 local longname=filename_avg_len_is_thirty_two_
10705 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10706 error "failed to hardlink many files"
10707 links=$($LFS fid2path $DIR $FID | wc -l)
10708 echo -n "${links}/1000 links in link EA"
10709 [[ $links -gt 60 ]] ||
10710 err17935 "expected at least 60 links in link EA"
10711 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10712 error "failed to unlink many hardlinks"
10714 run_test 161a "link ea sanity"
10717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10718 [ $MDSCOUNT -lt 2 ] &&
10719 skip "skipping remote directory test" && return
10721 local remote_dir=$DIR/$tdir/remote_dir
10723 mkdir -p $DIR/$tdir
10724 $LFS mkdir -i $MDTIDX $remote_dir ||
10725 error "create remote directory failed"
10727 cp /etc/hosts $remote_dir/$tfile
10728 mkdir -p $remote_dir/foo1
10729 mkdir -p $remote_dir/foo2
10730 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10731 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10732 ln $remote_dir/$tfile $remote_dir/foo1/luna
10733 ln $remote_dir/$tfile $remote_dir/foo2/thor
10735 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10737 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10738 $LFS fid2path $DIR $FID
10739 err17935 "bad link ea"
10742 rm $remote_dir/foo2/zachary
10744 rm $remote_dir/foo2/thor
10746 rm $remote_dir/$tfile
10748 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10749 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10750 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10751 $LFS fid2path $DIR $FID
10752 err17935 "bad link rename"
10754 rm $remote_dir/foo2/maggie
10757 local longname=filename_avg_len_is_thirty_two_
10758 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10759 error "failed to hardlink many files"
10760 links=$($LFS fid2path $DIR $FID | wc -l)
10761 echo -n "${links}/1000 links in link EA"
10762 [[ ${links} -gt 60 ]] ||
10763 err17935 "expected at least 60 links in link EA"
10764 unlinkmany $remote_dir/foo2/$longname 1000 ||
10765 error "failed to unlink many hardlinks"
10767 run_test 161b "link ea sanity under remote directory"
10770 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10772 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10773 skip "Need MDS version at least 2.1.5" && return
10775 # define CLF_RENAME_LAST 0x0001
10776 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10777 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10778 changelog_register -n)
10780 mkdir -p $DIR/$tdir
10781 touch $DIR/$tdir/foo_161c
10782 touch $DIR/$tdir/bar_161c
10783 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10784 $LFS changelog $MDT0 | grep RENME
10785 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10787 $LFS changelog_clear $MDT0 $USER 0
10788 if [ x$flags != "x0x1" ]; then
10789 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10791 error "flag $flags is not 0x1"
10793 echo "rename overwrite a target having nlink = 1," \
10794 "changelog record has flags of $flags"
10796 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10797 touch $DIR/$tdir/foo_161c
10798 touch $DIR/$tdir/bar_161c
10799 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10800 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10801 $LFS changelog $MDT0 | grep RENME
10802 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10803 $LFS changelog_clear $MDT0 $USER 0
10804 if [ x$flags != "x0x0" ]; then
10805 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10807 error "flag $flags is not 0x0"
10809 echo "rename overwrite a target having nlink > 1," \
10810 "changelog record has flags of $flags"
10812 # rename doesn't overwrite a target (changelog flag 0x0)
10813 touch $DIR/$tdir/foo_161c
10814 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10815 $LFS changelog $MDT0 | grep RENME
10816 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10817 $LFS changelog_clear $MDT0 $USER 0
10818 if [ x$flags != "x0x0" ]; then
10819 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10821 error "flag $flags is not 0x0"
10823 echo "rename doesn't overwrite a target," \
10824 "changelog record has flags of $flags"
10826 # define CLF_UNLINK_LAST 0x0001
10827 # unlink a file having nlink = 1 (changelog flag 0x1)
10828 rm -f $DIR/$tdir/foo2_161c
10829 $LFS changelog $MDT0 | grep UNLNK
10830 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10831 $LFS changelog_clear $MDT0 $USER 0
10832 if [ x$flags != "x0x1" ]; then
10833 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10835 error "flag $flags is not 0x1"
10837 echo "unlink a file having nlink = 1," \
10838 "changelog record has flags of $flags"
10840 # unlink a file having nlink > 1 (changelog flag 0x0)
10841 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10842 rm -f $DIR/$tdir/foobar_161c
10843 $LFS changelog $MDT0 | grep UNLNK
10844 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10845 $LFS changelog_clear $MDT0 $USER 0
10846 if [ x$flags != "x0x0" ]; then
10847 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10849 error "flag $flags is not 0x0"
10851 echo "unlink a file having nlink > 1," \
10852 "changelog record has flags of $flags"
10853 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10855 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10862 local path=$(${LFS} fid2path $*)
10863 # Remove the '//' indicating a remote directory
10864 path=$(echo $path | sed 's#//#/#g')
10867 if [ $RC -ne 0 ]; then
10868 err17935 "path looked up of $expected failed. Error $RC"
10870 elif [ "${path}" != "${expected}" ]; then
10871 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10874 echo "fid $fid resolves to path $path (expected $expected)"
10877 test_162a() { # was test_162
10878 # Make changes to filesystem
10879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10880 test_mkdir -p -c1 $DIR/$tdir/d2
10881 touch $DIR/$tdir/d2/$tfile
10882 touch $DIR/$tdir/d2/x1
10883 touch $DIR/$tdir/d2/x2
10884 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10885 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10887 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10888 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10889 error "check path $tdir/d2/$tfile failed"
10892 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10893 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10894 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10895 error "check path $tdir/d2/p/q/r/slink failed"
10897 # softlink to wrong file
10898 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10899 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10900 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10901 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10904 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10905 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10906 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10907 # fid2path dir/fsname should both work
10908 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10909 error "check path $tdir/d2/a/b/c/new_file failed"
10910 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10911 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10913 # hardlink count: check that there are 2 links
10914 # Doesnt work with CMD yet: 17935
10915 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10916 err17935 "expected 2 links"
10918 # hardlink indexing: remove the first link
10919 rm $DIR/$tdir/d2/p/q/r/hlink
10920 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10921 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10925 run_test 162a "path lookup sanity"
10928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10929 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10932 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10933 error "create striped dir failed"
10935 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10936 tail -n 1 | awk '{print $2}')
10937 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10939 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10940 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10943 for ((i=0;i<5;i++)); do
10944 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10945 error "get fid for f$i failed"
10946 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10947 error "check path $tdir/striped_dir/f$i failed"
10949 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10950 error "get fid for d$i failed"
10951 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10952 error "check path $tdir/striped_dir/d$i failed"
10957 run_test 162b "striped directory path lookup sanity"
10959 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10961 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
10962 skip "Need MDS version at least 2.7.51" && return
10963 test_mkdir $DIR/$tdir.local
10964 test_mkdir $DIR/$tdir.remote
10965 local lpath=$tdir.local
10966 local rpath=$tdir.remote
10968 for ((i = 0; i <= 101; i++)); do
10971 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10972 error "get fid for local directory $DIR/$lpath failed"
10973 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10974 error "check path for local directory $DIR/$lpath failed"
10977 test_mkdir $DIR/$rpath
10978 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10979 error "get fid for remote directory $DIR/$rpath failed"
10980 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10981 error "check path for remote directory $DIR/$rpath failed"
10986 run_test 162c "fid2path works with paths 100 or more directories deep"
10989 # do directio so as not to populate the page cache
10990 log "creating a 10 Mb file"
10991 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10992 log "starting reads"
10993 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10994 log "truncating the file"
10995 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10997 kill %+ || true # reads might have finished
10998 echo "wait until dd is finished"
11000 log "removing the temporary file"
11001 rm -rf $DIR/$tfile || error "tmp file removal failed"
11003 run_test 169 "parallel read and truncate should not deadlock"
11006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11007 $LCTL clear # bug 18514
11008 $LCTL debug_daemon start $TMP/${tfile}_log_good
11010 $LCTL debug_daemon stop
11011 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
11012 error "sed failed to read log_good"
11014 $LCTL debug_daemon start $TMP/${tfile}_log_good
11016 $LCTL debug_daemon stop
11018 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
11019 error "lctl df log_bad failed"
11021 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11022 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11024 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
11025 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
11027 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
11028 error "bad_line good_line1 good_line2 are empty"
11030 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11031 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
11032 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
11034 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
11035 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
11036 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
11038 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
11039 error "bad_line_new good_line_new are empty"
11041 local expected_good=$((good_line1 + good_line2*2))
11043 rm -f $TMP/${tfile}*
11044 # LU-231, short malformed line may not be counted into bad lines
11045 if [ $bad_line -ne $bad_line_new ] &&
11046 [ $bad_line -ne $((bad_line_new - 1)) ]; then
11047 error "expected $bad_line bad lines, but got $bad_line_new"
11051 if [ $expected_good -ne $good_line_new ]; then
11052 error "expected $expected_good good lines, but got $good_line_new"
11057 run_test 170 "test lctl df to handle corrupted log ====================="
11059 test_171() { # bug20592
11060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11061 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
11062 $LCTL set_param fail_loc=0x50e
11063 $LCTL set_param fail_val=3000
11064 multiop_bg_pause $DIR/$tfile O_s || true
11066 kill -USR1 $MULTIPID
11070 if dmesg | grep "recursive fault"; then
11071 error "caught a recursive fault"
11073 $LCTL set_param fail_loc=0
11076 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
11078 # it would be good to share it with obdfilter-survey/iokit-libecho code
11079 setup_obdecho_osc () {
11082 local obdfilter_name=$2
11083 echo "Creating new osc for $obdfilter_name on $ost_nid"
11084 # make sure we can find loopback nid
11085 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
11087 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
11088 ${obdfilter_name}_osc_UUID || rc=2; }
11089 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
11090 ${obdfilter_name}_UUID $ost_nid || rc=3; }
11094 cleanup_obdecho_osc () {
11095 local obdfilter_name=$1
11096 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
11097 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
11104 local pages=${3:-64}
11109 local obd_size=$(get_obd_size $node $OBD)
11110 local page_size=$(get_page_size $node)
11111 if [[ -n "$obd_size" ]]; then
11112 local new_count=$((obd_size / (pages * page_size / 1024)))
11113 [[ $new_count -ge $count ]] || count=$new_count
11116 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
11117 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
11119 if [ $rc -eq 0 ]; then
11120 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
11121 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
11123 echo "New object id is $id"
11124 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
11126 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
11127 "test_brw $count w v $pages $id" || rc=4; }
11128 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
11130 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
11131 "cleanup" || rc=5; }
11132 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
11133 "detach" || rc=6; }
11134 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
11139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11140 remote_ost_nodsh && skip "remote OST with nodsh" && return
11142 local rmmod_local=0
11144 if ! module_loaded obdecho; then
11145 load_module obdecho/obdecho
11149 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
11150 local host=$(lctl get_param -n osc.$osc.import |
11151 awk '/current_connection:/ {print $2}' )
11152 local target=$(lctl get_param -n osc.$osc.import |
11153 awk '/target:/ {print $2}' )
11154 target=${target%_UUID}
11156 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
11157 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
11158 [[ -n $target ]] && cleanup_obdecho_osc $target
11159 [ $rmmod_local -eq 1 ] && rmmod obdecho
11162 run_test 180a "test obdecho on osc"
11165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11166 remote_ost_nodsh && skip "remote OST with nodsh" && return
11168 local rmmod_remote=0
11170 do_facet ost1 "lsmod | grep -q obdecho || " \
11171 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
11172 "modprobe obdecho; }" && rmmod_remote=1
11173 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
11174 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
11175 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11178 run_test 180b "test obdecho directly on obdfilter"
11180 test_180c() { # LU-2598
11181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11182 remote_ost_nodsh && skip "remote OST with nodsh" && return
11183 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11184 skip "Need MDS version at least 2.4.0" && return
11187 local rmmod_remote=false
11188 local pages=16384 # 64MB bulk I/O RPC size
11191 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11192 rmmod_remote=true || error "failed to load module obdecho"
11194 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11196 if [ -n "$target" ]; then
11197 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11199 echo "there is no obdfilter target on ost1"
11202 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11205 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11207 test_181() { # bug 22177
11208 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11209 # create enough files to index the directory
11210 createmany -o $DIR/$tdir/foobar 4000
11211 # print attributes for debug purpose
11214 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11216 # remove the files & current working dir
11217 unlinkmany $DIR/$tdir/foobar 4000
11219 kill -USR1 $MULTIPID
11221 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11224 run_test 181 "Test open-unlinked dir ========================"
11230 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11232 $LCTL set_param mdc.*.rpc_stats=clear
11234 for (( i = 0; i < $tcount; i++ )) ; do
11235 mkdir $DIR/$tdir/$i
11238 for (( i = 0; i < $tcount; i++ )) ; do
11239 createmany -o $DIR/$tdir/$i/f- $fcount &
11243 for (( i = 0; i < $tcount; i++ )) ; do
11244 unlinkmany $DIR/$tdir/$i/f- $fcount &
11248 $LCTL get_param mdc.*.rpc_stats
11252 run_test 182 "Test parallel modify metadata operations ================"
11254 test_183() { # LU-2275
11255 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11256 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11257 skip "Need MDS version at least 2.3.56" && return
11259 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11260 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11261 echo aaa > $DIR/$tdir/$tfile
11263 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11264 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11266 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11267 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11269 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11271 # Flush negative dentry cache
11272 touch $DIR/$tdir/$tfile
11274 # We are not checking for any leaked references here, they'll
11275 # become evident next time we do cleanup with module unload.
11278 run_test 183 "No crash or request leak in case of strange dispositions ========"
11280 # test suite 184 is for LU-2016, LU-2017
11282 check_swap_layouts_support && return 0
11284 dir0=$DIR/$tdir/$testnum
11285 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11290 $SETSTRIPE -c1 $file1
11292 $SETSTRIPE -c2 $file2
11294 gen1=$($GETSTRIPE -g $file1)
11295 gen2=$($GETSTRIPE -g $file2)
11297 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11298 gen=$($GETSTRIPE -g $file1)
11299 [[ $gen1 != $gen ]] ||
11300 "Layout generation on $file1 does not change"
11301 gen=$($GETSTRIPE -g $file2)
11302 [[ $gen2 != $gen ]] ||
11303 "Layout generation on $file2 does not change"
11305 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11306 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11308 run_test 184a "Basic layout swap"
11311 check_swap_layouts_support && return 0
11313 dir0=$DIR/$tdir/$testnum
11314 mkdir -p $dir0 || error "creating dir $dir0"
11321 $SETSTRIPE -c1 $file1
11322 $SETSTRIPE -c2 $file2
11323 $SETSTRIPE -c1 $file3
11324 chown $RUNAS_ID $file3
11325 gen1=$($GETSTRIPE -g $file1)
11326 gen2=$($GETSTRIPE -g $file2)
11328 $LFS swap_layouts $dir1 $dir2 &&
11329 error "swap of directories layouts should fail"
11330 $LFS swap_layouts $dir1 $file1 &&
11331 error "swap of directory and file layouts should fail"
11332 $RUNAS $LFS swap_layouts $file1 $file2 &&
11333 error "swap of file we cannot write should fail"
11334 $LFS swap_layouts $file1 $file3 &&
11335 error "swap of file with different owner should fail"
11336 /bin/true # to clear error code
11338 run_test 184b "Forbidden layout swap (will generate errors)"
11341 check_swap_layouts_support && return 0
11343 local dir0=$DIR/$tdir/$testnum
11344 mkdir -p $dir0 || error "creating dir $dir0"
11346 local ref1=$dir0/ref1
11347 local ref2=$dir0/ref2
11348 local file1=$dir0/file1
11349 local file2=$dir0/file2
11350 # create a file large enough for the concurrent test
11351 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11352 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11353 echo "ref file size: ref1($(stat -c %s $ref1))," \
11354 "ref2($(stat -c %s $ref2))"
11357 dd if=$ref1 of=$file1 bs=16k &
11360 # Make sure dd starts to copy file
11361 while [ ! -f $file1 ]; do sleep 0.1; done
11363 $LFS swap_layouts $file1 $file2
11366 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11367 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11369 # how many bytes copied before swapping layout
11370 local copied=$(stat -c %s $file2)
11371 local remaining=$(stat -c %s $ref1)
11372 remaining=$((remaining - copied))
11373 echo "Copied $copied bytes before swapping layout..."
11375 cmp -n $copied $file1 $ref2 | grep differ &&
11376 error "Content mismatch [0, $copied) of ref2 and file1"
11377 cmp -n $copied $file2 $ref1 ||
11378 error "Content mismatch [0, $copied) of ref1 and file2"
11379 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11380 error "Content mismatch [$copied, EOF) of ref1 and file1"
11383 rm -f $ref1 $ref2 $file1 $file2
11385 run_test 184c "Concurrent write and layout swap"
11388 check_swap_layouts_support && return 0
11389 [ -z "$(which getfattr 2>/dev/null)" ] &&
11390 skip "no getfattr command" && return 0
11392 local file1=$DIR/$tdir/$tfile-1
11393 local file2=$DIR/$tdir/$tfile-2
11394 local file3=$DIR/$tdir/$tfile-3
11398 mkdir -p $DIR/$tdir
11399 touch $file1 || error "create $file1 failed"
11400 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11401 error "create $file2 failed"
11402 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11403 error "create $file3 failed"
11404 lovea1=$($LFS getstripe $file1 | sed 1d)
11406 $LFS swap_layouts $file2 $file3 ||
11407 error "swap $file2 $file3 layouts failed"
11408 $LFS swap_layouts $file1 $file2 ||
11409 error "swap $file1 $file2 layouts failed"
11411 lovea2=$($LFS getstripe $file2 | sed 1d)
11412 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11414 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11415 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11417 run_test 184d "allow stripeless layouts swap"
11420 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11421 { skip "Need MDS version at least 2.6.94"; return 0; }
11422 check_swap_layouts_support && return 0
11423 [ -z "$(which getfattr 2>/dev/null)" ] &&
11424 skip "no getfattr command" && return 0
11426 local file1=$DIR/$tdir/$tfile-1
11427 local file2=$DIR/$tdir/$tfile-2
11428 local file3=$DIR/$tdir/$tfile-3
11431 mkdir -p $DIR/$tdir
11432 touch $file1 || error "create $file1 failed"
11433 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11434 error "create $file2 failed"
11435 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11436 error "create $file3 failed"
11438 $LFS swap_layouts $file1 $file2 ||
11439 error "swap $file1 $file2 layouts failed"
11441 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11442 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11444 echo 123 > $file1 || error "Should be able to write into $file1"
11446 $LFS swap_layouts $file1 $file3 ||
11447 error "swap $file1 $file3 layouts failed"
11449 echo 123 > $file1 || error "Should be able to write into $file1"
11451 rm -rf $file1 $file2 $file3
11453 run_test 184e "Recreate layout after stripeless layout swaps"
11455 test_185() { # LU-2441
11456 # LU-3553 - no volatile file support in old servers
11457 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11458 { skip "Need MDS version at least 2.3.60"; return 0; }
11460 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11461 touch $DIR/$tdir/spoo
11462 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11463 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11464 error "cannot create/write a volatile file"
11465 [ "$FILESET" == "" ] &&
11466 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11467 error "FID is still valid after close"
11469 multiop_bg_pause $DIR/$tdir vVw4096_c
11476 # assume that the next FID for this client is sequential, since stdout
11477 # is unfortunately eaten by multiop_bg_pause
11478 local n=$((${fidv[1]} + 1))
11479 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11480 if [ "$FILESET" == "" ]; then
11481 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11482 error "FID is missing before close"
11484 kill -USR1 $multi_pid
11485 # 1 second delay, so if mtime change we will see it
11487 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11488 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11490 run_test 185 "Volatile file support"
11493 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11494 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11495 skip "Need MDS version at least 2.3.0" && return
11497 local dir0=$DIR/$tdir/$testnum
11498 mkdir -p $dir0 || error "creating dir $dir0"
11500 local file=$dir0/file1
11501 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11502 local dv1=$($LFS data_version $file)
11503 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11504 local dv2=$($LFS data_version $file)
11505 [[ $dv1 != $dv2 ]] ||
11506 error "data version did not change on write $dv1 == $dv2"
11511 run_test 187a "Test data version change"
11514 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11515 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11516 skip "Need MDS version at least 2.3.0" && return
11518 local dir0=$DIR/$tdir/$testnum
11519 mkdir -p $dir0 || error "creating dir $dir0"
11521 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11522 [[ ${DV[0]} != ${DV[1]} ]] ||
11523 error "data version did not change on write"\
11524 " ${DV[0]} == ${DV[1]}"
11529 run_test 187b "Test data version change on volatile file"
11532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11533 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11534 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
11536 local POOL=${POOL:-cea1}
11537 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11538 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11541 local last_ost=$(($OSTCOUNT - 1))
11543 local ost_list=$(seq $first_ost $ost_step $last_ost)
11544 local ost_range="$first_ost $last_ost $ost_step"
11545 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11546 local file_dir=$POOL_ROOT/file_tst
11547 local subdir=$test_path/subdir
11551 # former test_200a test_200b
11552 pool_add $POOL || { rc=$? ; break; }
11553 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11554 # former test_200c test_200d
11555 mkdir -p $test_path
11556 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11557 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11559 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11560 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11561 || { rc=$? ; break; }
11562 # former test_200e test_200f
11563 local files=$((OSTCOUNT*3))
11564 pool_alloc_files $POOL $test_path $files "$ost_list" \
11565 || { rc=$? ; break; }
11566 pool_create_files $POOL $file_dir $files "$ost_list" \
11567 || { rc=$? ; break; }
11568 # former test_200g test_200h
11569 pool_lfs_df $POOL || { rc=$? ; break; }
11570 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11572 # former test_201a test_201b test_201c
11573 pool_remove_first_target $POOL || { rc=$? ; break; }
11575 local f=$test_path/$tfile
11576 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11577 pool_remove $POOL $f || { rc=$? ; break; }
11584 run_test 200 "OST pools"
11586 # usage: default_attr <count | size | offset>
11588 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11591 # usage: check_default_stripe_attr
11592 check_default_stripe_attr() {
11593 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11595 --stripe-count|--count)
11596 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11597 --stripe-size|--size)
11598 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11599 --stripe-index|--index)
11602 error "unknown getstripe attr '$1'"
11605 [ $ACTUAL != $EXPECTED ] &&
11606 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11610 test_mkdir -p $DIR/$tdir
11611 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11613 check_default_stripe_attr --stripe-count
11614 check_default_stripe_attr --stripe-size
11615 check_default_stripe_attr --stripe-index
11619 run_test 204a "Print default stripe attributes ================="
11622 test_mkdir -p $DIR/$tdir
11623 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11625 check_default_stripe_attr --stripe-size
11626 check_default_stripe_attr --stripe-index
11630 run_test 204b "Print default stripe size and offset ==========="
11633 test_mkdir -p $DIR/$tdir
11634 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11636 check_default_stripe_attr --stripe-count
11637 check_default_stripe_attr --stripe-index
11641 run_test 204c "Print default stripe count and offset ==========="
11644 test_mkdir -p $DIR/$tdir
11645 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11647 check_default_stripe_attr --stripe-count
11648 check_default_stripe_attr --stripe-size
11652 run_test 204d "Print default stripe count and size ============="
11655 test_mkdir -p $DIR/$tdir
11656 $SETSTRIPE -d $DIR/$tdir
11658 check_default_stripe_attr --stripe-count --raw
11659 check_default_stripe_attr --stripe-size --raw
11660 check_default_stripe_attr --stripe-index --raw
11664 run_test 204e "Print raw stripe attributes ================="
11667 test_mkdir -p $DIR/$tdir
11668 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11670 check_default_stripe_attr --stripe-size --raw
11671 check_default_stripe_attr --stripe-index --raw
11675 run_test 204f "Print raw stripe size and offset ==========="
11678 test_mkdir -p $DIR/$tdir
11679 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11681 check_default_stripe_attr --stripe-count --raw
11682 check_default_stripe_attr --stripe-index --raw
11686 run_test 204g "Print raw stripe count and offset ==========="
11689 test_mkdir -p $DIR/$tdir
11690 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11692 check_default_stripe_attr --stripe-count --raw
11693 check_default_stripe_attr --stripe-size --raw
11697 run_test 204h "Print raw stripe count and size ============="
11699 # Figure out which job scheduler is being used, if any,
11700 # or use a fake one
11701 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11702 JOBENV=SLURM_JOB_ID
11703 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11705 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11707 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11708 JOBENV=LOADL_STEP_ID
11709 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11712 $LCTL list_param jobid_name > /dev/null 2>&1
11713 if [ $? -eq 0 ]; then
11720 verify_jobstats() {
11725 # we don't really need to clear the stats for this test to work, since each
11726 # command has a unique jobid, but it makes debugging easier if needed.
11727 # for facet in $facets; do
11728 # local dev=$(convert_facet2label $facet)
11729 # # clear old jobstats
11730 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11733 # use a new JobID for each test, or we might see an old one
11734 [ "$JOBENV" = "FAKE_JOBID" ] &&
11735 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11739 [ "$JOBENV" = "nodelocal" ] && {
11740 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11741 $LCTL set_param jobid_name=$FAKE_JOBID
11745 log "Test: ${cmd[*]}"
11746 log "Using JobID environment variable $JOBENV=$JOBVAL"
11748 if [ $JOBENV = "FAKE_JOBID" ]; then
11749 FAKE_JOBID=$JOBVAL ${cmd[*]}
11754 # all files are created on OST0000
11755 for facet in $facets; do
11756 local stats="*.$(convert_facet2label $facet).job_stats"
11757 if [ $(do_facet $facet lctl get_param $stats |
11758 grep -c $JOBVAL) -ne 1 ]; then
11759 do_facet $facet lctl get_param $stats
11760 error "No jobstats for $JOBVAL found on $facet::$stats"
11767 NEW_JOBENV=${1:-$OLD_JOBENV}
11768 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11769 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11773 do_facet $SINGLEMDS \
11774 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11775 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11776 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11779 test_205() { # Job stats
11780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11781 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11782 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11783 remote_ost_nodsh && skip "remote OST with nodsh" && return
11785 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11786 skip "Server doesn't support jobstats" && return 0
11787 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11789 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11790 if [ $OLD_JOBENV != $JOBENV ]; then
11791 jobstats_set $JOBENV
11792 trap cleanup_205 EXIT
11795 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11796 echo "Registered as changelog user $CL_USER"
11798 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11799 lctl get_param -n mdt.*.job_cleanup_interval)
11800 local interval_new=5
11801 do_facet $SINGLEMDS \
11802 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11803 local start=$SECONDS
11807 cmd="mkdir $DIR/$tdir"
11808 verify_jobstats "$cmd" "$SINGLEMDS"
11810 cmd="rmdir $DIR/$tdir"
11811 verify_jobstats "$cmd" "$SINGLEMDS"
11812 # mkdir on secondary MDT
11813 if [ $MDSCOUNT -gt 1 ]; then
11814 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11815 verify_jobstats "$cmd" "mds2"
11818 cmd="mknod $DIR/$tfile c 1 3"
11819 verify_jobstats "$cmd" "$SINGLEMDS"
11821 cmd="rm -f $DIR/$tfile"
11822 verify_jobstats "$cmd" "$SINGLEMDS"
11823 # create all files on OST0000 so verify_jobstats can find OST stats
11825 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11826 verify_jobstats "$cmd" "$SINGLEMDS"
11828 cmd="touch $DIR/$tfile"
11829 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11831 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11832 verify_jobstats "$cmd" "ost1"
11834 cancel_lru_locks osc
11835 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11836 verify_jobstats "$cmd" "ost1"
11838 cmd="$TRUNCATE $DIR/$tfile 0"
11839 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11841 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11842 verify_jobstats "$cmd" "$SINGLEMDS"
11843 # jobstats expiry - sleep until old stats should be expired
11844 local left=$((interval_new + 2 - (SECONDS - start)))
11845 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11846 cmd="mkdir $DIR/$tdir.expire"
11847 verify_jobstats "$cmd" "$SINGLEMDS"
11848 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11849 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11851 # Ensure that jobid are present in changelog (if supported by MDS)
11852 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11854 $LFS changelog $MDT0 | tail -9
11855 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11856 [ $jobids -eq 9 ] ||
11857 error "Wrong changelog jobid count $jobids != 9"
11861 jobstats_set $JOBENV
11863 $LFS changelog $MDT0 | tail -1
11864 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11865 [ $jobids -eq 0 ] ||
11866 error "Unexpected jobids when jobid_var=$JOBENV"
11871 run_test 205 "Verify job stats"
11873 # LU-1480, LU-1773 and LU-1657
11875 mkdir -p $DIR/$tdir
11876 $SETSTRIPE -c -1 $DIR/$tdir
11877 #define OBD_FAIL_LOV_INIT 0x1403
11878 $LCTL set_param fail_loc=0xa0001403
11879 $LCTL set_param fail_val=1
11880 touch $DIR/$tdir/$tfile || true
11882 run_test 206 "fail lov_init_raid0() doesn't lbug"
11885 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11886 local fsz=`stat -c %s $DIR/$tfile`
11887 cancel_lru_locks mdc
11889 # do not return layout in getattr intent
11890 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11891 $LCTL set_param fail_loc=0x170
11892 local sz=`stat -c %s $DIR/$tfile`
11894 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11898 run_test 207a "can refresh layout at glimpse"
11901 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11902 local cksum=`md5sum $DIR/$tfile`
11903 local fsz=`stat -c %s $DIR/$tfile`
11904 cancel_lru_locks mdc
11905 cancel_lru_locks osc
11907 # do not return layout in getattr intent
11908 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11909 $LCTL set_param fail_loc=0x171
11911 # it will refresh layout after the file is opened but before read issues
11912 echo checksum is "$cksum"
11913 echo "$cksum" |md5sum -c --quiet || error "file differs"
11917 run_test 207b "can refresh layout at open"
11920 # FIXME: in this test suite, only RD lease is used. This is okay
11921 # for now as only exclusive open is supported. After generic lease
11922 # is done, this test suite should be revised. - Jinshan
11924 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11925 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11926 { skip "Need MDS version at least 2.4.52"; return 0; }
11928 echo "==== test 1: verify get lease work"
11929 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11931 echo "==== test 2: verify lease can be broken by upcoming open"
11932 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11936 $MULTIOP $DIR/$tfile oO_RDONLY:c
11937 kill -USR1 $PID && wait $PID || error "break lease error"
11939 echo "==== test 3: verify lease can't be granted if an open already exists"
11940 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11944 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11945 kill -USR1 $PID && wait $PID || error "open file error"
11947 echo "==== test 4: lease can sustain over recovery"
11948 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11954 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11956 echo "==== test 5: lease broken can't be regained by replay"
11957 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11961 # open file to break lease and then recovery
11962 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11965 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11969 run_test 208 "Exclusive open"
11972 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11973 skip_env "must have disp_stripe" && return
11976 sync; sleep 5; sync;
11978 echo 3 > /proc/sys/vm/drop_caches
11979 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11981 # open/close 500 times
11982 for i in $(seq 500); do
11986 echo 3 > /proc/sys/vm/drop_caches
11987 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11989 echo "before: $req_before, after: $req_after"
11990 [ $((req_after - req_before)) -ge 300 ] &&
11991 error "open/close requests are not freed"
11994 run_test 209 "read-only open/close requests should be freed promptly"
11998 size=$((size % 8192 + 1))
11999 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
12000 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
12001 rm -f $DIR/f212 $DIR/f212.xyz
12003 run_test 212 "Sendfile test ============================================"
12006 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
12007 cancel_lru_locks osc
12008 lctl set_param fail_loc=0x8000040f
12009 # generate a read lock
12010 cat $DIR/$tfile > /dev/null
12011 # write to the file, it will try to cancel the above read lock.
12012 cat /etc/hosts >> $DIR/$tfile
12014 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
12016 test_214() { # for bug 20133
12017 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
12018 for (( i=0; i < 340; i++ )) ; do
12019 touch $DIR/$tdir/d214c/a$i
12022 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
12023 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
12024 ls $DIR/d214c || error "ls $DIR/d214c failed"
12025 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
12026 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
12028 run_test 214 "hash-indexed directory test - bug 20133"
12030 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
12031 create_lnet_proc_files() {
12032 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
12033 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
12035 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
12036 rm -f "$TMP/lnet_$1.sys_tmp"
12039 # counterpart of create_lnet_proc_files
12040 remove_lnet_proc_files() {
12041 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
12044 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12045 # 3rd arg as regexp for body
12046 check_lnet_proc_stats() {
12047 local l=$(cat "$TMP/lnet_$1" |wc -l)
12048 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
12050 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
12053 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
12054 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
12055 # optional and can be regexp for 2nd line (lnet.routes case)
12056 check_lnet_proc_entry() {
12057 local blp=2 # blp stands for 'position of 1st line of body'
12058 [ -z "$5" ] || blp=3 # lnet.routes case
12060 local l=$(cat "$TMP/lnet_$1" |wc -l)
12061 # subtracting one from $blp because the body can be empty
12062 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
12064 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
12065 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
12067 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
12068 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
12070 # bail out if any unexpected line happened
12071 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
12072 [ "$?" != 0 ] || error "$2 misformatted"
12075 test_215() { # for bugs 18102, 21079, 21517
12076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12077 local N='(0|[1-9][0-9]*)' # non-negative numeric
12078 local P='[1-9][0-9]*' # positive numeric
12079 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
12080 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
12081 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
12082 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
12084 local L1 # regexp for 1st line
12085 local L2 # regexp for 2nd line (optional)
12086 local BR # regexp for the rest (body)
12088 # lnet.stats should look as 11 space-separated non-negative numerics
12089 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
12090 create_lnet_proc_files "stats"
12091 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
12092 remove_lnet_proc_files "stats"
12094 # lnet.routes should look like this:
12095 # Routing disabled/enabled
12096 # net hops priority state router
12097 # where net is a string like tcp0, hops > 0, priority >= 0,
12098 # state is up/down,
12099 # router is a string like 192.168.1.1@tcp2
12100 L1="^Routing (disabled|enabled)$"
12101 L2="^net +hops +priority +state +router$"
12102 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
12103 create_lnet_proc_files "routes"
12104 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
12105 remove_lnet_proc_files "routes"
12107 # lnet.routers should look like this:
12108 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
12109 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
12110 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
12111 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
12112 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
12113 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
12114 create_lnet_proc_files "routers"
12115 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
12116 remove_lnet_proc_files "routers"
12118 # lnet.peers should look like this:
12119 # nid refs state last max rtr min tx min queue
12120 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
12121 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
12122 # numeric (0 or >0 or <0), queue >= 0.
12123 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
12124 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
12125 create_lnet_proc_files "peers"
12126 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
12127 remove_lnet_proc_files "peers"
12129 # lnet.buffers should look like this:
12130 # pages count credits min
12131 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
12132 L1="^pages +count +credits +min$"
12133 BR="^ +$N +$N +$I +$I$"
12134 create_lnet_proc_files "buffers"
12135 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
12136 remove_lnet_proc_files "buffers"
12138 # lnet.nis should look like this:
12139 # nid status alive refs peer rtr max tx min
12140 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
12141 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
12142 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
12143 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
12144 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
12145 create_lnet_proc_files "nis"
12146 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
12147 remove_lnet_proc_files "nis"
12149 # can we successfully write to lnet.stats?
12150 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
12151 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
12153 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
12155 test_216() { # bug 20317
12156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12157 remote_ost_nodsh && skip "remote OST with nodsh" && return
12160 local facets=$(get_facets OST)
12161 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12163 save_lustre_params client "osc.*.contention_seconds" > $p
12164 save_lustre_params $facets \
12165 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
12166 save_lustre_params $facets \
12167 "ldlm.namespaces.filter-*.contended_locks" >> $p
12168 save_lustre_params $facets \
12169 "ldlm.namespaces.filter-*.contention_seconds" >> $p
12172 # agressive lockless i/o settings
12173 for node in $(osts_nodes); do
12174 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
12176 lctl set_param -n osc.*.contention_seconds 60
12178 $DIRECTIO write $DIR/$tfile 0 10 4096
12179 $CHECKSTAT -s 40960 $DIR/$tfile
12181 # disable lockless i/o
12182 for node in $(osts_nodes); do
12183 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
12185 lctl set_param -n osc.*.contention_seconds 0
12188 dd if=/dev/zero of=$DIR/$tfile count=0
12189 $CHECKSTAT -s 0 $DIR/$tfile
12191 restore_lustre_params <$p
12195 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12197 test_217() { # bug 22430
12198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12202 for node in $(nodes_list); do
12203 nid=$(host_nids_address $node $NETTYPE)
12204 if [[ $nid = *-* ]] ; then
12205 echo "lctl ping $nid@$NETTYPE"
12206 lctl ping $nid@$NETTYPE
12208 echo "skipping $node (no hyphen detected)"
12212 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12215 # do directio so as not to populate the page cache
12216 log "creating a 10 Mb file"
12217 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12218 log "starting reads"
12219 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12220 log "truncating the file"
12221 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12223 kill %+ || true # reads might have finished
12224 echo "wait until dd is finished"
12226 log "removing the temporary file"
12227 rm -rf $DIR/$tfile || error "tmp file removal failed"
12229 run_test 218 "parallel read and truncate should not deadlock ======================="
12232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12233 # write one partial page
12234 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12235 # set no grant so vvp_io_commit_write will do sync write
12236 $LCTL set_param fail_loc=0x411
12237 # write a full page at the end of file
12238 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12240 $LCTL set_param fail_loc=0
12241 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12242 $LCTL set_param fail_loc=0x411
12243 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12246 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12247 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12249 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12251 test_220() { #LU-325
12252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12253 remote_ost_nodsh && skip "remote OST with nodsh" && return
12254 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12255 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12258 # create on MDT0000 so the last_id and next_id are correct
12260 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12264 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12265 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12266 osc.$mdtosc_proc1.prealloc_last_id)
12267 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12268 osc.$mdtosc_proc1.prealloc_next_id)
12272 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12273 #define OBD_FAIL_OST_ENOINO 0x229
12274 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12275 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12276 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12278 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12280 MDSOBJS=$((last_id - next_id))
12281 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12283 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12284 echo "OST still has $count kbytes free"
12286 echo "create $MDSOBJS files @next_id..."
12287 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12289 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12290 osc.$mdtosc_proc1.prealloc_last_id)
12291 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12292 osc.$mdtosc_proc1.prealloc_next_id)
12294 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12299 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12300 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12302 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12303 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12304 echo "unlink $MDSOBJS files @$next_id..."
12305 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12307 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12311 dd if=`which date` of=$MOUNT/date oflag=sync
12312 chmod +x $MOUNT/date
12314 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12315 $LCTL set_param fail_loc=0x80001401
12317 $MOUNT/date > /dev/null
12320 run_test 221 "make sure fault and truncate race to not cause OOM"
12323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12325 test_mkdir -p $DIR/$tdir
12326 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12327 createmany -o $DIR/$tdir/$tfile 10
12328 cancel_lru_locks mdc
12329 cancel_lru_locks osc
12330 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12331 $LCTL set_param fail_loc=0x31a
12332 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12333 $LCTL set_param fail_loc=0
12336 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12341 test_mkdir -p $DIR/$tdir
12342 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12343 createmany -o $DIR/$tdir/$tfile 10
12344 cancel_lru_locks mdc
12345 cancel_lru_locks osc
12346 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12347 $LCTL set_param fail_loc=0x31a
12348 rm -r $DIR/$tdir || "AGL for rmdir failed"
12349 $LCTL set_param fail_loc=0
12351 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12356 test_mkdir -p $DIR/$tdir
12357 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12358 createmany -o $DIR/$tdir/$tfile 10
12359 cancel_lru_locks mdc
12360 cancel_lru_locks osc
12361 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12362 $LCTL set_param fail_loc=0x31b
12363 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12364 $LCTL set_param fail_loc=0
12367 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12369 test_224a() { # LU-1039, MRP-303
12370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12371 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12372 $LCTL set_param fail_loc=0x508
12373 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12374 $LCTL set_param fail_loc=0
12377 run_test 224a "Don't panic on bulk IO failure"
12379 test_224b() { # LU-1039, MRP-303
12380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12381 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12382 cancel_lru_locks osc
12383 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12384 $LCTL set_param fail_loc=0x515
12385 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12386 $LCTL set_param fail_loc=0
12389 run_test 224b "Don't panic on bulk IO failure"
12391 test_224c() { # LU-6441
12392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12393 local pages_per_rpc=$($LCTL get_param \
12394 osc.*.max_pages_per_rpc)
12395 local at_max=$($LCTL get_param -n at_max)
12396 local timeout=$($LCTL get_param -n timeout)
12397 local test_at="$LCTL get_param -n at_max"
12398 local param_at="$FSNAME.sys.at_max"
12399 local test_timeout="$LCTL get_param -n timeout"
12400 local param_timeout="$FSNAME.sys.timeout"
12402 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12404 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12405 error "conf_param at_max=0 failed"
12406 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12407 error "conf_param timeout=5 failed"
12409 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12410 $LCTL set_param fail_loc=0x520
12411 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12413 $LCTL set_param fail_loc=0
12415 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12416 error "conf_param at_max=$at_max failed"
12417 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12418 $timeout || error "conf_param timeout=$timeout failed"
12420 $LCTL set_param -n $pages_per_rpc
12422 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12424 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12427 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12428 if [ -z ${MDSSURVEY} ]; then
12429 skip_env "mds-survey not found" && return
12432 [ $MDSCOUNT -ge 2 ] &&
12433 skip "skipping now for more than one MDT" && return
12435 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12436 { skip "Need MDS version at least 2.2.51"; return; }
12438 local mds=$(facet_host $SINGLEMDS)
12439 local target=$(do_nodes $mds 'lctl dl' | \
12440 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12442 local cmd1="file_count=1000 thrhi=4"
12443 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12444 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12445 local cmd="$cmd1 $cmd2 $cmd3"
12447 rm -f ${TMP}/mds_survey*
12449 eval $cmd || error "mds-survey with zero-stripe failed"
12450 cat ${TMP}/mds_survey*
12451 rm -f ${TMP}/mds_survey*
12453 run_test 225a "Metadata survey sanity with zero-stripe"
12456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12457 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12458 if [ -z ${MDSSURVEY} ]; then
12459 skip_env "mds-survey not found" && return
12461 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12462 { skip "Need MDS version at least 2.2.51"; return; }
12464 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12465 skip_env "Need to mount OST to test" && return
12468 [ $MDSCOUNT -ge 2 ] &&
12469 skip "skipping now for more than one MDT" && return
12470 local mds=$(facet_host $SINGLEMDS)
12471 local target=$(do_nodes $mds 'lctl dl' | \
12472 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12474 local cmd1="file_count=1000 thrhi=4"
12475 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12476 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12477 local cmd="$cmd1 $cmd2 $cmd3"
12479 rm -f ${TMP}/mds_survey*
12481 eval $cmd || error "mds-survey with stripe_count failed"
12482 cat ${TMP}/mds_survey*
12483 rm -f ${TMP}/mds_survey*
12485 run_test 225b "Metadata survey sanity with stripe_count = 1"
12487 mcreate_path2fid () {
12493 local path=$DIR/$tdir/$name
12498 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12499 error "cannot create $desc"
12501 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12503 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12505 fid_path=$($LFS fid2path $MOUNT $fid)
12507 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12509 [ "$path" == "$fid_path" ] ||
12510 error "fid2path returned $fid_path, expected $path"
12512 echo "pass with $path and $fid"
12517 mkdir -p $DIR/$tdir
12519 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12520 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12521 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12522 mcreate_path2fid 0040666 0 0 dir "directory"
12523 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12524 mcreate_path2fid 0100666 0 0 file "regular file"
12525 mcreate_path2fid 0120666 0 0 link "symbolic link"
12526 mcreate_path2fid 0140666 0 0 sock "socket"
12528 run_test 226a "call path2fid and fid2path on files of all type"
12531 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12535 mkdir -p $DIR/$tdir
12536 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12537 error "create remote directory failed"
12538 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12539 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12540 "character special file (null)"
12541 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12542 "character special file (no device)"
12543 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12544 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12545 "block special file (loop)"
12546 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12547 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12548 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12550 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12552 # LU-1299 Executing or running ldd on a truncated executable does not
12553 # cause an out-of-memory condition.
12555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12556 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12557 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12558 chmod +x $MOUNT/date
12560 $MOUNT/date > /dev/null
12561 ldd $MOUNT/date > /dev/null
12564 run_test 227 "running truncated executable does not cause OOM"
12566 # LU-1512 try to reuse idle OI blocks
12568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12569 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12570 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12571 skip "non-ldiskfs backend" && return
12573 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12574 local myDIR=$DIR/$tdir
12577 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12578 $LCTL set_param fail_loc=0x80001002
12579 createmany -o $myDIR/t- 10000
12580 $LCTL set_param fail_loc=0
12581 # The guard is current the largest FID holder
12583 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12585 local IDX=$(($SEQ % 64))
12587 do_facet $SINGLEMDS sync
12588 # Make sure journal flushed.
12590 local blk1=$(do_facet $SINGLEMDS \
12591 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12592 grep Blockcount | awk '{print $4}')
12594 # Remove old files, some OI blocks will become idle.
12595 unlinkmany $myDIR/t- 10000
12596 # Create new files, idle OI blocks should be reused.
12597 createmany -o $myDIR/t- 2000
12598 do_facet $SINGLEMDS sync
12599 # Make sure journal flushed.
12601 local blk2=$(do_facet $SINGLEMDS \
12602 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12603 grep Blockcount | awk '{print $4}')
12605 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12607 run_test 228a "try to reuse idle OI blocks"
12610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12611 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12612 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12613 skip "non-ldiskfs backend" && return
12615 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12616 local myDIR=$DIR/$tdir
12619 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12620 $LCTL set_param fail_loc=0x80001002
12621 createmany -o $myDIR/t- 10000
12622 $LCTL set_param fail_loc=0
12623 # The guard is current the largest FID holder
12625 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12627 local IDX=$(($SEQ % 64))
12629 do_facet $SINGLEMDS sync
12630 # Make sure journal flushed.
12632 local blk1=$(do_facet $SINGLEMDS \
12633 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12634 grep Blockcount | awk '{print $4}')
12636 # Remove old files, some OI blocks will become idle.
12637 unlinkmany $myDIR/t- 10000
12640 stop $SINGLEMDS || error "Fail to stop MDT."
12642 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12644 df $MOUNT || error "Fail to df."
12645 # Create new files, idle OI blocks should be reused.
12646 createmany -o $myDIR/t- 2000
12647 do_facet $SINGLEMDS sync
12648 # Make sure journal flushed.
12650 local blk2=$(do_facet $SINGLEMDS \
12651 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12652 grep Blockcount | awk '{print $4}')
12654 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12656 run_test 228b "idle OI blocks can be reused after MDT restart"
12660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12661 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12662 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12663 skip "non-ldiskfs backend" && return
12665 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12666 local myDIR=$DIR/$tdir
12669 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12670 $LCTL set_param fail_loc=0x80001002
12671 # 20000 files can guarantee there are index nodes in the OI file
12672 createmany -o $myDIR/t- 20000
12673 $LCTL set_param fail_loc=0
12674 # The guard is current the largest FID holder
12676 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12678 local IDX=$(($SEQ % 64))
12680 do_facet $SINGLEMDS sync
12681 # Make sure journal flushed.
12683 local blk1=$(do_facet $SINGLEMDS \
12684 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12685 grep Blockcount | awk '{print $4}')
12687 # Remove old files, some OI blocks will become idle.
12688 unlinkmany $myDIR/t- 20000
12690 # The OI file should become empty now
12692 # Create new files, idle OI blocks should be reused.
12693 createmany -o $myDIR/t- 2000
12694 do_facet $SINGLEMDS sync
12695 # Make sure journal flushed.
12697 local blk2=$(do_facet $SINGLEMDS \
12698 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12699 grep Blockcount | awk '{print $4}')
12701 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12703 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12705 test_229() { # LU-2482, LU-3448
12706 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12707 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12710 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12714 # Create a file with a released layout and stripe count 2.
12715 $MULTIOP $DIR/$tfile H2c ||
12716 error "failed to create file with released layout"
12718 $GETSTRIPE -v $DIR/$tfile
12720 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12721 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12723 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12724 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12725 stat $DIR/$tfile || error "failed to stat released file"
12727 chown $RUNAS_ID $DIR/$tfile ||
12728 error "chown $RUNAS_ID $DIR/$tfile failed"
12730 chgrp $RUNAS_ID $DIR/$tfile ||
12731 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12733 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12734 rm $DIR/$tfile || error "failed to remove released file"
12736 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12740 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12743 test_mkdir $DIR/$tdir
12744 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12745 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12746 [ $mdt_idx -ne 0 ] &&
12747 error "create local directory on wrong MDT $mdt_idx"
12749 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12750 error "create remote directory failed"
12751 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12752 [ $mdt_idx -ne $MDTIDX ] &&
12753 error "create remote directory on wrong MDT $mdt_idx"
12755 createmany -o $DIR/$tdir/test_230/t- 10 ||
12756 error "create files on remote directory failed"
12757 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12758 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12759 rm -r $DIR/$tdir || error "unlink remote directory failed"
12761 run_test 230a "Create remote directory and files under the remote directory"
12764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12765 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12772 local migrate_dir=$DIR/$tdir/migrate_dir
12773 local other_dir=$DIR/$tdir/other_dir
12775 test_mkdir $DIR/$tdir
12776 test_mkdir -i0 -c1 $migrate_dir
12777 test_mkdir -i0 -c1 $other_dir
12778 for ((i=0; i<10; i++)); do
12779 mkdir -p $migrate_dir/dir_${i}
12780 createmany -o $migrate_dir/dir_${i}/f 10 ||
12781 error "create files under remote dir failed $i"
12784 cp /etc/passwd $migrate_dir/$tfile
12785 cp /etc/passwd $other_dir/$tfile
12786 chattr +SAD $migrate_dir
12787 chattr +SAD $migrate_dir/$tfile
12789 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12790 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12791 local old_dir_mode=$(stat -c%f $migrate_dir)
12792 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12794 mkdir -p $migrate_dir/dir_default_stripe2
12795 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12796 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12798 mkdir -p $other_dir
12799 ln $migrate_dir/$tfile $other_dir/luna
12800 ln $migrate_dir/$tfile $migrate_dir/sofia
12801 ln $other_dir/$tfile $migrate_dir/david
12802 ln -s $migrate_dir/$tfile $other_dir/zachary
12803 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12804 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12806 $LFS migrate -m $MDTIDX $migrate_dir ||
12807 error "fails on migrating remote dir to MDT1"
12809 echo "migratate to MDT1, then checking.."
12810 for ((i = 0; i < 10; i++)); do
12811 for file in $(find $migrate_dir/dir_${i}); do
12812 mdt_index=$($LFS getstripe -M $file)
12813 [ $mdt_index == $MDTIDX ] ||
12814 error "$file is not on MDT${MDTIDX}"
12818 # the multiple link file should still in MDT0
12819 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12820 [ $mdt_index == 0 ] ||
12821 error "$file is not on MDT${MDTIDX}"
12823 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12824 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12825 error " expect $old_dir_flag get $new_dir_flag"
12827 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12828 [ "$old_file_flag" = "$new_file_flag" ] ||
12829 error " expect $old_file_flag get $new_file_flag"
12831 local new_dir_mode=$(stat -c%f $migrate_dir)
12832 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12833 error "expect mode $old_dir_mode get $new_dir_mode"
12835 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12836 [ "$old_file_mode" = "$new_file_mode" ] ||
12837 error "expect mode $old_file_mode get $new_file_mode"
12839 diff /etc/passwd $migrate_dir/$tfile ||
12840 error "$tfile different after migration"
12842 diff /etc/passwd $other_dir/luna ||
12843 error "luna different after migration"
12845 diff /etc/passwd $migrate_dir/sofia ||
12846 error "sofia different after migration"
12848 diff /etc/passwd $migrate_dir/david ||
12849 error "david different after migration"
12851 diff /etc/passwd $other_dir/zachary ||
12852 error "zachary different after migration"
12854 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12855 error "${tfile}_ln different after migration"
12857 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12858 error "${tfile}_ln_other different after migration"
12860 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12861 [ $stripe_count = 2 ] ||
12862 error "dir strpe_count $d != 2 after migration."
12864 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12865 [ $stripe_count = 2 ] ||
12866 error "file strpe_count $d != 2 after migration."
12868 #migrate back to MDT0
12871 $LFS migrate -m $MDTIDX $migrate_dir ||
12872 error "fails on migrating remote dir to MDT0"
12874 echo "migrate back to MDT0, checking.."
12875 for file in $(find $migrate_dir); do
12876 mdt_index=$($LFS getstripe -M $file)
12877 [ $mdt_index == $MDTIDX ] ||
12878 error "$file is not on MDT${MDTIDX}"
12881 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12882 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12883 error " expect $old_dir_flag get $new_dir_flag"
12885 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12886 [ "$old_file_flag" = "$new_file_flag" ] ||
12887 error " expect $old_file_flag get $new_file_flag"
12889 local new_dir_mode=$(stat -c%f $migrate_dir)
12890 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12891 error "expect mode $old_dir_mode get $new_dir_mode"
12893 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12894 [ "$old_file_mode" = "$new_file_mode" ] ||
12895 error "expect mode $old_file_mode get $new_file_mode"
12897 diff /etc/passwd ${migrate_dir}/$tfile ||
12898 error "$tfile different after migration"
12900 diff /etc/passwd ${other_dir}/luna ||
12901 error "luna different after migration"
12903 diff /etc/passwd ${migrate_dir}/sofia ||
12904 error "sofia different after migration"
12906 diff /etc/passwd ${other_dir}/zachary ||
12907 error "zachary different after migration"
12909 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12910 error "${tfile}_ln different after migration"
12912 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12913 error "${tfile}_ln_other different after migration"
12915 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12916 [ $stripe_count = 2 ] ||
12917 error "dir strpe_count $d != 2 after migration."
12919 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12920 [ $stripe_count = 2 ] ||
12921 error "file strpe_count $d != 2 after migration."
12923 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12925 run_test 230b "migrate directory"
12928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12929 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12930 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12934 local migrate_dir=$DIR/$tdir/migrate_dir
12936 #If migrating directory fails in the middle, all entries of
12937 #the directory is still accessiable.
12938 test_mkdir $DIR/$tdir
12939 test_mkdir -i0 -c1 $migrate_dir
12941 createmany -o $migrate_dir/f 10 ||
12942 error "create files under ${migrate_dir} failed"
12944 #failed after migrating 5 entries
12945 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12946 do_facet mds1 lctl set_param fail_loc=0x20001801
12947 do_facet mds1 lctl set_param fail_val=5
12948 local t=$(ls $migrate_dir | wc -l)
12949 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
12950 error "migrate should fail after 5 entries"
12952 mkdir $migrate_dir/dir &&
12953 error "mkdir succeeds under migrating directory"
12954 touch $migrate_dir/file &&
12955 error "touch file succeeds under migrating directory"
12957 local u=$(ls $migrate_dir | wc -l)
12958 [ "$u" == "$t" ] || error "$u != $t during migration"
12960 for file in $(find $migrate_dir); do
12961 stat $file || error "stat $file failed"
12964 do_facet mds1 lctl set_param fail_loc=0
12965 do_facet mds1 lctl set_param fail_val=0
12967 $LFS migrate -m $MDTIDX $migrate_dir ||
12968 error "migrate open files should failed with open files"
12970 echo "Finish migration, then checking.."
12971 for file in $(find $migrate_dir); do
12972 mdt_index=$($LFS getstripe -M $file)
12973 [ $mdt_index == $MDTIDX ] ||
12974 error "$file is not on MDT${MDTIDX}"
12977 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12979 run_test 230c "check directory accessiblity if migration is failed"
12982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12983 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12986 local migrate_dir=$DIR/$tdir/migrate_dir
12990 test_mkdir $DIR/$tdir
12991 test_mkdir -i0 -c1 $migrate_dir
12993 for ((i=0; i<100; i++)); do
12994 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12995 createmany -o $migrate_dir/dir_${i}/f 100 ||
12996 error "create files under remote dir failed $i"
12999 $LFS migrate -m $MDTIDX $migrate_dir ||
13000 error "migrate remote dir error"
13002 echo "Finish migration, then checking.."
13003 for file in $(find $migrate_dir); do
13004 mdt_index=$($LFS getstripe -M $file)
13005 [ $mdt_index == $MDTIDX ] ||
13006 error "$file is not on MDT${MDTIDX}"
13009 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13011 run_test 230d "check migrate big directory"
13014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13015 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13021 mkdir -p $DIR/$tdir
13022 mkdir $DIR/$tdir/migrate_dir
13023 mkdir $DIR/$tdir/other_dir
13024 touch $DIR/$tdir/migrate_dir/a
13025 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
13026 ls $DIR/$tdir/other_dir
13028 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13029 error "migrate dir fails"
13031 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13032 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13034 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13035 [ $mdt_index == 0 ] || error "a is not on MDT0"
13037 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
13038 error "migrate dir fails"
13040 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
13041 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
13043 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13044 [ $mdt_index == 1 ] || error "a is not on MDT1"
13046 mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
13047 [ $mdt_index == 1 ] || error "b is not on MDT1"
13049 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13050 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
13052 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
13054 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13056 run_test 230e "migrate mulitple local link files"
13059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13060 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13064 mkdir -p $DIR/$tdir
13065 mkdir $DIR/$tdir/migrate_dir
13066 $LFS mkdir -i1 $DIR/$tdir/other_dir
13067 touch $DIR/$tdir/migrate_dir/a
13068 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
13069 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
13070 ls $DIR/$tdir/other_dir
13072 # a should be migrated to MDT1, since no other links on MDT0
13073 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13074 error "migrate dir fails"
13075 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13076 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
13077 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13078 [ $mdt_index == 1 ] || error "a is not on MDT1"
13080 # a should stay on MDT1, because it is a mulitple link file
13081 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13082 error "migrate dir fails"
13083 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13084 [ $mdt_index == 1 ] || error "a is not on MDT1"
13086 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
13087 error "migrate dir fails"
13089 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
13090 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
13091 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
13093 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
13094 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
13096 # a should be migrated to MDT0, since no other links on MDT1
13097 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
13098 error "migrate dir fails"
13099 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
13100 [ $mdt_index == 0 ] || error "a is not on MDT0"
13102 rm -rf $DIR/$tdir || error "rm dir failed after migration"
13104 run_test 230f "migrate mulitple remote link files"
13107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13108 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13110 mkdir -p $DIR/$tdir/migrate_dir
13112 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
13113 error "migrating dir to non-exist MDT succeeds"
13116 run_test 230g "migrate dir to non-exist MDT"
13119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13120 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13121 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
13122 skip "Need MDS version at least 2.7.64" && return
13125 mkdir -p $DIR/$tdir/migrate_dir
13127 $LFS migrate -m1 $DIR &&
13128 error "migrating mountpoint1 should fail"
13130 $LFS migrate -m1 $DIR/$tdir/.. &&
13131 error "migrating mountpoint2 should fail"
13133 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
13134 error "migrating $tdir fail"
13136 mdt_index=$($LFS getstripe -M $DIR/$tdir)
13137 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13139 mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
13140 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
13143 run_test 230h "migrate .. and root"
13146 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13147 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13149 mkdir -p $DIR/$tdir/migrate_dir
13151 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
13152 error "migration fails with a tailing slash"
13154 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
13155 error "migration fails with two tailing slashes"
13157 run_test 230i "lfs migrate -m tolerates trailing slashes"
13161 # For simplicity this test assumes that max_pages_per_rpc
13162 # is the same across all OSCs
13163 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
13164 local bulk_size=$((max_pages * 4096))
13166 mkdir -p $DIR/$tdir
13168 # clear the OSC stats
13169 $LCTL set_param osc.*.stats=0 &>/dev/null
13172 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
13173 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
13174 oflag=direct &>/dev/null || error "dd failed"
13176 sync; sleep 1; sync # just to be safe
13177 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
13178 if [ x$nrpcs != "x1" ]; then
13179 $LCTL get_param osc.*.stats
13180 error "found $nrpcs ost_write RPCs, not 1 as expected"
13184 # Drop the OSC cache, otherwise we will read from it
13185 cancel_lru_locks osc
13187 # clear the OSC stats
13188 $LCTL set_param osc.*.stats=0 &>/dev/null
13190 # Client reads $bulk_size.
13191 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
13192 iflag=direct &>/dev/null || error "dd failed"
13194 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
13195 if [ x$nrpcs != "x1" ]; then
13196 $LCTL get_param osc.*.stats
13197 error "found $nrpcs ost_read RPCs, not 1 as expected"
13200 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
13203 mkdir -p $DIR/$tdir
13205 for i in {0..1023}; do
13206 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
13207 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
13208 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
13212 run_test 231b "must not assert on fully utilized OST request buffer"
13215 mkdir -p $DIR/$tdir
13216 #define OBD_FAIL_LDLM_OST_LVB 0x31c
13217 $LCTL set_param fail_loc=0x31c
13219 # ignore dd failure
13220 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
13222 $LCTL set_param fail_loc=0
13223 umount_client $MOUNT || error "umount failed"
13224 mount_client $MOUNT || error "mount failed"
13226 run_test 232 "failed lock should not block umount"
13229 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
13230 { skip "Need MDS version at least 2.3.64"; return; }
13231 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13233 local fid=$($LFS path2fid $MOUNT)
13234 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13235 error "cannot access $MOUNT using its FID '$fid'"
13237 run_test 233a "checking that OBF of the FS root succeeds"
13240 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
13241 { skip "Need MDS version at least 2.5.90"; return; }
13242 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
13244 local fid=$($LFS path2fid $MOUNT/.lustre)
13245 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13246 error "cannot access $MOUNT/.lustre using its FID '$fid'"
13248 fid=$($LFS path2fid $MOUNT/.lustre/fid)
13249 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
13250 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
13252 run_test 233b "checking that OBF of the FS .lustre succeeds"
13255 local p="$TMP/sanityN-$TESTNAME.parameters"
13256 save_lustre_params client "llite.*.xattr_cache" > $p
13257 lctl set_param llite.*.xattr_cache 1 ||
13258 { skip "xattr cache is not supported"; return 0; }
13260 mkdir -p $DIR/$tdir || error "mkdir failed"
13261 touch $DIR/$tdir/$tfile || error "touch failed"
13262 # OBD_FAIL_LLITE_XATTR_ENOMEM
13263 $LCTL set_param fail_loc=0x1405
13264 # output of the form: attr 2 4 44 3 fc13 x86_64
13265 V=($(IFS=".-" rpm -q attr))
13266 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
13267 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
13268 # attr pre-2.4.44-7 had a bug with rc
13269 # LU-3703 - SLES 11 and FC13 clients have older attr
13270 getfattr -n user.attr $DIR/$tdir/$tfile &&
13271 error "getfattr should have failed with ENOMEM"
13273 skip "LU-3703: attr version $(getfattr --version) too old"
13275 $LCTL set_param fail_loc=0x0
13278 restore_lustre_params < $p
13281 run_test 234 "xattr cache should not crash on ENOMEM"
13284 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
13285 skip "Need MDS version at least 2.4.52" && return
13286 flock_deadlock $DIR/$tfile
13291 124) error "process hangs on a deadlock"
13293 *) error "error executing flock_deadlock $DIR/$tfile"
13297 run_test 235 "LU-1715: flock deadlock detection does not work properly"
13301 check_swap_layouts_support && return 0
13302 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
13304 local ref1=/etc/passwd
13305 local ref2=/etc/group
13306 local file1=$DIR/$tdir/f1
13307 local file2=$DIR/$tdir/f2
13309 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
13310 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
13311 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
13312 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
13313 local fd=$(free_fd)
13314 local cmd="exec $fd<>$file2"
13317 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
13318 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
13321 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13326 run_test 236 "Layout swap on open unlinked file"
13328 # test to verify file handle related system calls
13329 # (name_to_handle_at/open_by_handle_at)
13330 # The new system calls are supported in glibc >= 2.14.
13333 echo "Test file_handle syscalls" > $DIR/$tfile ||
13334 error "write failed"
13335 check_fhandle_syscalls $DIR/$tfile ||
13336 error "check_fhandle_syscalls failed"
13338 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
13340 # LU-4659 linkea consistency
13342 local server_version=$(lustre_version_code $SINGLEMDS)
13344 [[ $server_version -gt $(version_code 2.5.57) ]] ||
13345 [[ $server_version -gt $(version_code 2.5.1) &&
13346 $server_version -lt $(version_code 2.5.50) ]] ||
13347 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13350 ln $DIR/$tfile $DIR/$tfile.lnk
13351 touch $DIR/$tfile.new
13352 mv $DIR/$tfile.new $DIR/$tfile
13353 local fid1=$($LFS path2fid $DIR/$tfile)
13354 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13355 local path1=$($LFS fid2path $FSNAME "$fid1")
13356 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13357 local path2=$($LFS fid2path $FSNAME "$fid2")
13358 [ $tfile.lnk == $path2 ] ||
13359 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13362 run_test 238 "Verify linkea consistency"
13365 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13366 skip "Need MDS version at least 2.5.60" && return
13367 local list=$(comma_list $(mdts_nodes))
13369 mkdir -p $DIR/$tdir
13370 createmany -o $DIR/$tdir/f- 5000
13371 unlinkmany $DIR/$tdir/f- 5000
13372 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13373 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13374 osc.*MDT*.sync_in_flight" | calc_sum)
13375 [ "$changes" -eq 0 ] || error "$changes not synced"
13377 run_test 239 "osp_sync test"
13379 test_239a() { #LU-5297
13381 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
13382 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
13383 chgrp $RUNAS_GID $DIR/$tfile
13384 wait_delete_completed
13386 run_test 239a "process invalid osp sync record correctly"
13388 test_239b() { #LU-5297
13390 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
13391 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
13392 chgrp $RUNAS_GID $DIR/$tfile1
13393 wait_delete_completed
13394 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13396 chgrp $RUNAS_GID $DIR/$tfile2
13397 wait_delete_completed
13399 run_test 239b "process osp sync record with ENOMEM error correctly"
13402 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13404 mkdir -p $DIR/$tdir
13406 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13407 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13408 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13409 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13411 umount_client $MOUNT || error "umount failed"
13412 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13413 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13414 mount_client $MOUNT || error "failed to mount client"
13416 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13417 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13419 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13422 for LOOP in $(seq $1); do
13423 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13424 cancel_lru_locks osc || true
13429 for LOOP in $(seq $1); do
13430 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13431 iflag=direct 2>/dev/null
13436 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13438 cancel_lru_locks osc
13439 test_241_bio 1000 &
13444 run_test 241 "bio vs dio"
13447 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13449 test_241_dio 1000 &
13454 run_test 241b "dio vs dio"
13457 mkdir -p $DIR/$tdir
13458 touch $DIR/$tdir/$tfile
13460 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13461 do_facet mds1 lctl set_param fail_loc=0x105
13462 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13464 do_facet mds1 lctl set_param fail_loc=0
13465 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13467 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13471 test_mkdir -p $DIR/$tdir
13472 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13474 run_test 243 "various group lock tests"
13478 test_mkdir -p $DIR/$tdir
13479 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13480 sendfile_grouplock $DIR/$tdir/$tfile || \
13481 error "sendfile+grouplock failed"
13484 run_test 244 "sendfile with group lock tests"
13487 local flagname="multi_mod_rpcs"
13488 local connect_data_name="max_mod_rpcs"
13491 # check if multiple modify RPCs flag is set
13492 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
13493 grep "connect_flags:")
13496 echo "$out" | grep -qw $flagname
13497 if [ $? -ne 0 ]; then
13498 echo "connect flag $flagname is not set"
13502 # check if multiple modify RPCs data is set
13503 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
13506 echo "$out" | grep -qw $connect_data_name ||
13507 error "import should have connect data $connect_data_name"
13509 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
13511 test_246() { # LU-7371
13512 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
13513 skip "Need OST version >= 2.7.62" && return 0
13514 do_facet ost1 $LCTL set_param fail_val=4095
13515 #define OBD_FAIL_OST_READ_SIZE 0x234
13516 do_facet ost1 $LCTL set_param fail_loc=0x234
13517 $LFS setstripe $DIR/$tfile -i 0 -c 1
13518 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
13519 cancel_lru_locks $FSNAME-OST0000
13520 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
13522 run_test 246 "Read file of size 4095 should return right length"
13525 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
13527 { skip "Fileset feature is not supported"; return; }
13529 local submount=${MOUNT}_$tdir
13532 mkdir -p $submount || error "mkdir $submount failed"
13533 FILESET="$FILESET/$tdir" mount_client $submount ||
13534 error "mount $submount failed"
13535 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
13536 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
13537 error "read $MOUNT/$tdir/$tfile failed"
13538 umount_client $submount || error "umount $submount failed"
13541 run_test 247a "mount subdir as fileset"
13544 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
13545 { skip "Fileset feature is not supported"; return; }
13547 local submount=${MOUNT}_$tdir
13549 rm -rf $MOUNT/$tdir
13550 mkdir -p $submount || error "mkdir $submount failed"
13552 FILESET="$FILESET/$tdir" mount_client $submount &&
13553 error "mount $submount should fail"
13556 run_test 247b "mount subdir that dose not exist"
13559 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
13560 { skip "Fileset feature is not supported"; return; }
13562 local submount=${MOUNT}_$tdir
13564 mkdir -p $MOUNT/$tdir/dir1
13565 mkdir -p $submount || error "mkdir $submount failed"
13566 FILESET="$FILESET/$tdir" mount_client $submount ||
13567 error "mount $submount failed"
13568 local fid=$($LFS path2fid $MOUNT/)
13569 $LFS fid2path $submount $fid && error "fid2path should fail"
13570 umount_client $submount || error "umount $submount failed"
13573 run_test 247c "running fid2path outside root"
13576 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
13577 { skip "Fileset feature is not supported"; return; }
13579 local submount=${MOUNT}_$tdir
13581 mkdir -p $MOUNT/$tdir/dir1
13582 mkdir -p $submount || error "mkdir $submount failed"
13583 FILESET="$FILESET/$tdir" mount_client $submount ||
13584 error "mount $submount failed"
13585 local fid=$($LFS path2fid $submount/dir1)
13586 $LFS fid2path $submount $fid || error "fid2path should succeed"
13587 umount_client $submount || error "umount $submount failed"
13590 run_test 247d "running fid2path inside root"
13594 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
13596 { skip "Fileset feature is not supported"; return; }
13598 local submount=${MOUNT}_$tdir
13601 mkdir -p $submount || error "mkdir $submount failed"
13602 FILESET="$FILESET/.." mount_client $submount &&
13603 error "mount $submount should fail"
13606 run_test 247e "mount .. as fileset"
13609 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13610 && skip "no 16TB file size limit on ZFS" && return
13612 $SETSTRIPE -c 1 $DIR/$tfile
13613 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13614 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13615 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13616 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13617 conv=notrunc,fsync && error "append succeeded"
13620 run_test 250 "Write above 16T limit"
13623 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13625 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13626 #Skip once - writing the first stripe will succeed
13627 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13628 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13629 error "short write happened"
13631 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13632 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13633 error "short read happened"
13637 run_test 251 "Handling short read and write correctly"
13647 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13648 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13649 skip "can only run lr_reader on ldiskfs target"
13653 # check lr_reader on OST0000
13655 dev=$(facet_device $tgt)
13656 out=$(do_facet $tgt $LR_READER $dev)
13657 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13659 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13660 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13661 error "Invalid uuid returned by $LR_READER on target $tgt"
13662 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13664 # check lr_reader -c on MDT0000
13666 dev=$(facet_device $tgt)
13667 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13668 echo "$LR_READER does not support additional options"
13671 out=$(do_facet $tgt $LR_READER -c $dev)
13672 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13674 num=$(echo "$out" | grep -c "mdtlov")
13675 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13676 error "Invalid number of mdtlov clients returned by $LR_READER"
13677 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13679 # check lr_reader -cr on MDT0000
13680 out=$(do_facet $tgt $LR_READER -cr $dev)
13681 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13683 echo "$out" | grep -q "^reply_data:$" ||
13684 error "$LR_READER should have returned 'reply_data' section"
13685 num=$(echo "$out" | grep -c "client_generation")
13686 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13688 run_test 252 "check lr_reader tool"
13693 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13694 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13695 do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
13696 { skip "MDS does not support changelog_size" && return; }
13698 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
13699 echo "Registered as changelog user $cl_user"
13701 $LFS changelog_clear $MDT0 $cl_user 0
13703 local size1=$(do_facet mds1 \
13704 $LCTL get_param -n mdd.$MDT0.changelog_size)
13705 echo "Changelog size $size1"
13708 $LFS mkdir -i 0 $DIR/$tdir
13710 mkdir -p $DIR/$tdir/pics/2008/zachy
13711 touch $DIR/$tdir/pics/2008/zachy/timestamp
13712 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
13713 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
13714 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
13715 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
13716 rm $DIR/$tdir/pics/desktop.jpg
13718 local size2=$(do_facet mds1 \
13719 $LCTL get_param -n mdd.$MDT0.changelog_size)
13720 echo "Changelog size after work $size2"
13722 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
13724 if (( size2 <= size1 )); then
13725 error "Changelog size after work should be greater than original"
13729 run_test 254 "Check changelog size"
13736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13737 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13738 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
13739 skip "non-ldiskfs backend" && return
13741 mdt_dev=$(mdsdevname 1)
13743 cl_user=$(do_facet mds1 \
13744 "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
13745 if [[ -n $cl_user ]]; then
13746 skip "active changelog user"
13750 cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
13751 echo "Registered as changelog user $cl_user"
13754 mkdir -p $DIR/$tdir
13756 $LFS changelog_clear $MDT0 $cl_user 0
13759 touch $DIR/$tdir/{1..10}
13762 stop mds1 || error "Fail to stop MDT."
13765 start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
13767 #after mount new plainllog is used
13768 touch $DIR/$tdir/{11..19}
13769 cat_sl=$(do_facet mds1 \
13770 "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
13771 llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
13773 if (( cat_sl != 2 )); then
13774 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
13775 error "Changelog catalog has wrong number of slots $cat_sl"
13778 $LFS changelog_clear $MDT0 $cl_user 0
13780 cat_sl=$(do_facet mds1 \
13781 "$DEBUGFS -R \\\"dump changelog_catalog cat.dmp\\\" $mdt_dev; \
13782 llog_reader cat.dmp | grep \\\"type=1064553b\\\" | wc -l")
13784 do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
13786 if (( cat_sl == 2 )); then
13787 error "Empty plain llog was not deleted from changelog catalog"
13789 if (( cat_sl != 1 )); then
13790 error "Active plain llog shouldn\`t be deleted from catalog"
13793 run_test 256 "Check llog delete for empty and not full state"
13795 cleanup_test_300() {
13799 test_striped_dir() {
13804 mkdir -p $DIR/$tdir
13806 SAVE_UMASK=$(umask)
13807 trap cleanup_test_300 RETURN EXIT
13809 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13810 $DIR/$tdir/striped_dir ||
13811 error "set striped dir error"
13813 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13814 [ "$mode" = "755" ] || error "expect 755 got $mode"
13816 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13817 error "getdirstripe failed"
13818 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13819 if [ "$stripe_count" != "2" ]; then
13820 error "stripe_count is $stripe_count, expect 2"
13823 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13824 if [ "$stripe_index" != "$mdt_index" ]; then
13825 error "stripe_index is $stripe_index, expect $mdt_index"
13828 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13829 error "nlink error after create striped dir"
13831 mkdir $DIR/$tdir/striped_dir/a
13832 mkdir $DIR/$tdir/striped_dir/b
13834 stat $DIR/$tdir/striped_dir/a ||
13835 error "create dir under striped dir failed"
13836 stat $DIR/$tdir/striped_dir/b ||
13837 error "create dir under striped dir failed"
13839 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13840 error "nlink error after mkdir"
13842 rmdir $DIR/$tdir/striped_dir/a
13843 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13844 error "nlink error after rmdir"
13846 rmdir $DIR/$tdir/striped_dir/b
13847 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13848 error "nlink error after rmdir"
13850 chattr +i $DIR/$tdir/striped_dir
13851 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13852 error "immutable flags not working under striped dir!"
13853 chattr -i $DIR/$tdir/striped_dir
13855 rmdir $DIR/$tdir/striped_dir ||
13856 error "rmdir striped dir error"
13864 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13865 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13867 test_striped_dir 0 || error "failed on striped dir on MDT0"
13868 test_striped_dir 1 || error "failed on striped dir on MDT0"
13870 run_test 300a "basic striped dir sanity test"
13873 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13874 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13880 test_mkdir $DIR/$tdir || error "mkdir fail"
13881 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13882 error "set striped dir error"
13883 for ((i=0; i<10; i++)); do
13884 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13886 touch $DIR/$tdir/striped_dir/file_$i ||
13887 error "touch error $i"
13888 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13889 [ $mtime1 -eq $mtime2 ] &&
13890 error "mtime not change after create"
13892 rm -f $DIR/$tdir/striped_dir/file_$i ||
13893 error "unlink error $i"
13894 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13895 [ $mtime2 -eq $mtime3 ] &&
13896 error "mtime did not change after unlink"
13900 run_test 300b "check ctime/mtime for striped dir"
13903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13904 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13907 mkdir -p $DIR/$tdir
13908 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13909 error "set striped dir error"
13911 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13912 error "chown striped dir failed"
13914 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13915 error "create 5k files failed"
13917 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13919 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13923 run_test 300c "chown && check ls under striped directory"
13926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13927 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13931 mkdir -p $DIR/$tdir
13932 $SETSTRIPE -c 2 $DIR/$tdir
13934 #local striped directory
13935 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13936 error "set striped dir error"
13937 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13938 error "create 10 files failed"
13940 #remote striped directory
13941 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13942 error "set striped dir error"
13943 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13944 error "create 10 files failed"
13946 for file in $(find $DIR/$tdir); do
13947 stripe_count=$($GETSTRIPE -c $file)
13948 [ $stripe_count -eq 2 ] ||
13949 error "wrong stripe $stripe_count for $file"
13954 run_test 300d "check default stripe under striped directory"
13957 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13958 skip "Need MDS version at least 2.7.55" && return
13959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13960 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13964 mkdir -p $DIR/$tdir
13966 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13967 error "set striped dir error"
13969 touch $DIR/$tdir/striped_dir/a
13970 touch $DIR/$tdir/striped_dir/b
13971 touch $DIR/$tdir/striped_dir/c
13973 mkdir $DIR/$tdir/striped_dir/dir_a
13974 mkdir $DIR/$tdir/striped_dir/dir_b
13975 mkdir $DIR/$tdir/striped_dir/dir_c
13977 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13978 error "set striped dir under striped dir error"
13980 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13981 error "set striped dir under striped dir error"
13983 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13984 error "set striped dir under striped dir error"
13986 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
13987 error "rename dir under striped dir fails"
13989 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
13990 error "rename dir under different stripes fails"
13992 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13993 error "rename file under striped dir should succeed"
13995 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
13996 error "rename dir under striped dir should succeed"
14000 run_test 300e "check rename under striped directory"
14003 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14004 skip "Need MDS version at least 2.7.55" && return
14005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14006 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14011 mkdir -p $DIR/$tdir
14013 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
14014 error "set striped dir error"
14016 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
14017 error "set striped dir error"
14019 touch $DIR/$tdir/striped_dir/a
14020 mkdir $DIR/$tdir/striped_dir/dir_a
14021 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
14022 error "create striped dir under striped dir fails"
14024 touch $DIR/$tdir/striped_dir1/b
14025 mkdir $DIR/$tdir/striped_dir1/dir_b
14026 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
14027 error "create striped dir under striped dir fails"
14029 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
14030 error "rename dir under different striped dir should fail"
14032 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
14033 error "rename striped dir under diff striped dir should fail"
14035 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
14036 error "rename file under diff striped dirs fails"
14040 run_test 300f "check rename cross striped directory"
14042 test_300_check_default_striped_dir()
14045 local default_count=$2
14046 local default_index=$3
14049 local dir_stripe_index
14052 echo "checking $dirname $default_count $default_index"
14053 $LFS setdirstripe -D -c $default_count -i $default_index \
14054 -t all_char $DIR/$tdir/$dirname ||
14055 error "set default stripe on striped dir error"
14056 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
14057 [ $stripe_count -eq $default_count ] ||
14058 error "expect $default_count get $stripe_count for $dirname"
14060 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
14061 [ $stripe_index -eq $default_index ] ||
14062 error "expect $default_index get $stripe_index for $dirname"
14064 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
14065 error "create dirs failed"
14067 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
14068 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
14069 for dir in $(find $DIR/$tdir/$dirname/*); do
14070 stripe_count=$($LFS getdirstripe -c $dir)
14071 [ $stripe_count -eq $default_count ] ||
14072 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
14073 error "stripe count $default_count != $stripe_count for $dir"
14075 stripe_index=$($LFS getdirstripe -i $dir)
14076 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
14077 error "$stripe_index != $default_index for $dir"
14079 #check default stripe
14080 stripe_count=$($LFS getdirstripe -D -c $dir)
14081 [ $stripe_count -eq $default_count ] ||
14082 error "default count $default_count != $stripe_count for $dir"
14084 stripe_index=$($LFS getdirstripe -D -i $dir)
14085 [ $stripe_index -eq $default_index ] ||
14086 error "default index $default_index != $stripe_index for $dir"
14088 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
14092 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14093 skip "Need MDS version at least 2.7.55" && return
14094 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14100 mkdir $DIR/$tdir/normal_dir
14102 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
14103 test_300_check_default_striped_dir normal_dir 1 0
14104 test_300_check_default_striped_dir normal_dir 2 1
14105 test_300_check_default_striped_dir normal_dir 2 -1
14107 #delete default stripe information
14108 echo "delete default stripeEA"
14109 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
14110 error "set default stripe on striped dir error"
14112 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
14113 for dir in $(find $DIR/$tdir/normal_dir/*); do
14114 stripe_count=$($LFS getdirstripe -c $dir)
14115 [ $stripe_count -eq 0 ] ||
14116 error "expect 1 get $stripe_count for $dir"
14117 stripe_index=$($LFS getdirstripe -i $dir)
14118 [ $stripe_index -eq 0 ] ||
14119 error "expect 0 get $stripe_index for $dir"
14122 run_test 300g "check default striped directory for normal directory"
14125 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14126 skip "Need MDS version at least 2.7.55" && return
14127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14132 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
14133 $DIR/$tdir/striped_dir ||
14134 error "set striped dir error"
14136 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
14137 test_300_check_default_striped_dir striped_dir 1 0
14138 test_300_check_default_striped_dir striped_dir 2 1
14139 test_300_check_default_striped_dir striped_dir 2 -1
14141 #delete default stripe information
14142 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
14143 error "set default stripe on striped dir error"
14145 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
14146 for dir in $(find $DIR/$tdir/striped_dir/*); do
14147 stripe_count=$($LFS getdirstripe -c $dir)
14148 [ $stripe_count -eq 0 ] ||
14149 error "expect 1 get $stripe_count for $dir"
14152 run_test 300h "check default striped directory for striped directory"
14155 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14156 skip "Need MDS version at least 2.7.55" && return
14157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14158 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14164 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
14165 error "set striped dir error"
14167 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
14168 error "create files under striped dir failed"
14170 # unfortunately, we need to umount to clear dir layout cache for now
14171 # once we fully implement dir layout, we can drop this
14172 umount_client $MOUNT || error "umount failed"
14173 mount_client $MOUNT || error "mount failed"
14175 #set the stripe to be unknown hash type
14176 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
14177 $LCTL set_param fail_loc=0x1901
14178 for ((i = 0; i < 10; i++)); do
14179 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
14180 error "stat f-$i failed"
14181 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
14184 touch $DIR/$tdir/striped_dir/f0 &&
14185 error "create under striped dir with unknown hash should fail"
14187 $LCTL set_param fail_loc=0
14189 umount_client $MOUNT || error "umount failed"
14190 mount_client $MOUNT || error "mount failed"
14194 run_test 300i "client handle unknown hash type striped directory"
14197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14198 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14199 skip "Need MDS version at least 2.7.55" && return
14200 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14206 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
14207 $LCTL set_param fail_loc=0x1702
14208 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
14209 error "set striped dir error"
14211 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
14212 error "create files under striped dir failed"
14214 $LCTL set_param fail_loc=0
14216 rm -rf $DIR/$tdir || error "unlink striped dir fails"
14220 run_test 300j "test large update record"
14223 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14224 skip "Need MDS version at least 2.7.55" && return
14225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14226 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14232 #define OBD_FAIL_LARGE_STRIPE 0x1703
14233 $LCTL set_param fail_loc=0x1703
14234 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
14235 error "set striped dir error"
14236 $LCTL set_param fail_loc=0
14238 $LFS getdirstripe $DIR/$tdir/striped_dir ||
14239 error "getstripeddir fails"
14240 rm -rf $DIR/$tdir/striped_dir ||
14241 error "unlink striped dir fails"
14245 run_test 300k "test large striped directory"
14248 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14249 skip "Need MDS version at least 2.7.55" && return
14250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14251 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14254 test_mkdir -p $DIR/$tdir/striped_dir
14255 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
14256 error "chown $RUNAS_ID failed"
14257 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
14258 error "set default striped dir failed"
14260 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
14261 $LCTL set_param fail_loc=0x80000158
14262 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
14264 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
14265 [ $stripe_index -eq 1 ] ||
14266 error "expect 1 get $stripe_index for $dir"
14268 run_test 300l "non-root user to create dir under striped dir with stale layout"
14271 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14272 skip "Need MDS version at least 2.7.55" && return
14273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14274 [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
14276 mkdir -p $DIR/$tdir/striped_dir
14277 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
14278 error "set default stripes dir error"
14280 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
14282 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
14283 [ $stripe_count -eq 0 ] ||
14284 error "expect 0 get $stripe_count for a"
14286 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
14287 error "set default stripes dir error"
14289 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
14291 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
14292 [ $stripe_count -eq 0 ] ||
14293 error "expect 0 get $stripe_count for b"
14295 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
14296 error "set default stripes dir error"
14298 mkdir $DIR/$tdir/striped_dir/c &&
14299 error "default stripe_index is invalid, mkdir c should fails"
14301 rm -rf $DIR/$tdir || error "rmdir fails"
14303 run_test 300m "setstriped directory on single MDT FS"
14306 local list=$(comma_list $(mdts_nodes))
14309 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14313 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14314 skip "Need MDS version at least 2.7.55" && return
14315 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14316 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14318 local list=$(comma_list $(mdts_nodes))
14320 trap cleanup_300n RETURN EXIT
14321 mkdir -p $DIR/$tdir
14322 chmod 777 $DIR/$tdir
14323 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
14324 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14325 error "create striped dir succeeds with gid=0"
14327 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14328 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
14329 error "create striped dir fails with gid=-1"
14331 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14332 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
14333 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
14334 error "set default striped dir succeeds with gid=0"
14337 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
14338 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
14339 error "set default striped dir fails with gid=-1"
14342 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
14343 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
14344 error "create test_dir fails"
14345 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
14346 error "create test_dir1 fails"
14347 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
14348 error "create test_dir2 fails"
14351 run_test 300n "non-root user to create dir under striped dir with default EA"
14354 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
14355 skip "Need MDS version at least 2.7.55" && return
14356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14357 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14361 mkdir -p $DIR/$tdir
14363 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
14364 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
14365 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
14366 skip "not enough free inodes $numfree1 $numfree2"
14370 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
14371 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
14372 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
14373 skip "not enough free space $numfree1 $numfree2"
14377 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
14378 error "setdirstripe fails"
14380 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
14381 error "create dirs fails"
14383 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
14384 ls $DIR/$tdir/striped_dir > /dev/null ||
14385 error "ls striped dir fails"
14386 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
14387 error "unlink big striped dir fails"
14389 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
14392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14393 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14395 mkdir -p $DIR/$tdir
14397 #define OBD_FAIL_OUT_ENOSPC 0x1704
14398 do_facet mds2 lctl set_param fail_loc=0x80001704
14399 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
14400 error "create striped directory should fail"
14402 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
14404 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
14407 run_test 300p "create striped directory without space"
14410 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14411 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
14413 local fd=$(free_fd)
14414 local cmd="exec $fd<$tdir"
14416 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
14419 trap "eval $cmd" EXIT
14420 cd $tdir || error "cd $tdir fails"
14421 rmdir ../$tdir || error "rmdir $tdir fails"
14422 mkdir local_dir && error "create dir succeeds"
14423 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
14427 run_test 300q "create remote directory under orphan directory"
14429 prepare_remote_file() {
14430 mkdir $DIR/$tdir/src_dir ||
14431 error "create remote source failed"
14433 cp /etc/hosts $DIR/$tdir/src_dir/a || error
14434 touch $DIR/$tdir/src_dir/a
14436 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
14437 error "create remote target dir failed"
14439 touch $DIR/$tdir/tgt_dir/b
14441 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
14442 error "rename dir cross MDT failed!"
14444 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
14445 error "src_child still exists after rename"
14447 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
14448 error "missing file(a) after rename"
14450 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
14451 error "diff after rename"
14455 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14457 local remote_file=$DIR/$tdir/tgt_dir/b
14459 mkdir -p $DIR/$tdir
14461 prepare_remote_file || error "prepare remote file failed"
14464 $OPENUNLINK $remote_file $remote_file || error
14465 $CHECKSTAT -a $remote_file || error
14467 run_test 310a "open unlink remote file"
14470 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
14471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14472 local remote_file=$DIR/$tdir/tgt_dir/b
14474 mkdir -p $DIR/$tdir
14476 prepare_remote_file || error "prepare remote file failed"
14478 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14479 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
14480 $CHECKSTAT -t file $remote_file || error "check file failed"
14482 run_test 310b "unlink remote file with multiple links while open"
14485 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
14486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14487 local remote_file=$DIR/$tdir/tgt_dir/b
14489 mkdir -p $DIR/$tdir
14491 prepare_remote_file || error "prepare remote file failed"
14493 ln $remote_file $DIR/$tfile || error "link failed for remote file"
14494 multiop_bg_pause $remote_file O_uc ||
14495 error "mulitop failed for remote file"
14497 $MULTIOP $DIR/$tfile Ouc
14498 kill -USR1 $MULTIPID
14501 run_test 310c "open-unlink remote file with multiple links"
14503 test_400a() { # LU-1606, was conf-sanity test_74
14504 local extra_flags=''
14505 local out=$TMP/$tfile
14506 local prefix=/usr/include/lustre
14509 if ! which $CC > /dev/null 2>&1; then
14510 skip_env "$CC is not installed"
14514 if ! [[ -d $prefix ]]; then
14515 # Assume we're running in tree and fixup the include path.
14516 extra_flags+=" -I$LUSTRE/../libcfs/include"
14517 extra_flags+=" -I$LUSTRE/include"
14518 extra_flags+=" -L$LUSTRE/utils"
14521 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
14522 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
14523 error "client api broken"
14526 run_test 400a "Lustre client api program can compile and link"
14528 test_400b() { # LU-1606, LU-5011
14530 local out=$TMP/$tfile
14531 local prefix=/usr/include/lustre
14533 # We use a hard coded prefix so that this test will not fail
14534 # when run in tree. There are headers in lustre/include/lustre/
14535 # that are not packaged (like lustre_idl.h) and have more
14536 # complicated include dependencies (like config.h and lnet/types.h).
14537 # Since this test about correct packaging we just skip them when
14538 # they don't exist (see below) rather than try to fixup cppflags.
14540 if ! which $CC > /dev/null 2>&1; then
14541 skip_env "$CC is not installed"
14545 for header in $prefix/*.h; do
14546 if ! [[ -f "$header" ]]; then
14550 if [[ "$(basename $header)" == liblustreapi.h ]]; then
14551 continue # liblustreapi.h is deprecated.
14554 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
14555 error "cannot compile '$header'"
14558 run_test 400b "packaged headers can be compiled"
14560 test_401a() { #LU-7437
14561 #count the number of parameters by "list_param -R"
14562 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
14563 #count the number of parameters by listing proc files
14564 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
14567 [ $params -eq $procs ] ||
14568 error "found $params parameters vs. $procs proc files"
14570 # test the list_param -D option only returns directories
14571 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
14572 #count the number of parameters by listing proc directories
14573 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
14576 [ $params -eq $procs ] ||
14577 error "found $params parameters vs. $procs proc files"
14579 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
14582 local save=$($LCTL get_param -n jobid_var)
14585 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
14586 error "no error returned when setting bad parameters"
14588 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
14589 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
14591 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
14592 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
14593 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
14595 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
14598 local jobid_var_old=$($LCTL get_param -n jobid_var)
14599 local jobid_var_new
14601 $LCTL set_param jobid_var= &&
14602 error "no error returned for 'set_param a='"
14604 jobid_var_new=$($LCTL get_param -n jobid_var)
14605 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
14606 error "jobid_var was changed by setting without value"
14608 $LCTL set_param jobid_var &&
14609 error "no error returned for 'set_param a'"
14611 jobid_var_new=$($LCTL get_param -n jobid_var)
14612 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
14613 error "jobid_var was changed by setting without value"
14615 run_test 401c "Verify 'lctl set_param' without value fails in either format."
14618 local jobid_var_old=$($LCTL get_param -n jobid_var)
14619 local jobid_var_new
14620 local new_value="foo=bar"
14622 $LCTL set_param jobid_var=$new_value ||
14623 error "'set_param a=b' did not accept a value containing '='"
14625 jobid_var_new=$($LCTL get_param -n jobid_var)
14626 [[ "$jobid_var_new" == "$new_value" ]] ||
14627 error "'set_param a=b' failed on a value containing '='"
14629 # Reset the jobid_var to test the other format
14630 $LCTL set_param jobid_var=$jobid_var_old
14631 jobid_var_new=$($LCTL get_param -n jobid_var)
14632 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
14633 error "failed to reset jobid_var"
14635 $LCTL set_param jobid_var $new_value ||
14636 error "'set_param a b' did not accept a value containing '='"
14638 jobid_var_new=$($LCTL get_param -n jobid_var)
14639 [[ "$jobid_var_new" == "$new_value" ]] ||
14640 error "'set_param a b' failed on a value containing '='"
14642 $LCTL set_param jobid_var $jobid_var_old
14643 jobid_var_new=$($LCTL get_param -n jobid_var)
14644 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
14645 error "failed to reset jobid_var"
14647 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
14650 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
14651 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
14652 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
14653 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
14654 echo "Touch failed - OK"
14656 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
14659 local file1=$DIR/$tfile.1
14660 local file2=$DIR/$tfile.2
14661 local tfile=$TMP/$tfile
14663 rm -f $file1 $file2 $tfile
14668 # 30 sec OBD_TIMEOUT in ll_getattr()
14669 # right before populating st_nlink
14670 $LCTL set_param fail_loc=0x80001409
14671 stat -c %h $file1 > $tfile &
14673 # create an alias, drop all locks and reclaim the dentry
14675 cancel_lru_locks mdc
14676 cancel_lru_locks osc
14677 sysctl -w vm.drop_caches=2
14681 [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
14683 rm -f $tfile $file1 $file2
14685 run_test 403 "i_nlink should not drop to zero due to aliasing"
14687 test_404() { # LU-6601
14688 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
14689 awk '/osp .*-osc-MDT/ { print $4}')
14692 for osp in $mosps; do
14693 echo "Deactivate: " $osp
14694 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
14695 local stat=$(do_facet $SINGLEMDS $LCTL dl |
14696 awk -vp=$osp '$4 == p { print $2 }')
14697 [ $stat = IN ] || {
14698 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
14699 error "deactivate error"
14701 echo "Activate: " $osp
14702 do_facet $SINGLEMDS $LCTL --device %$osp activate
14703 local stat=$(do_facet $SINGLEMDS $LCTL dl |
14704 awk -vp=$osp '$4 == p { print $2 }')
14705 [ $stat = UP ] || {
14706 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
14707 error "activate error"
14711 run_test 404 "validate manual {de}activated works properly for OSPs"
14714 # tests that do cleanup/setup should be run at the end
14718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
14720 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
14721 $LCTL set_param fail_loc=0x903
14723 cancel_lru_locks MGC
14725 FAIL_ON_ERROR=true cleanup
14726 FAIL_ON_ERROR=true setup
14728 run_test 900 "umount should not race with any mgc requeue thread"
14731 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
14732 check_and_cleanup_lustre
14733 if [ "$I_MOUNTED" != "yes" ]; then
14734 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true