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}'`
32 if is_sles11; then # LU-4351
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 54c"
36 SRCDIR=$(cd $(dirname $0); echo $PWD)
37 export PATH=$PATH:/sbin
42 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
43 CREATETEST=${CREATETEST:-createtest}
45 LFIND=${LFIND:-"$LFS find"}
46 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
48 MCREATE=${MCREATE:-mcreate}
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}
59 UMOUNT=${UMOUNT:-"umount -d"}
61 CHECK_GRANT=${CHECK_GRANT:-"yes"}
62 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
63 export PARALLEL=${PARALLEL:-"no"}
65 export NAME=${NAME:-local}
72 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
73 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
74 . $LUSTRE/tests/test-framework.sh
76 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
81 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
82 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
89 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
90 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
99 check_kernel_version() {
101 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
103 patchless|patchless_client) return 0;;
104 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
106 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
110 check_swap_layouts_support()
112 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
113 { skip "Does not support layout lock."; return 0; }
117 if [ "$ONLY" == "cleanup" ]; then
122 check_and_setup_lustre
127 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
128 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
129 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
130 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
131 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
132 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
133 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
134 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
136 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
137 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
138 rm -rf $DIR/[Rdfs][0-9]*
140 # $RUNAS_ID may get set incorrectly somewhere else
141 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
143 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
147 if [ "${ONLY}" = "MOUNT" ] ; then
148 echo "Lustre is up, please go on"
152 echo "preparing for tests involving mounts"
153 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
155 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
156 echo # add a newline after mke2fs.
160 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
161 lctl set_param debug=-1 2> /dev/null || true
164 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
166 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
168 run_test 0a "touch; rm ====================="
171 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
172 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
174 run_test 0b "chmod 0755 $DIR ============================="
177 $LCTL get_param mdc.*.import | grep "state: FULL" ||
178 error "import not FULL"
179 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
182 run_test 0c "check import proc ============================="
185 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
186 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
187 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
188 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
191 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
193 run_test 1 "mkdir; remkdir; rmdir =============================="
196 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
197 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
198 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
200 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
202 run_test 2 "mkdir; touch; rmdir; check file ===================="
205 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
206 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
207 touch $DIR/$tdir/$tfile
208 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
210 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
212 run_test 3 "mkdir; touch; rmdir; check dir ====================="
214 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
217 local remote_dir=remote_dir
219 test_mkdir $DIR/$remote_dir ||
220 error "Create remote directory failed"
222 touch $DIR/$remote_dir/$tfile ||
223 error "Create file under remote directory failed"
225 rmdir $DIR/$remote_dir &&
226 error "Expect error removing in-use dir $DIR/$remote_dir"
228 test -d $DIR/$remote_dir || error "Remote directory disappeared"
230 rm -rf $DIR/$remote_dir || error "remove remote dir error"
232 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
235 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
236 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
237 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
238 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
239 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
241 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
244 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
245 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
246 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
247 error "$tfile does not have perm 0666 or UID $UID"
248 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
249 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
250 error "$tfile should be 0666 and owned by UID $UID"
252 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
255 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
257 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
258 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
259 error "$tfile should be owned by UID $RUNAS_ID"
260 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
261 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
262 error "$tfile should be owned by UID $RUNAS_ID"
264 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
267 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
269 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
271 error "$tfile should be owned by GID $UID"
272 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
273 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
274 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
276 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
279 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
280 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
281 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
282 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
283 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
284 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
285 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
286 error "$tdir/d/subdir should be GID $RUNAS_GID"
288 run_test 6g "Is new dir in sgid dir inheriting group?"
290 test_6h() { # bug 7331
291 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
292 touch $DIR/$tfile || error "touch failed"
293 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
294 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
295 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
296 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
297 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
299 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
302 test_mkdir $DIR/$tdir
303 $MCREATE $DIR/$tdir/$tfile
304 chmod 0666 $DIR/$tdir/$tfile
305 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
306 error "$tdir/$tfile should be mode 0666"
308 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
311 if [ ! -d $DIR/$tdir ]; then
314 $MCREATE $DIR/$tdir/$tfile
315 echo -n foo > $DIR/$tdir/$tfile
316 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
317 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
319 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
322 test_mkdir $DIR/$tdir
323 touch $DIR/$tdir/$tfile
324 chmod 0666 $DIR/$tdir/$tfile
325 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
326 error "$tfile mode not 0666"
328 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
331 test_mkdir $DIR/$tdir
332 test_mkdir $DIR/$tdir/d2
333 test_mkdir $DIR/$tdir/d2/d3
334 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
336 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
339 test_mkdir $DIR/$tdir
340 test_mkdir $DIR/$tdir/d2
341 touch $DIR/$tdir/d2/$tfile
342 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
343 error "$tdir/d2/$tfile not a file"
345 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
348 test_mkdir $DIR/$tdir
349 test_mkdir $DIR/$tdir/d2
350 chmod 0666 $DIR/$tdir/d2
351 chmod 0705 $DIR/$tdir/d2
352 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
353 error "$tdir/d2 mode not 0705"
355 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
358 test_mkdir $DIR/$tdir
359 touch $DIR/$tdir/$tfile
360 chmod 0666 $DIR/$tdir/$tfile
361 chmod 0654 $DIR/$tdir/$tfile
362 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
363 error "$tdir/d2 mode not 0654"
365 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
368 test_mkdir $DIR/$tdir
369 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
371 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
372 error "$tdir/$tfile size not 0 after truncate"
374 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
377 test_mkdir $DIR/$tdir
378 touch $DIR/$tdir/$tfile
380 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
382 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 test_mkdir $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
388 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
389 error "$tdir/${tfile_2} not a file after rename"
391 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
394 test_mkdir $DIR/$tdir
395 touch $DIR/$tdir/$tfile
396 rm -rf $DIR/$tdir/$tfile
397 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
399 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
402 test_mkdir -p $DIR/$tdir
403 touch $DIR/$tdir/$tfile
404 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
406 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
407 error "$tdir/l-exist not a symlink"
408 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
409 error "$tdir/l-exist not referencing a file"
410 rm -f $DIR/$tdir/l-exist
411 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
413 run_test 17a "symlinks: create, remove (real) =================="
416 test_mkdir -p $DIR/$tdir
417 ln -s no-such-file $DIR/$tdir/l-dangle
419 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
420 error "$tdir/l-dangle not referencing no-such-file"
421 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
422 error "$tdir/l-dangle not referencing non-existent file"
423 rm -f $DIR/$tdir/l-dangle
424 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
426 run_test 17b "symlinks: create, remove (dangling) =============="
428 test_17c() { # bug 3440 - don't save failed open RPC for replay
429 test_mkdir -p $DIR/$tdir
430 ln -s foo $DIR/$tdir/$tfile
431 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
433 run_test 17c "symlinks: open dangling (should return error) ===="
436 test_mkdir -p $DIR/$tdir
437 ln -s foo $DIR/$tdir/$tfile
438 touch $DIR/$tdir/$tfile || error "creating to new symlink"
440 run_test 17d "symlinks: create dangling ========================"
443 test_mkdir -p $DIR/$tdir
444 local foo=$DIR/$tdir/$tfile
445 ln -s $foo $foo || error "create symlink failed"
446 ls -l $foo || error "ls -l failed"
447 ls $foo && error "ls not failed" || true
449 run_test 17e "symlinks: create recursive symlink (should return error) ===="
452 test_mkdir -p $DIR/d17f
453 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
456 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
457 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
458 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
461 run_test 17f "symlinks: long and very long symlink name ========================"
463 # str_repeat(S, N) generate a string that is string S repeated N times
468 while [ $((n -= 1)) -ge 0 ]; do
474 # Long symlinks and LU-2241
476 test_mkdir -p $DIR/$tdir
477 local TESTS="59 60 61 4094 4095"
479 # Fix for inode size boundary in 2.1.4
480 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
483 # Patch not applied to 2.2 or 2.3 branches
484 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
485 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
488 # skip long symlink name for rhel6.5.
489 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
490 grep -q '6.5' /etc/redhat-release &>/dev/null &&
491 TESTS="59 60 61 4062 4063"
494 local SYMNAME=$(str_repeat 'x' $i)
495 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
496 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
499 run_test 17g "symlinks: really long symlink name and inode boundaries"
501 test_17h() { #bug 17378
502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
505 test_mkdir -p $DIR/$tdir
506 if [[ $MDSCOUNT -gt 1 ]]; then
507 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
511 $SETSTRIPE -c -1 $DIR/$tdir
512 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
513 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
514 touch $DIR/$tdir/$tfile || true
516 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
518 test_17i() { #bug 20018
519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
521 test_mkdir -c1 $DIR/$tdir
522 local foo=$DIR/$tdir/$tfile
524 if [[ $MDSCOUNT -gt 1 ]]; then
525 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
529 ln -s $foo $foo || error "create symlink failed"
530 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
531 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
532 ls -l $foo && error "error not detected"
535 run_test 17i "don't panic on short symlink"
537 test_17k() { #bug 22301
538 [[ -z "$(which rsync 2>/dev/null)" ]] &&
539 skip "no rsync command" && return 0
540 rsync --help | grep -q xattr ||
541 skip_env "$(rsync --version | head -n1) does not support xattrs"
542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
543 test_mkdir -p $DIR/$tdir
544 test_mkdir -p $DIR/$tdir.new
545 touch $DIR/$tdir/$tfile
546 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
547 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
548 error "rsync failed with xattrs enabled"
550 run_test 17k "symlinks: rsync with xattrs enabled ========================="
552 test_17l() { # LU-279
553 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
554 skip "no getfattr command" && return 0
556 touch $DIR/$tdir/$tfile
557 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
558 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
559 # -h to not follow symlinks. -m '' to list all the xattrs.
560 # grep to remove first line: '# file: $path'.
561 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
563 lgetxattr_size_check $path $xattr ||
564 error "lgetxattr_size_check $path $xattr failed"
568 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
572 local short_sym="0123456789"
573 local WDIR=$DIR/${tdir}m
580 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
581 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
582 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
584 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
585 skip "only for ldiskfs MDT" && return 0
587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
591 # create a long symlink file
592 for ((i = 0; i < 4; ++i)); do
593 long_sym=${long_sym}${long_sym}
596 echo "create 512 short and long symlink files under $WDIR"
597 for ((i = 0; i < 256; ++i)); do
598 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
599 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
605 wait_delete_completed
607 echo "recreate the 512 symlink files with a shorter string"
608 for ((i = 0; i < 512; ++i)); do
609 # rewrite the symlink file with a shorter string
610 ln -sf ${long_sym} $WDIR/long-$i
611 ln -sf ${short_sym} $WDIR/short-$i
614 mds_index=$($LFS getstripe -M $WDIR)
615 mds_index=$((mds_index+1))
616 devname=$(mdsdevname $mds_index)
617 cmd="$E2FSCK -fnvd $devname"
619 echo "stop and checking mds${mds_index}: $cmd"
620 # e2fsck should not return error
622 do_facet mds${mds_index} $cmd || rc=$?
624 start mds${mds_index} $devname $MDS_MOUNT_OPTS
625 df $MOUNT > /dev/null 2>&1
626 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
627 "short/long symlink MDT: rc=$rc"
630 run_test 17m "run e2fsck against MDT which contains short/long symlink"
632 check_fs_consistency_17n() {
638 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
639 # so it only check MDT1/MDT2 instead of all of MDTs.
640 for mdt_index in $(seq 1 2); do
641 devname=$(mdsdevname $mdt_index)
642 cmd="$E2FSCK -fnvd $devname"
644 echo "stop and checking mds${mdt_index}: $cmd"
645 # e2fsck should not return error
647 do_facet mds${mdt_index} $cmd || rc=$?
649 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
650 df $MOUNT > /dev/null 2>&1
651 [ $rc -ne 0 ] && break
659 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
660 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
661 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
663 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
664 skip "only for ldiskfs MDT" && return 0
666 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
668 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
671 for ((i=0; i<10; i++)); do
672 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
673 error "create remote dir error $i"
674 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
675 error "create files under remote dir failed $i"
678 check_fs_consistency_17n ||
679 error "e2fsck report error after create files under remote dir"
681 for ((i=0;i<10;i++)); do
682 rm -rf $DIR/$tdir/remote_dir_${i} ||
683 error "destroy remote dir error $i"
686 check_fs_consistency_17n ||
687 error "e2fsck report error after unlink files under remote dir"
689 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
690 skip "lustre < 2.4.50 does not support migrate mv " && return
692 for ((i=0; i<10; i++)); do
693 mkdir -p $DIR/$tdir/remote_dir_${i}
694 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
695 error "create files under remote dir failed $i"
696 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
697 error "migrate remote dir error $i"
699 check_fs_consistency_17n || error "e2fsck report error after migration"
701 for ((i=0;i<10;i++)); do
702 rm -rf $DIR/$tdir/remote_dir_${i} ||
703 error "destroy remote dir error $i"
706 check_fs_consistency_17n || error "e2fsck report error after unlink"
708 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
711 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
712 skip "Need MDS version at least 2.3.64" && return
714 local WDIR=$DIR/${tdir}o
720 mdt_index=$($LFS getstripe -M $WDIR)
721 mdt_index=$((mdt_index+1))
722 mdtdevname=$(mdsdevname $mdt_index)
726 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
728 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
729 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
730 ls -l $WDIR/$tfile && rc=1
731 do_facet mds${mdt_index} lctl set_param fail_loc=0
732 [[ $rc -ne 0 ]] && error "stat file should fail"
735 run_test 17o "stat file with incompat LMA feature"
738 touch $DIR/f || error "Failed to touch $DIR/f: $?"
739 ls $DIR || error "Failed to ls $DIR: $?"
741 run_test 18 "touch .../f ; ls ... =============================="
747 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
749 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
752 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
754 run_test 19b "ls -l .../f19 (should return error) =============="
757 [ $RUNAS_ID -eq $UID ] &&
758 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
759 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
761 run_test 19c "$RUNAS touch .../f19 (should return error) =="
764 cat $DIR/f19 && error || true
766 run_test 19d "cat .../f19 (should return error) =============="
778 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
780 run_test 20 "touch .../f ; ls -l ... ==========================="
783 test_mkdir -p $DIR/$tdir
784 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
785 ln -s dangle $DIR/$tdir/link
786 echo foo >> $DIR/$tdir/link
787 cat $DIR/$tdir/dangle
788 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
789 $CHECKSTAT -f -t file $DIR/$tdir/link ||
790 error "$tdir/link not linked to a file"
792 run_test 21 "write to dangling link ============================"
796 test_mkdir -p $DIR/$tdir
797 chown $RUNAS_ID:$RUNAS_GID $WDIR
798 (cd $WDIR || error "cd $WDIR failed";
799 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
801 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
802 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
803 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
805 run_test 22 "unpack tar archive as non-root user ==============="
809 test_mkdir -p $DIR/$tdir
810 local file=$DIR/$tdir/$tfile
812 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
813 openfile -f O_CREAT:O_EXCL $file &&
814 error "$file recreate succeeded" || true
816 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
818 test_23b() { # bug 18988
819 test_mkdir -p $DIR/$tdir
820 local file=$DIR/$tdir/$tfile
823 echo foo > $file || error "write filed"
824 echo bar >> $file || error "append filed"
825 $CHECKSTAT -s 8 $file || error "wrong size"
828 run_test 23b "O_APPEND check =========================="
832 echo '-- same directory rename'
833 test_mkdir $DIR/$tdir
834 touch $DIR/$tdir/$tfile.1
835 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
836 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
838 run_test 24a "rename file to non-existent target"
841 test_mkdir $DIR/$tdir
842 touch $DIR/$tdir/$tfile.{1,2}
843 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
844 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
845 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
847 run_test 24b "rename file to existing target"
850 test_mkdir $DIR/$tdir
851 test_mkdir $DIR/$tdir/d$testnum.1
852 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
853 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
854 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
856 run_test 24c "rename directory to non-existent target"
859 test_mkdir -c1 $DIR/$tdir
860 test_mkdir -c1 $DIR/$tdir/d$testnum.1
861 test_mkdir -c1 $DIR/$tdir/d$testnum.2
862 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
863 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
864 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
866 run_test 24d "rename directory to existing target"
869 echo '-- cross directory renames --'
873 mv $DIR/R5a/f $DIR/R5b/g
874 $CHECKSTAT -a $DIR/R5a/f || error
875 $CHECKSTAT -t file $DIR/R5b/g || error
877 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
882 touch $DIR/R6a/f $DIR/R6b/g
883 mv $DIR/R6a/f $DIR/R6b/g
884 $CHECKSTAT -a $DIR/R6a/f || error
885 $CHECKSTAT -t file $DIR/R6b/g || error
887 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
892 test_mkdir $DIR/R7a/d
893 mv $DIR/R7a/d $DIR/R7b/e
894 $CHECKSTAT -a $DIR/R7a/d || error
895 $CHECKSTAT -t dir $DIR/R7b/e || error
897 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
900 test_mkdir -c1 $DIR/R8a
901 test_mkdir -c1 $DIR/R8b
902 test_mkdir -c1 $DIR/R8a/d
903 test_mkdir -c1 $DIR/R8b/e
904 mrename $DIR/R8a/d $DIR/R8b/e
905 $CHECKSTAT -a $DIR/R8a/d || error
906 $CHECKSTAT -t dir $DIR/R8b/e || error
908 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
911 echo "-- rename error cases"
915 mrename $DIR/R9/f $DIR/R9/a
916 $CHECKSTAT -t file $DIR/R9/f || error
917 $CHECKSTAT -t dir $DIR/R9/a || error
918 $CHECKSTAT -a $DIR/R9/a/f || error
920 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
924 mrename $DIR/R10/f $DIR/R10/g
925 $CHECKSTAT -t dir $DIR/R10 || error
926 $CHECKSTAT -a $DIR/R10/f || error
927 $CHECKSTAT -a $DIR/R10/g || error
929 run_test 24j "source does not exist ============================"
933 test_mkdir $DIR/R11a/d
935 mv $DIR/R11a/f $DIR/R11a/d
936 $CHECKSTAT -a $DIR/R11a/f || error
937 $CHECKSTAT -t file $DIR/R11a/d/f || error
939 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
941 # bug 2429 - rename foo foo foo creates invalid file
944 $MULTIOP $f OcNs || error
946 run_test 24l "Renaming a file to itself ========================"
950 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
951 # on ext3 this does not remove either the source or target files
952 # though the "expected" operation would be to remove the source
953 $CHECKSTAT -t file ${f} || error "${f} missing"
954 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
956 run_test 24m "Renaming a file to a hard link to itself ========="
960 # this stats the old file after it was renamed, so it should fail
964 $CHECKSTAT ${f}.rename
967 run_test 24n "Statting the old file after renaming (Posix rename 2)"
970 check_kernel_version 37 || return 0
971 test_mkdir -p $DIR/d24o
972 rename_many -s random -v -n 10 $DIR/d24o
974 run_test 24o "rename of files during htree split ==============="
979 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
980 mrename $DIR/R12a $DIR/R12b
981 $CHECKSTAT -a $DIR/R12a || error
982 $CHECKSTAT -t dir $DIR/R12b || error
983 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
984 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
986 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
988 cleanup_multiop_pause() {
994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
997 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
998 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1001 trap cleanup_multiop_pause EXIT
1002 mrename $DIR/R13a $DIR/R13b
1003 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1004 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1005 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1006 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1007 cleanup_multiop_pause
1008 wait $MULTIPID || error "multiop close failed"
1010 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1012 test_24r() { #bug 3789
1013 test_mkdir $DIR/R14a
1014 test_mkdir $DIR/R14a/b
1015 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1016 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1017 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1019 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1022 test_mkdir $DIR/R15a
1023 test_mkdir $DIR/R15a/b
1024 test_mkdir $DIR/R15a/b/c
1025 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1026 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1027 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1029 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1031 test_mkdir $DIR/R16a
1032 test_mkdir $DIR/R16a/b
1033 test_mkdir $DIR/R16a/b/c
1034 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1035 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1036 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1038 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1040 test_24u() { # bug12192
1042 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1043 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1045 run_test 24u "create stripe file"
1051 simple_cleanup_common() {
1054 wait_delete_completed
1057 max_pages_per_rpc() {
1058 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1062 local NRFILES=100000
1063 local FREE_INODES=$(mdt_free_inodes 0)
1064 [[ $FREE_INODES -lt $NRFILES ]] &&
1065 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1069 trap simple_cleanup_common EXIT
1071 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1072 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1075 createmany -m $DIR/$tdir/$tfile $NRFILES
1077 cancel_lru_locks mdc
1078 lctl set_param mdc.*.stats clear
1080 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1082 # LU-5 large readdir
1083 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1084 # 8 bytes for name(filename is mostly 5 in this test) +
1085 # 8 bytes for luda_type
1086 # take into account of overhead in lu_dirpage header and end mark in
1087 # each page, plus one in RPC_NUM calculation.
1089 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1090 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1091 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1092 awk '/^mds_readpage/ {print $2}')
1093 [[ $mds_readpage -gt $RPC_NUM ]] &&
1094 error "large readdir doesn't take effect"
1096 simple_cleanup_common
1098 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1100 test_24w() { # bug21506
1102 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1103 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1104 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1105 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1106 [ "$SZ1" = "$SZ2" ] || \
1107 error "Error reading at the end of the file $tfile"
1109 run_test 24w "Reading a file larger than 4Gb"
1112 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1115 local remote_dir=$DIR/$tdir/remote_dir
1118 $LFS mkdir -i $MDTIDX $remote_dir ||
1119 error "create remote directory failed"
1121 mkdir -p $DIR/$tdir/src_dir
1122 touch $DIR/$tdir/src_file
1123 mkdir -p $remote_dir/tgt_dir
1124 touch $remote_dir/tgt_file
1126 mrename $remote_dir $DIR/ &&
1127 error "rename dir cross MDT works!"
1129 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1130 error "rename dir cross MDT works!"
1132 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1133 error "rename file cross MDT works!"
1135 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1136 error "ln file cross MDT should not work!"
1138 rm -rf $DIR/$tdir || error "Can not delete directories"
1140 run_test 24x "cross rename/link should be failed"
1143 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1146 local remote_dir=$DIR/$tdir/remote_dir
1149 $LFS mkdir -i $MDTIDX $remote_dir ||
1150 error "create remote directory failed"
1152 mkdir -p $remote_dir/src_dir
1153 touch $remote_dir/src_file
1154 mkdir -p $remote_dir/tgt_dir
1155 touch $remote_dir/tgt_file
1157 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1158 error "rename subdir in the same remote dir failed!"
1160 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1161 error "rename files in the same remote dir failed!"
1163 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1164 error "link files in the same remote dir failed!"
1166 rm -rf $DIR/$tdir || error "Can not delete directories"
1168 run_test 24y "rename/link on the same dir should succeed"
1171 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1174 local remote_src=$DIR/$tdir/remote_dir
1175 local remote_tgt=$DIR/$tdir/remote_tgt
1178 $LFS mkdir -i $MDTIDX $remote_src ||
1179 error "create remote directory failed"
1181 $LFS mkdir -i $MDTIDX $remote_tgt ||
1182 error "create remote directory failed"
1184 mrename $remote_src $remote_tgt &&
1185 error "rename remote dirs should not work!"
1187 # If target dir does not exists, it should succeed
1189 mrename $remote_src $remote_tgt ||
1190 error "rename remote dirs(tgt dir does not exists) failed!"
1192 rm -rf $DIR/$tdir || error "Can not delete directories"
1194 run_test 24z "rename one remote dir to another remote dir should fail"
1196 test_24A() { # LU-3182
1201 createmany -m $DIR/$tdir/$tfile $NFILES
1202 local t=`ls $DIR/$tdir | wc -l`
1203 local u=`ls $DIR/$tdir | sort -u | wc -l`
1204 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1205 error "Expected $NFILES files, got $t ($u unique)"
1208 rm -rf $DIR/$tdir || error "Can not delete directories"
1210 run_test 24A "readdir() returns correct number of entries."
1213 echo '== symlink sanity ============================================='
1217 touch $DIR/s25/foo || error
1219 run_test 25a "create file in symlinked directory ==============="
1222 [ ! -d $DIR/d25 ] && test_25a
1223 $CHECKSTAT -t file $DIR/s25/foo || error
1225 run_test 25b "lookup file in symlinked directory ==============="
1229 test_mkdir $DIR/d26/d26-2
1230 ln -s d26/d26-2 $DIR/s26
1231 touch $DIR/s26/foo || error
1233 run_test 26a "multiple component symlink ======================="
1236 test_mkdir -p $DIR/d26b/d26-2
1237 ln -s d26b/d26-2/foo $DIR/s26-2
1238 touch $DIR/s26-2 || error
1240 run_test 26b "multiple component symlink at end of lookup ======"
1243 test_mkdir $DIR/d26.2
1244 touch $DIR/d26.2/foo
1245 ln -s d26.2 $DIR/s26.2-1
1246 ln -s s26.2-1 $DIR/s26.2-2
1247 ln -s s26.2-2 $DIR/s26.2-3
1248 chmod 0666 $DIR/s26.2-3/foo
1250 run_test 26c "chain of symlinks ================================"
1252 # recursive symlinks (bug 439)
1254 ln -s d26-3/foo $DIR/d26-3
1256 run_test 26d "create multiple component recursive symlink ======"
1259 [ ! -h $DIR/d26-3 ] && test_26d
1262 run_test 26e "unlink multiple component recursive symlink ======"
1264 # recursive symlinks (bug 7022)
1266 test_mkdir -p $DIR/$tdir
1267 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1268 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1269 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1270 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1271 cd $tfile || error "cd $tfile failed"
1272 ln -s .. dotdot || error "ln dotdot failed"
1273 ln -s dotdot/lndir lndir || error "ln lndir failed"
1274 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1275 output=`ls $tfile/$tfile/lndir/bar1`
1276 [ "$output" = bar1 ] && error "unexpected output"
1277 rm -r $tfile || error "rm $tfile failed"
1278 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1280 run_test 26f "rm -r of a directory which has recursive symlink ="
1283 echo '== stripe sanity =============================================='
1284 test_mkdir -p $DIR/d27 || error "mkdir failed"
1286 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1287 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1288 log "== test_27a: write to one stripe file ========================="
1289 cp /etc/hosts $DIR/d27/f0 || error
1291 run_test 27a "one stripe file =================================="
1294 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1295 test_mkdir -p $DIR/d27
1296 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1297 $GETSTRIPE -c $DIR/d27/f01
1298 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1299 error "two-stripe file doesn't have two stripes"
1301 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1303 run_test 27b "create and write to two stripe file"
1306 test_mkdir -p $DIR/d27
1307 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1308 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1309 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1311 run_test 27d "create file with default settings ================"
1314 test_mkdir -p $DIR/d27
1315 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1316 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1317 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1319 run_test 27e "setstripe existing file (should return error) ======"
1322 test_mkdir -p $DIR/d27
1323 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1324 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1325 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1327 run_test 27f "setstripe with bad stripe size (should return error)"
1330 test_mkdir -p $DIR/d27
1331 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1332 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1333 error "$DIR/d27/fnone has object"
1335 run_test 27g "$GETSTRIPE with no objects"
1338 touch $DIR/d27/fsome || error "touch failed"
1339 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1341 run_test 27i "$GETSTRIPE with some objects"
1344 test_mkdir -p $DIR/d27
1345 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1347 run_test 27j "setstripe with bad stripe offset (should return error)"
1349 test_27k() { # bug 2844
1350 test_mkdir -p $DIR/d27
1352 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1353 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1354 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1355 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1356 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1357 dd if=/dev/zero of=$FILE bs=4k count=1
1358 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1359 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1361 run_test 27k "limit i_blksize for broken user apps ============="
1364 test_mkdir -p $DIR/d27
1365 mcreate $DIR/f27l || error "creating file"
1366 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1367 error "setstripe should have failed" || true
1369 run_test 27l "check setstripe permissions (should return error)"
1372 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1374 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1375 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1378 trap simple_cleanup_common EXIT
1379 test_mkdir -p $DIR/$tdir
1380 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1381 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1382 error "dd should fill OST0"
1384 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1386 [ $i -gt 256 ] && break
1389 touch $DIR/$tdir/f27m_$i
1390 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1391 error "OST0 was full but new created file still use it"
1393 touch $DIR/$tdir/f27m_$i
1394 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1395 error "OST0 was full but new created file still use it"
1396 simple_cleanup_common
1398 run_test 27m "create file while OST0 was full =================="
1401 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1405 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1406 # if the OST isn't full anymore.
1408 local OSTIDX=${1:-""}
1410 local list=$(comma_list $(osts_nodes))
1411 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1413 do_nodes $list lctl set_param fail_loc=0
1414 sync # initiate all OST_DESTROYs from MDS to OST
1418 exhaust_precreations() {
1421 local FAILIDX=${3:-$OSTIDX}
1423 test_mkdir -p $DIR/$tdir
1424 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1425 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1427 local OST=$(ostname_from_index $OSTIDX)
1428 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1429 sed -e 's/_UUID$//;s/^.*-//')
1432 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1433 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1434 osc.$mdtosc_proc1.prealloc_last_id)
1435 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1436 osc.$mdtosc_proc1.prealloc_next_id)
1438 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1439 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1441 test_mkdir -p $DIR/$tdir/${OST}
1442 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1443 #define OBD_FAIL_OST_ENOSPC 0x215
1444 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1445 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1446 echo "Creating to objid $last_id on ost $OST..."
1447 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1448 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1449 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1453 exhaust_all_precreations() {
1455 for (( i=0; i < OSTCOUNT; i++ )) ; do
1456 exhaust_precreations $i $1 -1
1461 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1463 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1464 remote_ost_nodsh && skip "remote OST with nodsh" && return
1467 rm -f $DIR/$tdir/$tfile
1468 exhaust_precreations 0 0x80000215
1469 $SETSTRIPE -c -1 $DIR/$tdir
1470 touch $DIR/$tdir/$tfile || error
1471 $GETSTRIPE $DIR/$tdir/$tfile
1474 run_test 27n "create file with some full OSTs =================="
1477 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1479 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1480 remote_ost_nodsh && skip "remote OST with nodsh" && return
1483 rm -f $DIR/$tdir/$tfile
1484 exhaust_all_precreations 0x215
1486 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1491 run_test 27o "create file with all full OSTs (should error) ===="
1494 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1496 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1497 remote_ost_nodsh && skip "remote OST with nodsh" && return
1500 rm -f $DIR/$tdir/$tfile
1501 test_mkdir -p $DIR/$tdir
1503 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1504 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1505 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1507 exhaust_precreations 0 0x80000215
1508 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1509 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1510 $GETSTRIPE $DIR/$tdir/$tfile
1514 run_test 27p "append to a truncated file with some full OSTs ==="
1517 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1520 remote_ost_nodsh && skip "remote OST with nodsh" && return
1523 rm -f $DIR/$tdir/$tfile
1525 test_mkdir -p $DIR/$tdir
1526 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1527 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1528 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1530 exhaust_all_precreations 0x215
1532 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1533 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1537 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1540 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1542 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1543 remote_ost_nodsh && skip "remote OST with nodsh" && return
1546 rm -f $DIR/$tdir/$tfile
1547 exhaust_precreations 0 0x80000215
1549 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1553 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1555 test_27s() { # bug 10725
1556 test_mkdir -p $DIR/$tdir
1557 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1558 local stripe_count=0
1559 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1560 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1561 error "stripe width >= 2^32 succeeded" || true
1564 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1566 test_27t() { # bug 10864
1571 $WLFS getstripe $tfile
1574 run_test 27t "check that utils parse path correctly"
1576 test_27u() { # bug 4900
1577 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1578 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1580 local list=$(comma_list $(mdts_nodes))
1582 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1583 do_nodes $list $LCTL set_param fail_loc=0x139
1584 test_mkdir -p $DIR/$tdir
1586 createmany -o $DIR/$tdir/t- 1000
1587 do_nodes $list $LCTL set_param fail_loc=0
1589 TLOG=$DIR/$tfile.getstripe
1590 $GETSTRIPE $DIR/$tdir > $TLOG
1591 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1592 unlinkmany $DIR/$tdir/t- 1000
1593 [[ $OBJS -gt 0 ]] &&
1594 error "$OBJS objects created on OST-0. See $TLOG" || pass
1596 run_test 27u "skip object creation on OSC w/o objects =========="
1598 test_27v() { # bug 4900
1599 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1601 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1602 remote_ost_nodsh && skip "remote OST with nodsh" && return
1604 exhaust_all_precreations 0x215
1607 test_mkdir -p $DIR/$tdir
1608 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1610 touch $DIR/$tdir/$tfile
1611 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1613 for (( i=1; i < OSTCOUNT; i++ )); do
1614 do_facet ost$i lctl set_param fail_loc=0x705
1616 local START=`date +%s`
1617 createmany -o $DIR/$tdir/$tfile 32
1619 local FINISH=`date +%s`
1620 local TIMEOUT=`lctl get_param -n timeout`
1621 local PROCESS=$((FINISH - START))
1622 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1623 error "$FINISH - $START >= $TIMEOUT / 2"
1624 sleep $((TIMEOUT / 2 - PROCESS))
1627 run_test 27v "skip object creation on slow OST ================="
1629 test_27w() { # bug 10997
1630 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1631 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1632 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1633 error "stripe size $size != 65536" || true
1634 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1635 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1637 run_test 27w "check $SETSTRIPE -S option"
1640 [[ $OSTCOUNT -lt 2 ]] &&
1641 skip_env "skipping multiple stripe count/offset test" && return
1643 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1644 for i in $(seq 1 $OSTCOUNT); do
1646 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1647 error "setstripe -c $i -i $offset failed"
1648 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1649 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1650 [ $count -ne $i ] && error "stripe count $count != $i" || true
1651 [ $index -ne $offset ] &&
1652 error "stripe offset $index != $offset" || true
1655 run_test 27wa "check $SETSTRIPE -c -i options"
1658 remote_ost_nodsh && skip "remote OST with nodsh" && return
1659 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1661 OFFSET=$(($OSTCOUNT - 1))
1663 local OST=$(ostname_from_index $OSTIDX)
1665 test_mkdir -p $DIR/$tdir
1666 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1667 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1669 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1670 for i in `seq 0 $OFFSET`; do
1671 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1672 error "OST0 was degraded but new created file still use it"
1674 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1676 run_test 27x "create files while OST0 is degraded"
1679 [[ $OSTCOUNT -lt 2 ]] &&
1680 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1681 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1682 remote_ost_nodsh && skip "remote OST with nodsh" && return
1683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1685 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1686 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1687 osc.$mdtosc.prealloc_last_id)
1688 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1689 osc.$mdtosc.prealloc_next_id)
1690 local fcount=$((last_id - next_id))
1691 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1692 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1694 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1695 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1696 local OST_DEACTIVE_IDX=-1
1701 for OSC in $MDS_OSCS; do
1702 OST=$(osc_to_ost $OSC)
1703 OSTIDX=$(index_from_ostuuid $OST)
1704 if [ $OST_DEACTIVE_IDX == -1 ]; then
1705 OST_DEACTIVE_IDX=$OSTIDX
1707 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1708 echo $OSC "is Deactivated:"
1709 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1713 OSTIDX=$(index_from_ostuuid $OST)
1715 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1717 for OSC in $MDS_OSCS; do
1718 OST=$(osc_to_ost $OSC)
1719 OSTIDX=$(index_from_ostuuid $OST)
1720 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1721 echo $OST "is degraded:"
1722 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1723 obdfilter.$OST.degraded=1
1728 createmany -o $DIR/$tdir/$tfile $fcount
1730 for OSC in $MDS_OSCS; do
1731 OST=$(osc_to_ost $OSC)
1732 OSTIDX=$(index_from_ostuuid $OST)
1733 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1734 echo $OST "is recovered from degraded:"
1735 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1736 obdfilter.$OST.degraded=0
1738 do_facet $SINGLEMDS lctl --device %$OSC activate
1742 # all osp devices get activated, hence -1 stripe count restored
1745 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1746 # devices get activated.
1748 $SETSTRIPE -c -1 $DIR/$tfile
1749 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1751 [ $stripecnt -ne $OSTCOUNT ] &&
1752 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1755 run_test 27y "create files while OST0 is degraded and the rest inactive"
1761 lmm_count=$($GETSTRIPE -c $1)
1762 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1763 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1765 local old_ifs="$IFS"
1767 fid=($($LFS path2fid $1))
1770 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1771 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1773 # compare lmm_seq and lu_fid->f_seq
1774 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1775 # compare lmm_object_id and lu_fid->oid
1776 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1778 # check the trusted.fid attribute of the OST objects of the file
1779 local have_obdidx=false
1781 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1782 # skip lines up to and including "obdidx"
1783 [ -z "$obdidx" ] && break
1784 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1785 $have_obdidx || continue
1787 local ost=$((obdidx + 1))
1788 local dev=$(ostdevname $ost)
1791 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1793 seq=$(echo $seq | sed -e "s/^0x//g")
1794 if [ $seq == 0 ]; then
1795 oid_hex=$(echo $oid)
1797 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1799 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1803 # Don't unmount/remount the OSTs if we don't need to do that.
1804 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1805 # update too, until that use mount/ll_decode_filter_fid/mount.
1806 # Re-enable when debugfs will understand new filter_fid.
1808 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1809 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1810 $dev 2>/dev/null" | grep "parent=")
1813 mount_fstype ost$ost
1814 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1815 $(facet_mntpt ost$ost)/$obj_file)
1816 unmount_fstype ost$ost
1817 start ost$ost $dev $OST_MOUNT_OPTS
1820 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1822 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1824 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1825 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1826 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1827 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1828 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1830 if echo $ff_parent | grep -q 'stripe='; then
1831 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1834 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1835 # into f_ver in this case. See the comment on
1838 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1842 # compare lmm_seq and filter_fid->ff_parent.f_seq
1843 [ $ff_pseq = $lmm_seq ] ||
1844 error "FF parent SEQ $ff_pseq != $lmm_seq"
1845 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1846 [ $ff_poid = $lmm_oid ] ||
1847 error "FF parent OID $ff_poid != $lmm_oid"
1848 (($ff_pstripe == $stripe_nr)) ||
1849 error "FF stripe $ff_pstripe != $stripe_nr"
1851 stripe_nr=$((stripe_nr + 1))
1856 remote_ost_nodsh && skip "remote OST with nodsh" && return
1857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1858 test_mkdir -p $DIR/$tdir
1860 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1861 { error "setstripe -c -1 failed"; return 1; }
1862 # We need to send a write to every object to get parent FID info set.
1863 # This _should_ also work for setattr, but does not currently.
1864 # touch $DIR/$tdir/$tfile-1 ||
1865 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1866 { error "dd $tfile-1 failed"; return 2; }
1867 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1868 { error "setstripe -c -1 failed"; return 3; }
1869 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1870 { error "dd $tfile-2 failed"; return 4; }
1872 # make sure write RPCs have been sent to OSTs
1875 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1876 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1878 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1880 test_27A() { # b=19102
1881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1882 local restore_size=$($GETSTRIPE -S $MOUNT)
1883 local restore_count=$($GETSTRIPE -c $MOUNT)
1884 local restore_offset=$($GETSTRIPE -i $MOUNT)
1885 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1886 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1887 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1888 local default_size=$($GETSTRIPE -S $MOUNT)
1889 local default_offset=$($GETSTRIPE -i $MOUNT)
1890 local dsize=$((1024 * 1024))
1891 [ $default_size -eq $dsize ] ||
1892 error "stripe size $default_size != $dsize"
1893 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1894 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1896 run_test 27A "check filesystem-wide default LOV EA values"
1898 test_27B() { # LU-2523
1899 test_mkdir -p $DIR/$tdir
1900 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1902 # open f1 with O_LOV_DELAY_CREATE
1904 # call setstripe ioctl on open file descriptor for f1
1906 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1910 # open f1 with O_LOV_DELAY_CREATE
1912 # call setstripe ioctl on open file descriptor for f1
1914 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1916 # Allow multiop to fail in imitation of NFS's busted semantics.
1919 run_test 27B "call setstripe on open unlinked file/rename victim"
1921 test_27C() { #LU-2871
1922 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1930 test_mkdir -p $DIR/$tdir
1932 for i in $(seq 0 $((OSTCOUNT - 1))); do
1933 # set stripe across all OSTs starting from OST$i
1934 $SETSTRIPE -i $i -c -1 $tfile$i
1935 # get striping information
1936 ost_idx=($($GETSTRIPE $tfile$i |
1937 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1941 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1942 error "${#ost_idx[@]} != $OSTCOUNT"
1944 for index in $(seq 0 $((OSTCOUNT - 1))); do
1946 for j in $(echo ${ost_idx[@]}); do
1947 if [ $index -eq $j ]; then
1953 error "Can not find $index in ${ost_idx[@]}"
1957 run_test 27C "check full striping across all OSTs"
1959 # createtest also checks that device nodes are created and
1960 # then visible correctly (#2091)
1961 test_28() { # bug 2091
1963 $CREATETEST $DIR/d28/ct || error
1965 run_test 28 "create/mknod/mkdir with bad file types ============"
1968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1969 cancel_lru_locks mdc
1975 declare -i LOCKCOUNTORIG=0
1976 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1977 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1979 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1981 declare -i LOCKUNUSEDCOUNTORIG=0
1982 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1983 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1990 declare -i LOCKCOUNTCURRENT=0
1991 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1992 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1995 declare -i LOCKUNUSEDCOUNTCURRENT=0
1996 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1997 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2000 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2001 $LCTL set_param -n ldlm.dump_namespaces ""
2002 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2003 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2004 log "dumped log to $TMP/test_29.dk (bug 5793)"
2007 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2008 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2009 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2010 log "dumped log to $TMP/test_29.dk (bug 5793)"
2014 run_test 29 "IT_GETATTR regression ============================"
2016 test_30a() { # was test_30
2017 cp $(which ls) $DIR || cp /bin/ls $DIR
2021 run_test 30a "execute binary from Lustre (execve) =============="
2024 cp `which ls` $DIR || cp /bin/ls $DIR
2026 $RUNAS $DIR/ls / || error
2029 run_test 30b "execute binary from Lustre as non-root ==========="
2031 test_30c() { # b=22376
2032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2033 cp `which ls` $DIR || cp /bin/ls $DIR
2035 cancel_lru_locks mdc
2036 cancel_lru_locks osc
2037 $RUNAS $DIR/ls / || error
2040 run_test 30c "execute binary from Lustre without read perms ===="
2043 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2044 $CHECKSTAT -a $DIR/f31 || error
2046 run_test 31a "open-unlink file =================================="
2049 touch $DIR/f31 || error
2050 ln $DIR/f31 $DIR/f31b || error
2051 $MULTIOP $DIR/f31b Ouc || error
2052 $CHECKSTAT -t file $DIR/f31 || error
2054 run_test 31b "unlink file with multiple links while open ======="
2057 touch $DIR/f31 || error
2058 ln $DIR/f31 $DIR/f31c || error
2059 multiop_bg_pause $DIR/f31 O_uc || return 1
2061 $MULTIOP $DIR/f31c Ouc
2062 kill -USR1 $MULTIPID
2065 run_test 31c "open-unlink file with multiple links ============="
2068 opendirunlink $DIR/d31d $DIR/d31d || error
2069 $CHECKSTAT -a $DIR/d31d || error
2071 run_test 31d "remove of open directory ========================="
2073 test_31e() { # bug 2904
2074 check_kernel_version 34 || return 0
2075 openfilleddirunlink $DIR/d31e || error
2077 run_test 31e "remove of open non-empty directory ==============="
2079 test_31f() { # bug 4554
2080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2082 test_mkdir $DIR/d31f
2083 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2084 cp /etc/hosts $DIR/d31f
2086 $GETSTRIPE $DIR/d31f/hosts
2087 multiop_bg_pause $DIR/d31f D_c || return 1
2090 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2091 test_mkdir $DIR/d31f
2092 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2093 cp /etc/hosts $DIR/d31f
2095 $GETSTRIPE $DIR/d31f/hosts
2096 multiop_bg_pause $DIR/d31f D_c || return 1
2099 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2100 wait $MULTIPID || error "first opendir $MULTIPID failed"
2104 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2105 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2108 run_test 31f "remove of open directory with open-unlink file ==="
2111 echo "-- cross directory link --"
2112 test_mkdir -c1 $DIR/${tdir}ga
2113 test_mkdir -c1 $DIR/${tdir}gb
2114 touch $DIR/${tdir}ga/f
2115 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2116 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2117 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2118 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2119 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2121 run_test 31g "cross directory link==============="
2124 echo "-- cross directory link --"
2125 test_mkdir -c1 $DIR/${tdir}
2126 test_mkdir -c1 $DIR/${tdir}/dir
2127 touch $DIR/${tdir}/f
2128 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2129 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2130 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2131 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2132 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2134 run_test 31h "cross directory link under child==============="
2137 echo "-- cross directory link --"
2138 test_mkdir -c1 $DIR/$tdir
2139 test_mkdir -c1 $DIR/$tdir/dir
2140 touch $DIR/$tdir/dir/f
2141 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2142 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2143 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2144 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2145 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2147 run_test 31i "cross directory link under parent==============="
2150 test_mkdir -c1 -p $DIR/$tdir
2151 test_mkdir -c1 -p $DIR/$tdir/dir1
2152 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2153 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2154 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2155 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2158 run_test 31j "link for directory==============="
2161 test_mkdir -c1 -p $DIR/$tdir
2163 touch $DIR/$tdir/exist
2164 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2165 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2166 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2167 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2168 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2169 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2170 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2173 run_test 31k "link to file: the same, non-existing, dir==============="
2179 touch $DIR/d31m2/exist
2180 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2181 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2182 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2183 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2184 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2185 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2188 run_test 31m "link to file: the same, non-existing, dir==============="
2191 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2192 nlink=$(stat --format=%h $DIR/$tfile)
2193 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2195 local cmd="exec $fd<$DIR/$tfile"
2198 trap "eval $cmd" EXIT
2199 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2200 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2201 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2202 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2203 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2206 run_test 31n "check link count of unlinked file"
2209 local TEMPNAME=$(mktemp $1_XXXXXX)
2210 mlink $TEMPNAME $1 2> /dev/null &&
2211 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2215 test_31o() { # LU-2901
2217 for LOOP in $(seq 100); do
2218 rm -f $DIR/$tdir/$tfile*
2219 for THREAD in $(seq 8); do
2220 link_one $DIR/$tdir/$tfile.$LOOP &
2223 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2224 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2225 error "$LINKS duplicate links to $tfile.$LOOP" &&
2229 run_test 31o "duplicate hard links with same filename"
2232 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2235 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2236 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2238 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2239 error "open unlink test1 failed"
2240 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2241 error "open unlink test2 failed"
2243 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2244 error "test1 still exists"
2245 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2246 error "test2 still exists"
2248 run_test 31p "remove of open striped directory"
2250 cleanup_test32_mount() {
2252 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2257 echo "== more mountpoints and symlinks ================="
2258 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2259 trap cleanup_test32_mount EXIT
2260 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2261 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2262 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2263 cleanup_test32_mount
2265 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2269 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2270 trap cleanup_test32_mount EXIT
2271 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2272 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2273 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2274 cleanup_test32_mount
2276 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2280 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2281 trap cleanup_test32_mount EXIT
2282 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2283 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2284 test_mkdir -p $DIR/$tdir/d2/test_dir
2285 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2286 cleanup_test32_mount
2288 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2292 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2293 trap cleanup_test32_mount EXIT
2294 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2295 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2296 test_mkdir -p $DIR/$tdir/d2/test_dir
2297 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2298 cleanup_test32_mount
2300 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2303 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2304 test_mkdir -p $DIR/d32e/tmp
2305 TMP_DIR=$DIR/d32e/tmp
2306 ln -s $DIR/d32e $TMP_DIR/symlink11
2307 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2308 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2309 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2311 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2314 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2315 test_mkdir -p $DIR/d32f/tmp
2316 TMP_DIR=$DIR/d32f/tmp
2317 ln -s $DIR/d32f $TMP_DIR/symlink11
2318 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2319 ls $DIR/d32f/tmp/symlink11 || error
2320 ls $DIR/d32f/symlink01 || error
2322 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2325 TMP_DIR=$DIR/$tdir/tmp
2326 test_mkdir -p $DIR/$tdir/tmp
2327 test_mkdir $DIR/${tdir}2
2328 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2329 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2330 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2331 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2332 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2333 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2335 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2338 rm -fr $DIR/$tdir $DIR/${tdir}2
2339 TMP_DIR=$DIR/$tdir/tmp
2340 test_mkdir -p $DIR/$tdir/tmp
2341 test_mkdir $DIR/${tdir}2
2342 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2343 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2344 ls $TMP_DIR/symlink12 || error
2345 ls $DIR/$tdir/symlink02 || error
2347 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2351 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2352 trap cleanup_test32_mount EXIT
2353 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2354 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2355 touch $DIR/$tdir/test_file
2356 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2357 cleanup_test32_mount
2359 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2363 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2364 trap cleanup_test32_mount EXIT
2365 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2366 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2367 touch $DIR/$tdir/test_file
2368 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2369 cleanup_test32_mount
2371 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2376 trap cleanup_test32_mount EXIT
2377 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2378 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2379 test_mkdir -p $DIR/$tdir/d2
2380 touch $DIR/$tdir/d2/test_file || error
2381 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2382 cleanup_test32_mount
2384 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
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
2393 touch $DIR/$tdir/d2/test_file
2394 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2395 cleanup_test32_mount
2397 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2401 test_mkdir -p $DIR/d32m/tmp
2402 TMP_DIR=$DIR/d32m/tmp
2403 ln -s $DIR $TMP_DIR/symlink11
2404 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2405 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2406 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2408 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2412 test_mkdir -p $DIR/d32n/tmp
2413 TMP_DIR=$DIR/d32n/tmp
2414 ln -s $DIR $TMP_DIR/symlink11
2415 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2416 ls -l $DIR/d32n/tmp/symlink11 || error
2417 ls -l $DIR/d32n/symlink01 || error
2419 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2422 rm -fr $DIR/d32o $DIR/$tfile
2424 test_mkdir -p $DIR/d32o/tmp
2425 TMP_DIR=$DIR/d32o/tmp
2426 ln -s $DIR/$tfile $TMP_DIR/symlink12
2427 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2428 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2429 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2430 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2431 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2433 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2443 test_mkdir -p $DIR/d32p/tmp
2445 TMP_DIR=$DIR/d32p/tmp
2447 ln -s $DIR/$tfile $TMP_DIR/symlink12
2449 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2451 cat $DIR/d32p/tmp/symlink12 || error
2453 cat $DIR/d32p/symlink02 || error
2456 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2458 cleanup_testdir_mount() {
2460 $UMOUNT -d $DIR/$tdir
2464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2465 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2466 trap cleanup_testdir_mount EXIT
2467 test_mkdir -p $DIR/$tdir
2468 touch $DIR/$tdir/under_the_mount
2469 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2470 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2471 cleanup_testdir_mount
2473 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2477 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2478 trap cleanup_testdir_mount EXIT
2479 test_mkdir -p $DIR/$tdir
2480 touch $DIR/$tdir/under_the_mount
2481 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2482 ls $DIR/$tdir | grep -q under_the_mount && error || true
2483 cleanup_testdir_mount
2485 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2490 chmod 444 $DIR/$tfile
2491 chown $RUNAS_ID $DIR/$tfile
2493 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2496 run_test 33aa "write file with mode 444 (should return error) ===="
2500 test_mkdir -p $DIR/d33
2501 chown $RUNAS_ID $DIR/d33
2502 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2503 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2504 error "open RDWR" || true
2506 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2510 test_mkdir -p $DIR/d33
2511 chown $RUNAS_ID $DIR/d33
2512 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2514 run_test 33b "test open file with malformed flags (No panic and return error)"
2517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2523 remote_ost_nodsh && skip "remote OST with nodsh" && return
2526 test_mkdir -p $DIR/d33
2527 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2530 for ostnum in $(seq $OSTCOUNT); do
2531 # test-framework's OST numbering is one-based, while Lustre's
2533 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2534 # Parsing llobdstat's output sucks; we could grep the /proc
2535 # path, but that's likely to not be as portable as using the
2536 # llobdstat utility. So we parse lctl output instead.
2537 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2538 obdfilter/$ostname/stats |
2539 awk '/^write_bytes/ {print $7}' )
2540 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2541 if (( ${write_bytes:-0} > 0 ))
2548 $all_zeros || return 0
2551 echo foo > $DIR/d33/bar
2555 # Total up write_bytes after writing. We'd better find non-zeros.
2556 for ostnum in $(seq $OSTCOUNT); do
2557 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2558 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2559 obdfilter/$ostname/stats |
2560 awk '/^write_bytes/ {print $7}' )
2561 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2562 if (( ${write_bytes:-0} > 0 ))
2571 for ostnum in $(seq $OSTCOUNT); do
2572 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2573 echo "Check that write_bytes is present in obdfilter/*/stats:"
2574 do_facet ost$ostnum lctl get_param -n \
2575 obdfilter/$ostname/stats
2577 error "OST not keeping write_bytes stats (b22312)"
2580 run_test 33c "test llobdstat and write_bytes"
2583 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2586 local remote_dir=$DIR/$tdir/remote_dir
2589 $LFS mkdir -i $MDTIDX $remote_dir ||
2590 error "create remote directory failed"
2592 touch $remote_dir/$tfile
2593 chmod 444 $remote_dir/$tfile
2594 chown $RUNAS_ID $remote_dir/$tfile
2596 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2598 chown $RUNAS_ID $remote_dir
2599 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2600 error "create" || true
2601 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2602 error "open RDWR" || true
2603 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2604 error "create" || true
2606 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2608 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2611 $MCREATE $DIR/f34 || error
2612 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2613 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2614 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2615 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2617 run_test 34a "truncate file that has not been opened ==========="
2620 [ ! -f $DIR/f34 ] && test_34a
2621 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2622 $OPENFILE -f O_RDONLY $DIR/f34
2623 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2624 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2626 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2629 [ ! -f $DIR/f34 ] && test_34a
2630 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2631 $OPENFILE -f O_RDWR $DIR/f34
2632 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2633 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2635 run_test 34c "O_RDWR opening file-with-size works =============="
2638 [ ! -f $DIR/f34 ] && test_34a
2639 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2640 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2643 run_test 34d "write to sparse file ============================="
2647 $MCREATE $DIR/f34e || error
2648 $TRUNCATE $DIR/f34e 1000 || error
2649 $CHECKSTAT -s 1000 $DIR/f34e || error
2650 $OPENFILE -f O_RDWR $DIR/f34e
2651 $CHECKSTAT -s 1000 $DIR/f34e || error
2653 run_test 34e "create objects, some with size and some without =="
2655 test_34f() { # bug 6242, 6243
2656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2659 $MCREATE $DIR/f34f || error
2660 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2661 dd if=$DIR/f34f of=$TMP/f34f
2662 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2663 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2664 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2665 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2666 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2668 run_test 34f "read from a file with no objects until EOF ======="
2671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2672 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2673 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2674 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2675 cancel_lru_locks osc
2676 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2677 error "wrong size after lock cancel"
2679 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2680 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2681 error "expanding truncate failed"
2682 cancel_lru_locks osc
2683 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2684 error "wrong expanded size after lock cancel"
2686 run_test 34g "truncate long file ==============================="
2689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2693 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2694 sync # Flush the cache so that multiop below does not block on cache
2695 # flush when getting the group lock
2696 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2699 # Since just timed wait is not good enough, let's do a sync write
2700 # that way we are sure enough time for a roundtrip + processing
2701 # passed + 2 seconds of extra margin.
2702 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2706 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2707 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2711 local nsz=`stat -c %s $DIR/$tfile`
2712 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2714 run_test 34h "ftruncate file under grouplock should not block"
2717 cp /bin/sh $DIR/f35a
2719 chown $RUNAS_ID $DIR/f35a
2720 $RUNAS $DIR/f35a && error || true
2723 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2727 utime $DIR/f36 || error
2729 run_test 36a "MDS utime check (mknod, utime) ==================="
2733 utime $DIR/f36 || error
2735 run_test 36b "OST utime check (open, utime) ===================="
2740 chown $RUNAS_ID $DIR/d36
2741 $RUNAS utime $DIR/d36/f36 || error
2743 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2746 [ ! -d $DIR/d36 ] && test_36c
2747 echo "" > $DIR/d36/f36
2748 $RUNAS utime $DIR/d36/f36 || error
2750 run_test 36d "non-root OST utime check (open, utime) ==========="
2753 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2754 test_mkdir -p $DIR/$tdir
2755 touch $DIR/$tdir/$tfile
2756 $RUNAS utime $DIR/$tdir/$tfile && \
2757 error "utime worked, expected failure" || true
2759 run_test 36e "utime on non-owned file (should return error) ===="
2763 local LANG_SAVE=$LANG
2764 local LC_LANG_SAVE=$LC_LANG
2765 export LANG=C LC_LANG=C # for date language
2767 DATESTR="Dec 20 2000"
2768 test_mkdir -p $DIR/$tdir
2769 lctl set_param fail_loc=$fl
2771 cp /etc/hosts $DIR/$tdir/$tfile
2772 sync & # write RPC generated with "current" inode timestamp, but delayed
2774 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2775 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2776 cancel_lru_locks osc
2777 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2779 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2780 echo "BEFORE: $LS_BEFORE" && \
2781 echo "AFTER : $LS_AFTER" && \
2782 echo "WANT : $DATESTR" && \
2783 error "$DIR/$tdir/$tfile timestamps changed" || true
2785 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2790 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2791 subr_36fh "0x80000214"
2793 run_test 36f "utime on file racing with OST BRW write =========="
2796 remote_ost_nodsh && skip "remote OST with nodsh" && return
2797 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2802 test_mkdir -p $DIR/$tdir
2803 fmd_max_age=$(do_facet ost1 \
2804 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2807 fmd_before=$(do_facet ost1 \
2808 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2809 touch $DIR/$tdir/$tfile
2810 sleep $((fmd_max_age + 12))
2811 fmd_after=$(do_facet ost1 \
2812 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2814 echo "fmd_before: $fmd_before"
2815 echo "fmd_after: $fmd_after"
2816 [[ $fmd_after -gt $fmd_before ]] &&
2817 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2818 error "fmd didn't expire after ping" || true
2820 run_test 36g "filter mod data cache expiry ====================="
2823 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2824 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2825 subr_36fh "0x80000227"
2827 run_test 36h "utime on file racing with OST BRW write =========="
2830 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2833 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2835 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2836 local new_mtime=$((mtime + 200))
2838 #change Modify time of striped dir
2839 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2840 error "change mtime failed"
2842 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2844 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2846 run_test 36i "change mtime on striped directory"
2848 # test_37 - duplicate with tests 32q 32r
2851 local file=$DIR/$tfile
2853 openfile -f O_DIRECTORY $file
2856 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2857 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2859 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2863 touch $DIR/${tfile}2
2864 # ls -l $DIR/$tfile $DIR/${tfile}2
2865 # ls -lu $DIR/$tfile $DIR/${tfile}2
2866 # ls -lc $DIR/$tfile $DIR/${tfile}2
2868 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2869 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2871 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2873 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2875 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2876 error "O_TRUNC didn't change timestamps"
2879 run_test 39 "mtime changed on create ==========================="
2882 test_mkdir -p -c1 $DIR/$tdir
2883 cp -p /etc/passwd $DIR/$tdir/fopen
2884 cp -p /etc/passwd $DIR/$tdir/flink
2885 cp -p /etc/passwd $DIR/$tdir/funlink
2886 cp -p /etc/passwd $DIR/$tdir/frename
2887 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2890 echo "aaaaaa" >> $DIR/$tdir/fopen
2891 echo "aaaaaa" >> $DIR/$tdir/flink
2892 echo "aaaaaa" >> $DIR/$tdir/funlink
2893 echo "aaaaaa" >> $DIR/$tdir/frename
2895 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2896 local link_new=`stat -c %Y $DIR/$tdir/flink`
2897 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2898 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2900 cat $DIR/$tdir/fopen > /dev/null
2901 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2902 rm -f $DIR/$tdir/funlink2
2903 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2905 for (( i=0; i < 2; i++ )) ; do
2906 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2907 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2908 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2909 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2911 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2912 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2913 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2914 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2916 cancel_lru_locks osc
2917 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2920 run_test 39b "mtime change on open, link, unlink, rename ======"
2922 # this should be set to past
2923 TEST_39_MTIME=`date -d "1 year ago" +%s`
2929 local mtime0=`stat -c %Y $DIR1/$tfile`
2931 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2932 local mtime1=`stat -c %Y $DIR1/$tfile`
2933 [ "$mtime1" = $TEST_39_MTIME ] || \
2934 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2937 echo hello >> $DIR1/$tfile
2939 local mtime2=`stat -c %Y $DIR1/$tfile`
2940 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2941 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2943 mv $DIR1/$tfile $DIR1/$tfile-1
2945 for (( i=0; i < 2; i++ )) ; do
2946 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2947 [ "$mtime2" = "$mtime3" ] || \
2948 error "mtime ($mtime2) changed (to $mtime3) on rename"
2950 cancel_lru_locks osc
2951 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2954 run_test 39c "mtime change on rename ==========================="
2958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2961 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2963 for (( i=0; i < 2; i++ )) ; do
2964 local mtime=`stat -c %Y $DIR1/$tfile`
2965 [ $mtime = $TEST_39_MTIME ] || \
2966 error "mtime($mtime) is not set to $TEST_39_MTIME"
2968 cancel_lru_locks osc
2969 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2972 run_test 39d "create, utime, stat =============================="
2976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2978 local mtime1=`stat -c %Y $DIR1/$tfile`
2980 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2982 for (( i=0; i < 2; i++ )) ; do
2983 local mtime2=`stat -c %Y $DIR1/$tfile`
2984 [ $mtime2 = $TEST_39_MTIME ] || \
2985 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2987 cancel_lru_locks osc
2988 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2991 run_test 39e "create, stat, utime, stat ========================"
2995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2997 mtime1=`stat -c %Y $DIR1/$tfile`
3000 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3002 for (( i=0; i < 2; i++ )) ; do
3003 local mtime2=`stat -c %Y $DIR1/$tfile`
3004 [ $mtime2 = $TEST_39_MTIME ] || \
3005 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3007 cancel_lru_locks osc
3008 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3011 run_test 39f "create, stat, sleep, utime, stat ================="
3015 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3016 echo hello >> $DIR1/$tfile
3017 local mtime1=`stat -c %Y $DIR1/$tfile`
3020 chmod o+r $DIR1/$tfile
3022 for (( i=0; i < 2; i++ )) ; do
3023 local mtime2=`stat -c %Y $DIR1/$tfile`
3024 [ "$mtime1" = "$mtime2" ] || \
3025 error "lost mtime: $mtime2, should be $mtime1"
3027 cancel_lru_locks osc
3028 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3031 run_test 39g "write, chmod, stat ==============================="
3035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3040 echo hello >> $DIR1/$tfile
3041 local mtime1=`stat -c %Y $DIR1/$tfile`
3043 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3045 if [ "$d1" != "$d2" ]; then
3046 echo "write and touch not within one second"
3048 for (( i=0; i < 2; i++ )) ; do
3049 local mtime2=`stat -c %Y $DIR1/$tfile`
3050 [ "$mtime2" = $TEST_39_MTIME ] || \
3051 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3053 cancel_lru_locks osc
3054 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3058 run_test 39h "write, utime within one second, stat ============="
3061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3065 echo hello >> $DIR1/$tfile
3066 local mtime1=`stat -c %Y $DIR1/$tfile`
3068 mv $DIR1/$tfile $DIR1/$tfile-1
3070 for (( i=0; i < 2; i++ )) ; do
3071 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3073 [ "$mtime1" = "$mtime2" ] || \
3074 error "lost mtime: $mtime2, should be $mtime1"
3076 cancel_lru_locks osc
3077 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3080 run_test 39i "write, rename, stat =============================="
3083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3084 start_full_debug_logging
3088 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3089 lctl set_param fail_loc=0x80000412
3090 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3091 error "multiop failed"
3093 local mtime1=`stat -c %Y $DIR1/$tfile`
3095 mv $DIR1/$tfile $DIR1/$tfile-1
3097 kill -USR1 $multipid
3098 wait $multipid || error "multiop close failed"
3100 for (( i=0; i < 2; i++ )) ; do
3101 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3102 [ "$mtime1" = "$mtime2" ] ||
3103 error "mtime is lost on close: $mtime2, " \
3106 cancel_lru_locks osc
3107 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3109 lctl set_param fail_loc=0
3110 stop_full_debug_logging
3112 run_test 39j "write, rename, close, stat ======================="
3115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3119 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3121 local mtime1=`stat -c %Y $DIR1/$tfile`
3123 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3125 kill -USR1 $multipid
3126 wait $multipid || error "multiop close failed"
3128 for (( i=0; i < 2; i++ )) ; do
3129 local mtime2=`stat -c %Y $DIR1/$tfile`
3131 [ "$mtime2" = $TEST_39_MTIME ] || \
3132 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3134 cancel_lru_locks osc
3135 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3138 run_test 39k "write, utime, close, stat ========================"
3140 # this should be set to future
3141 TEST_39_ATIME=`date -d "1 year" +%s`
3144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3145 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3146 local atime_diff=$(do_facet $SINGLEMDS \
3147 lctl get_param -n mdd.*MDT0000*.atime_diff)
3151 # test setting directory atime to future
3152 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3153 local atime=$(stat -c %X $DIR/$tdir)
3154 [ "$atime" = $TEST_39_ATIME ] || \
3155 error "atime is not set to future: $atime, $TEST_39_ATIME"
3157 # test setting directory atime from future to now
3158 local d1=$(date +%s)
3160 local d2=$(date +%s)
3162 cancel_lru_locks mdc
3163 atime=$(stat -c %X $DIR/$tdir)
3164 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3165 error "atime is not updated from future: $atime, $d1<atime<$d2"
3167 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3170 # test setting directory atime when now > dir atime + atime_diff
3174 cancel_lru_locks mdc
3175 atime=$(stat -c %X $DIR/$tdir)
3176 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3177 error "atime is not updated : $atime, should be $d2"
3179 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3182 # test not setting directory atime when now < dir atime + atime_diff
3184 cancel_lru_locks mdc
3185 atime=$(stat -c %X $DIR/$tdir)
3186 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3187 error "atime is updated to $atime, should remain $d1<atime<$d2"
3189 do_facet $SINGLEMDS \
3190 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3192 run_test 39l "directory atime update ==========================="
3195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3198 local far_past_mtime=$(date -d "May 29 1953" +%s)
3199 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3201 touch -m -d @$far_past_mtime $DIR1/$tfile
3202 touch -a -d @$far_past_atime $DIR1/$tfile
3204 for (( i=0; i < 2; i++ )) ; do
3205 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3206 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3207 error "atime or mtime set incorrectly"
3209 cancel_lru_locks osc
3210 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3213 run_test 39m "test atime and mtime before 1970"
3215 test_39n() { # LU-3832
3216 local atime_diff=$(do_facet $SINGLEMDS \
3217 lctl get_param -n mdd.*MDT0000*.atime_diff)
3222 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3225 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3226 atime0=$(stat -c %X $DIR/$tfile)
3229 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3230 atime1=$(stat -c %X $DIR/$tfile)
3233 cancel_lru_locks mdc
3234 cancel_lru_locks osc
3235 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3236 atime2=$(stat -c %X $DIR/$tfile)
3238 do_facet $SINGLEMDS \
3239 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3241 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3242 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3244 run_test 39n "check that O_NOATIME is honored"
3247 TESTDIR=$DIR/$tdir/$tfile
3248 [ -e $TESTDIR ] && rm -rf $TESTDIR
3249 test_mkdir -p $TESTDIR
3255 links2=$(stat -c %h .)
3256 [ $(($links1 + 2)) != $links2 ] &&
3257 error "wrong links count $(($links1 + 2)) != $links2"
3259 links3=$(stat -c %h .)
3260 [ $(($links1 + 1)) != $links3 ] &&
3261 error "wrong links count $links1 != $links3"
3264 run_test 39o "directory cached attributes updated after create ========"
3267 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3269 TESTDIR=$DIR/$tdir/$tfile
3270 [ -e $TESTDIR ] && rm -rf $TESTDIR
3275 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3276 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3278 links2=$(stat -c %h .)
3279 [ $(($links1 + 2)) != $links2 ] &&
3280 error "wrong links count $(($links1 + 2)) != $links2"
3282 links3=$(stat -c %h .)
3283 [ $(($links1 + 1)) != $links3 ] &&
3284 error "wrong links count $links1 != $links3"
3287 run_test 39p "remote directory cached attributes updated after create ========"
3291 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3292 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3293 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3294 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3295 error "$tfile is not 4096 bytes in size"
3297 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3301 small_write $DIR/f41 18
3303 run_test 41 "test small file write + fstat ====================="
3305 count_ost_writes() {
3306 lctl get_param -n osc.*.stats |
3307 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3308 END { printf("%0.0f", writes) }'
3315 BG_DIRTY_RATIO_SAVE=10
3316 MAX_BG_DIRTY_RATIO=25
3320 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3321 # dirty_ratio, dirty_background_ratio
3322 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3323 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3324 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3325 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3327 # if file not here, we are a 2.4 kernel
3328 kill -CONT `pidof kupdated`
3333 # setup the trap first, so someone cannot exit the test at the
3334 # exact wrong time and mess up a machine
3335 trap start_writeback EXIT
3336 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3337 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3338 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3339 sysctl -w vm.dirty_writeback_centisecs=0
3340 sysctl -w vm.dirty_writeback_centisecs=0
3341 # save and increase /proc/sys/vm/dirty_ratio
3342 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3343 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3344 # save and increase /proc/sys/vm/dirty_background_ratio
3345 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3346 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3348 # if file not here, we are a 2.4 kernel
3349 kill -STOP `pidof kupdated`
3353 # ensure that all stripes have some grant before we test client-side cache
3355 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3356 dd if=/dev/zero of=$i bs=4k count=1
3361 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3362 # file truncation, and file removal.
3364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3366 cancel_lru_locks osc
3368 sync; sleep 1; sync # just to be safe
3369 BEFOREWRITES=`count_ost_writes`
3370 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3371 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3372 AFTERWRITES=`count_ost_writes`
3373 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3374 error "$BEFOREWRITES < $AFTERWRITES"
3377 run_test 42a "ensure that we don't flush on close =============="
3380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3382 cancel_lru_locks osc
3385 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3386 BEFOREWRITES=$(count_ost_writes)
3387 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3388 AFTERWRITES=$(count_ost_writes)
3389 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3390 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3392 BEFOREWRITES=$(count_ost_writes)
3393 sync || error "sync: $?"
3394 AFTERWRITES=$(count_ost_writes)
3395 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3396 error "$BEFOREWRITES < $AFTERWRITES on sync"
3398 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3402 run_test 42b "test destroy of file with cached dirty data ======"
3404 # if these tests just want to test the effect of truncation,
3405 # they have to be very careful. consider:
3406 # - the first open gets a {0,EOF}PR lock
3407 # - the first write conflicts and gets a {0, count-1}PW
3408 # - the rest of the writes are under {count,EOF}PW
3409 # - the open for truncate tries to match a {0,EOF}PR
3410 # for the filesize and cancels the PWs.
3411 # any number of fixes (don't get {0,EOF} on open, match
3412 # composite locks, do smarter file size management) fix
3413 # this, but for now we want these tests to verify that
3414 # the cancellation with truncate intent works, so we
3415 # start the file with a full-file pw lock to match against
3416 # until the truncate.
3421 cancel_lru_locks osc
3423 # prime the file with 0,EOF PW to match
3427 # now the real test..
3428 dd if=/dev/zero of=$file bs=1024 count=100
3429 BEFOREWRITES=`count_ost_writes`
3430 $TRUNCATE $file $offset
3431 cancel_lru_locks osc
3432 AFTERWRITES=`count_ost_writes`
3437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3439 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3440 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3443 run_test 42c "test partial truncate of file with cached dirty data"
3446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3448 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3449 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3452 run_test 42d "test complete truncate of file with cached dirty data"
3454 test_42e() { # bug22074
3455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3456 local TDIR=$DIR/${tdir}e
3457 local pagesz=$(page_size)
3458 local pages=16 # hardcoded 16 pages, don't change it.
3459 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3460 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3464 test_mkdir -p $DIR/${tdir}e
3465 $SETSTRIPE -c 1 $TDIR
3466 createmany -o $TDIR/f $files
3468 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3470 # we assume that with $OSTCOUNT files, at least one of them will
3471 # be allocated on OST0.
3472 warmup_files=$((OSTCOUNT * max_dirty_mb))
3473 createmany -o $TDIR/w $warmup_files
3475 # write a large amount of data into one file and sync, to get good
3476 # avail_grant number from OST.
3477 for ((i=0; i<$warmup_files; i++)); do
3478 idx=$($GETSTRIPE -i $TDIR/w$i)
3479 [ $idx -ne 0 ] && continue
3480 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3483 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3485 $LCTL get_param $proc_osc0/cur_dirty_bytes
3486 $LCTL get_param $proc_osc0/cur_grant_bytes
3488 # create as much dirty pages as we can while not to trigger the actual
3489 # RPCs directly. but depends on the env, VFS may trigger flush during this
3490 # period, hopefully we are good.
3491 for ((i=0; i<$warmup_files; i++)); do
3492 idx=$($GETSTRIPE -i $TDIR/w$i)
3493 [ $idx -ne 0 ] && continue
3494 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3496 $LCTL get_param $proc_osc0/cur_dirty_bytes
3497 $LCTL get_param $proc_osc0/cur_grant_bytes
3499 # perform the real test
3500 $LCTL set_param $proc_osc0/rpc_stats 0
3501 for ((;i<$files; i++)); do
3502 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3503 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3506 $LCTL get_param $proc_osc0/rpc_stats
3509 local have_ppr=false
3510 $LCTL get_param $proc_osc0/rpc_stats |
3511 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3512 # skip lines until we are at the RPC histogram data
3513 [ "$PPR" == "pages" ] && have_ppr=true && continue
3514 $have_ppr || continue
3516 # we only want the percent stat for < 16 pages
3517 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3519 percent=$((percent + WPCT))
3520 if [[ $percent -gt 15 ]]; then
3521 error "less than 16-pages write RPCs" \
3528 run_test 42e "verify sub-RPC writes are not done synchronously"
3531 test_mkdir -p $DIR/$tdir
3532 cp -p /bin/ls $DIR/$tdir/$tfile
3533 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3535 # give multiop a chance to open
3538 $DIR/$tdir/$tfile && error || true
3541 run_test 43 "execution of file opened for write should return -ETXTBSY"
3544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3545 test_mkdir -p $DIR/$tdir
3546 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3547 cp -p multiop $DIR/$tdir/multiop
3548 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3551 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3552 kill -USR1 $MULTIOP_PID || return 2
3553 wait $MULTIOP_PID || return 3
3554 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3556 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3560 test_mkdir -p $DIR/$tdir
3561 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3562 cp -p multiop $DIR/$tdir/multiop
3563 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3566 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3567 kill -USR1 $MULTIOP_PID || return 2
3568 wait $MULTIOP_PID || return 3
3569 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3571 run_test 43b "truncate of file being executed should return -ETXTBSY"
3574 local testdir="$DIR/$tdir"
3575 test_mkdir -p $DIR/$tdir
3577 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3578 ( cd $testdir && md5sum -c)
3580 run_test 43c "md5sum of copy into lustre========================"
3583 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3584 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3585 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3587 run_test 44 "zero length read from a sparse stripe ============="
3590 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3592 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3593 [[ $nstripe -gt $OSTCOUNT ]] &&
3594 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3596 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3598 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3599 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3603 OFFSETS="0 $((stride/2)) $((stride-1))"
3604 for offset in $OFFSETS; do
3605 for i in $(seq 0 $((nstripe-1))); do
3606 local GLOBALOFFSETS=""
3608 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3609 local myfn=$DIR/d44a-$size
3610 echo "--------writing $myfn at $size"
3611 ll_sparseness_write $myfn $size ||
3612 error "ll_sparseness_write"
3613 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3614 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3615 error "ll_sparseness_verify $GLOBALOFFSETS"
3617 for j in $(seq 0 $((nstripe-1))); do
3619 size=$((((j + $nstripe )*$stride + $offset)))
3620 ll_sparseness_write $myfn $size ||
3621 error "ll_sparseness_write"
3622 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3624 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3625 error "ll_sparseness_verify $GLOBALOFFSETS"
3630 run_test 44a "test sparse pwrite ==============================="
3634 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3640 before=`dirty_osc_total`
3641 echo executing "\"$*\""
3643 after=`dirty_osc_total`
3644 echo before $before, after $after
3647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3649 # Obtain grants from OST if it supports it
3650 echo blah > ${f}_grant
3653 do_dirty_record "echo blah > $f"
3654 [[ $before -eq $after ]] && error "write wasn't cached"
3655 do_dirty_record "> $f"
3656 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3657 do_dirty_record "echo blah > $f"
3658 [[ $before -eq $after ]] && error "write wasn't cached"
3659 do_dirty_record "sync"
3660 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3661 do_dirty_record "echo blah > $f"
3662 [[ $before -eq $after ]] && error "write wasn't cached"
3663 do_dirty_record "cancel_lru_locks osc"
3664 [[ $before -gt $after ]] ||
3665 error "lock cancellation didn't lower dirty count"
3668 run_test 45 "osc io page accounting ============================"
3670 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3671 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3672 # objects offset and an assert hit when an rpc was built with 1023's mapped
3673 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3679 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3681 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3682 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3686 run_test 46 "dirtying a previously written page ================"
3688 # test_47 is removed "Device nodes check" is moved to test_28
3690 test_48a() { # bug 2399
3691 check_kernel_version 34 || return 0
3692 test_mkdir -p $DIR/$tdir
3694 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3695 test_mkdir $DIR/$tdir || error "recreate directory failed"
3696 touch foo || error "'touch foo' failed after recreating cwd"
3697 test_mkdir $DIR/$tdir/bar ||
3698 error "'mkdir foo' failed after recreating cwd"
3699 if check_kernel_version 44; then
3700 touch .foo || error "'touch .foo' failed after recreating cwd"
3701 test_mkdir $DIR/$tdir/.bar ||
3702 error "'mkdir .foo' failed after recreating cwd"
3704 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3705 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3706 cd . || error "'cd .' failed after recreating cwd"
3707 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3708 rmdir . && error "'rmdir .' worked after recreating cwd"
3709 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3710 cd .. || error "'cd ..' failed after recreating cwd"
3712 run_test 48a "Access renamed working dir (should return errors)="
3714 test_48b() { # bug 2399
3715 check_kernel_version 34 || return 0
3717 test_mkdir -p $DIR/$tdir
3719 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3720 touch foo && error "'touch foo' worked after removing cwd"
3721 test_mkdir $DIR/$tdir/foo &&
3722 error "'mkdir foo' worked after removing cwd"
3723 if check_kernel_version 44; then
3724 touch .foo && error "'touch .foo' worked after removing cwd"
3725 test_mkdir $DIR/$tdir/.foo &&
3726 error "'mkdir .foo' worked after removing cwd"
3728 ls . > /dev/null && error "'ls .' worked after removing cwd"
3729 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3730 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3731 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3732 rmdir . && error "'rmdir .' worked after removing cwd"
3733 ln -s . foo && error "'ln -s .' worked after removing cwd"
3734 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3736 run_test 48b "Access removed working dir (should return errors)="
3738 test_48c() { # bug 2350
3739 check_kernel_version 36 || return 0
3740 #lctl set_param debug=-1
3743 test_mkdir -p $DIR/$tdir/dir
3745 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3746 $TRACE touch foo && error "touch foo worked after removing cwd"
3747 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3748 if check_kernel_version 44; then
3749 touch .foo && error "touch .foo worked after removing cwd"
3750 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3752 $TRACE ls . && error "'ls .' worked after removing cwd"
3753 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3754 is_patchless || ( $TRACE cd . &&
3755 error "'cd .' worked after removing cwd" )
3756 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3757 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3758 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3759 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3761 run_test 48c "Access removed working subdir (should return errors)"
3763 test_48d() { # bug 2350
3764 check_kernel_version 36 || return 0
3765 #lctl set_param debug=-1
3768 test_mkdir -p $DIR/$tdir/dir
3770 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3771 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3772 $TRACE touch foo && error "'touch foo' worked after removing parent"
3773 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3774 if check_kernel_version 44; then
3775 touch .foo && error "'touch .foo' worked after removing parent"
3777 error "mkdir .foo worked after removing parent"
3779 $TRACE ls . && error "'ls .' worked after removing parent"
3780 $TRACE ls .. && error "'ls ..' worked after removing parent"
3781 is_patchless || ( $TRACE cd . &&
3782 error "'cd .' worked after recreate parent" )
3783 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3784 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3785 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3786 is_patchless || ( $TRACE cd .. &&
3787 error "'cd ..' worked after removing parent" || true )
3789 run_test 48d "Access removed parent subdir (should return errors)"
3791 test_48e() { # bug 4134
3792 check_kernel_version 41 || return 0
3793 #lctl set_param debug=-1
3796 test_mkdir -p $DIR/$tdir/dir
3798 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3799 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3800 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3801 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3802 # On a buggy kernel addition of "touch foo" after cd .. will
3803 # produce kernel oops in lookup_hash_it
3804 touch ../foo && error "'cd ..' worked after recreate parent"
3806 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3808 run_test 48e "Access to recreated parent subdir (should return errors)"
3810 test_49() { # LU-1030
3811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3812 # get ost1 size - lustre-OST0000
3813 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3815 # write 800M at maximum
3816 [[ $ost1_size -lt 2 ]] && ost1_size=2
3817 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3819 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3820 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3823 # change max_pages_per_rpc while writing the file
3824 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3825 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3826 # loop until dd process exits
3827 while ps ax -opid | grep -wq $dd_pid; do
3828 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3829 sleep $((RANDOM % 5 + 1))
3831 # restore original max_pages_per_rpc
3832 $LCTL set_param $osc1_mppc=$orig_mppc
3833 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3835 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3839 test_mkdir $DIR/$tdir
3841 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3843 run_test 50 "special situations: /proc symlinks ==============="
3845 test_51a() { # was test_51
3846 # bug 1516 - create an empty entry right after ".." then split dir
3847 test_mkdir -c1 $DIR/$tdir
3848 touch $DIR/$tdir/foo
3849 $MCREATE $DIR/$tdir/bar
3851 createmany -m $DIR/$tdir/longfile 201
3853 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3854 $MCREATE $DIR/$tdir/longfile$FNUM
3859 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3861 run_test 51a "special situations: split htree with empty entry =="
3863 export NUMTEST=70000
3865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3866 local BASE=$DIR/d${base}.${TESTSUITE}
3868 # cleanup the directory
3871 test_mkdir -p -c1 $BASE
3873 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3874 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3875 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3878 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3879 echo "reduced count to $NUMTEST due to inodes"
3881 # need to check free space for the directories as well
3882 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3883 numfree=$((blkfree / 4))
3884 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3885 echo "reduced count to $NUMTEST due to blocks"
3887 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3888 echo "failed" > $BASE/fnum
3890 run_test 51b "exceed 64k subdirectory nlink limit"
3892 test_51ba() { # LU-993
3893 local BASE=$DIR/d${base}.${TESTSUITE}
3894 # unlink all but 100 subdirectories, then check it still works
3896 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3898 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3899 local DELETE=$((NUMTEST - LEFT))
3901 # continue on to run this test even if 51b didn't finish,
3902 # just to delete the many subdirectories created.
3903 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3905 # for ldiskfs the nlink count should be 1, but this is OSD specific
3906 # and so this is listed for informational purposes only
3907 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3908 unlinkmany -d $BASE/d $DELETE
3911 if [ $RC -ne 0 ]; then
3912 if [ "$NUMPREV" == "failed" ]; then
3913 skip "previous setup failed"
3916 error "unlink of first $DELETE subdirs failed"
3921 echo "nlink between: $(stat -c %h $BASE)"
3922 # trim the first line of ls output
3923 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3924 [ $FOUND -ne $LEFT ] &&
3925 error "can't find subdirs: found only $FOUND/$LEFT"
3927 unlinkmany -d $BASE/d $DELETE $LEFT ||
3928 error "unlink of second $LEFT subdirs failed"
3929 # regardless of whether the backing filesystem tracks nlink accurately
3930 # or not, the nlink count shouldn't be more than "." and ".." here
3931 local AFTER=$(stat -c %h $BASE)
3932 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
3933 echo "nlink after: $AFTER"
3935 run_test 51ba "verify nlink for many subdirectory cleanup"
3938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3939 [[ $OSTCOUNT -lt 3 ]] &&
3940 skip_env "skipping test with few OSTs" && return
3941 test_mkdir -p $DIR/$tdir
3942 createmany -o $DIR/$tdir/t- 1000
3943 $GETSTRIPE $DIR/$tdir > $TMP/files
3944 for N in $(seq 0 $((OSTCOUNT - 1))); do
3945 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
3946 END { printf("%0.0f", objs) }' $TMP/files)
3947 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
3948 '($1 == '$N') { objs += 1 } \
3949 END { printf("%0.0f", objs) }')
3950 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3952 unlinkmany $DIR/$tdir/t- 1000
3955 for N in $(seq 1 $((OSTCOUNT - 1))); do
3956 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
3957 error "OST $N has less objects vs OST $NLAST" \
3958 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
3959 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
3960 error "OST $N has less objects vs OST $NLAST" \
3961 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
3963 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
3964 error "OST $N has less #0 objects vs OST $NLAST" \
3965 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3966 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
3967 error "OST $N has less #0 objects vs OST $NLAST" \
3968 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3972 run_test 51d "check object distribution ===================="
3975 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3976 test_mkdir -p $DIR/$tdir
3977 touch $DIR/$tdir/foo
3978 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3979 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3980 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3981 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3982 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3984 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3985 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3986 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3988 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3989 cp -r $DIR/$tdir /tmp/
3990 rm -fr $DIR/$tdir || error "cleanup rm failed"
3992 run_test 52a "append-only flag test (should return errors) ====="
3995 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3996 test_mkdir -p $DIR/$tdir
3997 touch $DIR/$tdir/foo
3998 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3999 cat test > $DIR/$tdir/foo && error "cat test worked"
4000 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4001 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4002 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4004 echo foo >> $DIR/$tdir/foo && error "echo worked"
4005 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4006 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4007 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4008 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4010 chattr -i $DIR/$tdir/foo || error "chattr failed"
4012 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4014 run_test 52b "immutable flag test (should return errors) ======="
4017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4018 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4019 remote_ost_nodsh && skip "remote OST with nodsh" && return
4032 local support_last_seq=true
4034 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4035 support_last_seq=false
4038 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4040 for value in $(do_facet $SINGLEMDS \
4041 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4042 param=$(echo ${value[0]} | cut -d "=" -f1)
4043 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4045 if $support_last_seq; then
4046 param_seq=$(echo $param |
4047 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4048 mds_last_seq=$(do_facet $SINGLEMDS \
4049 $LCTL get_param -n $param_seq)
4051 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4053 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4054 node=$(facet_active_host ost$((ostnum+1)))
4055 param="obdfilter.$ostname.last_id"
4056 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4057 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4058 ost_last_id=$ost_last
4060 if $support_last_seq; then
4061 ost_last_id=$(echo $ost_last |
4062 awk -F':' '{print $2}' |
4064 ost_last_seq=$(echo $ost_last |
4065 awk -F':' '{print $1}')
4066 [[ $ost_last_seq = $mds_last_seq ]] || continue
4069 if [[ $ost_last_id != $mds_last ]]; then
4070 error "$ost_last_id != $mds_last"
4077 $found || error "can not match last_seq/last_id for $mdtosc"
4080 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4083 $SOCKETSERVER $DIR/socket ||
4084 error "$SOCKETSERVER $DIR/socket failed: $?"
4085 $SOCKETCLIENT $DIR/socket ||
4086 error "$SOCKETCLIENT $DIR/socket failed: $?"
4087 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4089 run_test 54a "unix domain socket test =========================="
4095 dd if=/dev/zero of=$f bs=$(page_size) count=1
4097 run_test 54b "char device works in lustre ======================"
4100 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4101 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4102 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4104 for i in $(seq 3 7); do
4105 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4113 loopdev="$DIR/loop54c"
4116 $UMOUNT -d $tdir || rc=$?
4117 losetup -d $loopdev || true
4123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4126 loopdev="$DIR/loop54c"
4129 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4130 mknod $loopdev b 7 $LOOPNUM
4131 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
4132 dd if=/dev/zero of=$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4133 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
4134 trap cleanup_54c EXIT
4135 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4137 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
4138 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
4140 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
4143 run_test 54c "block device works in lustre ====================="
4149 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4151 run_test 54d "fifo device works in lustre ======================"
4154 check_kernel_version 46 || return 0
4157 cp -aL /dev/console $f
4158 echo $string > $f || error "echo $string to $f failed"
4160 run_test 54e "console/tty device works in lustre ======================"
4162 #The test_55 used to be iopen test and it was removed by bz#24037.
4163 #run_test 55 "check iopen_connect_dentry() ======================"
4165 test_56a() { # was test_56
4168 test_mkdir -p $DIR/$tdir/dir
4170 NUMFILESx2=$(($NUMFILES * 2))
4171 for i in $(seq 1 $NUMFILES); do
4172 touch $DIR/$tdir/file$i
4173 touch $DIR/$tdir/dir/file$i
4176 # test lfs getstripe with --recursive
4177 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4178 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4179 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4180 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4181 [[ $FILENUM -eq $NUMFILES ]] ||
4182 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4183 echo "$GETSTRIPE --recursive passed."
4185 # test lfs getstripe with file instead of dir
4186 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4187 [[ $FILENUM -eq 1 ]] ||
4188 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4189 echo "$GETSTRIPE file1 passed."
4191 #test lfs getstripe with --verbose
4192 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4193 grep -c lmm_magic) -eq $NUMFILES ]] ||
4194 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4195 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4196 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4197 echo "$GETSTRIPE --verbose passed."
4199 #test lfs getstripe with --obd
4200 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4201 grep -q "unknown obduuid" ||
4202 error "$GETSTRIPE --obd wrong_uuid should return error message"
4204 [[ $OSTCOUNT -lt 2 ]] &&
4205 skip_env "skipping other $GETSTRIPE --obd test" && return
4208 OBDUUID=$(ostuuid_from_index $OSTIDX)
4209 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4210 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4211 [[ $FOUND -eq $FILENUM ]] ||
4212 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4213 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4214 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4215 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4216 error "$GETSTRIPE --obd: should not show file on other obd"
4217 echo "$GETSTRIPE --obd passed"
4219 run_test 56a "check $GETSTRIPE"
4224 local LOCAL_NUMFILES="$1"
4225 local LOCAL_NUMDIRS="$2"
4226 local MKDIR_PARAMS="$3"
4227 local DIR_STRIPE_PARAMS="$4"
4229 if [ ! -d "$TDIR" ] ; then
4230 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4231 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4232 for i in `seq 1 $LOCAL_NUMFILES` ; do
4235 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4236 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4237 for j in `seq 1 $LOCAL_NUMFILES` ; do
4238 touch $TDIR/dir$i/file$j
4244 setup_56_special() {
4248 if [ ! -e "$TDIR/loop1b" ] ; then
4249 for i in `seq 1 $LOCAL_NUMFILES` ; do
4250 mknod $TDIR/loop${i}b b 7 $i
4251 mknod $TDIR/null${i}c c 1 3
4252 ln -s $TDIR/file1 $TDIR/link${i}l
4254 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4255 mknod $TDIR/dir$i/loop${i}b b 7 $i
4256 mknod $TDIR/dir$i/null${i}c c 1 3
4257 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4266 setup_56 $NUMFILES $NUMDIRS
4268 EXPECTED=$(($NUMDIRS + 2))
4269 # test lfs find with -name
4270 for i in $(seq 1 $NUMFILES) ; do
4271 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4272 [ $NUMS -eq $EXPECTED ] ||
4273 error "lfs find -name \"*$i\" $TDIR wrong: "\
4274 "found $NUMS, expected $EXPECTED"
4277 run_test 56g "check lfs find -name ============================="
4283 setup_56 $NUMFILES $NUMDIRS
4285 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4286 # test lfs find with ! -name
4287 for i in $(seq 1 $NUMFILES) ; do
4288 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4289 [ $NUMS -eq $EXPECTED ] ||
4290 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4291 "found $NUMS, expected $EXPECTED"
4294 run_test 56h "check lfs find ! -name ============================="
4298 test_mkdir -p $DIR/$tdir
4299 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4300 CMD="$LFIND -ost $UUID $DIR/$tdir"
4302 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4304 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4308 setup_56_special $NUMFILES $NUMDIRS
4310 EXPECTED=$((NUMDIRS + 1))
4311 CMD="$LFIND -type d $TDIR"
4312 NUMS=$($CMD | wc -l)
4313 [ $NUMS -eq $EXPECTED ] ||
4314 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4316 run_test 56j "check lfs find -type d ============================="
4320 setup_56_special $NUMFILES $NUMDIRS
4322 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4323 CMD="$LFIND -type f $TDIR"
4324 NUMS=$($CMD | wc -l)
4325 [ $NUMS -eq $EXPECTED ] ||
4326 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4328 run_test 56k "check lfs find -type f ============================="
4332 setup_56_special $NUMFILES $NUMDIRS
4334 EXPECTED=$((NUMDIRS + NUMFILES))
4335 CMD="$LFIND -type b $TDIR"
4336 NUMS=$($CMD | wc -l)
4337 [ $NUMS -eq $EXPECTED ] ||
4338 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4340 run_test 56l "check lfs find -type b ============================="
4344 setup_56_special $NUMFILES $NUMDIRS
4346 EXPECTED=$((NUMDIRS + NUMFILES))
4347 CMD="$LFIND -type c $TDIR"
4348 NUMS=$($CMD | wc -l)
4349 [ $NUMS -eq $EXPECTED ] ||
4350 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4352 run_test 56m "check lfs find -type c ============================="
4356 setup_56_special $NUMFILES $NUMDIRS
4358 EXPECTED=$((NUMDIRS + NUMFILES))
4359 CMD="$LFIND -type l $TDIR"
4360 NUMS=$($CMD | wc -l)
4361 [ $NUMS -eq $EXPECTED ] ||
4362 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4364 run_test 56n "check lfs find -type l ============================="
4368 setup_56 $NUMFILES $NUMDIRS
4369 utime $TDIR/file1 > /dev/null || error "utime (1)"
4370 utime $TDIR/file2 > /dev/null || error "utime (2)"
4371 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4372 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4373 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4374 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4377 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4378 [ $NUMS -eq $EXPECTED ] || \
4379 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4382 CMD="$LFIND -mtime 0 $TDIR"
4383 NUMS=$($CMD | wc -l)
4384 [ $NUMS -eq $EXPECTED ] ||
4385 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4387 run_test 56o "check lfs find -mtime for old files =========================="
4390 [ $RUNAS_ID -eq $UID ] &&
4391 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4394 setup_56 $NUMFILES $NUMDIRS
4396 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4398 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4399 NUMS=$($CMD | wc -l)
4400 [ $NUMS -eq $EXPECTED ] || \
4401 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4403 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4404 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4405 NUMS=$($CMD | wc -l)
4406 [ $NUMS -eq $EXPECTED ] || \
4407 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4409 run_test 56p "check lfs find -uid and ! -uid ==============================="
4412 [ $RUNAS_ID -eq $UID ] &&
4413 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4416 setup_56 $NUMFILES $NUMDIRS
4418 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4421 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4422 NUMS=$($CMD | wc -l)
4423 [ $NUMS -eq $EXPECTED ] ||
4424 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4426 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4427 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4428 NUMS=$($CMD | wc -l)
4429 [ $NUMS -eq $EXPECTED ] ||
4430 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4432 run_test 56q "check lfs find -gid and ! -gid ==============================="
4436 setup_56 $NUMFILES $NUMDIRS
4439 CMD="$LFIND -size 0 -type f $TDIR"
4440 NUMS=$($CMD | wc -l)
4441 [ $NUMS -eq $EXPECTED ] ||
4442 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4444 CMD="$LFIND ! -size 0 -type f $TDIR"
4445 NUMS=$($CMD | wc -l)
4446 [ $NUMS -eq $EXPECTED ] ||
4447 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4448 echo "test" > $TDIR/$tfile
4449 echo "test2" > $TDIR/$tfile.2 && sync
4451 CMD="$LFIND -size 5 -type f $TDIR"
4452 NUMS=$($CMD | wc -l)
4453 [ $NUMS -eq $EXPECTED ] ||
4454 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4456 CMD="$LFIND -size +5 -type f $TDIR"
4457 NUMS=$($CMD | wc -l)
4458 [ $NUMS -eq $EXPECTED ] ||
4459 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4461 CMD="$LFIND -size +0 -type f $TDIR"
4462 NUMS=$($CMD | wc -l)
4463 [ $NUMS -eq $EXPECTED ] ||
4464 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4466 CMD="$LFIND ! -size -5 -type f $TDIR"
4467 NUMS=$($CMD | wc -l)
4468 [ $NUMS -eq $EXPECTED ] ||
4469 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4471 CMD="$LFIND -size -5 -type f $TDIR"
4472 NUMS=$($CMD | wc -l)
4473 [ $NUMS -eq $EXPECTED ] ||
4474 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4476 run_test 56r "check lfs find -size works =========================="
4478 test_56s() { # LU-611
4480 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4482 if [[ $OSTCOUNT -gt 1 ]]; then
4483 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4487 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4491 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4492 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4493 NUMS=$($CMD | wc -l)
4494 [ $NUMS -eq $EXPECTED ] || {
4496 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4499 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4500 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4501 NUMS=$($CMD | wc -l)
4502 [ $NUMS -eq $EXPECTED ] || {
4504 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4508 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4509 NUMS=$($CMD | wc -l)
4510 [ $NUMS -eq $EXPECTED ] || {
4512 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4515 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4516 NUMS=$($CMD | wc -l)
4517 [ $NUMS -eq $EXPECTED ] || {
4519 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4523 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4524 NUMS=$($CMD | wc -l)
4525 [ $NUMS -eq $EXPECTED ] || {
4527 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4530 run_test 56s "check lfs find -stripe-count works"
4532 test_56t() { # LU-611
4534 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4536 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4538 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4539 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4540 NUMS=$($CMD | wc -l)
4541 [ $NUMS -eq $EXPECTED ] ||
4542 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4544 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4545 NUMS=$($CMD | wc -l)
4546 [ $NUMS -eq $EXPECTED ] ||
4547 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4549 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4550 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4551 NUMS=$($CMD | wc -l)
4552 [ $NUMS -eq $EXPECTED ] ||
4553 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4555 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4556 NUMS=$($CMD | wc -l)
4557 [ $NUMS -eq $EXPECTED ] ||
4558 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4561 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4562 NUMS=$($CMD | wc -l)
4563 [ $NUMS -eq $EXPECTED ] ||
4564 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4566 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4567 NUMS=$($CMD | wc -l)
4568 [ $NUMS -eq $EXPECTED ] ||
4569 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4572 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4573 NUMS=$($CMD | wc -l)
4574 [ $NUMS -eq $EXPECTED ] ||
4575 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4577 run_test 56t "check lfs find -stripe-size works"
4579 test_56u() { # LU-611
4581 setup_56 $NUMFILES $NUMDIRS "-i 0"
4583 if [[ $OSTCOUNT -gt 1 ]]; then
4584 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4590 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4591 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4592 NUMS=$($CMD | wc -l)
4593 [ $NUMS -eq $EXPECTED ] ||
4594 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4597 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4598 NUMS=$($CMD | wc -l)
4599 [ $NUMS -eq $EXPECTED ] ||
4600 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4602 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4603 NUMS=$($CMD | wc -l)
4604 [ $NUMS -eq $EXPECTED ] ||
4605 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4608 # This should produce an error and not return any files
4609 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4610 NUMS=$($CMD 2>/dev/null | wc -l)
4611 [ $NUMS -eq $EXPECTED ] ||
4612 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4614 if [[ $OSTCOUNT -gt 1 ]]; then
4615 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4616 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4617 NUMS=$($CMD | wc -l)
4618 [ $NUMS -eq $EXPECTED ] ||
4619 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4622 run_test 56u "check lfs find -stripe-index works"
4629 setup_56 $NUMFILES $NUMDIRS
4631 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4632 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4634 for file in $($LFIND -mdt $UUID $TDIR); do
4635 file_mdt_idx=$($GETSTRIPE -M $file)
4636 [ $file_mdt_idx -eq $MDT_IDX ] ||
4637 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4640 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4642 # Get and check the actual stripe count of one file.
4643 # Usage: check_stripe_count <file> <expected_stripe_count>
4644 check_stripe_count() {
4649 [[ -z "$file" || -z "$expected" ]] &&
4650 error "check_stripe_count: invalid argument!"
4652 local cmd="$GETSTRIPE -c $file"
4653 actual=$($cmd) || error "$cmd failed"
4654 actual=${actual%% *}
4656 if [[ $actual -ne $expected ]]; then
4657 [[ $expected -eq -1 ]] ||
4658 error "$cmd wrong: found $actual, expected $expected"
4659 [[ $actual -eq $OSTCOUNT ]] ||
4660 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4668 rm -rf $TDIR || error "remove $TDIR failed"
4669 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4672 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4673 error "$GETSTRIPE -S -d $TDIR failed"
4674 stripe_size=${stripe_size%% *}
4676 local file_size=$((stripe_size * OSTCOUNT))
4677 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4678 local required_space=$((file_num * file_size))
4679 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4680 [[ $free_space -le $((required_space / 1024)) ]] &&
4681 skip_env "need at least $required_space bytes free space," \
4682 "have $free_space kbytes" && return
4685 local dd_count=$((file_size / dd_bs))
4687 # write data into the files
4691 for i in $(seq 1 $NUMFILES); do
4693 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4694 error "write data into $file failed"
4696 for i in $(seq 1 $NUMDIRS); do
4697 for j in $(seq 1 $NUMFILES); do
4698 file=$TDIR/dir$i/file$j
4699 yes | dd bs=$dd_bs count=$dd_count of=$file \
4701 error "write data into $file failed"
4706 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4709 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4711 eval $cmd || error "$cmd failed"
4713 check_stripe_count $TDIR/file1 $expected
4716 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4718 eval $cmd || error "$cmd failed"
4720 for j in $(seq 1 $NUMFILES); do
4721 check_stripe_count $TDIR/dir1/file$j $expected
4724 # lfs_migrate works with lfs find
4725 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4726 $LFS_MIGRATE -y -c $expected"
4728 eval $cmd || error "$cmd failed"
4730 for i in $(seq 2 $NUMFILES); do
4731 check_stripe_count $TDIR/file$i $expected
4733 for i in $(seq 2 $NUMDIRS); do
4734 for j in $(seq 1 $NUMFILES); do
4735 check_stripe_count $TDIR/dir$i/file$j $expected
4739 run_test 56w "check lfs_migrate -c stripe_count works"
4742 check_swap_layouts_support && return 0
4743 [[ $OSTCOUNT -lt 2 ]] &&
4744 skip_env "need 2 OST, skipping test" && return
4746 local dir0=$DIR/$tdir/$testnum
4747 mkdir -p $dir0 || error "creating dir $dir0"
4749 local ref1=/etc/passwd
4750 local file1=$dir0/file1
4752 $SETSTRIPE -c 2 $file1
4754 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4755 stripe=$($GETSTRIPE -c $file1)
4756 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4757 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4762 run_test 56x "lfs migration support"
4765 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4766 skip "No HSM support on MDS of $(get_lustre_version)," \
4767 "need 2.4.53 at least" && return
4770 local dir0=$DIR/$tdir/$testnum
4771 mkdir -p $dir0 || error "creating dir $dir0"
4772 local f1=$dir0/file1
4773 local f2=$dir0/file2
4775 touch $f1 || error "creating std file $f1"
4776 $MULTIOP $f2 H2c || error "creating released file $f2"
4778 # a directory can be raid0, so ask only for files
4779 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4780 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4782 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4783 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4785 # only files can be released, so no need to force file search
4786 res=$($LFIND $dir0 -L released)
4787 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4789 res=$($LFIND $dir0 \! -L released)
4790 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4793 run_test 56y "lfs find -L raid0|released"
4796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4797 # note test will not do anything if MDS is not local
4798 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4799 skip "Only applicable to ldiskfs-based MDTs"
4803 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4804 local MNTDEV="osd*.*MDT*.mntdev"
4805 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4806 [ -z "$DEV" ] && error "can't access $MNTDEV"
4807 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4808 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4809 error "can't access $DEV"
4810 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4811 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4815 run_test 57a "verify MDS filesystem created with large inodes =="
4818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4819 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4820 skip "Only applicable to ldiskfs-based MDTs"
4824 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4829 local FILEN=$dir/f$FILECOUNT
4831 rm -rf $dir || error "removing $dir"
4832 test_mkdir -p $dir || error "creating $dir"
4833 local num=$(get_mds_dir $dir)
4836 echo "mcreating $FILECOUNT files"
4837 createmany -m $dir/f 1 $FILECOUNT || \
4838 error "creating files in $dir"
4840 # verify that files do not have EAs yet
4841 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4842 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4846 df $dir #make sure we get new statfs data
4847 local MDSFREE=$(do_facet $mymds \
4848 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4849 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4850 echo "opening files to create objects/EAs"
4852 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4853 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4856 # verify that files have EAs now
4857 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4858 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4860 sleep 1 #make sure we get new statfs data
4862 local MDSFREE2=$(do_facet $mymds \
4863 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4864 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4865 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
4866 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4867 error "MDC before $MDCFREE != after $MDCFREE2"
4869 echo "MDC before $MDCFREE != after $MDCFREE2"
4870 echo "unable to confirm if MDS has large inodes"
4875 run_test 57b "default LOV EAs are stored inside large inodes ==="
4878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4879 [ -z "$(which wiretest 2>/dev/null)" ] &&
4880 skip_env "could not find wiretest" && return
4883 run_test 58 "verify cross-platform wire constants =============="
4886 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4887 echo "touch 130 files"
4888 createmany -o $DIR/f59- 130
4890 unlinkmany $DIR/f59- 130
4892 # wait for commitment of removal
4893 wait_delete_completed
4895 run_test 59 "verify cancellation of llog records async ========="
4897 TEST60_HEAD="test_60 run $RANDOM"
4899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4900 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4901 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4902 skip_env "missing subtest run-llog.sh" && return
4903 log "$TEST60_HEAD - from kernel mode"
4904 do_facet mgs sh run-llog.sh
4906 run_test 60a "llog sanity tests run from kernel module =========="
4908 test_60b() { # bug 6411
4909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4911 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4923 [[ $LLOG_COUNT -gt 50 ]] &&
4924 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
4926 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4930 echo "create 5000 files"
4931 createmany -o $DIR/f60c- 5000
4932 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4933 lctl set_param fail_loc=0x80000137
4934 unlinkmany $DIR/f60c- 5000
4935 lctl set_param fail_loc=0
4937 run_test 60c "unlink file when mds full"
4940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4941 SAVEPRINTK=$(lctl get_param -n printk)
4943 # verify "lctl mark" is even working"
4944 MESSAGE="test message ID $RANDOM $$"
4945 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4946 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4948 lctl set_param printk=0 || error "set lnet.printk failed"
4949 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4950 MESSAGE="new test message ID $RANDOM $$"
4951 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4952 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4953 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4955 lctl set_param -n printk="$SAVEPRINTK"
4957 run_test 60d "test printk console message masking"
4960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4962 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4963 cancel_lru_locks osc
4964 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4967 run_test 61 "mmap() writes don't make sync hang ================"
4969 # bug 2330 - insufficient obd_match error checking causes LBUG
4971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4974 cancel_lru_locks osc
4975 lctl set_param fail_loc=0x405
4976 cat $f && error "cat succeeded, expect -EIO"
4977 lctl set_param fail_loc=0
4979 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4980 # match every page all of the time.
4981 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4983 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4984 # Though this test is irrelevant anymore, it helped to reveal some
4985 # other grant bugs (LU-4482), let's keep it.
4986 test_63a() { # was test_63
4987 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4988 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4989 for i in `seq 10` ; do
4990 dd if=/dev/zero of=$DIR/f63 bs=8k &
4996 rm -f $DIR/f63 || true
4998 run_test 63a "Verify oig_wait interruption does not crash ======="
5000 # bug 2248 - async write errors didn't return to application on sync
5001 # bug 3677 - async write errors left page locked
5003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5005 lctl set_param debug=-1
5007 # ensure we have a grant to do async writes
5008 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5011 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5012 lctl set_param fail_loc=0x80000406
5013 $MULTIOP $DIR/$tfile Owy && \
5014 error "sync didn't return ENOMEM"
5015 sync; sleep 2; sync # do a real sync this time to flush page
5016 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5017 error "locked page left in cache after async error" || true
5020 run_test 63b "async write errors should be returned to fsync ==="
5023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5025 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5027 run_test 64a "verify filter grant calculations (in kernel) ====="
5030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5031 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5033 run_test 64b "check out-of-space detection on client ==========="
5036 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5038 run_test 64c "verify grant shrink ========================------"
5040 # bug 1414 - set/get directories' stripe info
5042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5043 test_mkdir -p $DIR/$tdir
5045 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5047 run_test 65a "directory with no stripe info ===================="
5050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5051 test_mkdir -p $DIR/$tdir
5052 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5055 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5057 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5061 if [[ $OSTCOUNT -gt 1 ]]; then
5062 test_mkdir -p $DIR/$tdir
5063 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5064 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5066 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5069 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5073 test_mkdir -p $DIR/$tdir
5074 if [[ $STRIPECOUNT -le 0 ]]; then
5076 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5077 #LOV_MAX_STRIPE_COUNT is 2000
5078 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5080 sc=$(($STRIPECOUNT - 1))
5082 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5083 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5084 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5085 error "lverify failed"
5087 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5091 test_mkdir -p $DIR/$tdir
5093 $SETSTRIPE $DIR/$tdir || error "setstripe"
5094 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5095 error "no stripe info failed"
5097 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5099 run_test 65e "directory setstripe defaults ======================="
5102 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5103 test_mkdir -p $DIR/${tdir}f
5104 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5106 run_test 65f "dir setstripe permission (should return error) ==="
5109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5110 test_mkdir -p $DIR/$tdir
5111 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5113 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5114 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5115 error "delete default stripe failed"
5117 run_test 65g "directory setstripe -d ==========================="
5120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5121 test_mkdir -p $DIR/$tdir
5122 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5124 test_mkdir -p $DIR/$tdir/dd1
5125 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5126 error "stripe info inherit failed"
5128 run_test 65h "directory stripe info inherit ===================="
5130 test_65i() { # bug6367
5131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5132 $SETSTRIPE -S 65536 -c -1 $MOUNT
5134 run_test 65i "set non-default striping on root directory (bug 6367)="
5136 test_65ia() { # bug12836
5137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5138 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5140 run_test 65ia "getstripe on -1 default directory striping"
5142 test_65ib() { # bug12836
5143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5144 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5146 run_test 65ib "getstripe -v on -1 default directory striping"
5148 test_65ic() { # bug12836
5149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5150 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5152 run_test 65ic "new find on -1 default directory striping"
5154 test_65j() { # bug6367
5155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5157 # if we aren't already remounting for each test, do so for this test
5158 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5159 cleanup || error "failed to unmount"
5162 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5164 run_test 65j "set default striping on root directory (bug 6367)="
5166 test_65k() { # bug11679
5167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5168 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5169 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5171 echo "Check OST status: "
5172 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5173 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5175 for OSC in $MDS_OSCS; do
5176 echo $OSC "is activate"
5177 do_facet $SINGLEMDS lctl --device %$OSC activate
5181 for INACTIVE_OSC in $MDS_OSCS; do
5182 echo "Deactivate: " $INACTIVE_OSC
5183 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5184 for STRIPE_OSC in $MDS_OSCS; do
5185 OST=`osc_to_ost $STRIPE_OSC`
5186 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5187 awk -F: /$OST/'{ print $1 }' | head -n 1`
5189 [ -f $DIR/$tdir/$IDX ] && continue
5190 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5191 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5193 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5196 echo $INACTIVE_OSC "is Activate."
5197 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5200 run_test 65k "validate manual striping works properly with deactivated OSCs"
5202 test_65l() { # bug 12836
5203 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5204 test_mkdir -p $DIR/$tdir/test_dir
5205 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5206 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5208 run_test 65l "lfs find on -1 stripe dir ========================"
5210 # bug 2543 - update blocks count on client
5212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5214 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5215 sync; sync_all_data; sync; sync_all_data
5216 cancel_lru_locks osc
5217 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5218 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5220 run_test 66 "update inode blocks count on client ==============="
5225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5227 if [ ! -z "$LLOOP" ]; then
5228 if swapon -s | grep -q $LLOOP; then
5229 swapoff $LLOOP || error "swapoff failed"
5232 $LCTL blockdev_detach $LLOOP || error "detach failed"
5236 if [ ! -z "$LLITELOOPLOAD" ]; then
5244 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5248 swapon -s | awk '($1 == "'$1'") { print $4 }'
5251 # test case for lloop driver, basic function
5253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5254 [ "$UID" != 0 ] && skip_env "must run as root" && return
5255 llite_lloop_enabled || \
5256 { skip_env "llite_lloop module disabled" && return; }
5258 trap cleanup_68 EXIT
5260 if ! module_loaded llite_lloop; then
5261 if load_module llite/llite_lloop; then
5264 skip_env "can't find module llite_lloop"
5269 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5270 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5271 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5273 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5274 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5278 run_test 68a "lloop driver - basic test ========================"
5280 # excercise swapping to lustre by adding a high priority swapfile entry
5281 # and then consuming memory until it is used.
5282 test_68b() { # was test_68
5283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5284 [ "$UID" != 0 ] && skip_env "must run as root" && return
5285 lctl get_param -n devices | grep -q obdfilter && \
5286 skip "local OST" && return
5288 grep -q llite_lloop /proc/modules
5289 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5291 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5292 skip "can't reliably test swap with TCP" && return
5294 MEMTOTAL=`meminfo MemTotal`
5295 NR_BLOCKS=$((MEMTOTAL>>8))
5296 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5298 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5299 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5302 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5304 trap cleanup_68 EXIT
5306 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5308 echo "before: `swapon -s | grep $LLOOP`"
5309 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5310 echo "after: `swapon -s | grep $LLOOP`"
5311 SWAPUSED=`swap_used $LLOOP`
5315 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5317 run_test 68b "support swapping to Lustre ========================"
5319 # bug5265, obdfilter oa2dentry return -ENOENT
5320 # #define OBD_FAIL_OST_ENOENT 0x217
5322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5323 remote_ost_nodsh && skip "remote OST with nodsh" && return
5326 $SETSTRIPE -c 1 -i 0 $f
5328 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5330 do_facet ost1 lctl set_param fail_loc=0x217
5331 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5332 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5334 do_facet ost1 lctl set_param fail_loc=0
5335 $DIRECTIO write $f 0 2 || error "write error"
5337 cancel_lru_locks osc
5338 $DIRECTIO read $f 0 1 || error "read error"
5340 do_facet ost1 lctl set_param fail_loc=0x217
5341 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5343 do_facet ost1 lctl set_param fail_loc=0
5346 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5349 test_mkdir -p $DIR/$tdir
5350 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5352 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5354 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5356 [ "$RUNAS_ID" = "$UID" ] &&
5357 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5359 # Check that testing environment is properly set up. Skip if not
5360 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5361 skip_env "User $RUNAS_ID does not exist - skipping"
5364 # We had better clear the $DIR to get enough space for dd
5367 chmod 777 $DIR/$tfile
5368 chmod ug+s $DIR/$tfile
5369 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5370 error "$RUNAS dd $DIR/$tfile failed"
5371 # See if we are still setuid/sgid
5372 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5373 error "S/gid is not dropped on write"
5374 # Now test that MDS is updated too
5375 cancel_lru_locks mdc
5376 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5377 error "S/gid is not dropped on MDS"
5380 run_test 72a "Test that remove suid works properly (bug5695) ===="
5382 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5385 [ "$RUNAS_ID" = "$UID" ] && \
5386 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5387 [ "$RUNAS_ID" -eq 0 ] && \
5388 skip_env "RUNAS_ID = 0 -- skipping" && return
5390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5391 # Check that testing environment is properly set up. Skip if not
5392 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5393 skip_env "User $RUNAS_ID does not exist - skipping"
5396 touch $DIR/${tfile}-f{g,u}
5397 test_mkdir $DIR/${tfile}-dg
5398 test_mkdir $DIR/${tfile}-du
5399 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5400 chmod g+s $DIR/${tfile}-{f,d}g
5401 chmod u+s $DIR/${tfile}-{f,d}u
5402 for perm in 777 2777 4777; do
5403 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5404 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5405 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5406 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5410 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5412 # bug 3462 - multiple simultaneous MDC requests
5414 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5415 test_mkdir $DIR/d73-1
5416 test_mkdir $DIR/d73-2
5417 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5420 lctl set_param fail_loc=0x80000129
5421 $MULTIOP $DIR/d73-1/f73-2 Oc &
5423 lctl set_param fail_loc=0
5425 $MULTIOP $DIR/d73-2/f73-3 Oc &
5429 wait $pid1 || return 1
5433 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5434 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5435 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5439 run_test 73 "multiple MDC requests (should not deadlock)"
5441 test_74a() { # bug 6149, 6184
5442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5443 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5445 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5446 # will spin in a tight reconnection loop
5448 $LCTL set_param fail_loc=0x8000030e
5449 # get any lock that won't be difficult - lookup works.
5451 $LCTL set_param fail_loc=0
5455 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5457 test_74b() { # bug 13310
5458 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5459 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5461 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5462 # will spin in a tight reconnection loop
5463 $LCTL set_param fail_loc=0x8000030e
5464 # get a "difficult" lock
5466 $LCTL set_param fail_loc=0
5470 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5474 #define OBD_FAIL_LDLM_NEW_LOCK
5475 $LCTL set_param fail_loc=0x319
5476 touch $DIR/$tfile && error "touch successful"
5477 $LCTL set_param fail_loc=0
5480 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5483 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5486 get_inode_slab_tunables() {
5487 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5490 set_inode_slab_tunables() {
5491 echo "lustre_inode_cache $1" > /proc/slabinfo
5494 test_76() { # Now for bug 20433, added originally in bug 1443
5495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5496 local SLAB_SETTINGS=`get_inode_slab_tunables`
5497 local CPUS=`getconf _NPROCESSORS_ONLN`
5498 # we cannot set limit below 1 which means 1 inode in each
5499 # per-cpu cache is still allowed
5500 set_inode_slab_tunables "1 1 0"
5501 cancel_lru_locks osc
5502 BEFORE_INODES=$(num_inodes)
5503 echo "before inodes: $BEFORE_INODES"
5505 [ "$SLOW" = "no" ] && COUNT=100
5506 for i in $(seq $COUNT); do
5510 cancel_lru_locks osc
5511 AFTER_INODES=$(num_inodes)
5512 echo "after inodes: $AFTER_INODES"
5514 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5516 AFTER_INODES=$(num_inodes)
5518 echo "wait $wait seconds inodes: $AFTER_INODES"
5519 if [ $wait -gt 30 ]; then
5520 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5523 set_inode_slab_tunables "$SLAB_SETTINGS"
5525 run_test 76 "confirm clients recycle inodes properly ===="
5531 # Note: in sptlrpc modes which enable its own bulk checksum, the
5532 # original crc32_le bulk checksum will be automatically disabled,
5533 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5534 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5535 # In this case set_checksums() will not be no-op, because sptlrpc
5536 # bulk checksum will be enabled all through the test.
5538 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5539 lctl set_param -n osc.*.checksums $1
5543 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5544 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5545 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5546 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5549 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5550 log "set checksum type to $1"
5553 F77_TMP=$TMP/f77-temp
5556 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5557 error "error writing to $F77_TMP"
5560 test_77a() { # bug 10889
5561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5562 $GSS && skip "could not run with gss" && return
5563 [ ! -f $F77_TMP ] && setup_f77
5565 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5569 run_test 77a "normal checksum read/write operation"
5571 test_77b() { # bug 10889
5572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5573 $GSS && skip "could not run with gss" && return
5574 [ ! -f $F77_TMP ] && setup_f77
5575 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5576 $LCTL set_param fail_loc=0x80000409
5579 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5580 error "dd error: $?"
5581 $LCTL set_param fail_loc=0
5583 for algo in $CKSUM_TYPES; do
5584 cancel_lru_locks osc
5585 set_checksum_type $algo
5586 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5587 $LCTL set_param fail_loc=0x80000408
5588 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5589 $LCTL set_param fail_loc=0
5592 set_checksum_type $ORIG_CSUM_TYPE
5595 run_test 77b "checksum error on client write, read"
5597 test_77d() { # bug 10889
5598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5599 $GSS && skip "could not run with gss" && return
5600 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5601 $LCTL set_param fail_loc=0x80000409
5603 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5604 error "direct write: rc=$?"
5605 $LCTL set_param fail_loc=0
5608 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5609 $LCTL set_param fail_loc=0x80000408
5611 cancel_lru_locks osc
5612 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5613 error "direct read: rc=$?"
5614 $LCTL set_param fail_loc=0
5617 run_test 77d "checksum error on OST direct write, read"
5619 test_77f() { # bug 10889
5620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5621 $GSS && skip "could not run with gss" && return
5623 for algo in $CKSUM_TYPES; do
5624 cancel_lru_locks osc
5625 set_checksum_type $algo
5626 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5627 $LCTL set_param fail_loc=0x409
5628 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5629 error "direct write succeeded"
5630 $LCTL set_param fail_loc=0
5632 set_checksum_type $ORIG_CSUM_TYPE
5635 run_test 77f "repeat checksum error on write (expect error)"
5637 test_77g() { # bug 10889
5638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5639 $GSS && skip "could not run with gss" && return
5640 remote_ost_nodsh && skip "remote OST with nodsh" && return
5642 [ ! -f $F77_TMP ] && setup_f77
5644 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5645 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5646 do_facet ost1 lctl set_param fail_loc=0x8000021a
5648 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5649 error "write error: rc=$?"
5650 do_facet ost1 lctl set_param fail_loc=0
5653 cancel_lru_locks osc
5654 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5655 do_facet ost1 lctl set_param fail_loc=0x8000021b
5657 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5658 do_facet ost1 lctl set_param fail_loc=0
5661 run_test 77g "checksum error on OST write, read"
5663 test_77i() { # bug 13805
5664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5665 $GSS && skip "could not run with gss" && return
5666 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5667 lctl set_param fail_loc=0x40b
5668 remount_client $MOUNT
5669 lctl set_param fail_loc=0
5670 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5671 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5672 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5673 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5675 remount_client $MOUNT
5677 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5679 test_77j() { # bug 13805
5680 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5681 $GSS && skip "could not run with gss" && return
5682 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5683 lctl set_param fail_loc=0x40c
5684 remount_client $MOUNT
5685 lctl set_param fail_loc=0
5686 sleep 2 # wait async osc connect to finish
5687 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5688 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5689 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5690 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5692 remount_client $MOUNT
5694 run_test 77j "client only supporting ADLER32"
5696 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5700 test_78() { # bug 10901
5701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5702 remote_ost || { skip_env "local OST" && return; }
5705 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5706 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5707 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5708 echo "MemTotal: $MEMTOTAL"
5710 # reserve 256MB of memory for the kernel and other running processes,
5711 # and then take 1/2 of the remaining memory for the read/write buffers.
5712 if [ $MEMTOTAL -gt 512 ] ;then
5713 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5715 # for those poor memory-starved high-end clusters...
5716 MEMTOTAL=$((MEMTOTAL / 2))
5718 echo "Mem to use for directio: $MEMTOTAL"
5720 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5721 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5722 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5723 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5725 echo "Smallest OST: $SMALLESTOST"
5726 [[ $SMALLESTOST -lt 10240 ]] &&
5727 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5729 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5730 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5732 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5733 echo "File size: $F78SIZE"
5734 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5735 for i in $(seq 1 $NSEQ); do
5736 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5737 echo directIO rdwr round $i of $NSEQ
5738 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5743 run_test 78 "handle large O_DIRECT writes correctly ============"
5745 test_79() { # bug 12743
5746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5747 wait_delete_completed
5749 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5750 BKFREE=$(calc_osc_kbytes kbytesfree)
5751 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5753 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5754 DFTOTAL=`echo $STRING | cut -d, -f1`
5755 DFUSED=`echo $STRING | cut -d, -f2`
5756 DFAVAIL=`echo $STRING | cut -d, -f3`
5757 DFFREE=$(($DFTOTAL - $DFUSED))
5759 ALLOWANCE=$((64 * $OSTCOUNT))
5761 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5762 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5763 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5765 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5766 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5767 error "df free($DFFREE) mismatch OST free($BKFREE)"
5769 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5770 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5771 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5774 run_test 79 "df report consistency check ======================="
5776 test_80() { # bug 10718
5777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5778 # relax strong synchronous semantics for slow backends like ZFS
5779 local soc="obdfilter.*.sync_on_lock_cancel"
5780 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5782 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5783 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5784 facet_active_host $host; done | sort -u)
5785 do_nodes $hosts lctl set_param $soc=never
5788 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5790 local BEFORE=`date +%s`
5791 cancel_lru_locks osc
5792 local AFTER=`date +%s`
5793 local DIFF=$((AFTER-BEFORE))
5794 if [ $DIFF -gt 1 ] ; then
5795 error "elapsed for 1M@1T = $DIFF"
5798 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5802 run_test 80 "Page eviction is equally fast at high offsets too ===="
5804 test_81a() { # LU-456
5805 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5806 remote_ost_nodsh && skip "remote OST with nodsh" && return
5807 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5808 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5809 do_facet ost1 lctl set_param fail_loc=0x80000228
5811 # write should trigger a retry and success
5812 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5813 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5815 if [ $RC -ne 0 ] ; then
5816 error "write should success, but failed for $RC"
5819 run_test 81a "OST should retry write when get -ENOSPC ==============="
5821 test_81b() { # LU-456
5822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5823 remote_ost_nodsh && skip "remote OST with nodsh" && return
5824 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5825 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5826 do_facet ost1 lctl set_param fail_loc=0x228
5828 # write should retry several times and return -ENOSPC finally
5829 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5830 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5833 if [ $RC -ne $ENOSPC ] ; then
5834 error "dd should fail for -ENOSPC, but succeed."
5837 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5839 test_82() { # LU-1031
5840 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5844 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5846 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5848 kill -USR1 $MULTIPID2
5850 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5851 error "First grouplock does not block second one"
5853 echo "Second grouplock blocks first one"
5855 kill -USR1 $MULTIPID1
5859 run_test 82 "Basic grouplock test ==============================="
5862 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5864 test_mkdir -p $DIR/d99cvsroot
5865 chown $RUNAS_ID $DIR/d99cvsroot
5866 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5869 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5872 run_test 99a "cvs init ========================================="
5875 [ -z "$(which cvs 2>/dev/null)" ] &&
5876 skip_env "could not find cvs" && return
5877 [ ! -d $DIR/d99cvsroot ] && test_99a
5879 # some versions of cvs import exit(1) when asked to import links or
5880 # files they can't read. ignore those files.
5881 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5882 ! -perm +4 -printf '-I %f\n')
5883 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5884 d99reposname vtag rtag
5886 run_test 99b "cvs import ======================================="
5889 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5890 [ ! -d $DIR/d99cvsroot ] && test_99b
5892 test_mkdir -p $DIR/d99reposname
5893 chown $RUNAS_ID $DIR/d99reposname
5894 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5896 run_test 99c "cvs checkout ====================================="
5899 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5900 [ ! -d $DIR/d99cvsroot ] && test_99c
5901 cd $DIR/d99reposname
5903 $RUNAS cvs add -m 'addmsg' foo99
5905 run_test 99d "cvs add =========================================="
5908 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5909 [ ! -d $DIR/d99cvsroot ] && test_99c
5910 cd $DIR/d99reposname
5913 run_test 99e "cvs update ======================================="
5916 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5917 [ ! -d $DIR/d99cvsroot ] && test_99d
5918 cd $DIR/d99reposname
5919 $RUNAS cvs commit -m 'nomsg' foo99
5920 rm -fr $DIR/d99cvsroot
5922 run_test 99f "cvs commit ======================================="
5925 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5926 [ "$NETTYPE" = tcp ] || \
5927 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5930 remote_ost_nodsh && skip "remote OST with nodsh" && return
5931 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5933 { skip "useless for local single node setup" && return; }
5935 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5936 [ "$PROT" != "tcp" ] && continue
5937 RPORT=$(echo $REMOTE | cut -d: -f2)
5938 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5941 LPORT=`echo $LOCAL | cut -d: -f2`
5942 if [ $LPORT -ge 1024 ]; then
5943 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5945 error_exit "local: $LPORT > 1024, remote: $RPORT"
5948 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5950 run_test 100 "check local port using privileged port ==========="
5952 function get_named_value()
5961 echo $line | sed "s/^$tag[ ]*//"
5968 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5969 awk '/^max_cached_mb/ { print $2 }')
5972 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5978 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
5982 local cache_limit=32
5984 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5985 trap cleanup_101a EXIT
5986 $LCTL set_param -n llite.*.read_ahead_stats 0
5987 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5990 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5992 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5993 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5996 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
5997 get_named_value 'read but discarded' | cut -d" " -f1); do
5998 discard=$(($discard + $s))
6002 if [[ $(($discard * 10)) -gt $nreads ]]; then
6003 $LCTL get_param osc.*-osc*.rpc_stats
6004 $LCTL get_param llite.*.read_ahead_stats
6005 error "too many ($discard) discarded pages"
6007 rm -f $DIR/$tfile || true
6009 run_test 101a "check read-ahead for random reads ================"
6012 test_mkdir -p $DIR/$tdir
6013 local STRIPE_SIZE=$1
6014 local FILE_LENGTH=$2
6017 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6019 local list=$(comma_list $(osts_nodes))
6020 set_osd_param $list '' read_cache_enable 0
6021 set_osd_param $list '' writethrough_cache_enable 0
6023 trap cleanup_test101bc EXIT
6024 # prepare the read-ahead file
6025 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6027 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6028 count=$FILE_SIZE_MB 2> /dev/null
6032 cleanup_test101bc() {
6037 local list=$(comma_list $(osts_nodes))
6038 set_osd_param $list '' read_cache_enable 1
6039 set_osd_param $list '' writethrough_cache_enable 1
6043 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6048 local STRIPE_SIZE=$2
6049 local FILE_LENGTH=$3
6050 local RA_INC=1048576
6051 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6052 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6053 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6054 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6055 get_named_value 'read but discarded' |
6056 cut -d" " -f1 | calc_total)
6057 if [[ $DISCARD -gt $discard_limit ]]; then
6058 $LCTL get_param llite.*.read_ahead_stats
6059 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6061 echo "Read-ahead success for size ${READ_SIZE}"
6066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6067 [[ $OSTCOUNT -lt 2 ]] &&
6068 skip_env "skipping stride IO stride-ahead test" && return
6069 local STRIPE_SIZE=1048576
6070 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6071 if [ $SLOW == "yes" ]; then
6072 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6074 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6077 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6079 # prepare the read-ahead file
6080 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6081 cancel_lru_locks osc
6082 for BIDX in 2 4 8 16 32 64 128 256
6084 local BSIZE=$((BIDX*4096))
6085 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6086 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6087 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6088 $LCTL set_param -n llite.*.read_ahead_stats 0
6089 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6090 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6091 cancel_lru_locks osc
6092 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6097 run_test 101b "check stride-io mode read-ahead ================="
6100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6101 local STRIPE_SIZE=1048576
6102 local FILE_LENGTH=$((STRIPE_SIZE*100))
6106 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6108 cancel_lru_locks osc
6109 $LCTL set_param osc.*.rpc_stats 0
6110 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6111 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6112 local stats=$($LCTL get_param -n $osc_rpc_stats)
6113 local lines=$(echo "$stats" | awk 'END {print NR;}')
6116 if [ $lines -le 20 ]; then
6119 for size in 1 2 4 8; do
6120 local rpc=$(echo "$stats" |
6121 awk '($1 == "'$size':") {print $2; exit; }')
6123 error "Small $((size*4))k read IO $rpc !"
6125 echo "$osc_rpc_stats check passed!"
6130 run_test 101c "check stripe_size aligned read-ahead ================="
6133 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6134 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6139 local file=$DIR/$tfile
6140 local sz_MB=${FILESIZE_101d:-500}
6141 local ra_MB=${READAHEAD_MB:-40}
6143 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6144 [ $free_MB -lt $sz_MB ] &&
6145 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6147 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6148 $SETSTRIPE -c -1 $file || error "setstripe failed"
6150 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6151 echo Cancel LRU locks on lustre client to flush the client cache
6152 cancel_lru_locks osc
6154 echo Disable read-ahead
6155 local old_READAHEAD=$(set_read_ahead 0)
6157 echo Reading the test file $file with read-ahead disabled
6158 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6160 echo Cancel LRU locks on lustre client to flush the client cache
6161 cancel_lru_locks osc
6162 echo Enable read-ahead with ${ra_MB}MB
6163 set_read_ahead $ra_MB
6165 echo Reading the test file $file with read-ahead enabled
6166 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6168 echo "read-ahead disabled time read $raOFF"
6169 echo "read-ahead enabled time read $raON"
6171 set_read_ahead $old_READAHEAD
6173 wait_delete_completed
6175 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6176 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6178 run_test 101d "file read with and without read-ahead enabled"
6181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6182 local file=$DIR/$tfile
6183 local size_KB=500 #KB
6187 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6188 local need_KB=$((count * size_KB))
6189 [[ $free_KB -le $need_KB ]] &&
6190 skip_env "Need free space $need_KB, have $free_KB" && return
6192 echo "Creating $count ${size_KB}K test files"
6193 for ((i = 0; i < $count; i++)); do
6194 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6197 echo "Cancel LRU locks on lustre client to flush the client cache"
6198 cancel_lru_locks osc
6200 echo "Reset readahead stats"
6201 $LCTL set_param -n llite.*.read_ahead_stats 0
6203 for ((i = 0; i < $count; i++)); do
6204 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6207 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6208 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6210 for ((i = 0; i < $count; i++)); do
6211 rm -rf $file.$i 2>/dev/null
6214 #10000 means 20% reads are missing in readahead
6215 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6217 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6219 cleanup_test101f() {
6221 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6222 rm -rf $DIR/$tfile 2>/dev/null
6226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6227 local file=$DIR/$tfile
6230 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6231 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6232 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6233 trap cleanup_test101f EXIT
6235 echo Cancel LRU locks on lustre client to flush the client cache
6236 cancel_lru_locks osc
6238 echo Reset readahead stats
6239 $LCTL set_param -n llite.*.read_ahead_stats 0
6240 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6241 # readahead should read in 2M file on second read, so only miss
6243 echo Random 4K reads on 2M file for 1000 times
6244 $READS -f $file -s 2097152 -b 4096 -n $nreads
6246 echo checking missing pages
6247 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6248 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6250 [ $miss -lt 3 ] || error "misses too much pages!"
6253 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6256 test_mkdir -p $DIR/$tdir
6257 chown $RUNAS_ID $DIR/$tdir
6260 STRIPE_COUNT=$OSTCOUNT
6261 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6263 trap cleanup_test102 EXIT
6265 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6267 for num in 1 2 3 4; do
6268 for count in $(seq 1 $STRIPE_COUNT); do
6269 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6270 local size=`expr $STRIPE_SIZE \* $num`
6271 local file=file"$num-$idx-$count"
6272 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6278 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6284 rm -rf $DIR/d0.sanity/d102
6288 local testfile=$DIR/xattr_testfile
6292 [ "$UID" != 0 ] && skip_env "must run as root" && return
6293 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6294 skip_env "must have user_xattr" && return
6296 [ -z "$(which setfattr 2>/dev/null)" ] &&
6297 skip_env "could not find setfattr" && return
6299 echo "set/get xattr..."
6300 setfattr -n trusted.name1 -v value1 $testfile ||
6301 error "setfattr -n trusted.name1=value1 $testfile failed"
6302 getfattr -n trusted.name1 $testfile 2> /dev/null |
6303 grep "trusted.name1=.value1" ||
6304 error "$testfile missing trusted.name1=value1"
6306 setfattr -n user.author1 -v author1 $testfile ||
6307 error "setfattr -n user.author1=author1 $testfile failed"
6308 getfattr -n user.author1 $testfile 2> /dev/null |
6309 grep "user.author1=.author1" ||
6310 error "$testfile missing trusted.author1=author1"
6313 setfattr -n trusted.name2 -v value2 $testfile ||
6314 error "$testfile unable to set trusted.name2"
6315 setfattr -n trusted.name3 -v value3 $testfile ||
6316 error "$testfile unable to set trusted.name3"
6317 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6318 grep "trusted.name" | wc -l) -eq 3 ] ||
6319 error "$testfile missing 3 trusted.name xattrs"
6321 setfattr -n user.author2 -v author2 $testfile ||
6322 error "$testfile unable to set user.author2"
6323 setfattr -n user.author3 -v author3 $testfile ||
6324 error "$testfile unable to set user.author3"
6325 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6326 grep "user.author" | wc -l) -eq 3 ] ||
6327 error "$testfile missing 3 user.author xattrs"
6329 echo "remove xattr..."
6330 setfattr -x trusted.name1 $testfile ||
6331 error "$testfile error deleting trusted.name1"
6332 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6333 error "$testfile did not delete trusted.name1 xattr"
6335 setfattr -x user.author1 $testfile ||
6336 error "$testfile error deleting user.author1"
6337 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6338 error "$testfile did not delete trusted.name1 xattr"
6340 # b10667: setting lustre special xattr be silently discarded
6341 echo "set lustre special xattr ..."
6342 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6343 error "$testfile allowed setting trusted.lov"
6345 run_test 102a "user xattr test =================================="
6348 [ -z "$(which setfattr 2>/dev/null)" ] &&
6349 skip_env "could not find setfattr" && return
6351 # b10930: get/set/list trusted.lov xattr
6352 echo "get/set/list trusted.lov xattr ..."
6353 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6354 local testfile=$DIR/$tfile
6355 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6356 error "setstripe failed"
6357 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6358 error "getstripe failed"
6359 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6360 error "can't get trusted.lov from $testfile"
6362 local testfile2=${testfile}2
6363 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6364 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6367 setfattr -n trusted.lov -v $value $testfile2
6368 local stripe_size=$($GETSTRIPE -S $testfile2)
6369 local stripe_count=$($GETSTRIPE -c $testfile2)
6370 [[ $stripe_size -eq 65536 ]] ||
6371 error "stripe size $stripe_size != 65536"
6372 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6373 error "stripe count $stripe_count != $STRIPECOUNT"
6376 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6379 [ -z "$(which setfattr 2>/dev/null)" ] &&
6380 skip_env "could not find setfattr" && return
6382 # b10930: get/set/list lustre.lov xattr
6383 echo "get/set/list lustre.lov xattr ..."
6384 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6385 test_mkdir -p $DIR/$tdir
6386 chown $RUNAS_ID $DIR/$tdir
6387 local testfile=$DIR/$tdir/$tfile
6388 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6389 error "setstripe failed"
6390 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6391 error "getstripe failed"
6392 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6393 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6395 local testfile2=${testfile}2
6396 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6397 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6399 $RUNAS $MCREATE $testfile2
6400 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6401 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6402 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6403 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6404 [ $stripe_count -eq $STRIPECOUNT ] ||
6405 error "stripe count $stripe_count != $STRIPECOUNT"
6407 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6409 compare_stripe_info1() {
6410 local stripe_index_all_zero=true
6412 for num in 1 2 3 4; do
6413 for count in $(seq 1 $STRIPE_COUNT); do
6414 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6415 local size=$((STRIPE_SIZE * num))
6416 local file=file"$num-$offset-$count"
6417 stripe_size=$(lfs getstripe -S $PWD/$file)
6418 [[ $stripe_size -ne $size ]] &&
6419 error "$file: size $stripe_size != $size"
6420 stripe_count=$(lfs getstripe -c $PWD/$file)
6421 # allow fewer stripes to be created, ORI-601
6422 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6423 error "$file: count $stripe_count != $count"
6424 stripe_index=$(lfs getstripe -i $PWD/$file)
6425 [[ $stripe_index -ne 0 ]] &&
6426 stripe_index_all_zero=false
6430 $stripe_index_all_zero &&
6431 error "all files are being extracted starting from OST index 0"
6436 [ -n "$(which tar 2>/dev/null)" ] &&
6437 strings $(which tar) | grep -q "lustre" && echo tar
6441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6442 # b10930: tar test for trusted.lov xattr
6443 TAR=$(find_lustre_tar)
6444 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6445 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6447 test_mkdir -p $DIR/d102d
6448 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6450 compare_stripe_info1
6452 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6456 # b10930: tar test for trusted.lov xattr
6457 TAR=$(find_lustre_tar)
6458 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6459 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6461 test_mkdir -p $DIR/d102f
6463 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6465 compare_stripe_info1
6467 run_test 102f "tar copy files, not keep osts ==========="
6470 local xsize=${1:-1024} # in bytes
6471 local file=$DIR/$tfile
6473 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6474 skip "must have user_xattr" && return 0
6475 [ -z "$(which setfattr 2>/dev/null)" ] &&
6476 skip_env "could not find setfattr" && return 0
6477 [ -z "$(which getfattr 2>/dev/null)" ] &&
6478 skip_env "could not find getfattr" && return 0
6482 local value="$(generate_string $xsize)"
6484 local xbig=trusted.big
6485 log "save $xbig on $file"
6486 setfattr -n $xbig -v $value $file ||
6487 error "saving $xbig on $file failed"
6489 local orig=$(get_xattr_value $xbig $file)
6490 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6492 local xsml=trusted.sml
6493 log "save $xsml on $file"
6494 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6496 local new=$(get_xattr_value $xbig $file)
6497 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6499 log "grow $xsml on $file"
6500 setfattr -n $xsml -v "$value" $file ||
6501 error "growing $xsml on $file failed"
6503 new=$(get_xattr_value $xbig $file)
6504 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6505 log "$xbig still valid after growing $xsml"
6510 test_102h() { # bug 15777
6513 run_test 102h "grow xattr from inside inode to external block"
6516 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6517 grow_xattr $(max_xattr_size)
6519 run_test 102ha "grow xattr from inside inode to external inode"
6521 test_102i() { # bug 17038
6522 [ -z "$(which getfattr 2>/dev/null)" ] &&
6523 skip "could not find getfattr" && return
6525 ln -s $DIR/$tfile $DIR/${tfile}link
6526 getfattr -n trusted.lov $DIR/$tfile ||
6527 error "lgetxattr on $DIR/$tfile failed"
6528 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6529 grep -i "no such attr" ||
6530 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6531 rm -f $DIR/$tfile $DIR/${tfile}link
6533 run_test 102i "lgetxattr test on symbolic link ============"
6536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6537 TAR=$(find_lustre_tar)
6538 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6539 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6540 setup_test102 "$RUNAS"
6541 test_mkdir -p $DIR/d102j
6542 chown $RUNAS_ID $DIR/d102j
6543 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6545 compare_stripe_info1 "$RUNAS"
6547 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6550 [ -z "$(which setfattr 2>/dev/null)" ] &&
6551 skip "could not find setfattr" && return
6553 # b22187 just check that does not crash for regular file.
6554 setfattr -n trusted.lov $DIR/$tfile
6555 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6556 local test_kdir=$DIR/d102k
6557 test_mkdir $test_kdir
6558 local default_size=`$GETSTRIPE -S $test_kdir`
6559 local default_count=`$GETSTRIPE -c $test_kdir`
6560 local default_offset=`$GETSTRIPE -i $test_kdir`
6561 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6562 error 'dir setstripe failed'
6563 setfattr -n trusted.lov $test_kdir
6564 local stripe_size=`$GETSTRIPE -S $test_kdir`
6565 local stripe_count=`$GETSTRIPE -c $test_kdir`
6566 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6567 [ $stripe_size -eq $default_size ] ||
6568 error "stripe size $stripe_size != $default_size"
6569 [ $stripe_count -eq $default_count ] ||
6570 error "stripe count $stripe_count != $default_count"
6571 [ $stripe_offset -eq $default_offset ] ||
6572 error "stripe offset $stripe_offset != $default_offset"
6573 rm -rf $DIR/$tfile $test_kdir
6575 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6578 [ -z "$(which getfattr 2>/dev/null)" ] &&
6579 skip "could not find getfattr" && return
6581 # LU-532 trusted. xattr is invisible to non-root
6582 local testfile=$DIR/$tfile
6586 echo "listxattr as user..."
6587 chown $RUNAS_ID $testfile
6588 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6589 grep -q "trusted" &&
6590 error "$testfile trusted xattrs are user visible"
6594 run_test 102l "listxattr size test =================================="
6596 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6597 local path=$DIR/$tfile
6600 listxattr_size_check $path || error "listattr_size_check $path failed"
6602 run_test 102m "Ensure listxattr fails on small bufffer ========"
6606 getxattr() { # getxattr path name
6607 # Return the base64 encoding of the value of xattr name on path.
6611 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6613 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6615 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6617 getfattr --absolute-names --encoding=base64 --name=$name $path |
6618 awk -F= -v name=$name '$1 == name {
6619 print substr($0, index($0, "=") + 1);
6623 test_102n() { # LU-4101 mdt: protect internal xattrs
6624 local file0=$DIR/$tfile.0
6625 local file1=$DIR/$tfile.1
6626 local xattr0=$TMP/$tfile.0
6627 local xattr1=$TMP/$tfile.1
6631 [ -z "$(which setfattr 2>/dev/null)" ] &&
6632 skip "could not find setfattr" && return
6634 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6636 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6640 rm -rf $file0 $file1 $xattr0 $xattr1
6643 # Get 'before' xattrs of $file1.
6644 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6646 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6647 # Try to copy xattr from $file0 to $file1.
6648 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6650 setfattr --name=trusted.$name --value="$value" $file1 ||
6651 error "setxattr 'trusted.$name' failed"
6653 # Try to set a garbage xattr.
6654 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6656 setfattr --name=trusted.$name --value="$value" $file1 ||
6657 error "setxattr 'trusted.$name' failed"
6659 # Try to remove the xattr from $file1. We don't care if this
6660 # appears to succeed or fail, we just don't want there to be
6661 # any changes or crashes.
6662 setfattr --remove=$trusted.$name $file1 2> /dev/null
6665 # Get 'after' xattrs of file1.
6666 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6668 if ! diff $xattr0 $xattr1; then
6669 error "before and after xattrs of '$file1' differ"
6672 rm -rf $file0 $file1 $xattr0 $xattr1
6676 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6678 test_102p() { # LU-4703 setxattr did not check ownership
6679 local testfile=$DIR/$tfile
6681 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6682 skip "MDS needs to be at least 2.5.56" && return
6686 echo "setfacl as user..."
6687 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6688 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6690 echo "setfattr as user..."
6691 setfacl -m "u:$RUNAS_ID:---" $testfile
6692 $RUNAS setfattr -x system.posix_acl_access $testfile
6693 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6695 run_test 102p "check setxattr(2) correctly fails without permission"
6699 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6704 [ "$UID" != 0 ] && skip_env "must run as root" && return
6705 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6706 skip "must have acl enabled" && return
6707 [ -z "$(which setfacl 2>/dev/null)" ] &&
6708 skip_env "could not find setfacl" && return
6709 $GSS && skip "could not run under gss" && return
6711 declare -a identity_old
6713 for num in $(seq $MDSCOUNT); do
6714 switch_identity $num true || identity_old[$num]=$?
6721 echo "performing cp ..."
6722 run_acl_subtest cp || error "run_acl_subtest cp failed"
6723 echo "performing getfacl-noacl..."
6724 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6725 echo "performing misc..."
6726 run_acl_subtest misc || error "misc test failed"
6727 echo "performing permissions..."
6728 run_acl_subtest permissions || error "permissions failed"
6729 echo "performing setfacl..."
6730 run_acl_subtest setfacl || error "setfacl test failed"
6732 # inheritance test got from HP
6733 echo "performing inheritance..."
6734 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6735 chmod +x make-tree || error "chmod +x failed"
6736 run_acl_subtest inheritance || error "inheritance test failed"
6739 echo "LU-974 ignore umask when acl is enabled..."
6740 run_acl_subtest 974 || error "LU-974 umask test failed"
6741 if [ $MDSCOUNT -ge 2 ]; then
6742 run_acl_subtest 974_remote ||
6743 error "LU-974 umask test failed under remote dir"
6746 echo "LU-2561 newly created file is same size as directory..."
6747 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6748 run_acl_subtest 2561 || error "LU-2561 test failed"
6750 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6753 run_acl_subtest 4924 || error "LU-4924 test failed"
6758 for num in $(seq $MDSCOUNT); do
6759 if [ "${identity_old[$num]}" = 1 ]; then
6760 switch_identity $num false || identity_old[$num]=$?
6764 run_test 103 "acl test ========================================="
6767 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6769 lfs df || error "lfs df failed"
6770 lfs df -ih || error "lfs df -ih failed"
6771 lfs df -h $DIR || error "lfs df -h $DIR failed"
6772 lfs df -i $DIR || error "lfs df -i $DIR failed"
6773 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6774 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6776 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6777 lctl --device %$OSC deactivate
6778 lfs df || error "lfs df with deactivated OSC failed"
6779 lctl --device %$OSC activate
6780 # wait the osc back to normal
6781 wait_osc_import_state client ost FULL
6783 lfs df || error "lfs df with reactivated OSC failed"
6786 run_test 104a "lfs df [-ih] [path] test ========================="
6789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6790 [ $RUNAS_ID -eq $UID ] &&
6791 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6793 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6794 grep "Permission denied" | wc -l)))
6795 if [ $denied_cnt -ne 0 ]; then
6796 error "lfs check servers test failed"
6799 run_test 104b "$RUNAS lfs check servers test ===================="
6802 # doesn't work on 2.4 kernels
6804 if $(flock_is_enabled); then
6805 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6807 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6811 run_test 105a "flock when mounted without -o flock test ========"
6815 if $(flock_is_enabled); then
6816 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6818 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6822 run_test 105b "fcntl when mounted without -o flock test ========"
6826 if $(flock_is_enabled); then
6827 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6829 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6833 run_test 105c "lockf when mounted without -o flock test ========"
6835 test_105d() { # bug 15924
6836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6837 test_mkdir -p $DIR/$tdir
6838 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6839 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6840 $LCTL set_param fail_loc=0x80000315
6841 flocks_test 2 $DIR/$tdir
6843 run_test 105d "flock race (should not freeze) ========"
6845 test_105e() { # bug 22660 && 22040
6846 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6848 flocks_test 3 $DIR/$tfile
6850 run_test 105e "Two conflicting flocks from same process ======="
6852 test_106() { #bug 10921
6853 test_mkdir -p $DIR/$tdir
6854 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6855 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6857 run_test 106 "attempt exec of dir followed by chown of that dir"
6860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6867 local save_pattern=$(sysctl -n kernel.core_pattern)
6868 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6869 sysctl -w kernel.core_pattern=$file
6870 sysctl -w kernel.core_uses_pid=0
6878 kill -s 11 $SLEEPPID
6880 if [ -e $file ]; then
6881 size=`stat -c%s $file`
6882 [ $size -eq 0 ] && error "Fail to create core file $file"
6884 error "Fail to create core file $file"
6887 sysctl -w kernel.core_pattern=$save_pattern
6888 sysctl -w kernel.core_uses_pid=$save_uses_pid
6891 run_test 107 "Coredump on SIG"
6894 test_mkdir -p $DIR/$tdir
6895 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6896 error "mkdir with 255 char failed"
6897 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6898 error "mkdir with 256 char should fail, but did not"
6899 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6900 error "create with 255 char failed"
6901 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6902 error "create with 256 char should fail, but did not"
6907 run_test 110 "filename length checking"
6910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6911 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
6912 tail -1 | cut -c11-20)
6913 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
6914 echo "Starting with $OSTIO_pre threads"
6917 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
6918 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
6919 echo "$NUMTEST creates/unlinks"
6920 test_mkdir -p $DIR/$tdir
6921 createmany -o $DIR/$tdir/$tfile $NUMTEST
6922 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6924 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
6925 tail -1 | cut -c11-20)
6927 # don't return an error
6928 [ $OSTIO_post == $OSTIO_pre ] && echo \
6929 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6930 echo "This may be fine, depending on what ran before this test" &&
6931 echo "and how fast this system is." && return
6933 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6935 run_test 115 "verify dynamic thread creation===================="
6938 wait_delete_completed
6939 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6940 echo OST kbytes available: ${AVAIL[@]}
6941 MAXI=0; MAXV=${AVAIL[0]}
6942 MINI=0; MINV=${AVAIL[0]}
6943 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6944 #echo OST $i: ${AVAIL[i]}kb
6945 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
6946 MAXV=${AVAIL[i]}; MAXI=$i
6948 if [[ ${AVAIL[i]} -lt $MINV ]]; then
6949 MINV=${AVAIL[i]}; MINI=$i
6952 echo Min free space: OST $MINI: $MINV
6953 echo Max free space: OST $MAXI: $MAXV
6956 test_116a() { # was previously test_116()
6957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6958 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
6960 echo -n "Free space priority "
6961 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6966 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6967 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
6969 trap simple_cleanup_common EXIT
6972 # Check if we need to generate uneven OSTs
6973 test_mkdir -p $DIR/$tdir/OST${MINI}
6974 local FILL=$(($MINV / 4))
6975 local DIFF=$(($MAXV - $MINV))
6976 local DIFF2=$(($DIFF * 100 / $MINV))
6978 local threshold=$(do_facet $SINGLEMDS \
6979 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
6980 threshold=${threshold%%%}
6981 echo -n "Check for uneven OSTs: "
6982 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6984 if [[ $DIFF2 -gt $threshold ]]; then
6986 echo "Don't need to fill OST$MINI"
6988 # generate uneven OSTs. Write 2% over the QOS threshold value
6990 DIFF=$(($threshold - $DIFF2 + 2))
6991 DIFF2=$(( ($MINV * $DIFF)/100 ))
6992 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6993 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6994 error "setstripe failed"
6995 DIFF=$(($DIFF2 / 2048))
6997 while [ $i -lt $DIFF ]; do
6999 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7000 bs=2M count=1 2>/dev/null
7009 DIFF=$(($MAXV - $MINV))
7010 DIFF2=$(($DIFF * 100 / $MINV))
7011 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7012 if [[ $DIFF2 -gt $threshold ]]; then
7015 echo "failed - QOS mode won't be used"
7016 skip "QOS imbalance criteria not met"
7017 simple_cleanup_common
7021 MINI1=$MINI; MINV1=$MINV
7022 MAXI1=$MAXI; MAXV1=$MAXV
7024 # now fill using QOS
7025 $SETSTRIPE -c 1 $DIR/$tdir
7026 FILL=$(($FILL / 200))
7027 if [ $FILL -gt 600 ]; then
7030 echo "writing $FILL files to QOS-assigned OSTs"
7032 while [ $i -lt $FILL ]; do
7034 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7038 echo "wrote $i 200k files"
7042 echo "Note: free space may not be updated, so measurements might be off"
7044 DIFF2=$(($MAXV - $MINV))
7045 echo "free space delta: orig $DIFF final $DIFF2"
7046 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7047 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7048 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7049 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7050 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7051 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7053 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7055 # Figure out which files were written where
7056 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7057 awk '/'$MINI1': / {print $2; exit}')
7059 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7060 echo "$MINC files created on smaller OST $MINI1"
7061 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7062 awk '/'$MAXI1': / {print $2; exit}')
7064 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7065 echo "$MAXC files created on larger OST $MAXI1"
7066 FILL=$(($MAXC * 100 / $MINC - 100))
7067 [[ $MINC -gt 0 ]] &&
7068 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7069 [[ $MAXC -gt $MINC ]] ||
7070 error_ignore LU-9 "stripe QOS didn't balance free space"
7071 simple_cleanup_common
7073 run_test 116a "stripe QOS: free space balance ==================="
7075 test_116b() { # LU-2093
7076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7077 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7078 head -1 2>/dev/null)" ] && skip "no QOS" && return
7079 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7081 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7082 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7083 do_facet $SINGLEMDS lctl set_param \
7084 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7086 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7087 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7088 do_facet $SINGLEMDS lctl set_param fail_loc=0
7090 do_facet $SINGLEMDS lctl set_param \
7091 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7093 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7095 test_117() # bug 10891
7097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7098 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7099 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7100 lctl set_param fail_loc=0x21e
7101 > $DIR/$tfile || error "truncate failed"
7102 lctl set_param fail_loc=0
7103 echo "Truncate succeeded."
7106 run_test 117 "verify osd extend =========="
7108 NO_SLOW_RESENDCOUNT=4
7109 export OLD_RESENDCOUNT=""
7110 set_resend_count () {
7111 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7112 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7113 lctl set_param -n $PROC_RESENDCOUNT $1
7114 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7117 # for reduce test_118* time (b=14842)
7118 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7120 # Reset async IO behavior after error case
7122 FILE=$DIR/reset_async
7124 # Ensure all OSCs are cleared
7125 $SETSTRIPE -c -1 $FILE
7126 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7131 test_118a() #bug 11710
7133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7136 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7137 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7138 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7140 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7141 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7146 run_test 118a "verify O_SYNC works =========="
7150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7151 remote_ost_nodsh && skip "remote OST with nodsh" && return
7155 #define OBD_FAIL_OST_ENOENT 0x217
7156 set_nodes_failloc "$(osts_nodes)" 0x217
7157 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7159 set_nodes_failloc "$(osts_nodes)" 0
7160 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7161 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7164 if [[ $RC -eq 0 ]]; then
7165 error "Must return error due to dropped pages, rc=$RC"
7169 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7170 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7174 echo "Dirty pages not leaked on ENOENT"
7176 # Due to the above error the OSC will issue all RPCs syncronously
7177 # until a subsequent RPC completes successfully without error.
7178 $MULTIOP $DIR/$tfile Ow4096yc
7183 run_test 118b "Reclaim dirty pages on fatal error =========="
7187 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7189 # for 118c, restore the original resend count, LU-1940
7190 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7191 set_resend_count $OLD_RESENDCOUNT
7192 remote_ost_nodsh && skip "remote OST with nodsh" && return
7196 #define OBD_FAIL_OST_EROFS 0x216
7197 set_nodes_failloc "$(osts_nodes)" 0x216
7199 # multiop should block due to fsync until pages are written
7200 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7204 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7205 error "Multiop failed to block on fsync, pid=$MULTIPID"
7208 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7210 if [[ $WRITEBACK -eq 0 ]]; then
7211 error "No page in writeback, writeback=$WRITEBACK"
7214 set_nodes_failloc "$(osts_nodes)" 0
7217 if [[ $RC -ne 0 ]]; then
7218 error "Multiop fsync failed, rc=$RC"
7221 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7222 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7224 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7225 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7229 echo "Dirty pages flushed via fsync on EROFS"
7232 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7234 # continue to use small resend count to reduce test_118* time (b=14842)
7235 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7240 remote_ost_nodsh && skip "remote OST with nodsh" && return
7244 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7245 set_nodes_failloc "$(osts_nodes)" 0x214
7246 # multiop should block due to fsync until pages are written
7247 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7251 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7252 error "Multiop failed to block on fsync, pid=$MULTIPID"
7255 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7257 if [[ $WRITEBACK -eq 0 ]]; then
7258 error "No page in writeback, writeback=$WRITEBACK"
7261 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7262 set_nodes_failloc "$(osts_nodes)" 0
7264 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7265 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7267 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7268 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7272 echo "Dirty pages gaurenteed flushed via fsync"
7275 run_test 118d "Fsync validation inject a delay of the bulk =========="
7278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7281 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7282 lctl set_param fail_loc=0x8000040a
7284 # Should simulate EINVAL error which is fatal
7285 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7287 if [[ $RC -eq 0 ]]; then
7288 error "Must return error due to dropped pages, rc=$RC"
7291 lctl set_param fail_loc=0x0
7293 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7294 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7295 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7297 if [[ $LOCKED -ne 0 ]]; then
7298 error "Locked pages remain in cache, locked=$LOCKED"
7301 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7302 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7306 echo "No pages locked after fsync"
7311 run_test 118f "Simulate unrecoverable OSC side error =========="
7314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7317 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7318 lctl set_param fail_loc=0x406
7320 # simulate local -ENOMEM
7321 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7324 lctl set_param fail_loc=0
7325 if [[ $RC -eq 0 ]]; then
7326 error "Must return error due to dropped pages, rc=$RC"
7329 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7330 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7331 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7333 if [[ $LOCKED -ne 0 ]]; then
7334 error "Locked pages remain in cache, locked=$LOCKED"
7337 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7338 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7342 echo "No pages locked after fsync"
7347 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7351 remote_ost_nodsh && skip "remote OST with nodsh" && return
7355 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7356 set_nodes_failloc "$(osts_nodes)" 0x20e
7357 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7358 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7361 set_nodes_failloc "$(osts_nodes)" 0
7362 if [[ $RC -eq 0 ]]; then
7363 error "Must return error due to dropped pages, rc=$RC"
7366 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7367 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7368 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7370 if [[ $LOCKED -ne 0 ]]; then
7371 error "Locked pages remain in cache, locked=$LOCKED"
7374 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7375 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7379 echo "No pages locked after fsync"
7383 run_test 118h "Verify timeout in handling recoverables errors =========="
7385 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7389 remote_ost_nodsh && skip "remote OST with nodsh" && return
7393 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7394 set_nodes_failloc "$(osts_nodes)" 0x20e
7396 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7397 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7400 set_nodes_failloc "$(osts_nodes)" 0
7404 if [[ $RC -ne 0 ]]; then
7405 error "got error, but should be not, rc=$RC"
7408 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7409 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7410 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7411 if [[ $LOCKED -ne 0 ]]; then
7412 error "Locked pages remain in cache, locked=$LOCKED"
7415 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7416 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7420 echo "No pages locked after fsync"
7424 run_test 118i "Fix error before timeout in recoverable error =========="
7426 [ "$SLOW" = "no" ] && set_resend_count 4
7429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7430 remote_ost_nodsh && skip "remote OST with nodsh" && return
7434 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7435 set_nodes_failloc "$(osts_nodes)" 0x220
7437 # return -EIO from OST
7438 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7440 set_nodes_failloc "$(osts_nodes)" 0x0
7441 if [[ $RC -eq 0 ]]; then
7442 error "Must return error due to dropped pages, rc=$RC"
7445 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7446 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7447 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7448 if [[ $LOCKED -ne 0 ]]; then
7449 error "Locked pages remain in cache, locked=$LOCKED"
7452 # in recoverable error on OST we want resend and stay until it finished
7453 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7454 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7458 echo "No pages locked after fsync"
7462 run_test 118j "Simulate unrecoverable OST side error =========="
7466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7467 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7469 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7470 set_nodes_failloc "$(osts_nodes)" 0x20e
7471 test_mkdir -p $DIR/$tdir
7473 for ((i=0;i<10;i++)); do
7474 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7475 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7482 set_nodes_failloc "$(osts_nodes)" 0
7485 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7491 test_mkdir -p $DIR/$tdir
7492 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7495 run_test 118l "fsync dir ========="
7497 test_118m() # LU-3066
7499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7500 test_mkdir -p $DIR/$tdir
7501 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7504 run_test 118m "fdatasync dir ========="
7506 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7508 test_119a() # bug 11737
7510 BSIZE=$((512 * 1024))
7511 directio write $DIR/$tfile 0 1 $BSIZE
7512 # We ask to read two blocks, which is more than a file size.
7513 # directio will indicate an error when requested and actual
7514 # sizes aren't equeal (a normal situation in this case) and
7515 # print actual read amount.
7516 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7517 if [ "$NOB" != "$BSIZE" ]; then
7518 error "read $NOB bytes instead of $BSIZE"
7522 run_test 119a "Short directIO read must return actual read amount"
7524 test_119b() # bug 11737
7526 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7528 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7529 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7531 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7532 error "direct read failed"
7535 run_test 119b "Sparse directIO read must return actual read amount"
7537 test_119c() # bug 13099
7540 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7541 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7544 run_test 119c "Testing for direct read hitting hole"
7546 test_119d() # bug 15950
7548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7549 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7550 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7552 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7553 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7554 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7555 lctl set_param fail_loc=0x40d
7556 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7559 cat $DIR/$tfile > /dev/null &
7560 lctl set_param fail_loc=0
7563 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7565 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7566 error "the read rpcs have not completed in 2s"
7568 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7570 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7574 test_mkdir -p $DIR/$tdir
7575 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7576 skip "no early lock cancel on server" && return 0
7578 lru_resize_disable mdc
7579 lru_resize_disable osc
7580 cancel_lru_locks mdc
7581 # asynchronous object destroy at MDT could cause bl ast to client
7582 cancel_lru_locks osc
7584 stat $DIR/$tdir > /dev/null
7585 can1=$(do_facet $SINGLEMDS \
7586 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7587 awk '/ldlm_cancel/ {print $2}')
7588 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7589 awk '/ldlm_bl_callback/ {print $2}')
7590 test_mkdir -c1 $DIR/$tdir/d1
7591 can2=$(do_facet $SINGLEMDS \
7592 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7593 awk '/ldlm_cancel/ {print $2}')
7594 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7595 awk '/ldlm_bl_callback/ {print $2}')
7596 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7597 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7598 lru_resize_enable mdc
7599 lru_resize_enable osc
7601 run_test 120a "Early Lock Cancel: mkdir test"
7604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7605 test_mkdir $DIR/$tdir
7606 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7607 skip "no early lock cancel on server" && return 0
7608 lru_resize_disable mdc
7609 lru_resize_disable osc
7610 cancel_lru_locks mdc
7611 stat $DIR/$tdir > /dev/null
7612 can1=$(do_facet $SINGLEMDS \
7613 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7614 awk '/ldlm_cancel/ {print $2}')
7615 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7616 awk '/ldlm_bl_callback/ {print $2}')
7618 can2=$(do_facet $SINGLEMDS \
7619 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7620 awk '/ldlm_cancel/ {print $2}')
7621 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7622 awk '/ldlm_bl_callback/ {print $2}')
7623 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7624 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7625 lru_resize_enable mdc
7626 lru_resize_enable osc
7628 run_test 120b "Early Lock Cancel: create test"
7631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7632 test_mkdir -c1 $DIR/$tdir
7633 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7634 skip "no early lock cancel on server" && return 0
7635 lru_resize_disable mdc
7636 lru_resize_disable osc
7637 test_mkdir -p -c1 $DIR/$tdir/d1
7638 test_mkdir -p -c1 $DIR/$tdir/d2
7639 touch $DIR/$tdir/d1/f1
7640 cancel_lru_locks mdc
7641 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7642 can1=$(do_facet $SINGLEMDS \
7643 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7644 awk '/ldlm_cancel/ {print $2}')
7645 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7646 awk '/ldlm_bl_callback/ {print $2}')
7647 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7648 can2=$(do_facet $SINGLEMDS \
7649 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7650 awk '/ldlm_cancel/ {print $2}')
7651 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7652 awk '/ldlm_bl_callback/ {print $2}')
7653 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7654 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7655 lru_resize_enable mdc
7656 lru_resize_enable osc
7658 run_test 120c "Early Lock Cancel: link test"
7661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7662 test_mkdir -p -c1 $DIR/$tdir
7663 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7664 skip "no early lock cancel on server" && return 0
7665 lru_resize_disable mdc
7666 lru_resize_disable osc
7668 cancel_lru_locks mdc
7669 stat $DIR/$tdir > /dev/null
7670 can1=$(do_facet $SINGLEMDS \
7671 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7672 awk '/ldlm_cancel/ {print $2}')
7673 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7674 awk '/ldlm_bl_callback/ {print $2}')
7675 chmod a+x $DIR/$tdir
7676 can2=$(do_facet $SINGLEMDS \
7677 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7678 awk '/ldlm_cancel/ {print $2}')
7679 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7680 awk '/ldlm_bl_callback/ {print $2}')
7681 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7682 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7683 lru_resize_enable mdc
7684 lru_resize_enable osc
7686 run_test 120d "Early Lock Cancel: setattr test"
7689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7690 test_mkdir -p -c1 $DIR/$tdir
7691 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7692 skip "no early lock cancel on server" && return 0
7693 lru_resize_disable mdc
7694 lru_resize_disable osc
7695 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7696 cancel_lru_locks mdc
7697 cancel_lru_locks osc
7698 dd if=$DIR/$tdir/f1 of=/dev/null
7699 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7700 # XXX client can not do early lock cancel of OST lock
7701 # during unlink (LU-4206), so cancel osc lock now.
7702 cancel_lru_locks osc
7703 can1=$(do_facet $SINGLEMDS \
7704 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7705 awk '/ldlm_cancel/ {print $2}')
7706 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7707 awk '/ldlm_bl_callback/ {print $2}')
7708 unlink $DIR/$tdir/f1
7710 can2=$(do_facet $SINGLEMDS \
7711 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7712 awk '/ldlm_cancel/ {print $2}')
7713 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7714 awk '/ldlm_bl_callback/ {print $2}')
7715 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7716 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7717 lru_resize_enable mdc
7718 lru_resize_enable osc
7720 run_test 120e "Early Lock Cancel: unlink test"
7723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7724 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7725 skip "no early lock cancel on server" && return 0
7726 test_mkdir -p -c1 $DIR/$tdir
7727 lru_resize_disable mdc
7728 lru_resize_disable osc
7729 test_mkdir -p -c1 $DIR/$tdir/d1
7730 test_mkdir -p -c1 $DIR/$tdir/d2
7731 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7732 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7733 cancel_lru_locks mdc
7734 cancel_lru_locks osc
7735 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7736 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7737 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7738 # XXX client can not do early lock cancel of OST lock
7739 # during rename (LU-4206), so cancel osc lock now.
7740 cancel_lru_locks osc
7741 can1=$(do_facet $SINGLEMDS \
7742 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7743 awk '/ldlm_cancel/ {print $2}')
7744 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7745 awk '/ldlm_bl_callback/ {print $2}')
7746 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7748 can2=$(do_facet $SINGLEMDS \
7749 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7750 awk '/ldlm_cancel/ {print $2}')
7751 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7752 awk '/ldlm_bl_callback/ {print $2}')
7753 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7754 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7755 lru_resize_enable mdc
7756 lru_resize_enable osc
7758 run_test 120f "Early Lock Cancel: rename test"
7761 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7762 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7763 skip "no early lock cancel on server" && return 0
7764 lru_resize_disable mdc
7765 lru_resize_disable osc
7767 echo create $count files
7768 test_mkdir -p $DIR/$tdir
7769 cancel_lru_locks mdc
7770 cancel_lru_locks osc
7773 can0=$(do_facet $SINGLEMDS \
7774 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7775 awk '/ldlm_cancel/ {print $2}')
7776 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7777 awk '/ldlm_bl_callback/ {print $2}')
7778 createmany -o $DIR/$tdir/f $count
7780 can1=$(do_facet $SINGLEMDS \
7781 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7782 awk '/ldlm_cancel/ {print $2}')
7783 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7784 awk '/ldlm_bl_callback/ {print $2}')
7786 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7787 echo rm $count files
7790 can2=$(do_facet $SINGLEMDS \
7791 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7792 awk '/ldlm_cancel/ {print $2}')
7793 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7794 awk '/ldlm_bl_callback/ {print $2}')
7796 echo total: $count removes in $((t2-t1))
7797 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7799 # wait for commitment of removal
7800 lru_resize_enable mdc
7801 lru_resize_enable osc
7803 run_test 120g "Early Lock Cancel: performance test"
7805 test_121() { #bug #10589
7806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7808 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7809 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7810 lctl set_param fail_loc=0x310
7811 cancel_lru_locks osc > /dev/null
7812 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7813 lctl set_param fail_loc=0
7814 [[ $reads -eq $writes ]] ||
7815 error "read $reads blocks, must be $writes blocks"
7817 run_test 121 "read cancel race ========="
7819 test_123a() { # was test 123, statahead(bug 11401)
7820 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7822 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7823 log "testing on UP system. Performance may be not as good as expected."
7828 test_mkdir -p $DIR/$tdir
7829 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7830 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7832 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7833 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7835 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7836 lctl set_param -n llite.*.statahead_max 0
7837 lctl get_param llite.*.statahead_max
7838 cancel_lru_locks mdc
7839 cancel_lru_locks osc
7841 time ls -l $DIR/$tdir | wc -l
7843 delta=$((etime - stime))
7844 log "ls $i files without statahead: $delta sec"
7845 lctl set_param llite.*.statahead_max=$max
7847 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7848 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7849 cancel_lru_locks mdc
7850 cancel_lru_locks osc
7852 time ls -l $DIR/$tdir | wc -l
7854 delta_sa=$((etime - stime))
7855 log "ls $i files with statahead: $delta_sa sec"
7856 lctl get_param -n llite.*.statahead_stats
7857 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7859 [[ $swrong -lt $ewrong ]] &&
7860 log "statahead was stopped, maybe too many locks held!"
7861 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
7863 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7864 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7865 lctl set_param -n llite.*.statahead_max 0
7866 lctl get_param llite.*.statahead_max
7867 cancel_lru_locks mdc
7868 cancel_lru_locks osc
7870 time ls -l $DIR/$tdir | wc -l
7872 delta=$((etime - stime))
7873 log "ls $i files again without statahead: $delta sec"
7874 lctl set_param llite.*.statahead_max=$max
7875 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7876 if [ $SLOWOK -eq 0 ]; then
7877 error "ls $i files is slower with statahead!"
7879 log "ls $i files is slower with statahead!"
7885 [ $delta -gt 20 ] && break
7886 [ $delta -gt 8 ] && MULT=$((50 / delta))
7887 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7895 delta=$((etime - stime))
7896 log "rm -r $DIR/$tdir/: $delta seconds"
7898 lctl get_param -n llite.*.statahead_stats
7900 run_test 123a "verify statahead work"
7902 test_123b () { # statahead(bug 15027)
7903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7904 test_mkdir -p $DIR/$tdir
7905 createmany -o $DIR/$tdir/$tfile-%d 1000
7907 cancel_lru_locks mdc
7908 cancel_lru_locks osc
7910 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7911 lctl set_param fail_loc=0x80000803
7912 ls -lR $DIR/$tdir > /dev/null
7914 lctl set_param fail_loc=0x0
7915 lctl get_param -n llite.*.statahead_stats
7920 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7924 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
7925 skip "no lru resize on server" && return 0
7927 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7929 log "create $NR files at $DIR/$tdir"
7930 createmany -o $DIR/$tdir/f $NR ||
7931 error "failed to create $NR files in $DIR/$tdir"
7933 cancel_lru_locks mdc
7934 ls -l $DIR/$tdir > /dev/null
7938 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
7939 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
7940 LRU_SIZE=$($LCTL get_param -n $PARAM)
7941 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
7942 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7944 log "NS=$(basename $NSDIR)"
7949 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
7950 skip "Not enough cached locks created!"
7957 # We know that lru resize allows one client to hold $LIMIT locks
7958 # for 10h. After that locks begin to be killed by client.
7960 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
7963 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7964 # killing locks. Some time was spent for creating locks. This means
7965 # that up to the moment of sleep finish we must have killed some of
7966 # them (10-100 locks). This depends on how fast ther were created.
7967 # Many of them were touched in almost the same moment and thus will
7968 # be killed in groups.
7969 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7971 # Use $LRU_SIZE_B here to take into account real number of locks
7972 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7973 local LRU_SIZE_B=$LRU_SIZE
7975 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
7976 log "OLD_LVF=$OLD_LVF"
7977 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
7979 # Let's make sure that we really have some margin. Client checks
7980 # cached locks every 10 sec.
7982 log "Sleep ${SLEEP} sec"
7984 while ((SEC<$SLEEP)); do
7988 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
7992 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7993 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
7995 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
7996 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7997 unlinkmany $DIR/$tdir/f $NR
8001 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8002 log "unlink $NR files at $DIR/$tdir"
8003 unlinkmany $DIR/$tdir/f $NR
8005 run_test 124a "lru resize ======================================="
8007 get_max_pool_limit()
8009 local limit=$($LCTL get_param \
8010 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8013 if [[ $l -gt $max ]]; then
8021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8022 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8023 skip "no lru resize on server" && return 0
8025 LIMIT=$(get_max_pool_limit)
8027 NR=$(($(default_lru_size)*20))
8028 if [[ $NR -gt $LIMIT ]]; then
8029 log "Limit lock number by $LIMIT locks"
8032 lru_resize_disable mdc
8033 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8034 error "failed to create $DIR/$tdir/disable_lru_resize"
8036 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8037 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8038 cancel_lru_locks mdc
8041 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8044 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8047 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8051 nolruresize_delta=$((etime-stime))
8052 log "ls -la time: $nolruresize_delta seconds"
8053 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8054 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8056 lru_resize_enable mdc
8057 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8058 error "failed to create $DIR/$tdir/enable_lru_resize"
8060 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8061 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8062 cancel_lru_locks mdc
8065 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8068 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8071 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8075 lruresize_delta=$((etime-stime))
8076 log "ls -la time: $lruresize_delta seconds"
8077 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8079 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8080 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8081 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8082 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8084 log "lru resize performs the same with no lru resize"
8086 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8088 run_test 124b "lru resize (performance test) ======================="
8090 test_125() { # 13358
8091 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8092 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8093 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8094 test_mkdir -p $DIR/d125 || error "mkdir failed"
8095 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8096 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8097 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8099 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8101 test_126() { # bug 12829/13455
8102 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8103 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8104 $GSS && skip "must run as gss disabled" && return
8106 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8107 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8109 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8111 run_test 126 "check that the fsgid provided by the client is taken into account"
8113 test_127a() { # bug 15521
8114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8115 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8116 $LCTL set_param osc.*.stats=0
8117 FSIZE=$((2048 * 1024))
8118 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8119 cancel_lru_locks osc
8120 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8122 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8123 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8124 echo "got $COUNT $NAME"
8125 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8126 eval $NAME=$COUNT || error "Wrong proc format"
8129 read_bytes|write_bytes)
8130 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8131 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8132 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8133 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8134 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8135 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8136 error "sumsquare is too small: $SUMSQ"
8137 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8138 error "sumsquare is too big: $SUMSQ"
8142 done < $DIR/${tfile}.tmp
8144 #check that we actually got some stats
8145 [ "$read_bytes" ] || error "Missing read_bytes stats"
8146 [ "$write_bytes" ] || error "Missing write_bytes stats"
8147 [ "$read_bytes" != 0 ] || error "no read done"
8148 [ "$write_bytes" != 0 ] || error "no write done"
8150 run_test 127a "verify the client stats are sane"
8152 test_127b() { # bug LU-333
8153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8154 $LCTL set_param llite.*.stats=0
8155 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8156 # perform 2 reads and writes so MAX is different from SUM.
8157 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8158 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8159 cancel_lru_locks osc
8160 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8161 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8163 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8164 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8165 echo "got $COUNT $NAME"
8166 eval $NAME=$COUNT || error "Wrong proc format"
8170 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8171 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8172 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8173 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8176 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8177 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8178 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8179 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8183 done < $TMP/${tfile}.tmp
8185 #check that we actually got some stats
8186 [ "$read_bytes" ] || error "Missing read_bytes stats"
8187 [ "$write_bytes" ] || error "Missing write_bytes stats"
8188 [ "$read_bytes" != 0 ] || error "no read done"
8189 [ "$write_bytes" != 0 ] || error "no write done"
8191 run_test 127b "verify the llite client stats are sane"
8193 test_128() { # bug 15212
8195 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8200 result=$(grep error $TMP/$tfile.log)
8202 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8204 run_test 128 "interactive lfs for 2 consecutive find's"
8211 local LDPROC=/proc/fs/ldiskfs
8212 local facets=$(get_facets MDS)
8214 for facet in ${facets//,/ }; do
8215 canondev=$(ldiskfs_canon \
8216 *.$(convert_facet2label $facet).mntdev $facet)
8217 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8218 LDPROC=/sys/fs/ldiskfs
8219 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8225 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8226 skip "Only applicable to ldiskfs-based MDTs"
8229 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8234 test_mkdir -p $DIR/$tdir
8236 # block size of mds1
8237 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8238 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8239 local MAX=$((MDSBLOCKSIZE * 3))
8241 local I=$(stat -c%s "$DIR/$tdir")
8243 local STRIPE_COUNT=1
8244 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8245 MAX=$((MAX*STRIPE_COUNT))
8246 while [[ $I -le $MAX ]]; do
8247 $MULTIOP $DIR/$tdir/$J Oc
8249 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8250 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8251 #and EFBIG for previous versions
8252 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8254 echo "return code $rc received as expected"
8255 multiop $DIR/$tdir/$J Oc ||
8256 error_exit "multiop failed w/o dir size limit"
8258 I=$(stat -c%s "$DIR/$tdir")
8260 if [ $(lustre_version_code $SINGLEMDS) -lt \
8261 $(version_code 2.4.51) ]
8263 [[ $I -eq $MAX ]] && return 0
8265 [[ $I -gt $MAX ]] && return 0
8267 error_exit "current dir size $I, previous limit $MAX"
8268 elif [ $rc -ne 0 ]; then
8270 error_exit "return code $rc received instead of expected " \
8271 "$EFBIG or $ENOSPC, files in dir $I"
8274 I=$(stat -c%s "$DIR/$tdir")
8278 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8280 run_test 129 "test directory size limit ========================"
8289 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8290 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8293 trap cleanup_130 EXIT RETURN
8295 local fm_file=$DIR/$tfile
8296 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8297 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8298 error "dd failed for $fm_file"
8300 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8301 filefrag -ves $fm_file
8303 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8304 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8305 [ $RC != 0 ] && error "filefrag $fm_file failed"
8307 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8308 grep -v "ext:" | grep -v "found")
8309 lun=$($GETSTRIPE -i $fm_file)
8311 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8314 for line in $filefrag_op
8316 frag_lun=`echo $line | cut -d: -f5`
8317 ext_len=`echo $line | cut -d: -f4`
8318 if (( $frag_lun != $lun )); then
8320 error "FIEMAP on 1-stripe file($fm_file) failed"
8323 (( tot_len += ext_len ))
8326 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8328 error "FIEMAP on 1-stripe file($fm_file) failed;"
8334 echo "FIEMAP on single striped file succeeded"
8336 run_test 130a "FIEMAP (1-stripe file)"
8339 [ "$OSTCOUNT" -lt "2" ] &&
8340 skip_env "skipping FIEMAP on 2-stripe file test" && return
8342 [ "$OSTCOUNT" -ge "10" ] &&
8343 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8345 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8346 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8349 trap cleanup_130 EXIT RETURN
8351 local fm_file=$DIR/$tfile
8352 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8353 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8354 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8356 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8357 error "dd failed on $fm_file"
8359 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8360 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8361 grep -v "ext:" | grep -v "found")
8363 last_lun=$(echo $filefrag_op | cut -d: -f5)
8368 for line in $filefrag_op
8370 frag_lun=`echo $line | cut -d: -f5`
8371 ext_len=`echo $line | cut -d: -f4`
8372 if (( $frag_lun != $last_lun )); then
8373 if (( tot_len != 1024 )); then
8375 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8382 (( tot_len += ext_len ))
8385 if (( num_luns != 2 || tot_len != 1024 )); then
8387 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8393 echo "FIEMAP on 2-stripe file succeeded"
8395 run_test 130b "FIEMAP (2-stripe file)"
8398 [ "$OSTCOUNT" -lt "2" ] &&
8399 skip_env "skipping FIEMAP on 2-stripe file" && return
8401 [ "$OSTCOUNT" -ge "10" ] &&
8402 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8404 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8405 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8408 trap cleanup_130 EXIT RETURN
8410 local fm_file=$DIR/$tfile
8411 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8412 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8413 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8415 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8417 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8418 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8420 last_lun=`echo $filefrag_op | cut -d: -f5`
8425 for line in $filefrag_op
8427 frag_lun=`echo $line | cut -d: -f5`
8428 ext_len=`echo $line | cut -d: -f4`
8429 if (( $frag_lun != $last_lun )); then
8430 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8431 if (( logical != 512 )); then
8433 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8436 if (( tot_len != 512 )); then
8438 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8445 (( tot_len += ext_len ))
8448 if (( num_luns != 2 || tot_len != 512 )); then
8450 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8456 echo "FIEMAP on 2-stripe file with hole succeeded"
8458 run_test 130c "FIEMAP (2-stripe file with hole)"
8461 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8463 [ "$OSTCOUNT" -ge "10" ] &&
8464 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8466 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8467 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8469 trap cleanup_130 EXIT RETURN
8471 local fm_file=$DIR/$tfile
8472 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8473 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8474 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8476 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8477 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8478 error "dd failed on $fm_file"
8480 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8481 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8482 grep -v "ext:" | grep -v "found"`
8484 last_lun=`echo $filefrag_op | cut -d: -f5`
8489 for line in $filefrag_op
8491 frag_lun=`echo $line | cut -d: -f5`
8492 ext_len=`echo $line | cut -d: -f4`
8493 if (( $frag_lun != $last_lun )); then
8494 if (( tot_len != 1024 )); then
8496 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8503 (( tot_len += ext_len ))
8506 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8508 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8514 echo "FIEMAP on N-stripe file succeeded"
8516 run_test 130d "FIEMAP (N-stripe file)"
8519 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8521 [ "$OSTCOUNT" -ge "10" ] &&
8522 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8524 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8525 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8527 trap cleanup_130 EXIT RETURN
8529 local fm_file=$DIR/$tfile
8530 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8531 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8532 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8535 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8536 for ((i = 0; i < $NUM_BLKS; i++))
8538 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8541 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8542 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8544 last_lun=`echo $filefrag_op | cut -d: -f5`
8549 for line in $filefrag_op
8551 frag_lun=`echo $line | cut -d: -f5`
8552 ext_len=`echo $line | cut -d: -f4`
8553 if (( $frag_lun != $last_lun )); then
8554 if (( tot_len != $EXPECTED_LEN )); then
8556 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8563 (( tot_len += ext_len ))
8566 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8568 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8574 echo "FIEMAP with continuation calls succeeded"
8576 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8578 # Test for writev/readv
8580 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8581 error "writev test failed"
8582 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8583 error "readv failed"
8586 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8589 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8590 error "append writev test failed"
8591 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8592 error "append writev test failed"
8595 run_test 131b "test append writev"
8598 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8601 run_test 131c "test read/write on file w/o objects"
8604 rwv -f $DIR/$tfile -w -n 1 1572864
8605 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8606 if [ "$NOB" != 1572864 ]; then
8607 error "Short read filed: read $NOB bytes instead of 1572864"
8611 run_test 131d "test short read"
8614 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8615 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8616 error "read hitting hole failed"
8619 run_test 131e "test read hitting hole"
8624 for node in $(osts_nodes); do
8625 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8626 [ x$gl = x"" ] && gl=0
8627 gl_sum=$((gl_sum + gl))
8637 if [ x$som = x"enabled" ]; then
8638 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8639 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8640 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8642 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8643 MOUNTOPT="$MOUNTOPT,som_preview"
8644 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8647 # do remount to make new mount-conf parameters actual
8654 test_132() { #1028, SOM
8655 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8656 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8657 local num=$(get_mds_dir $DIR)
8658 local mymds=mds${num}
8659 local MOUNTOPT_SAVE=$MOUNTOPT
8661 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8662 cancel_lru_locks osc
8664 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8666 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8667 stat $DIR/$tfile >/dev/null
8668 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8669 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8671 som_mode_switch $som1 $gl1 $gl2
8673 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8674 cancel_lru_locks osc
8676 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8677 if [ $som1 == $som2 ]; then
8678 error "som is still "$som2
8679 if [ x$som2 = x"enabled" ]; then
8686 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8687 stat $DIR/$tfile >/dev/null
8688 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8689 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8690 som_mode_switch $som2 $gl1 $gl2
8691 MOUNTOPT=$MOUNTOPT_SAVE
8693 run_test 132 "som avoids glimpse rpc"
8699 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8701 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8703 *) error "Wrong argument $1" ;;
8706 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8707 # if the argument $3 is zero, it means any stat increment is ok.
8708 if [[ $3 -gt 0 ]]; then
8709 count=$(echo $res | awk '{ print $2 }')
8710 [[ $count -ne $3 ]] &&
8711 error "The $2 counter on $1 is wrong - expected $3"
8716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8717 remote_ost_nodsh && skip "remote OST with nodsh" && return
8718 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8720 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8721 { skip "MDS doesn't support rename stats"; return; }
8722 local testdir=$DIR/${tdir}/stats_testdir
8723 mkdir -p $DIR/${tdir}
8726 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8727 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8729 # verify mdt stats first.
8730 mkdir ${testdir} || error "mkdir failed"
8731 check_stats $SINGLEMDS "mkdir" 1
8732 touch ${testdir}/${tfile} || "touch failed"
8733 check_stats $SINGLEMDS "open" 1
8734 check_stats $SINGLEMDS "close" 1
8735 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8736 check_stats $SINGLEMDS "mknod" 1
8737 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8738 check_stats $SINGLEMDS "unlink" 1
8739 rm -f ${testdir}/${tfile} || error "file remove failed"
8740 check_stats $SINGLEMDS "unlink" 2
8742 # remove working dir and check mdt stats again.
8743 rmdir ${testdir} || error "rmdir failed"
8744 check_stats $SINGLEMDS "rmdir" 1
8746 local testdir1=$DIR/${tdir}/stats_testdir1
8748 mkdir -p ${testdir1}
8749 touch ${testdir1}/test1
8750 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8751 check_stats $SINGLEMDS "crossdir_rename" 1
8753 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8754 check_stats $SINGLEMDS "samedir_rename" 1
8758 run_test 133a "Verifying MDT stats ========================================"
8761 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8762 remote_ost_nodsh && skip "remote OST with nodsh" && return
8763 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8764 local testdir=$DIR/${tdir}/stats_testdir
8765 mkdir -p ${testdir} || error "mkdir failed"
8766 touch ${testdir}/${tfile} || "touch failed"
8767 cancel_lru_locks mdc
8770 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8771 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8773 # extra mdt stats verification.
8774 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8775 check_stats $SINGLEMDS "setattr" 1
8776 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8777 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8779 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8780 check_stats $SINGLEMDS "getattr" 1
8782 $LFS df || error "lfs failed"
8783 check_stats $SINGLEMDS "statfs" 1
8787 run_test 133b "Verifying extra MDT stats =================================="
8790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8791 remote_ost_nodsh && skip "remote OST with nodsh" && return
8792 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8793 local testdir=$DIR/${tdir}/stats_testdir
8794 test_mkdir -p ${testdir} || error "mkdir failed"
8796 # verify obdfilter stats.
8797 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8799 cancel_lru_locks osc
8800 wait_delete_completed
8803 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8804 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8806 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8808 cancel_lru_locks osc
8809 check_stats ost "write" 1
8811 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8812 check_stats ost "read" 1
8814 > ${testdir}/${tfile} || error "truncate failed"
8815 check_stats ost "punch" 1
8817 rm -f ${testdir}/${tfile} || error "file remove failed"
8818 wait_delete_completed
8819 check_stats ost "destroy" 1
8823 run_test 133c "Verifying OST stats ========================================"
8830 while [ $value -ge 2 ]; do
8835 if [ $orig -gt $order ]; then
8843 local size=('K' 'M' 'G' 'T');
8845 local size_string=$value
8847 while [ $value -ge 1024 ]; do
8848 if [ $i -gt 3 ]; then
8849 #T is the biggest unit we get here, if that is bigger,
8851 size_string=${value}T
8854 value=$((value >> 10))
8855 if [ $value -lt 1024 ]; then
8856 size_string=${value}${size[$i]}
8867 local context=${2:-.}
8868 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8870 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8876 remote_ost_nodsh && skip "remote OST with nodsh" && return
8877 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8878 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8879 { skip "MDS doesn't support rename stats"; return; }
8881 local testdir1=$DIR/${tdir}/stats_testdir1
8882 local testdir2=$DIR/${tdir}/stats_testdir2
8884 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8886 mkdir -p ${testdir1} || error "mkdir failed"
8887 mkdir -p ${testdir2} || error "mkdir failed"
8889 createmany -o $testdir1/test 512 || error "createmany failed"
8891 # check samedir rename size
8892 mv ${testdir1}/test0 ${testdir1}/test_0
8894 local testdir1_size=$(ls -l $DIR/${tdir} |
8895 awk '/stats_testdir1/ {print $5}')
8896 local testdir2_size=$(ls -l $DIR/${tdir} |
8897 awk '/stats_testdir2/ {print $5}')
8899 testdir1_size=$(order_2 $testdir1_size)
8900 testdir2_size=$(order_2 $testdir2_size)
8902 testdir1_size=$(size_in_KMGT $testdir1_size)
8903 testdir2_size=$(size_in_KMGT $testdir2_size)
8905 echo "source rename dir size: ${testdir1_size}"
8906 echo "target rename dir size: ${testdir2_size}"
8908 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8909 eval $cmd || error "$cmd failed"
8910 local samedir=$($cmd | grep 'same_dir')
8911 local same_sample=$(get_rename_size $testdir1_size)
8912 [ -z "$samedir" ] && error "samedir_rename_size count error"
8913 [[ $same_sample -eq 1 ]] ||
8914 error "samedir_rename_size error $same_sample"
8915 echo "Check same dir rename stats success"
8917 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8919 # check crossdir rename size
8920 mv ${testdir1}/test_0 ${testdir2}/test_0
8922 testdir1_size=$(ls -l $DIR/${tdir} |
8923 awk '/stats_testdir1/ {print $5}')
8924 testdir2_size=$(ls -l $DIR/${tdir} |
8925 awk '/stats_testdir2/ {print $5}')
8927 testdir1_size=$(order_2 $testdir1_size)
8928 testdir2_size=$(order_2 $testdir2_size)
8930 testdir1_size=$(size_in_KMGT $testdir1_size)
8931 testdir2_size=$(size_in_KMGT $testdir2_size)
8933 echo "source rename dir size: ${testdir1_size}"
8934 echo "target rename dir size: ${testdir2_size}"
8936 eval $cmd || error "$cmd failed"
8937 local crossdir=$($cmd | grep 'crossdir')
8938 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8939 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8940 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8941 [[ $src_sample -eq 1 ]] ||
8942 error "crossdir_rename_size error $src_sample"
8943 [[ $tgt_sample -eq 1 ]] ||
8944 error "crossdir_rename_size error $tgt_sample"
8945 echo "Check cross dir rename stats success"
8948 run_test 133d "Verifying rename_stats ========================================"
8951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8952 local testdir=$DIR/${tdir}/stats_testdir
8953 local ctr f0 f1 bs=32768 count=42 sum
8955 remote_ost_nodsh && skip "remote OST with nodsh" && return
8956 mkdir -p ${testdir} || error "mkdir failed"
8958 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8960 for ctr in {write,read}_bytes; do
8962 cancel_lru_locks osc
8964 do_facet ost1 $LCTL set_param -n \
8965 "obdfilter.*.exports.clear=clear"
8967 if [ $ctr = write_bytes ]; then
8969 f1=${testdir}/${tfile}
8971 f0=${testdir}/${tfile}
8975 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8978 cancel_lru_locks osc
8980 sum=$(do_facet ost1 $LCTL get_param \
8981 "obdfilter.*.exports.*.stats" |
8982 awk -v ctr=$ctr 'BEGIN { sum = 0 }
8983 $1 == ctr { sum += $7 }
8984 END { printf("%0.0f", sum) }')
8986 if ((sum != bs * count)); then
8987 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8993 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8996 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8999 # First without trusting modes.
9000 find $proc_dirs -exec cat '{}' \; &> /dev/null
9002 # Second verifying readability.
9005 -exec cat '{}' \; &> /dev/null ||
9006 error "proc file read failed"
9008 for facet in $SINGLEMDS ost1; do
9009 do_facet $facet find $proc_dirs \
9010 ! -name req_history \
9011 -exec cat '{}' \\\; &> /dev/null
9013 do_facet $facet find $proc_dirs \
9014 ! -name req_history \
9016 -exec cat '{}' \\\; &> /dev/null ||
9017 error "proc file read failed"
9020 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9023 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9026 # Second verifying readability.
9029 -not -name force_lbug \
9030 -not -name changelog_mask \
9031 -exec badarea_io '{}' \; &> /dev/null ||
9032 error "find $proc_dirs failed"
9034 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9035 skip "Too old lustre on MDS"
9037 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9038 skip "Too old lustre on ost1"
9040 for facet in $SINGLEMDS ost1; do
9041 do_facet $facet find $proc_dirs \
9043 -not -name force_lbug \
9044 -not -name changelog_mask \
9045 -exec badarea_io '{}' \\\; &> /dev/null ||
9046 error "$facet find $proc_dirs failed"
9050 # remount the FS in case writes/reads /proc break the FS
9051 cleanup || error "failed to unmount"
9052 setup || error "failed to setup"
9055 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9057 test_140() { #bug-17379
9058 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9059 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9060 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9061 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9063 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9064 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9066 while i=`expr $i + 1`; do
9067 test_mkdir -p $i || error "Creating dir $i"
9068 cd $i || error "Changing to $i"
9069 ln -s ../stat stat || error "Creating stat symlink"
9070 # Read the symlink until ELOOP present,
9071 # not LBUGing the system is considered success,
9072 # we didn't overrun the stack.
9073 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9075 if [ $ret -eq 40 ]; then
9078 error "Open stat symlink"
9084 echo "The symlink depth = $i"
9085 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9086 error "Invalid symlink depth"
9088 # Test recursive symlink
9089 ln -s symlink_self symlink_self
9090 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9091 echo "open symlink_self returns $ret"
9092 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9094 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9098 local TF="$TMP/$tfile"
9100 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9102 cancel_lru_locks osc
9103 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9104 remount_client $MOUNT
9106 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9109 $TRUNCATE $DIR/$tfile 6000
9110 cancel_lru_locks osc
9111 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9114 echo "12345" >>$DIR/$tfile
9115 cancel_lru_locks osc
9116 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9119 echo "12345" >>$DIR/$tfile
9120 cancel_lru_locks osc
9121 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9126 run_test 150 "truncate/append tests"
9128 #LU-2902 roc_hit was not able to read all values from lproc
9129 function roc_hit_init() {
9130 local list=$(comma_list $(osts_nodes))
9131 local dir=$DIR/$tdir-check
9132 local file=$dir/file
9138 #use setstripe to do a write to every ost
9139 for i in $(seq 0 $((OSTCOUNT-1))); do
9140 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9141 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9142 idx=$(printf %04x $i)
9143 BEFORE=$(get_osd_param $list *OST*$idx stats |
9144 awk '$1 == "cache_access" {sum += $2}
9145 END { printf("%0.0f", sum) }')
9147 cancel_lru_locks osc
9148 cat $file >/dev/null
9150 AFTER=$(get_osd_param $list *OST*$idx stats |
9151 awk '$1 == "cache_access" {sum += $2}
9152 END { printf("%0.0f", sum) }')
9154 echo BEFORE:$BEFORE AFTER:$AFTER
9155 if ! let "AFTER - BEFORE == 4"; then
9157 error "roc_hit is not safe to use"
9165 function roc_hit() {
9166 local list=$(comma_list $(osts_nodes))
9167 echo $(get_osd_param $list '' stats |
9168 awk '$1 == "cache_hit" {sum += $2}
9169 END { printf("%0.0f", sum) }')
9172 function set_cache() {
9175 if [ "$2" == "off" ]; then
9178 local list=$(comma_list $(osts_nodes))
9179 set_osd_param $list '' $1_cache_enable $on
9181 cancel_lru_locks osc
9185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9186 remote_ost_nodsh && skip "remote OST with nodsh" && return
9189 local list=$(comma_list $(osts_nodes))
9191 # check whether obdfilter is cache capable at all
9192 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9193 echo "not cache-capable obdfilter"
9197 # check cache is enabled on all obdfilters
9198 if get_osd_param $list '' read_cache_enable | grep 0; then
9199 echo "oss cache is disabled"
9203 set_osd_param $list '' writethrough_cache_enable 1
9205 # check write cache is enabled on all obdfilters
9206 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9207 echo "oss write cache is NOT enabled"
9213 #define OBD_FAIL_OBD_NO_LRU 0x609
9214 do_nodes $list $LCTL set_param fail_loc=0x609
9216 # pages should be in the case right after write
9217 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9220 local BEFORE=$(roc_hit)
9221 cancel_lru_locks osc
9222 cat $DIR/$tfile >/dev/null
9223 local AFTER=$(roc_hit)
9225 do_nodes $list $LCTL set_param fail_loc=0
9227 if ! let "AFTER - BEFORE == CPAGES"; then
9228 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9231 # the following read invalidates the cache
9232 cancel_lru_locks osc
9233 set_osd_param $list '' read_cache_enable 0
9234 cat $DIR/$tfile >/dev/null
9236 # now data shouldn't be found in the cache
9238 cancel_lru_locks osc
9239 cat $DIR/$tfile >/dev/null
9241 if let "AFTER - BEFORE != 0"; then
9242 error "IN CACHE: before: $BEFORE, after: $AFTER"
9245 set_osd_param $list '' read_cache_enable 1
9248 run_test 151 "test cache on oss and controls ==============================="
9251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9252 local TF="$TMP/$tfile"
9254 # simulate ENOMEM during write
9255 #define OBD_FAIL_OST_NOMEM 0x226
9256 lctl set_param fail_loc=0x80000226
9257 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9259 sync || error "sync failed"
9260 lctl set_param fail_loc=0
9262 # discard client's cache
9263 cancel_lru_locks osc
9265 # simulate ENOMEM during read
9266 lctl set_param fail_loc=0x80000226
9267 cmp $TF $DIR/$tfile || error "cmp failed"
9268 lctl set_param fail_loc=0
9272 run_test 152 "test read/write with enomem ============================"
9275 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9277 run_test 153 "test if fdatasync does not crash ======================="
9279 dot_lustre_fid_permission_check() {
9281 local ffid=$MOUNT/.lustre/fid/$fid
9284 echo "stat fid $fid"
9285 stat $ffid > /dev/null || error "stat $ffid failed."
9286 echo "touch fid $fid"
9287 touch $ffid || error "touch $ffid failed."
9288 echo "write to fid $fid"
9289 cat /etc/hosts > $ffid || error "write $ffid failed."
9290 echo "read fid $fid"
9291 diff /etc/hosts $ffid || error "read $ffid failed."
9292 echo "append write to fid $fid"
9293 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9294 echo "rename fid $fid"
9295 mv $ffid $test_dir/$tfile.1 &&
9296 error "rename $ffid to $tfile.1 should fail."
9297 touch $test_dir/$tfile.1
9298 mv $test_dir/$tfile.1 $ffid &&
9299 error "rename $tfile.1 to $ffid should fail."
9300 rm -f $test_dir/$tfile.1
9301 echo "truncate fid $fid"
9302 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9303 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9304 echo "link fid $fid"
9305 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9307 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9308 echo "setfacl fid $fid"
9309 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9310 echo "getfacl fid $fid"
9311 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9313 echo "unlink fid $fid"
9314 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9315 echo "mknod fid $fid"
9316 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9318 fid=[0xf00000400:0x1:0x0]
9319 ffid=$MOUNT/.lustre/fid/$fid
9321 echo "stat non-exist fid $fid"
9322 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9323 echo "write to non-exist fid $fid"
9324 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9325 echo "link new fid $fid"
9326 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9328 mkdir -p $test_dir/$tdir
9329 touch $test_dir/$tdir/$tfile
9330 fid=$($LFS path2fid $test_dir/$tdir)
9333 error "error: could not get fid for $test_dir/$dir/$tfile."
9335 ffid=$MOUNT/.lustre/fid/$fid
9338 ls $ffid > /dev/null || error "ls $ffid failed."
9339 echo "touch $fid/$tfile.1"
9340 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9342 echo "touch $MOUNT/.lustre/fid/$tfile"
9343 touch $MOUNT/.lustre/fid/$tfile && \
9344 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9346 echo "setxattr to $MOUNT/.lustre/fid"
9347 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9349 echo "listxattr for $MOUNT/.lustre/fid"
9350 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9352 echo "delxattr from $MOUNT/.lustre/fid"
9353 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9355 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9356 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9357 error "touch invalid fid should fail."
9359 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9360 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9361 error "touch non-normal fid should fail."
9363 echo "rename $tdir to $MOUNT/.lustre/fid"
9364 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9365 error "rename to $MOUNT/.lustre/fid should fail."
9367 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9369 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9370 local new_obf_mode=777
9372 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9373 chmod $new_obf_mode $DIR/.lustre/fid ||
9374 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9376 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9377 [ $obf_mode -eq $new_obf_mode ] ||
9378 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9380 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9381 chmod $old_obf_mode $DIR/.lustre/fid ||
9382 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9385 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9386 fid=$($LFS path2fid $test_dir/$tfile-2)
9387 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9388 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9389 error "create lov data thru .lustre should fail."
9390 echo "cp /etc/passwd $test_dir/$tfile-2"
9391 cp /etc/passwd $test_dir/$tfile-2 ||
9392 error "copy to $test_dir/$tfile-2 failed."
9393 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9394 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9395 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9397 rm -rf $test_dir/tfile.lnk
9398 rm -rf $test_dir/$tfile-2
9402 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9403 skip "Need MDS version at least 2.4.1" && return
9406 local FID=$($LFS path2fid $DIR/$tfile)
9407 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9409 # check that we get the same pathname back
9410 local FOUND=$($LFS fid2path $MOUNT $FID)
9411 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9412 [ "$FOUND" != "$DIR/$tfile" ] &&
9413 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9417 run_test 154A "lfs path2fid and fid2path basic checks"
9420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9421 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9422 { skip "Need MDS version at least 2.2.51"; return 0; }
9423 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9425 cp /etc/hosts $DIR/$tfile
9427 fid=$($LFS path2fid $DIR/$tfile)
9429 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9431 dot_lustre_fid_permission_check "$fid" $DIR ||
9432 error "dot lustre permission check $fid failed"
9434 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9436 touch $MOUNT/.lustre/file &&
9437 error "creation is not allowed under .lustre"
9439 mkdir $MOUNT/.lustre/dir &&
9440 error "mkdir is not allowed under .lustre"
9444 run_test 154a "Open-by-FID"
9447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9448 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9449 { skip "Need MDS version at least 2.2.51"; return 0; }
9451 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9453 local remote_dir=$DIR/$tdir/remote_dir
9458 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9459 error "create remote directory failed"
9461 cp /etc/hosts $remote_dir/$tfile
9463 fid=$($LFS path2fid $remote_dir/$tfile)
9465 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9467 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9468 error "dot lustre permission check $fid failed"
9471 run_test 154b "Open-by-FID for remote directory"
9474 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9475 skip "Need MDS version at least 2.4.1" && return
9477 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9478 local FID1=$($LFS path2fid $DIR/$tfile.1)
9479 local FID2=$($LFS path2fid $DIR/$tfile.2)
9480 local FID3=$($LFS path2fid $DIR/$tfile.3)
9483 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9484 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9485 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9487 [ "$FID" = "${!want}" ] ||
9488 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9492 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9493 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9494 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9498 run_test 154c "lfs path2fid and fid2path multiple arguments"
9501 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9502 skip "Need MDS version at least 2.5.53" && return
9505 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9509 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9516 fid=$($LFS path2fid $DIR/$tfile)
9519 cmd="exec $fd<$DIR/$tfile"
9521 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9522 echo $fid_list | grep $fid
9525 cmd="exec $fd>/dev/null"
9527 if [ $rc -ne 0 ]; then
9528 error "FID $fid not found in open files list $fid_list"
9531 run_test 154d "Verify open file fid"
9533 test_155_small_load() {
9534 local temp=$TMP/$tfile
9535 local file=$DIR/$tfile
9537 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9538 error "dd of=$temp bs=6096 count=1 failed"
9540 cancel_lru_locks osc
9541 cmp $temp $file || error "$temp $file differ"
9543 $TRUNCATE $temp 6000
9544 $TRUNCATE $file 6000
9545 cmp $temp $file || error "$temp $file differ (truncate1)"
9547 echo "12345" >>$temp
9548 echo "12345" >>$file
9549 cmp $temp $file || error "$temp $file differ (append1)"
9551 echo "12345" >>$temp
9552 echo "12345" >>$file
9553 cmp $temp $file || error "$temp $file differ (append2)"
9559 test_155_big_load() {
9560 remote_ost_nodsh && skip "remote OST with nodsh" && return
9561 local temp=$TMP/$tfile
9562 local file=$DIR/$tfile
9565 local cache_size=$(do_facet ost$((MAXI+1)) \
9566 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9567 local large_file_size=$((cache_size * 2))
9569 echo "OSS cache size: $cache_size KB"
9570 echo "Large file size: $large_file_size KB"
9572 [ $MAXV -le $large_file_size ] && \
9573 skip_env "max available OST size needs > $large_file_size KB" && \
9576 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9578 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9579 error "dd of=$temp bs=$large_file_size count=1k failed"
9582 cancel_lru_locks osc
9583 cmp $temp $file || error "$temp $file differ"
9590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9592 set_cache writethrough on
9595 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9600 set_cache writethrough off
9603 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9608 set_cache writethrough on
9611 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9616 set_cache writethrough off
9619 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9624 set_cache writethrough on
9627 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9630 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9632 set_cache writethrough off
9635 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9640 set_cache writethrough on
9643 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9648 set_cache writethrough off
9651 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9658 local file="$DIR/$tfile"
9660 [ "$(facet_fstype ost1)" = "zfs" ] &&
9661 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9666 log "Turn on read and write cache"
9668 set_cache writethrough on
9670 log "Write data and read it back."
9671 log "Read should be satisfied from the cache."
9672 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9674 cancel_lru_locks osc
9675 cat $file >/dev/null
9677 if ! let "AFTER - BEFORE == CPAGES"; then
9678 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9680 log "cache hits:: before: $BEFORE, after: $AFTER"
9683 log "Read again; it should be satisfied from the cache."
9685 cancel_lru_locks osc
9686 cat $file >/dev/null
9688 if ! let "AFTER - BEFORE == CPAGES"; then
9689 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9691 log "cache hits:: before: $BEFORE, after: $AFTER"
9695 log "Turn off the read cache and turn on the write cache"
9697 set_cache writethrough on
9699 log "Read again; it should be satisfied from the cache."
9701 cancel_lru_locks osc
9702 cat $file >/dev/null
9704 if ! let "AFTER - BEFORE == CPAGES"; then
9705 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9707 log "cache hits:: before: $BEFORE, after: $AFTER"
9710 log "Read again; it should not be satisfied from the cache."
9712 cancel_lru_locks osc
9713 cat $file >/dev/null
9715 if ! let "AFTER - BEFORE == 0"; then
9716 error "IN CACHE: before: $BEFORE, after: $AFTER"
9718 log "cache hits:: before: $BEFORE, after: $AFTER"
9721 log "Write data and read it back."
9722 log "Read should be satisfied from the cache."
9723 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9725 cancel_lru_locks osc
9726 cat $file >/dev/null
9728 if ! let "AFTER - BEFORE == CPAGES"; then
9729 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9731 log "cache hits:: before: $BEFORE, after: $AFTER"
9734 log "Read again; it should not be satisfied from the cache."
9736 cancel_lru_locks osc
9737 cat $file >/dev/null
9739 if ! let "AFTER - BEFORE == 0"; then
9740 error "IN CACHE: before: $BEFORE, after: $AFTER"
9742 log "cache hits:: before: $BEFORE, after: $AFTER"
9746 log "Turn off read and write cache"
9748 set_cache writethrough off
9750 log "Write data and read it back"
9751 log "It should not be satisfied from the cache."
9753 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9754 cancel_lru_locks osc
9756 cat $file >/dev/null
9758 if ! let "AFTER - BEFORE == 0"; then
9759 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9761 log "cache hits:: before: $BEFORE, after: $AFTER"
9764 log "Turn on the read cache and turn off the write cache"
9766 set_cache writethrough off
9768 log "Write data and read it back"
9769 log "It should not be satisfied from the cache."
9771 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9773 cancel_lru_locks osc
9774 cat $file >/dev/null
9776 if ! let "AFTER - BEFORE == 0"; then
9777 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9779 log "cache hits:: before: $BEFORE, after: $AFTER"
9782 log "Read again; it should be satisfied from the cache."
9784 cancel_lru_locks osc
9785 cat $file >/dev/null
9787 if ! let "AFTER - BEFORE == CPAGES"; then
9788 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9790 log "cache hits:: before: $BEFORE, after: $AFTER"
9795 run_test 156 "Verification of tunables ============================"
9799 if [[ $MDSCOUNT -gt 1 ]]; then
9800 error_ignore bz17935 $*
9808 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9810 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9812 if [ $MASK -eq 1 ]; then
9813 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9815 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9819 changelog_extract_field() {
9825 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9826 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9832 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9833 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9834 { skip "Need MDS version at least 2.2.0"; return; }
9836 local CL_USERS="mdd.$MDT0.changelog_users"
9837 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9838 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9839 echo "Registered as changelog user $USER"
9840 $GET_CL_USERS | grep -q $USER ||
9841 error "User $USER not found in changelog_users"
9844 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9845 touch $DIR/$tdir/pics/2008/zachy/timestamp
9846 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9847 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9848 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9849 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9850 rm $DIR/$tdir/pics/desktop.jpg
9852 $LFS changelog $MDT0 | tail -5
9854 echo "verifying changelog mask"
9855 changelog_chmask "MKDIR"
9856 changelog_chmask "CLOSE"
9858 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9859 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9861 changelog_chmask "MKDIR"
9862 changelog_chmask "CLOSE"
9864 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9865 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9867 $LFS changelog $MDT0
9868 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9869 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9870 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9871 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9874 echo "verifying target fid"
9875 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9876 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9877 [ "$fidc" == "$fidf" ] ||
9878 err17935 "fid in changelog $fidc != file fid $fidf"
9879 echo "verifying parent fid"
9880 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9881 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9882 [ "$fidc" == "$fidf" ] ||
9883 err17935 "pfid in changelog $fidc != dir fid $fidf"
9885 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9886 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9887 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9888 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9889 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9890 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9892 MIN_REC=$($GET_CL_USERS |
9893 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9894 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
9895 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9896 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9897 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9899 # LU-3446 changelog index reset on MDT restart
9900 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9901 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9902 $LFS changelog_clear $MDT0 $USER 0
9903 stop $SINGLEMDS || error "Fail to stop MDT."
9904 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9905 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9906 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9907 [ $CUR_REC1 == $CUR_REC2 ] ||
9908 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9910 echo "verifying user deregister"
9911 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9912 $GET_CL_USERS | grep -q $USER &&
9913 error "User $USER still in changelog_users"
9915 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9916 if [ $USERS -eq 0 ]; then
9917 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9918 touch $DIR/$tdir/chloe
9919 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9920 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9921 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9923 echo "$USERS other changelog users; can't verify off"
9926 run_test 160a "changelog sanity"
9928 test_160b() { # LU-3587
9929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9930 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9931 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9932 { skip "Need MDS version at least 2.2.0"; return; }
9934 local CL_USERS="mdd.$MDT0.changelog_users"
9935 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9936 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9937 echo "Registered as changelog user $USER"
9938 $GET_CL_USERS | grep -q $USER ||
9939 error "User $USER not found in changelog_users"
9941 local LONGNAME1=$(str_repeat a 255)
9942 local LONGNAME2=$(str_repeat b 255)
9945 echo "creating very long named file"
9946 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9947 echo "moving very long named file"
9948 mv $LONGNAME1 $LONGNAME2
9950 $LFS changelog $MDT0 | grep RENME
9952 echo "deregistering $USER"
9953 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9957 run_test 160b "Verify that very long rename doesn't crash in changelog"
9961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9964 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9965 changelog_register -n)
9969 $MCREATE $DIR/$tdir/foo_160c
9970 changelog_chmask "TRUNC"
9971 $TRUNCATE $DIR/$tdir/foo_160c 200
9972 changelog_chmask "TRUNC"
9973 $TRUNCATE $DIR/$tdir/foo_160c 199
9974 $LFS changelog $MDT0
9975 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
9976 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
9977 $LFS changelog_clear $MDT0 $USER 0
9979 # Deregistration step
9980 echo "deregistering $USER"
9981 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9983 run_test 160c "verify that changelog log catch the truncate event"
9986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9987 test_mkdir -p -c1 $DIR/$tdir
9988 cp /etc/hosts $DIR/$tdir/$tfile
9989 test_mkdir -c1 $DIR/$tdir/foo1
9990 test_mkdir -c1 $DIR/$tdir/foo2
9991 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9992 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9993 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9994 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9995 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9996 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9997 $LFS fid2path $DIR $FID
9998 err17935 "bad link ea"
10001 rm $DIR/$tdir/foo2/zachary
10003 rm $DIR/$tdir/foo2/thor
10005 rm $DIR/$tdir/$tfile
10007 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10008 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10010 $LFS fid2path $DIR $FID
10011 err17935 "bad link rename"
10013 rm $DIR/$tdir/foo2/maggie
10016 local longname=filename_avg_len_is_thirty_two_
10017 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10018 error "failed to hardlink many files"
10019 links=$($LFS fid2path $DIR $FID | wc -l)
10020 echo -n "${links}/1000 links in link EA"
10021 [[ $links -gt 60 ]] ||
10022 err17935 "expected at least 60 links in link EA"
10023 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10024 error "failed to unlink many hardlinks"
10026 run_test 161a "link ea sanity"
10029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10030 [ $MDSCOUNT -lt 2 ] &&
10031 skip "skipping remote directory test" && return
10033 local remote_dir=$DIR/$tdir/remote_dir
10035 mkdir -p $DIR/$tdir
10036 $LFS mkdir -i $MDTIDX $remote_dir ||
10037 error "create remote directory failed"
10039 cp /etc/hosts $remote_dir/$tfile
10040 mkdir -p $remote_dir/foo1
10041 mkdir -p $remote_dir/foo2
10042 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10043 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10044 ln $remote_dir/$tfile $remote_dir/foo1/luna
10045 ln $remote_dir/$tfile $remote_dir/foo2/thor
10047 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10049 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10050 $LFS fid2path $DIR $FID
10051 err17935 "bad link ea"
10054 rm $remote_dir/foo2/zachary
10056 rm $remote_dir/foo2/thor
10058 rm $remote_dir/$tfile
10060 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10061 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10062 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10063 $LFS fid2path $DIR $FID
10064 err17935 "bad link rename"
10066 rm $remote_dir/foo2/maggie
10069 local longname=filename_avg_len_is_thirty_two_
10070 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10071 error "failed to hardlink many files"
10072 links=$($LFS fid2path $DIR $FID | wc -l)
10073 echo -n "${links}/1000 links in link EA"
10074 [[ ${links} -gt 60 ]] ||
10075 err17935 "expected at least 60 links in link EA"
10076 unlinkmany $remote_dir/foo2/$longname 1000 ||
10077 error "failed to unlink many hardlinks"
10079 run_test 161b "link ea sanity under remote directory"
10082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10083 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10084 skip "Need MDS version at least 2.1.5" && return
10086 # define CLF_RENAME_LAST 0x0001
10087 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10088 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10089 changelog_register -n)
10091 mkdir -p $DIR/$tdir
10092 touch $DIR/$tdir/foo_161c
10093 touch $DIR/$tdir/bar_161c
10094 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10095 $LFS changelog $MDT0 | grep RENME
10096 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10098 $LFS changelog_clear $MDT0 $USER 0
10099 if [ x$flags != "x0x1" ]; then
10100 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10102 error "flag $flags is not 0x1"
10104 echo "rename overwrite a target having nlink = 1," \
10105 "changelog record has flags of $flags"
10107 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10108 touch $DIR/$tdir/foo_161c
10109 touch $DIR/$tdir/bar_161c
10110 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10111 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10112 $LFS changelog $MDT0 | grep RENME
10113 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10114 $LFS changelog_clear $MDT0 $USER 0
10115 if [ x$flags != "x0x0" ]; then
10116 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10118 error "flag $flags is not 0x0"
10120 echo "rename overwrite a target having nlink > 1," \
10121 "changelog record has flags of $flags"
10123 # rename doesn't overwrite a target (changelog flag 0x0)
10124 touch $DIR/$tdir/foo_161c
10125 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10126 $LFS changelog $MDT0 | grep RENME
10127 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10128 $LFS changelog_clear $MDT0 $USER 0
10129 if [ x$flags != "x0x0" ]; then
10130 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10132 error "flag $flags is not 0x0"
10134 echo "rename doesn't overwrite a target," \
10135 "changelog record has flags of $flags"
10137 # define CLF_UNLINK_LAST 0x0001
10138 # unlink a file having nlink = 1 (changelog flag 0x1)
10139 rm -f $DIR/$tdir/foo2_161c
10140 $LFS changelog $MDT0 | grep UNLNK
10141 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10142 $LFS changelog_clear $MDT0 $USER 0
10143 if [ x$flags != "x0x1" ]; then
10144 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10146 error "flag $flags is not 0x1"
10148 echo "unlink a file having nlink = 1," \
10149 "changelog record has flags of $flags"
10151 # unlink a file having nlink > 1 (changelog flag 0x0)
10152 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10153 rm -f $DIR/$tdir/foobar_161c
10154 $LFS changelog $MDT0 | grep UNLNK
10155 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10156 $LFS changelog_clear $MDT0 $USER 0
10157 if [ x$flags != "x0x0" ]; then
10158 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10160 error "flag $flags is not 0x0"
10162 echo "unlink a file having nlink > 1," \
10163 "changelog record has flags of $flags"
10164 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10166 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10173 local path=$(${LFS} fid2path $*)
10176 if [ $RC -ne 0 ]; then
10177 err17935 "path looked up of $expected failed. Error $RC"
10179 elif [ "${path}" != "${expected}" ]; then
10180 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10183 echo "fid $fid resolves to path $path (expected $expected)"
10187 # Make changes to filesystem
10188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10189 test_mkdir -p -c1 $DIR/$tdir/d2
10190 touch $DIR/$tdir/d2/$tfile
10191 touch $DIR/$tdir/d2/x1
10192 touch $DIR/$tdir/d2/x2
10193 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10194 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10196 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10197 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
10200 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10201 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10202 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
10204 # softlink to wrong file
10205 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10206 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10207 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
10210 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10211 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10212 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10213 # fid2path dir/fsname should both work
10214 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
10215 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
10217 # hardlink count: check that there are 2 links
10218 # Doesnt work with CMD yet: 17935
10219 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10220 err17935 "expected 2 links"
10222 # hardlink indexing: remove the first link
10223 rm $DIR/$tdir/d2/p/q/r/hlink
10224 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
10228 run_test 162 "path lookup sanity"
10231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10232 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10235 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10236 error "create striped dir failed"
10238 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10239 tail -n 1 | awk '{print $2}')
10240 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10242 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10243 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10246 for ((i=0;i<5;i++)); do
10247 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10248 error "get fid for f$i failed"
10249 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
10251 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10252 error "get fid for d$i failed"
10253 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
10258 run_test 162b "striped directory path lookup sanity"
10261 # do directio so as not to populate the page cache
10262 log "creating a 10 Mb file"
10263 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10264 log "starting reads"
10265 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10266 log "truncating the file"
10267 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10269 kill %+ || true # reads might have finished
10270 echo "wait until dd is finished"
10272 log "removing the temporary file"
10273 rm -rf $DIR/$tfile || error "tmp file removal failed"
10275 run_test 169 "parallel read and truncate should not deadlock"
10278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10279 $LCTL clear # bug 18514
10280 $LCTL debug_daemon start $TMP/${tfile}_log_good
10282 $LCTL debug_daemon stop
10283 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10284 error "sed failed to read log_good"
10286 $LCTL debug_daemon start $TMP/${tfile}_log_good
10288 $LCTL debug_daemon stop
10290 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10291 error "lctl df log_bad failed"
10293 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10294 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10296 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10297 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10299 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10300 error "bad_line good_line1 good_line2 are empty"
10302 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10303 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10304 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10306 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10307 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10308 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10310 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10311 error "bad_line_new good_line_new are empty"
10313 local expected_good=$((good_line1 + good_line2*2))
10315 rm -f $TMP/${tfile}*
10316 # LU-231, short malformed line may not be counted into bad lines
10317 if [ $bad_line -ne $bad_line_new ] &&
10318 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10319 error "expected $bad_line bad lines, but got $bad_line_new"
10323 if [ $expected_good -ne $good_line_new ]; then
10324 error "expected $expected_good good lines, but got $good_line_new"
10329 run_test 170 "test lctl df to handle corrupted log ====================="
10331 test_171() { # bug20592
10332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10333 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10334 $LCTL set_param fail_loc=0x50e
10335 $LCTL set_param fail_val=3000
10336 multiop_bg_pause $DIR/$tfile O_s || true
10338 kill -USR1 $MULTIPID
10342 if dmesg | grep "recursive fault"; then
10343 error "caught a recursive fault"
10345 $LCTL set_param fail_loc=0
10348 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10350 # it would be good to share it with obdfilter-survey/libecho code
10351 setup_obdecho_osc () {
10354 local obdfilter_name=$2
10355 echo "Creating new osc for $obdfilter_name on $ost_nid"
10356 # make sure we can find loopback nid
10357 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10359 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10360 ${obdfilter_name}_osc_UUID || rc=2; }
10361 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10362 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10366 cleanup_obdecho_osc () {
10367 local obdfilter_name=$1
10368 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10369 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10376 local pages=${3:-64}
10381 local obd_size=$(get_obd_size $node $OBD)
10382 local page_size=$(get_page_size $node)
10383 if [[ -n "$obd_size" ]]; then
10384 local new_count=$((obd_size / (pages * page_size / 1024)))
10385 [[ $new_count -ge $count ]] || count=$new_count
10388 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10389 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10391 if [ $rc -eq 0 ]; then
10392 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10393 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10395 echo "New object id is $id"
10396 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10398 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10399 "test_brw $count w v $pages $id" || rc=4; }
10400 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10402 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10403 "cleanup" || rc=5; }
10404 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10405 "detach" || rc=6; }
10406 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10412 remote_ost_nodsh && skip "remote OST with nodsh" && return
10414 local rmmod_local=0
10416 if ! module_loaded obdecho; then
10417 load_module obdecho/obdecho
10421 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10422 local host=$(lctl get_param -n osc.$osc.import |
10423 awk '/current_connection:/ {print $2}' )
10424 local target=$(lctl get_param -n osc.$osc.import |
10425 awk '/target:/ {print $2}' )
10426 target=${target%_UUID}
10428 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10429 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10430 [[ -n $target ]] && cleanup_obdecho_osc $target
10431 [ $rmmod_local -eq 1 ] && rmmod obdecho
10434 run_test 180a "test obdecho on osc"
10437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10438 remote_ost_nodsh && skip "remote OST with nodsh" && return
10440 local rmmod_remote=0
10442 do_facet ost1 "lsmod | grep -q obdecho || " \
10443 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10444 "modprobe obdecho; }" && rmmod_remote=1
10445 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10446 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10447 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10450 run_test 180b "test obdecho directly on obdfilter"
10452 test_180c() { # LU-2598
10453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10454 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10455 skip "Need MDS version at least 2.4.0" && return
10458 local rmmod_remote=false
10459 local pages=16384 # 64MB bulk I/O RPC size
10462 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10463 rmmod_remote=true || error "failed to load module obdecho"
10465 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10467 if [ -n "$target" ]; then
10468 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10470 echo "there is no obdfilter target on ost1"
10473 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10476 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10478 test_181() { # bug 22177
10479 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10480 # create enough files to index the directory
10481 createmany -o $DIR/$tdir/foobar 4000
10482 # print attributes for debug purpose
10485 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10487 # remove the files & current working dir
10488 unlinkmany $DIR/$tdir/foobar 4000
10490 kill -USR1 $MULTIPID
10492 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10495 run_test 181 "Test open-unlinked dir ========================"
10498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10499 # disable MDC RPC lock wouldn't crash client
10503 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10504 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10505 $LCTL set_param fail_loc=0x804
10507 for (( i=0; i < $tcount; i++ )) ; do
10508 mkdir $DIR/$tdir/$i
10509 createmany -o $DIR/$tdir/$i/f- $fcount &
10513 for (( i=0; i < $tcount; i++ )) ; do
10514 unlinkmany $DIR/$tdir/$i/f- $fcount &
10520 $LCTL set_param fail_loc=0
10522 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10524 test_183() { # LU-2275
10525 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10526 skip "Need MDS version at least 2.3.56" && return
10528 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10529 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10530 echo aaa > $DIR/$tdir/$tfile
10532 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10533 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10535 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10536 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10538 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10540 # Flush negative dentry cache
10541 touch $DIR/$tdir/$tfile
10543 # We are not checking for any leaked references here, they'll
10544 # become evident next time we do cleanup with module unload.
10547 run_test 183 "No crash or request leak in case of strange dispositions ========"
10549 # test suite 184 is for LU-2016, LU-2017
10551 check_swap_layouts_support && return 0
10553 dir0=$DIR/$tdir/$testnum
10554 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10559 $SETSTRIPE -c1 $file1
10561 $SETSTRIPE -c2 $file2
10563 gen1=$($GETSTRIPE -g $file1)
10564 gen2=$($GETSTRIPE -g $file2)
10566 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10567 gen=$($GETSTRIPE -g $file1)
10568 [[ $gen1 != $gen ]] ||
10569 "Layout generation on $file1 does not change"
10570 gen=$($GETSTRIPE -g $file2)
10571 [[ $gen2 != $gen ]] ||
10572 "Layout generation on $file2 does not change"
10574 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10575 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10577 run_test 184a "Basic layout swap"
10580 check_swap_layouts_support && return 0
10582 dir0=$DIR/$tdir/$testnum
10583 mkdir -p $dir0 || error "creating dir $dir0"
10590 $SETSTRIPE -c1 $file1
10591 $SETSTRIPE -c2 $file2
10592 $SETSTRIPE -c1 $file3
10593 chown $RUNAS_ID $file3
10594 gen1=$($GETSTRIPE -g $file1)
10595 gen2=$($GETSTRIPE -g $file2)
10597 $LFS swap_layouts $dir1 $dir2 &&
10598 error "swap of directories layouts should fail"
10599 $LFS swap_layouts $dir1 $file1 &&
10600 error "swap of directory and file layouts should fail"
10601 $RUNAS $LFS swap_layouts $file1 $file2 &&
10602 error "swap of file we cannot write should fail"
10603 $LFS swap_layouts $file1 $file3 &&
10604 error "swap of file with different owner should fail"
10605 /bin/true # to clear error code
10607 run_test 184b "Forbidden layout swap (will generate errors)"
10610 check_swap_layouts_support && return 0
10612 local dir0=$DIR/$tdir/$testnum
10613 mkdir -p $dir0 || error "creating dir $dir0"
10615 local ref1=$dir0/ref1
10616 local ref2=$dir0/ref2
10617 local file1=$dir0/file1
10618 local file2=$dir0/file2
10619 # create a file large enough for the concurent test
10620 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10621 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10622 echo "ref file size: ref1($(stat -c %s $ref1))," \
10623 "ref2($(stat -c %s $ref2))"
10626 dd if=$ref1 of=$file1 bs=16k &
10629 # Make sure dd starts to copy file
10630 while [ ! -f $file1 ]; do sleep 0.1; done
10632 $LFS swap_layouts $file1 $file2
10635 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10636 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10638 # how many bytes copied before swapping layout
10639 local copied=$(stat -c %s $file2)
10640 local remaining=$(stat -c %s $ref1)
10641 remaining=$((remaining - copied))
10642 echo "Copied $copied bytes before swapping layout..."
10644 cmp -n $copied $file1 $ref2 | grep differ &&
10645 error "Content mismatch [0, $copied) of ref2 and file1"
10646 cmp -n $copied $file2 $ref1 ||
10647 error "Content mismatch [0, $copied) of ref1 and file2"
10648 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10649 error "Content mismatch [$copied, EOF) of ref1 and file1"
10652 rm -f $ref1 $ref2 $file1 $file2
10654 run_test 184c "Concurrent write and layout swap"
10657 check_swap_layouts_support && return 0
10658 [ -z "$(which getfattr 2>/dev/null)" ] &&
10659 skip "no getfattr command" && return 0
10661 local file1=$DIR/$tdir/$tfile-1
10662 local file2=$DIR/$tdir/$tfile-2
10663 local file3=$DIR/$tdir/$tfile-3
10667 mkdir -p $DIR/$tdir
10668 touch $file1 || error "create $file1 failed"
10669 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10670 error "create $file2 failed"
10671 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10672 error "create $file3 failed"
10673 lovea1=$($LFS getstripe $file1 | sed 1d)
10675 $LFS swap_layouts $file2 $file3 ||
10676 error "swap $file2 $file3 layouts failed"
10677 $LFS swap_layouts $file1 $file2 ||
10678 error "swap $file1 $file2 layouts failed"
10680 lovea2=$($LFS getstripe $file2 | sed 1d)
10681 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10683 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10684 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10686 run_test 184d "allow stripeless layouts swap"
10689 test_185() { # LU-2441
10690 # LU-3553 - no volatile file support in old servers
10691 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10692 { skip "Need MDS version at least 2.3.60"; return 0; }
10694 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10695 touch $DIR/$tdir/spoo
10696 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10697 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10698 error "cannot create/write a volatile file"
10699 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10700 error "FID is still valid after close"
10702 multiop_bg_pause $DIR/$tdir vVw4096_c
10709 # assume that the next FID for this client is sequential, since stdout
10710 # is unfortunately eaten by multiop_bg_pause
10711 local n=$((${fidv[1]} + 1))
10712 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10713 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10714 error "FID is missing before close"
10715 kill -USR1 $multi_pid
10716 # 1 second delay, so if mtime change we will see it
10718 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10719 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10721 run_test 185 "Volatile file support"
10724 local dir0=$DIR/$tdir/$testnum
10725 mkdir -p $dir0 || error "creating dir $dir0"
10727 local file=$dir0/file1
10728 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10729 local dv1=$($LFS data_version $file)
10730 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10731 local dv2=$($LFS data_version $file)
10732 [[ $dv1 != $dv2 ]] ||
10733 error "data version did not change on write $dv1 == $dv2"
10738 run_test 187a "Test data version change"
10741 local dir0=$DIR/$tdir/$testnum
10742 mkdir -p $dir0 || error "creating dir $dir0"
10744 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10745 [[ ${DV[0]} != ${DV[1]} ]] ||
10746 error "data version did not change on write"\
10747 " ${DV[0]} == ${DV[1]}"
10752 run_test 187b "Test data version change on volatile file"
10755 check_file_in_pool()
10760 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10763 for t in $tlist ; do
10764 [ "$i" -eq "$t" ] && continue 2
10767 echo "pool list: $tlist"
10768 echo "striping: $res"
10769 error_noexit "$file not allocated in $pool"
10776 echo "Creating new pool"
10779 create_pool $FSNAME.$pool ||
10780 { error_noexit "No pool created, result code $?"; return 1; }
10781 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10782 { error_noexit "$pool not in lfs pool_list"; return 2; }
10785 pool_add_targets() {
10786 echo "Adding targets to pool"
10792 local list=$(seq $first $step $last)
10794 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10795 do_facet mgs $LCTL pool_add \
10796 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10797 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10798 | sort -u | tr '\n' ' ' " "$t" || {
10799 error_noexit "Add to pool failed"
10802 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10803 local addcount=$(((last - first) / step + 1))
10804 [ $lfscount -eq $addcount ] || {
10805 error_noexit "lfs pool_list bad ost count" \
10806 "$lfscount != $addcount"
10814 echo "Setting pool on directory $tdir"
10816 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10818 error_noexit "Cannot set pool $pool to $tdir"
10825 echo "Checking pool on directory $tdir"
10827 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10828 [ "$res" = "$pool" ] && return 0
10830 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10834 pool_dir_rel_path() {
10835 echo "Testing relative path works well"
10840 mkdir -p $root/$tdir/$tdir
10842 pool_set_dir $pool $tdir || return 1
10843 pool_set_dir $pool ./$tdir || return 2
10844 pool_set_dir $pool ../$tdir || return 3
10845 pool_set_dir $pool ../$tdir/$tdir || return 4
10846 rm -rf $tdir; cd - > /dev/null
10849 pool_alloc_files() {
10850 echo "Checking files allocation from directory pool"
10857 for i in $(seq -w 1 $count)
10859 local file=$tdir/file-$i
10861 check_file_in_pool $file $pool "$tlist" || \
10862 failed=$((failed + 1))
10864 [ "$failed" = 0 ] && return 0
10866 error_noexit "$failed files not allocated in $pool"
10870 pool_create_files() {
10871 echo "Creating files in pool"
10879 for i in $(seq -w 1 $count)
10881 local file=$tdir/spoo-$i
10882 $SETSTRIPE -p $pool $file
10883 check_file_in_pool $file $pool "$tlist" || \
10884 failed=$((failed + 1))
10886 [ "$failed" = 0 ] && return 0
10888 error_noexit "$failed files not allocated in $pool"
10893 echo "Checking 'lfs df' output"
10896 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10898 local res=$($LFS df --pool $FSNAME.$pool |
10900 grep "$FSNAME-OST" |
10902 [ "$res" = "$t" ] && return 0
10904 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10908 pool_file_rel_path() {
10909 echo "Creating files in a pool with relative pathname"
10914 { error_noexit "unable to create $tdir"; return 1 ; }
10915 local file="/..$tdir/$tfile-1"
10916 $SETSTRIPE -p $pool $file ||
10917 { error_noexit "unable to create $file" ; return 2 ; }
10920 $SETSTRIPE -p $pool $tfile-2 || {
10921 error_noexit "unable to create $tfile-2 in $tdir"
10926 pool_remove_first_target() {
10927 echo "Removing first target from a pool"
10930 local pname="lov.$FSNAME-*.pools.$pool"
10931 local t=$($LCTL get_param -n $pname | head -n1)
10932 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10933 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10934 error_noexit "$t not removed from $FSNAME.$pool"
10939 pool_remove_all_targets() {
10940 echo "Removing all targets from pool"
10943 local pname="lov.$FSNAME-*.pools.$pool"
10944 for t in $($LCTL get_param -n $pname | sort -u)
10946 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10948 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10949 error_noexit "Pool $FSNAME.$pool cannot be drained"
10952 # striping on an empty/nonexistant pool should fall back
10953 # to "pool of everything"
10955 error_noexit "failed to use fallback striping for empty pool"
10958 # setstripe on an empty pool should fail
10959 $SETSTRIPE -p $pool $file 2>/dev/null && {
10960 error_noexit "expected failure when creating file" \
10968 echo "Destroying pool"
10972 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10975 # striping on an empty/nonexistant pool should fall back
10976 # to "pool of everything"
10978 error_noexit "failed to use fallback striping for missing pool"
10981 # setstripe on an empty pool should fail
10982 $SETSTRIPE -p $pool $file 2>/dev/null && {
10983 error_noexit "expected failure when creating file" \
10984 "with missing pool"
10988 # get param should return err once pool is gone
10989 if wait_update $HOSTNAME "lctl get_param -n \
10990 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10992 remove_pool_from_list $FSNAME.$pool
10995 error_noexit "Pool $FSNAME.$pool is not destroyed"
11000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11001 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11003 local POOL=${POOL:-cea1}
11004 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11005 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11008 local last_ost=$(($OSTCOUNT - 1))
11010 local ost_list=$(seq $first_ost $ost_step $last_ost)
11011 local ost_range="$first_ost $last_ost $ost_step"
11012 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11013 local file_dir=$POOL_ROOT/file_tst
11017 # former test_200a test_200b
11018 pool_add $POOL || { rc=$? ; break; }
11019 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11020 # former test_200c test_200d
11021 mkdir -p $test_path
11022 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11023 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11024 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11025 || { rc=$? ; break; }
11026 # former test_200e test_200f
11027 local files=$((OSTCOUNT*3))
11028 pool_alloc_files $POOL $test_path $files "$ost_list" \
11029 || { rc=$? ; break; }
11030 pool_create_files $POOL $file_dir $files "$ost_list" \
11031 || { rc=$? ; break; }
11032 # former test_200g test_200h
11033 pool_lfs_df $POOL || { rc=$? ; break; }
11034 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11036 # former test_201a test_201b test_201c
11037 pool_remove_first_target $POOL || { rc=$? ; break; }
11039 local f=$test_path/$tfile
11040 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11041 pool_remove $POOL $f || { rc=$? ; break; }
11048 run_test 200 "OST pools"
11050 # usage: default_attr <count | size | offset>
11052 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11055 # usage: check_default_stripe_attr
11056 check_default_stripe_attr() {
11057 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11059 --stripe-count|--count)
11060 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11061 --stripe-size|--size)
11062 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11063 --stripe-index|--index)
11066 error "unknown getstripe attr '$1'"
11069 [ $ACTUAL != $EXPECTED ] &&
11070 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11074 test_mkdir -p $DIR/$tdir
11075 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11077 check_default_stripe_attr --stripe-count
11078 check_default_stripe_attr --stripe-size
11079 check_default_stripe_attr --stripe-index
11083 run_test 204a "Print default stripe attributes ================="
11086 test_mkdir -p $DIR/$tdir
11087 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11089 check_default_stripe_attr --stripe-size
11090 check_default_stripe_attr --stripe-index
11094 run_test 204b "Print default stripe size and offset ==========="
11097 test_mkdir -p $DIR/$tdir
11098 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11100 check_default_stripe_attr --stripe-count
11101 check_default_stripe_attr --stripe-index
11105 run_test 204c "Print default stripe count and offset ==========="
11108 test_mkdir -p $DIR/$tdir
11109 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11111 check_default_stripe_attr --stripe-count
11112 check_default_stripe_attr --stripe-size
11116 run_test 204d "Print default stripe count and size ============="
11119 test_mkdir -p $DIR/$tdir
11120 $SETSTRIPE -d $DIR/$tdir
11122 check_default_stripe_attr --stripe-count --raw
11123 check_default_stripe_attr --stripe-size --raw
11124 check_default_stripe_attr --stripe-index --raw
11128 run_test 204e "Print raw stripe attributes ================="
11131 test_mkdir -p $DIR/$tdir
11132 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11134 check_default_stripe_attr --stripe-size --raw
11135 check_default_stripe_attr --stripe-index --raw
11139 run_test 204f "Print raw stripe size and offset ==========="
11142 test_mkdir -p $DIR/$tdir
11143 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11145 check_default_stripe_attr --stripe-count --raw
11146 check_default_stripe_attr --stripe-index --raw
11150 run_test 204g "Print raw stripe count and offset ==========="
11153 test_mkdir -p $DIR/$tdir
11154 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11156 check_default_stripe_attr --stripe-count --raw
11157 check_default_stripe_attr --stripe-size --raw
11161 run_test 204h "Print raw stripe count and size ============="
11163 # Figure out which job scheduler is being used, if any,
11164 # or use a fake one
11165 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11166 JOBENV=SLURM_JOB_ID
11167 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11169 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11171 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11172 JOBENV=LOADL_STEP_ID
11173 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11179 verify_jobstats() {
11183 # clear old jobstats
11184 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11185 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11187 # use a new JobID for this test, or we might see an old one
11188 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11192 log "Using JobID environment variable $JOBENV=$JOBVAL"
11194 if [ $JOBENV = "FAKE_JOBID" ]; then
11195 FAKE_JOBID=$JOBVAL $cmd
11200 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11201 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11202 do_facet $FACET lctl get_param mdt.*.job_stats |
11203 grep $JOBVAL || error "No job stats found on MDT $FACET"
11205 if [ "$target" = "ost" -o "$target" = "both" ]; then
11207 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11208 grep $JOBVAL || error "No job stats found on OST $FACET"
11214 NEW_JOBENV=${1:-$OLD_JOBENV}
11215 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11216 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11219 test_205() { # Job stats
11220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11221 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11222 skip "Server doesn't support jobstats" && return 0
11223 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11226 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11227 if [ $OLD_JOBENV != $JOBENV ]; then
11228 jobstats_set $JOBENV
11229 trap jobstats_set EXIT
11233 cmd="mkdir $DIR/$tfile"
11234 verify_jobstats "$cmd" "mdt"
11236 cmd="rm -fr $DIR/$tfile"
11237 verify_jobstats "$cmd" "mdt"
11239 cmd="mknod $DIR/$tfile c 1 3"
11240 verify_jobstats "$cmd" "mdt"
11242 cmd="rm -f $DIR/$tfile"
11243 verify_jobstats "$cmd" "mdt"
11245 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11246 verify_jobstats "$cmd" "mdt"
11248 cmd="touch $DIR/$tfile"
11249 verify_jobstats "$cmd" "both"
11251 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11252 verify_jobstats "$cmd" "ost"
11254 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11255 verify_jobstats "$cmd" "ost"
11257 cmd="$TRUNCATE $DIR/$tfile 0"
11258 verify_jobstats "$cmd" "both"
11260 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11261 verify_jobstats "$cmd" "mdt"
11264 rm -f $DIR/jobstats_test_rename
11266 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11268 run_test 205 "Verify job stats"
11270 # LU-1480, LU-1773 and LU-1657
11272 mkdir -p $DIR/$tdir
11273 $SETSTRIPE -c -1 $DIR/$tdir
11274 #define OBD_FAIL_LOV_INIT 0x1403
11275 $LCTL set_param fail_loc=0xa0001403
11276 $LCTL set_param fail_val=1
11277 touch $DIR/$tdir/$tfile || true
11279 run_test 206 "fail lov_init_raid0() doesn't lbug"
11282 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11283 local fsz=`stat -c %s $DIR/$tfile`
11284 cancel_lru_locks mdc
11286 # do not return layout in getattr intent
11287 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11288 $LCTL set_param fail_loc=0x170
11289 local sz=`stat -c %s $DIR/$tfile`
11291 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11295 run_test 207a "can refresh layout at glimpse"
11298 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11299 local cksum=`md5sum $DIR/$tfile`
11300 local fsz=`stat -c %s $DIR/$tfile`
11301 cancel_lru_locks mdc
11302 cancel_lru_locks osc
11304 # do not return layout in getattr intent
11305 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11306 $LCTL set_param fail_loc=0x171
11308 # it will refresh layout after the file is opened but before read issues
11309 echo checksum is "$cksum"
11310 echo "$cksum" |md5sum -c --quiet || error "file differs"
11314 run_test 207b "can refresh layout at open"
11317 # FIXME: in this test suite, only RD lease is used. This is okay
11318 # for now as only exclusive open is supported. After generic lease
11319 # is done, this test suite should be revised. - Jinshan
11321 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11322 { skip "Need MDS version at least 2.4.52"; return 0; }
11324 echo "==== test 1: verify get lease work"
11325 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11327 echo "==== test 2: verify lease can be broken by upcoming open"
11328 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11332 $MULTIOP $DIR/$tfile oO_RDONLY:c
11333 kill -USR1 $PID && wait $PID || error "break lease error"
11335 echo "==== test 3: verify lease can't be granted if an open already exists"
11336 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11340 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11341 kill -USR1 $PID && wait $PID || error "open file error"
11343 echo "==== test 4: lease can sustain over recovery"
11344 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11350 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11352 echo "==== test 5: lease broken can't be regained by replay"
11353 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11357 # open file to break lease and then recovery
11358 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11361 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11365 run_test 208 "Exclusive open"
11368 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11369 skip_env "must have disp_stripe" && return
11372 sync; sleep 5; sync;
11374 echo 3 > /proc/sys/vm/drop_caches
11375 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11377 # open/close 500 times
11378 for i in $(seq 500); do
11382 echo 3 > /proc/sys/vm/drop_caches
11383 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11385 echo "before: $req_before, after: $req_after"
11386 [ $((req_after - req_before)) -ge 300 ] &&
11387 error "open/close requests are not freed"
11390 run_test 209 "read-only open/close requests should be freed promptly"
11394 size=$((size % 8192 + 1))
11395 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11396 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11397 rm -f $DIR/f212 $DIR/f212.xyz
11399 run_test 212 "Sendfile test ============================================"
11402 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11403 cancel_lru_locks osc
11404 lctl set_param fail_loc=0x8000040f
11405 # generate a read lock
11406 cat $DIR/$tfile > /dev/null
11407 # write to the file, it will try to cancel the above read lock.
11408 cat /etc/hosts >> $DIR/$tfile
11410 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11412 test_214() { # for bug 20133
11413 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11414 for (( i=0; i < 340; i++ )) ; do
11415 touch $DIR/$tdir/d214c/a$i
11418 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11419 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11420 ls $DIR/d214c || error "ls $DIR/d214c failed"
11421 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11422 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11424 run_test 214 "hash-indexed directory test - bug 20133"
11426 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11427 create_lnet_proc_files() {
11428 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11429 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11431 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11432 rm -f "$TMP/lnet_$1.sys_tmp"
11435 # counterpart of create_lnet_proc_files
11436 remove_lnet_proc_files() {
11437 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11440 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11441 # 3rd arg as regexp for body
11442 check_lnet_proc_stats() {
11443 local l=$(cat "$TMP/lnet_$1" |wc -l)
11444 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11446 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11449 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11450 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11451 # optional and can be regexp for 2nd line (lnet.routes case)
11452 check_lnet_proc_entry() {
11453 local blp=2 # blp stands for 'position of 1st line of body'
11454 [ -z "$5" ] || blp=3 # lnet.routes case
11456 local l=$(cat "$TMP/lnet_$1" |wc -l)
11457 # subtracting one from $blp because the body can be empty
11458 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11460 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11461 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11463 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11464 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11466 # bail out if any unexpected line happened
11467 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11468 [ "$?" != 0 ] || error "$2 misformatted"
11471 test_215() { # for bugs 18102, 21079, 21517
11472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11473 local N='(0|[1-9][0-9]*)' # non-negative numeric
11474 local P='[1-9][0-9]*' # positive numeric
11475 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11476 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11477 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11478 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11480 local L1 # regexp for 1st line
11481 local L2 # regexp for 2nd line (optional)
11482 local BR # regexp for the rest (body)
11484 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11485 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11486 create_lnet_proc_files "stats"
11487 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11488 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11489 remove_lnet_proc_files "stats"
11491 # /proc/sys/lnet/routes should look like this:
11492 # Routing disabled/enabled
11493 # net hops priority state router
11494 # where net is a string like tcp0, hops > 0, priority >= 0,
11495 # state is up/down,
11496 # router is a string like 192.168.1.1@tcp2
11497 L1="^Routing (disabled|enabled)$"
11498 L2="^net +hops +priority +state +router$"
11499 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11500 create_lnet_proc_files "routes"
11501 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11502 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11503 remove_lnet_proc_files "routes"
11505 # /proc/sys/lnet/routers should look like this:
11506 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11507 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11508 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11509 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11510 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11511 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11512 create_lnet_proc_files "routers"
11513 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11514 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11515 remove_lnet_proc_files "routers"
11517 # /proc/sys/lnet/peers should look like this:
11518 # nid refs state last max rtr min tx min queue
11519 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11520 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11521 # numeric (0 or >0 or <0), queue >= 0.
11522 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11523 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11524 create_lnet_proc_files "peers"
11525 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11526 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11527 remove_lnet_proc_files "peers"
11529 # /proc/sys/lnet/buffers should look like this:
11530 # pages count credits min
11531 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11532 L1="^pages +count +credits +min$"
11533 BR="^ +$N +$N +$I +$I$"
11534 create_lnet_proc_files "buffers"
11535 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11536 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11537 remove_lnet_proc_files "buffers"
11539 # /proc/sys/lnet/nis should look like this:
11540 # nid status alive refs peer rtr max tx min
11541 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11542 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11543 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11544 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11545 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11546 create_lnet_proc_files "nis"
11547 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11548 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11549 remove_lnet_proc_files "nis"
11551 # can we successfully write to /proc/sys/lnet/stats?
11552 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11553 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11555 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11557 test_216() { # bug 20317
11558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11559 remote_ost_nodsh && skip "remote OST with nodsh" && return
11562 local facets=$(get_facets OST)
11563 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11565 save_lustre_params client "osc.*.contention_seconds" > $p
11566 save_lustre_params $facets \
11567 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11568 save_lustre_params $facets \
11569 "ldlm.namespaces.filter-*.contended_locks" >> $p
11570 save_lustre_params $facets \
11571 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11574 # agressive lockless i/o settings
11575 for node in $(osts_nodes); do
11576 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'
11578 lctl set_param -n osc.*.contention_seconds 60
11580 $DIRECTIO write $DIR/$tfile 0 10 4096
11581 $CHECKSTAT -s 40960 $DIR/$tfile
11583 # disable lockless i/o
11584 for node in $(osts_nodes); do
11585 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'
11587 lctl set_param -n osc.*.contention_seconds 0
11590 dd if=/dev/zero of=$DIR/$tfile count=0
11591 $CHECKSTAT -s 0 $DIR/$tfile
11593 restore_lustre_params <$p
11597 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11599 test_217() { # bug 22430
11600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11604 for node in $(nodes_list); do
11605 nid=$(host_nids_address $node $NETTYPE)
11606 if [[ $nid = *-* ]] ; then
11607 echo "lctl ping $nid@$NETTYPE"
11608 lctl ping $nid@$NETTYPE
11610 echo "skipping $node (no hyphen detected)"
11614 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11617 # do directio so as not to populate the page cache
11618 log "creating a 10 Mb file"
11619 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11620 log "starting reads"
11621 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11622 log "truncating the file"
11623 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11625 kill %+ || true # reads might have finished
11626 echo "wait until dd is finished"
11628 log "removing the temporary file"
11629 rm -rf $DIR/$tfile || error "tmp file removal failed"
11631 run_test 218 "parallel read and truncate should not deadlock ======================="
11634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11635 # write one partial page
11636 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11637 # set no grant so vvp_io_commit_write will do sync write
11638 $LCTL set_param fail_loc=0x411
11639 # write a full page at the end of file
11640 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11642 $LCTL set_param fail_loc=0
11643 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11644 $LCTL set_param fail_loc=0x411
11645 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11648 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11649 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11651 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11653 test_220() { #LU-325
11654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11655 remote_ost_nodsh && skip "remote OST with nodsh" && return
11658 test_mkdir -p $DIR/$tdir
11659 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11660 awk '{print $2}' | sed -e 's/_UUID$//')
11663 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11664 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11665 osc.$mdtosc_proc1.prealloc_last_id)
11666 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11667 osc.$mdtosc_proc1.prealloc_next_id)
11671 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11672 #define OBD_FAIL_OST_ENOINO 0x229
11673 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11674 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11675 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11677 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11679 MDSOBJS=$((last_id - next_id))
11680 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11682 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11683 echo "OST still has $count kbytes free"
11685 echo "create $MDSOBJS files @next_id..."
11686 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11688 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11689 osc.$mdtosc_proc1.prealloc_last_id)
11690 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11691 osc.$mdtosc_proc1.prealloc_next_id)
11693 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11698 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11699 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11701 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11702 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11703 echo "unlink $MDSOBJS files @$next_id..."
11704 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11706 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11710 dd if=`which date` of=$MOUNT/date oflag=sync
11711 chmod +x $MOUNT/date
11713 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11714 $LCTL set_param fail_loc=0x80001401
11716 $MOUNT/date > /dev/null
11719 run_test 221 "make sure fault and truncate race to not cause OOM"
11722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11724 test_mkdir -p $DIR/$tdir
11725 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11726 createmany -o $DIR/$tdir/$tfile 10
11727 cancel_lru_locks mdc
11728 cancel_lru_locks osc
11729 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11730 $LCTL set_param fail_loc=0x31a
11731 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11732 $LCTL set_param fail_loc=0
11735 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11740 test_mkdir -p $DIR/$tdir
11741 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11742 createmany -o $DIR/$tdir/$tfile 10
11743 cancel_lru_locks mdc
11744 cancel_lru_locks osc
11745 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11746 $LCTL set_param fail_loc=0x31a
11747 rm -r $DIR/$tdir || "AGL for rmdir failed"
11748 $LCTL set_param fail_loc=0
11750 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11755 test_mkdir -p $DIR/$tdir
11756 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11757 createmany -o $DIR/$tdir/$tfile 10
11758 cancel_lru_locks mdc
11759 cancel_lru_locks osc
11760 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11761 $LCTL set_param fail_loc=0x31b
11762 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11763 $LCTL set_param fail_loc=0
11766 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11768 test_224a() { # LU-1039, MRP-303
11769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11770 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11771 $LCTL set_param fail_loc=0x508
11772 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11773 $LCTL set_param fail_loc=0
11776 run_test 224a "Don't panic on bulk IO failure"
11778 test_224b() { # LU-1039, MRP-303
11779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11780 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11781 cancel_lru_locks osc
11782 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11783 $LCTL set_param fail_loc=0x515
11784 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11785 $LCTL set_param fail_loc=0
11788 run_test 224b "Don't panic on bulk IO failure"
11790 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11792 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11793 if [ -z ${MDSSURVEY} ]; then
11794 skip_env "mds-survey not found" && return
11797 [ $MDSCOUNT -ge 2 ] &&
11798 skip "skipping now for more than one MDT" && return
11800 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11801 { skip "Need MDS version at least 2.2.51"; return; }
11803 local mds=$(facet_host $SINGLEMDS)
11804 local target=$(do_nodes $mds 'lctl dl' | \
11805 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11807 local cmd1="file_count=1000 thrhi=4"
11808 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11809 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11810 local cmd="$cmd1 $cmd2 $cmd3"
11812 rm -f ${TMP}/mds_survey*
11814 eval $cmd || error "mds-survey with zero-stripe failed"
11815 cat ${TMP}/mds_survey*
11816 rm -f ${TMP}/mds_survey*
11818 run_test 225a "Metadata survey sanity with zero-stripe"
11821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11823 if [ -z ${MDSSURVEY} ]; then
11824 skip_env "mds-survey not found" && return
11826 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11827 { skip "Need MDS version at least 2.2.51"; return; }
11829 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11830 skip_env "Need to mount OST to test" && return
11833 [ $MDSCOUNT -ge 2 ] &&
11834 skip "skipping now for more than one MDT" && return
11835 local mds=$(facet_host $SINGLEMDS)
11836 local target=$(do_nodes $mds 'lctl dl' | \
11837 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11839 local cmd1="file_count=1000 thrhi=4"
11840 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11841 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11842 local cmd="$cmd1 $cmd2 $cmd3"
11844 rm -f ${TMP}/mds_survey*
11846 eval $cmd || error "mds-survey with stripe_count failed"
11847 cat ${TMP}/mds_survey*
11848 rm -f ${TMP}/mds_survey*
11850 run_test 225b "Metadata survey sanity with stripe_count = 1"
11852 mcreate_path2fid () {
11858 local path=$DIR/$tdir/$name
11863 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11864 error "cannot create $desc"
11866 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11868 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11870 fid_path=$($LFS fid2path $MOUNT $fid)
11872 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11874 [ "$path" == "$fid_path" ] ||
11875 error "fid2path returned $fid_path, expected $path"
11877 echo "pass with $path and $fid"
11882 mkdir -p $DIR/$tdir
11884 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11885 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11886 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11887 mcreate_path2fid 0040666 0 0 dir "directory"
11888 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11889 mcreate_path2fid 0100666 0 0 file "regular file"
11890 mcreate_path2fid 0120666 0 0 link "symbolic link"
11891 mcreate_path2fid 0140666 0 0 sock "socket"
11893 run_test 226a "call path2fid and fid2path on files of all type"
11896 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11900 mkdir -p $DIR/$tdir
11901 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11902 error "create remote directory failed"
11903 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11904 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11905 "character special file (null)"
11906 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11907 "character special file (no device)"
11908 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11909 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11910 "block special file (loop)"
11911 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11912 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11913 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11915 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11917 # LU-1299 Executing or running ldd on a truncated executable does not
11918 # cause an out-of-memory condition.
11920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11921 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
11922 dd if=$(which date) of=$MOUNT/date bs=1k count=1
11923 chmod +x $MOUNT/date
11925 $MOUNT/date > /dev/null
11926 ldd $MOUNT/date > /dev/null
11929 run_test 227 "running truncated executable does not cause OOM"
11931 # LU-1512 try to reuse idle OI blocks
11933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11934 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11935 skip "non-ldiskfs backend" && return
11937 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11938 local myDIR=$DIR/$tdir
11941 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11942 $LCTL set_param fail_loc=0x80001002
11943 createmany -o $myDIR/t- 10000
11944 $LCTL set_param fail_loc=0
11945 # The guard is current the largest FID holder
11947 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11949 local IDX=$(($SEQ % 64))
11951 do_facet $SINGLEMDS sync
11952 # Make sure journal flushed.
11954 local blk1=$(do_facet $SINGLEMDS \
11955 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11956 grep Blockcount | awk '{print $4}')
11958 # Remove old files, some OI blocks will become idle.
11959 unlinkmany $myDIR/t- 10000
11960 # Create new files, idle OI blocks should be reused.
11961 createmany -o $myDIR/t- 2000
11962 do_facet $SINGLEMDS sync
11963 # Make sure journal flushed.
11965 local blk2=$(do_facet $SINGLEMDS \
11966 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11967 grep Blockcount | awk '{print $4}')
11969 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11971 run_test 228a "try to reuse idle OI blocks"
11974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11975 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11976 skip "non-ldiskfs backend" && return
11978 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11979 local myDIR=$DIR/$tdir
11982 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11983 $LCTL set_param fail_loc=0x80001002
11984 createmany -o $myDIR/t- 10000
11985 $LCTL set_param fail_loc=0
11986 # The guard is current the largest FID holder
11988 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11990 local IDX=$(($SEQ % 64))
11992 do_facet $SINGLEMDS sync
11993 # Make sure journal flushed.
11995 local blk1=$(do_facet $SINGLEMDS \
11996 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11997 grep Blockcount | awk '{print $4}')
11999 # Remove old files, some OI blocks will become idle.
12000 unlinkmany $myDIR/t- 10000
12003 stop $SINGLEMDS || error "Fail to stop MDT."
12005 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12007 df $MOUNT || error "Fail to df."
12008 # Create new files, idle OI blocks should be reused.
12009 createmany -o $myDIR/t- 2000
12010 do_facet $SINGLEMDS sync
12011 # Make sure journal flushed.
12013 local blk2=$(do_facet $SINGLEMDS \
12014 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12015 grep Blockcount | awk '{print $4}')
12017 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12019 run_test 228b "idle OI blocks can be reused after MDT restart"
12023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12024 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12025 skip "non-ldiskfs backend" && return
12027 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12028 local myDIR=$DIR/$tdir
12031 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12032 $LCTL set_param fail_loc=0x80001002
12033 # 20000 files can guarantee there are index nodes in the OI file
12034 createmany -o $myDIR/t- 20000
12035 $LCTL set_param fail_loc=0
12036 # The guard is current the largest FID holder
12038 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12040 local IDX=$(($SEQ % 64))
12042 do_facet $SINGLEMDS sync
12043 # Make sure journal flushed.
12045 local blk1=$(do_facet $SINGLEMDS \
12046 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12047 grep Blockcount | awk '{print $4}')
12049 # Remove old files, some OI blocks will become idle.
12050 unlinkmany $myDIR/t- 20000
12052 # The OI file should become empty now
12054 # Create new files, idle OI blocks should be reused.
12055 createmany -o $myDIR/t- 2000
12056 do_facet $SINGLEMDS sync
12057 # Make sure journal flushed.
12059 local blk2=$(do_facet $SINGLEMDS \
12060 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12061 grep Blockcount | awk '{print $4}')
12063 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12065 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12067 test_229() { # LU-2482, LU-3448
12068 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12069 skip "No HSM support on MDS of $(get_lustre_version)," \
12070 "need 2.4.53 at least" && return
12071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12072 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12076 # Create a file with a released layout and stripe count 2.
12077 $MULTIOP $DIR/$tfile H2c ||
12078 error "failed to create file with released layout"
12080 $GETSTRIPE -v $DIR/$tfile
12082 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12083 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12085 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12086 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12087 stat $DIR/$tfile || error "failed to stat released file"
12089 chown $RUNAS_ID $DIR/$tfile ||
12090 error "chown $RUNAS_ID $DIR/$tfile failed"
12092 chgrp $RUNAS_ID $DIR/$tfile ||
12093 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12095 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12096 rm $DIR/$tfile || error "failed to remove released file"
12098 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12102 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12105 mkdir -p $DIR/$tdir/test_230_local
12106 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12107 [ $mdt_idx -ne 0 ] &&
12108 error "create local directory on wrong MDT $mdt_idx"
12110 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12111 error "create remote directory failed"
12112 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12113 [ $mdt_idx -ne $MDTIDX ] &&
12114 error "create remote directory on wrong MDT $mdt_idx"
12116 createmany -o $DIR/$tdir/test_230/t- 10 ||
12117 error "create files on remote directory failed"
12118 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12119 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12120 rm -r $DIR/$tdir || error "unlink remote directory failed"
12122 run_test 230a "Create remote directory and files under the remote directory"
12125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12126 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12133 local migrate_dir=$DIR/$tdir/migrate_dir
12134 local other_dir=$DIR/$tdir/other_dir
12136 mkdir -p $migrate_dir
12137 mkdir -p $other_dir
12138 for ((i=0; i<10; i++)); do
12139 mkdir -p $migrate_dir/dir_${i}
12140 createmany -o $migrate_dir/dir_${i}/f 10 ||
12141 error "create files under remote dir failed $i"
12144 cp /etc/passwd $migrate_dir/$tfile
12145 cp /etc/passwd $other_dir/$tfile
12146 chattr +SAD $migrate_dir
12147 chattr +SAD $migrate_dir/$tfile
12149 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12150 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12151 local old_dir_mode=$(stat -c%f $migrate_dir)
12152 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12154 mkdir -p $migrate_dir/dir_default_stripe2
12155 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12156 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12158 mkdir -p $other_dir
12159 ln $migrate_dir/$tfile $other_dir/luna
12160 ln $migrate_dir/$tfile $migrate_dir/sofia
12161 ln $other_dir/$tfile $migrate_dir/david
12162 ln -s $migrate_dir/$tfile $other_dir/zachary
12163 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12164 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12166 $LFS mv -v -M $MDTIDX $migrate_dir ||
12167 error "migrate remote dir error"
12169 echo "migratate to MDT1, then checking.."
12170 for ((i=0; i<10; i++)); do
12171 for file in $(find $migrate_dir/dir_${i}); do
12172 mdt_index=$($LFS getstripe -M $file)
12173 [ $mdt_index == $MDTIDX ] ||
12174 error "$file is not on MDT${MDTIDX}"
12178 # the multiple link file should still in MDT0
12179 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12180 [ $mdt_index == 0 ] ||
12181 error "$file is not on MDT${MDTIDX}"
12183 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12184 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12185 error " expect $old_dir_flag get $new_dir_flag"
12187 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12188 [ "$old_file_flag" = "$new_file_flag" ] ||
12189 error " expect $old_file_flag get $new_file_flag"
12191 local new_dir_mode=$(stat -c%f $migrate_dir)
12192 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12193 error "expect mode $old_dir_mode get $new_dir_mode"
12195 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12196 [ "$old_file_mode" = "$new_file_mode" ] ||
12197 error "expect mode $old_file_mode get $new_file_mode"
12199 diff /etc/passwd $migrate_dir/$tfile ||
12200 error "$tfile different after migration"
12202 diff /etc/passwd $other_dir/luna ||
12203 error "luna different after migration"
12205 diff /etc/passwd $migrate_dir/sofia ||
12206 error "sofia different after migration"
12208 diff /etc/passwd $migrate_dir/david ||
12209 error "david different after migration"
12211 diff /etc/passwd $other_dir/zachary ||
12212 error "zachary different after migration"
12214 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12215 error "${tfile}_ln different after migration"
12217 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12218 error "${tfile}_ln_other different after migration"
12220 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12221 [ $stripe_count = 2 ] ||
12222 error "dir strpe_count $d != 2 after migration."
12224 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12225 [ $stripe_count = 2 ] ||
12226 error "file strpe_count $d != 2 after migration."
12228 #migrate back to MDT0
12230 $LFS mv -v -M $MDTIDX $migrate_dir ||
12231 error "migrate remote dir error"
12233 echo "migrate back to MDT0, checking.."
12234 for file in $(find $migrate_dir); do
12235 mdt_index=$($LFS getstripe -M $file)
12236 [ $mdt_index == $MDTIDX ] ||
12237 error "$file is not on MDT${MDTIDX}"
12240 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12241 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12242 error " expect $old_dir_flag get $new_dir_flag"
12244 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12245 [ "$old_file_flag" = "$new_file_flag" ] ||
12246 error " expect $old_file_flag get $new_file_flag"
12248 local new_dir_mode=$(stat -c%f $migrate_dir)
12249 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12250 error "expect mode $old_dir_mode get $new_dir_mode"
12252 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12253 [ "$old_file_mode" = "$new_file_mode" ] ||
12254 error "expect mode $old_file_mode get $new_file_mode"
12256 diff /etc/passwd ${migrate_dir}/$tfile ||
12257 error "$tfile different after migration"
12259 diff /etc/passwd ${other_dir}/luna ||
12260 error "luna different after migration"
12262 diff /etc/passwd ${migrate_dir}/sofia ||
12263 error "sofia different after migration"
12265 diff /etc/passwd ${other_dir}/zachary ||
12266 error "zachary different after migration"
12268 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12269 error "${tfile}_ln different after migration"
12271 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12272 error "${tfile}_ln_other different after migration"
12274 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12275 [ $stripe_count = 2 ] ||
12276 error "dir strpe_count $d != 2 after migration."
12278 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12279 [ $stripe_count = 2 ] ||
12280 error "file strpe_count $d != 2 after migration."
12282 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12284 run_test 230b "migrate directory"
12287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12288 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12293 #If migrating directory fails in the middle, all entries of
12294 #the directory is still accessiable.
12295 mkdir -p $DIR/$tdir
12297 createmany -o $DIR/$tdir/f 10 ||
12298 error "create files under ${tdir} failed"
12300 #failed after migrating 5 entries
12301 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12302 do_facet mds1 lctl set_param fail_loc=0x20001801
12303 do_facet mds1 lctl set_param fail_val=5
12304 local t=`ls $DIR/$tdir | wc -l`
12305 $LFS mv -M $MDTIDX $DIR/$tdir &&
12306 error "migrate should failed after 5 entries"
12307 local u=`ls $DIR/$tdir | wc -l`
12308 [ "$u" == "$t" ] || error "$u != $t during migration"
12310 for file in $(find $DIR/$tdir); do
12311 stat $file || error "stat $file failed"
12314 do_facet mds1 lctl set_param fail_loc=0
12315 do_facet mds1 lctl set_param fail_val=0
12317 $LFS mv -M $MDTIDX $DIR/$tdir ||
12318 error "migrate open files should failed with open files"
12320 echo "Finish migration, then checking.."
12321 for file in $(find $DIR/$tdir); do
12322 mdt_index=$($LFS getstripe -M $file)
12323 [ $mdt_index == $MDTIDX ] ||
12324 error "$file is not on MDT${MDTIDX}"
12327 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12329 run_test 230c "check directory accessiblity if migration is failed"
12332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12333 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12339 mkdir -p $DIR/$tdir
12341 for ((i=0; i<100; i++)); do
12342 mkdir -p $DIR/$tdir/dir_${i}
12343 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12344 error "create files under remote dir failed $i"
12347 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12349 echo "Finish migration, then checking.."
12350 for file in $(find $DIR/$tdir); do
12351 mdt_index=$($LFS getstripe -M $file)
12352 [ $mdt_index == $MDTIDX ] ||
12353 error "$file is not on MDT${MDTIDX}"
12356 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12358 run_test 230d "check migrate big directory"
12362 # For simplicity this test assumes that max_pages_per_rpc
12363 # is the same across all OSCs
12364 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12365 local bulk_size=$((max_pages * 4096))
12367 mkdir -p $DIR/$tdir
12369 # clear the OSC stats
12370 $LCTL set_param osc.*.stats=0 &>/dev/null
12372 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12373 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12374 oflag=direct &>/dev/null || error "dd failed"
12376 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12377 if [ x$nrpcs != "x1" ]; then
12378 error "found $nrpc ost_write RPCs, not 1 as expected"
12381 # Drop the OSC cache, otherwise we will read from it
12382 cancel_lru_locks osc
12384 # clear the OSC stats
12385 $LCTL set_param osc.*.stats=0 &>/dev/null
12387 # Client reads $bulk_size.
12388 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12389 iflag=direct &>/dev/null || error "dd failed"
12391 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12392 if [ x$nrpcs != "x1" ]; then
12393 error "found $nrpc ost_read RPCs, not 1 as expected"
12396 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12399 mkdir -p $DIR/$tdir
12401 for i in {0..1023}; do
12402 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12403 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12404 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12408 run_test 231b "must not assert on fully utilized OST request buffer"
12411 mkdir -p $DIR/$tdir
12412 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12413 $LCTL set_param fail_loc=0x31c
12415 # ignore dd failure
12416 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12418 $LCTL set_param fail_loc=0
12419 umount_client $MOUNT || error "umount failed"
12420 mount_client $MOUNT || error "mount failed"
12422 run_test 232 "failed lock should not block umount"
12425 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12426 { skip "Need MDS version at least 2.3.64"; return; }
12428 local fid=$($LFS path2fid $MOUNT)
12429 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12430 error "cannot access $MOUNT using its FID '$fid'"
12432 run_test 233a "checking that OBF of the FS root succeeds"
12435 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12436 { skip "Need MDS version at least 2.5.90"; return; }
12438 local fid=$($LFS path2fid $MOUNT/.lustre)
12439 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12440 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12442 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12443 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12444 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12446 run_test 233b "checking that OBF of the FS .lustre succeeds"
12449 local p="$TMP/sanityN-$TESTNAME.parameters"
12450 save_lustre_params client "llite.*.xattr_cache" > $p
12451 lctl set_param llite.*.xattr_cache 1 ||
12452 { skip "xattr cache is not supported"; return 0; }
12454 mkdir -p $DIR/$tdir || error "mkdir failed"
12455 touch $DIR/$tdir/$tfile || error "touch failed"
12456 # OBD_FAIL_LLITE_XATTR_ENOMEM
12457 $LCTL set_param fail_loc=0x1405
12458 if [ ! -f /etc/SuSE-release ]; then
12459 # attr pre-2.4.44-7 had a bug with rc
12460 # LU-3703 - SLES clients have older attr
12461 getfattr -n user.attr $DIR/$tdir/$tfile &&
12462 error "getfattr should have failed with ENOMEM"
12464 $LCTL set_param fail_loc=0x0
12467 restore_lustre_params < $p
12470 run_test 234 "xattr cache should not crash on ENOMEM"
12473 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12474 skip "Need MDS version at least 2.4.52" && return
12475 flock_deadlock $DIR/$tfile
12480 124) error "process hangs on a deadlock"
12482 *) error "error executing flock_deadlock $DIR/$tfile"
12486 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12490 check_swap_layouts_support && return 0
12491 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12493 local ref1=/etc/passwd
12494 local ref2=/etc/group
12495 local file1=$DIR/$tdir/f1
12496 local file2=$DIR/$tdir/f2
12498 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12499 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12500 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12501 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12502 local fd=$(free_fd)
12503 local cmd="exec $fd<>$file2"
12506 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12507 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12510 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12515 run_test 236 "Layout swap on open unlinked file"
12517 # test to verify file handle related system calls
12518 # (name_to_handle_at/open_by_handle_at)
12519 # The new system calls are supported in glibc >= 2.14.
12522 echo "Test file_handle syscalls" > $DIR/$tfile
12523 check_fhandle_syscalls $DIR/$tfile ||
12524 error "check_fhandle_syscalls failed"
12526 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12528 # LU-4659 linkea consistency
12531 ln $DIR/$tfile $DIR/$tfile.lnk
12532 touch $DIR/$tfile.new
12533 mv $DIR/$tfile.new $DIR/$tfile
12534 local fid1=$(lfs path2fid $DIR/$tfile)
12535 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12536 local path1=$(lfs fid2path $FSNAME $fid1)
12537 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12538 local path2=$(lfs fid2path $FSNAME $fid2)
12539 [ $tfile.lnk == $path2 ] ||
12540 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12543 run_test 238 "Verify linkea consistency"
12545 test_striped_dir() {
12550 mkdir -p $DIR/$tdir
12551 $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
12552 error "set striped dir error"
12554 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12555 if [ "$stripe_count" != "2" ]; then
12556 error "stripe_count is $stripe_count, expect 2"
12559 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12560 if [ "$stripe_index" != "$mdt_index" ]; then
12561 error "stripe_index is $stripe_index, expect $mdt_index"
12564 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12565 error "nlink error after create striped dir"
12567 mkdir $DIR/$tdir/striped_dir/a
12568 mkdir $DIR/$tdir/striped_dir/b
12570 stat $DIR/$tdir/striped_dir/a ||
12571 error "create dir under striped dir failed"
12572 stat $DIR/$tdir/striped_dir/b ||
12573 error "create dir under striped dir failed"
12575 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12576 error "nlink error after mkdir"
12578 rmdir $DIR/$tdir/striped_dir/a
12579 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12580 error "nlink error after rmdir"
12582 rmdir $DIR/$tdir/striped_dir/b
12583 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12584 error "nlink error after rmdir"
12586 rmdir $DIR/$tdir/striped_dir ||
12587 error "rmdir striped dir error"
12592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12595 test_striped_dir 0 || error "failed on striped dir on MDT0"
12596 test_striped_dir 1 || error "failed on striped dir on MDT0"
12598 run_test 300a "basic striped dir sanity test"
12601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12602 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12608 test_mkdir $DIR/$tdir || error "mkdir fail"
12609 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12610 error "set striped dir error"
12611 for ((i=0; i<10; i++)); do
12612 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12614 touch $DIR/$tdir/striped_dir/file_$i ||
12615 error "touch error $i"
12616 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12617 [ $mtime1 -eq $mtime2 ] &&
12618 error "mtime not change after create"
12620 rm -f $DIR/$tdir/striped_dir/file_$i ||
12621 error "unlink error $i"
12622 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12623 [ $mtime2 -eq $mtime3 ] &&
12624 error "mtime did not change after unlink"
12628 run_test 300b "check ctime/mtime for striped dir"
12631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12632 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12635 mkdir -p $DIR/$tdir
12636 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12637 error "set striped dir error"
12639 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12640 error "chown striped dir failed"
12642 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12643 error "create 5k files failed"
12645 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12647 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12651 run_test 300c "chown && check ls under striped directory"
12654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12655 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12659 mkdir -p $DIR/$tdir
12660 $SETSTRIPE -c 2 $DIR/$tdir
12662 #local striped directory
12663 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12664 error "set striped dir error"
12665 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12666 error "create 10 files failed"
12668 #remote striped directory
12669 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12670 error "set striped dir error"
12671 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12672 error "create 10 files failed"
12674 for file in $(find $DIR/$tdir); do
12675 stripe_count=$($GETSTRIPE -c $file)
12676 [ $stripe_count -eq 2 ] ||
12677 error "wrong stripe $stripe_count for $file"
12682 run_test 300d "check default stripe under striped directory"
12685 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12686 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12690 mkdir -p $DIR/$tdir
12692 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12693 error "set striped dir error"
12695 touch $DIR/$tdir/striped_dir/a
12696 touch $DIR/$tdir/striped_dir/b
12697 touch $DIR/$tdir/striped_dir/c
12699 mkdir $DIR/$tdir/striped_dir/dir_a
12700 mkdir $DIR/$tdir/striped_dir/dir_b
12701 mkdir $DIR/$tdir/striped_dir/dir_c
12703 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12704 error "set striped dir under striped dir error"
12706 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12707 error "set striped dir under striped dir error"
12709 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12710 error "set striped dir under striped dir error"
12712 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12713 error "rename file under striped dir should fail"
12715 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12716 error "rename dir under striped dir should fail"
12718 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12719 error "rename dir under different stripes should fail"
12721 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12722 error "rename file under striped dir should succeed"
12724 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12725 error "rename dir under striped dir should succeed"
12729 run_test 300e "check rename under striped directory"
12732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12733 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12738 mkdir -p $DIR/$tdir
12740 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12741 error "set striped dir error"
12743 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12744 error "set striped dir error"
12746 touch $DIR/$tdir/striped_dir/a
12747 mkdir $DIR/$tdir/striped_dir/dir_a
12748 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12749 error "create striped dir under striped dir fails"
12751 touch $DIR/$tdir/striped_dir1/b
12752 mkdir $DIR/$tdir/striped_dir1/dir_b
12753 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12754 error "create striped dir under striped dir fails"
12756 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12757 error "rename file under different striped dir should fail"
12759 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12760 error "rename dir under different striped dir should fail"
12762 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12763 error "rename striped dir under diff striped dir should fail"
12765 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12766 error "rename file under diff striped dirs fails"
12768 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12769 error "rename dir under diff striped dirs fails"
12773 run_test 300f "check rename cross striped directory"
12776 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12781 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12782 $DIR/$tdir/striped_dir ||
12783 error "set striped dir error"
12785 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12786 error "set default stripe on striped dir error"
12788 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12790 for dir in $(find $DIR/$tdir/striped_dir/*); do
12791 stripe_count=$($LFS getdirstripe -c $dir)
12792 [ $stripe_count -eq $MDSCOUNT ] ||
12793 error "expect $MDSCOUNT get $stripe_count for $dir"
12796 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12797 #change default stripe count to 2
12798 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12799 error "set default stripe on striped dir error"
12801 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12803 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12805 #change default stripe count to 1
12806 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
12807 error "set default stripe on striped dir error"
12809 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12810 for dir in $(find $DIR/$tdir/striped_dir/*); do
12811 stripe_count=$($LFS getdirstripe -c $dir)
12812 [ $stripe_count -eq 1 ] ||
12813 error "expect 1 get $stripe_count for $dir"
12815 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
12817 run_test 300g "check default striped directory for striped directory"
12819 test_400a() { # LU-1606, was conf-sanity test_74
12820 local extra_flags=''
12821 local out=$TMP/$tfile
12822 local prefix=/usr/include/lustre
12825 if ! which $CC > /dev/null 2>&1; then
12826 skip_env "$CC is not installed"
12830 if ! [[ -d $prefix ]]; then
12831 # Assume we're running in tree and fixup the include path.
12832 extra_flags+=" -I$LUSTRE/../libcfs/include"
12833 extra_flags+=" -I$LUSTRE/include"
12834 extra_flags+=" -L$LUSTRE/utils"
12837 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
12838 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
12839 error "client api broken"
12842 run_test 400a "Lustre client api program can compile and link"
12844 test_400b() { # LU-1606, LU-5011
12846 local out=$TMP/$tfile
12847 local prefix=/usr/include/lustre
12849 # We use a hard coded prefix so that this test will not fail
12850 # when run in tree. There are headers in lustre/include/lustre/
12851 # that are not packaged (like lustre_idl.h) and have more
12852 # complicated include dependencies (like config.h and lnet/types.h).
12853 # Since this test about correct packaging we just skip them when
12854 # they don't exist (see below) rather than try to fixup cppflags.
12856 if ! which $CC > /dev/null 2>&1; then
12857 skip_env "$CC is not installed"
12861 for header in $prefix/*.h; do
12862 if ! [[ -f "$header" ]]; then
12866 if [[ "$(basename $header)" == liblustreapi.h ]]; then
12867 continue # liblustreapi.h is deprecated.
12870 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
12871 error "cannot compile '$header'"
12874 run_test 400b "packaged headers can be compiled"
12877 # tests that do cleanup/setup should be run at the end
12881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12883 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12884 $LCTL set_param fail_loc=0x903
12885 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12886 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12889 FAIL_ON_ERROR=true cleanup
12890 FAIL_ON_ERROR=true setup
12892 run_test 900 "umount should not race with any mgc requeue thread"
12895 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
12896 check_and_cleanup_lustre
12897 if [ "$I_MOUNTED" != "yes" ]; then
12898 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true