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 ] ||
4495 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4497 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4498 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4499 NUMS=$($CMD | wc -l)
4500 [ $NUMS -eq $EXPECTED ] ||
4501 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4504 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4505 NUMS=$($CMD | wc -l)
4506 [ $NUMS -eq $EXPECTED ] ||
4507 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4509 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4510 NUMS=$($CMD | wc -l)
4511 [ $NUMS -eq $EXPECTED ] ||
4512 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4515 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4516 NUMS=$($CMD | wc -l)
4517 [ $NUMS -eq $EXPECTED ] ||
4518 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4520 run_test 56s "check lfs find -stripe-count works"
4522 test_56t() { # LU-611
4524 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4526 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4528 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4529 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4530 NUMS=$($CMD | wc -l)
4531 [ $NUMS -eq $EXPECTED ] ||
4532 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4534 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4535 NUMS=$($CMD | wc -l)
4536 [ $NUMS -eq $EXPECTED ] ||
4537 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4539 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4540 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4541 NUMS=$($CMD | wc -l)
4542 [ $NUMS -eq $EXPECTED ] ||
4543 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4545 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4546 NUMS=$($CMD | wc -l)
4547 [ $NUMS -eq $EXPECTED ] ||
4548 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4551 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4552 NUMS=$($CMD | wc -l)
4553 [ $NUMS -eq $EXPECTED ] ||
4554 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4556 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4557 NUMS=$($CMD | wc -l)
4558 [ $NUMS -eq $EXPECTED ] ||
4559 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4562 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4563 NUMS=$($CMD | wc -l)
4564 [ $NUMS -eq $EXPECTED ] ||
4565 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4567 run_test 56t "check lfs find -stripe-size works"
4569 test_56u() { # LU-611
4571 setup_56 $NUMFILES $NUMDIRS "-i 0"
4573 if [[ $OSTCOUNT -gt 1 ]]; then
4574 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4580 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4581 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4582 NUMS=$($CMD | wc -l)
4583 [ $NUMS -eq $EXPECTED ] ||
4584 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4587 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4588 NUMS=$($CMD | wc -l)
4589 [ $NUMS -eq $EXPECTED ] ||
4590 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4592 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4593 NUMS=$($CMD | wc -l)
4594 [ $NUMS -eq $EXPECTED ] ||
4595 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4598 # This should produce an error and not return any files
4599 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4600 NUMS=$($CMD 2>/dev/null | wc -l)
4601 [ $NUMS -eq $EXPECTED ] ||
4602 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4604 if [[ $OSTCOUNT -gt 1 ]]; then
4605 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4606 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4607 NUMS=$($CMD | wc -l)
4608 [ $NUMS -eq $EXPECTED ] ||
4609 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4612 run_test 56u "check lfs find -stripe-index works"
4619 setup_56 $NUMFILES $NUMDIRS
4621 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4622 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4624 for file in $($LFIND -mdt $UUID $TDIR); do
4625 file_mdt_idx=$($GETSTRIPE -M $file)
4626 [ $file_mdt_idx -eq $MDT_IDX ] ||
4627 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4630 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4632 # Get and check the actual stripe count of one file.
4633 # Usage: check_stripe_count <file> <expected_stripe_count>
4634 check_stripe_count() {
4639 [[ -z "$file" || -z "$expected" ]] &&
4640 error "check_stripe_count: invalid argument!"
4642 local cmd="$GETSTRIPE -c $file"
4643 actual=$($cmd) || error "$cmd failed"
4644 actual=${actual%% *}
4646 if [[ $actual -ne $expected ]]; then
4647 [[ $expected -eq -1 ]] ||
4648 error "$cmd wrong: found $actual, expected $expected"
4649 [[ $actual -eq $OSTCOUNT ]] ||
4650 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4655 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4658 rm -rf $TDIR || error "remove $TDIR failed"
4659 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4662 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4663 error "$GETSTRIPE -S -d $TDIR failed"
4664 stripe_size=${stripe_size%% *}
4666 local file_size=$((stripe_size * OSTCOUNT))
4667 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4668 local required_space=$((file_num * file_size))
4669 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4670 [[ $free_space -le $((required_space / 1024)) ]] &&
4671 skip_env "need at least $required_space bytes free space," \
4672 "have $free_space kbytes" && return
4675 local dd_count=$((file_size / dd_bs))
4677 # write data into the files
4681 for i in $(seq 1 $NUMFILES); do
4683 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4684 error "write data into $file failed"
4686 for i in $(seq 1 $NUMDIRS); do
4687 for j in $(seq 1 $NUMFILES); do
4688 file=$TDIR/dir$i/file$j
4689 yes | dd bs=$dd_bs count=$dd_count of=$file \
4691 error "write data into $file failed"
4696 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4699 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4701 eval $cmd || error "$cmd failed"
4703 check_stripe_count $TDIR/file1 $expected
4706 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4708 eval $cmd || error "$cmd failed"
4710 for j in $(seq 1 $NUMFILES); do
4711 check_stripe_count $TDIR/dir1/file$j $expected
4714 # lfs_migrate works with lfs find
4715 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4716 $LFS_MIGRATE -y -c $expected"
4718 eval $cmd || error "$cmd failed"
4720 for i in $(seq 2 $NUMFILES); do
4721 check_stripe_count $TDIR/file$i $expected
4723 for i in $(seq 2 $NUMDIRS); do
4724 for j in $(seq 1 $NUMFILES); do
4725 check_stripe_count $TDIR/dir$i/file$j $expected
4729 run_test 56w "check lfs_migrate -c stripe_count works"
4732 check_swap_layouts_support && return 0
4733 [[ $OSTCOUNT -lt 2 ]] &&
4734 skip_env "need 2 OST, skipping test" && return
4736 local dir0=$DIR/$tdir/$testnum
4737 mkdir -p $dir0 || error "creating dir $dir0"
4739 local ref1=/etc/passwd
4740 local file1=$dir0/file1
4742 $SETSTRIPE -c 2 $file1
4744 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4745 stripe=$($GETSTRIPE -c $file1)
4746 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4747 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4752 run_test 56x "lfs migration support"
4755 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4756 skip "No HSM support on MDS of $(get_lustre_version)," \
4757 "need 2.4.53 at least" && return
4760 local dir0=$DIR/$tdir/$testnum
4761 mkdir -p $dir0 || error "creating dir $dir0"
4762 local f1=$dir0/file1
4763 local f2=$dir0/file2
4765 touch $f1 || error "creating std file $f1"
4766 $MULTIOP $f2 H2c || error "creating released file $f2"
4768 # a directory can be raid0, so ask only for files
4769 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4770 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4772 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4773 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4775 # only files can be released, so no need to force file search
4776 res=$($LFIND $dir0 -L released)
4777 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4779 res=$($LFIND $dir0 \! -L released)
4780 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4783 run_test 56y "lfs find -L raid0|released"
4786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4787 # note test will not do anything if MDS is not local
4788 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4789 skip "Only applicable to ldiskfs-based MDTs"
4793 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4794 local MNTDEV="osd*.*MDT*.mntdev"
4795 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4796 [ -z "$DEV" ] && error "can't access $MNTDEV"
4797 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4798 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4799 error "can't access $DEV"
4800 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4801 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4805 run_test 57a "verify MDS filesystem created with large inodes =="
4808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4809 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4810 skip "Only applicable to ldiskfs-based MDTs"
4814 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4819 local FILEN=$dir/f$FILECOUNT
4821 rm -rf $dir || error "removing $dir"
4822 test_mkdir -p $dir || error "creating $dir"
4823 local num=$(get_mds_dir $dir)
4826 echo "mcreating $FILECOUNT files"
4827 createmany -m $dir/f 1 $FILECOUNT || \
4828 error "creating files in $dir"
4830 # verify that files do not have EAs yet
4831 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4832 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4836 df $dir #make sure we get new statfs data
4837 local MDSFREE=$(do_facet $mymds \
4838 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4839 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4840 echo "opening files to create objects/EAs"
4842 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4843 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4846 # verify that files have EAs now
4847 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4848 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4850 sleep 1 #make sure we get new statfs data
4852 local MDSFREE2=$(do_facet $mymds \
4853 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4854 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4855 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
4856 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4857 error "MDC before $MDCFREE != after $MDCFREE2"
4859 echo "MDC before $MDCFREE != after $MDCFREE2"
4860 echo "unable to confirm if MDS has large inodes"
4865 run_test 57b "default LOV EAs are stored inside large inodes ==="
4868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4869 [ -z "$(which wiretest 2>/dev/null)" ] &&
4870 skip_env "could not find wiretest" && return
4873 run_test 58 "verify cross-platform wire constants =============="
4876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4877 echo "touch 130 files"
4878 createmany -o $DIR/f59- 130
4880 unlinkmany $DIR/f59- 130
4882 # wait for commitment of removal
4883 wait_delete_completed
4885 run_test 59 "verify cancellation of llog records async ========="
4887 TEST60_HEAD="test_60 run $RANDOM"
4889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4890 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4891 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4892 skip_env "missing subtest run-llog.sh" && return
4893 log "$TEST60_HEAD - from kernel mode"
4894 do_facet mgs sh run-llog.sh
4896 run_test 60a "llog sanity tests run from kernel module =========="
4898 test_60b() { # bug 6411
4899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4901 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4913 [[ $LLOG_COUNT -gt 50 ]] &&
4914 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
4916 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4920 echo "create 5000 files"
4921 createmany -o $DIR/f60c- 5000
4922 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4923 lctl set_param fail_loc=0x80000137
4924 unlinkmany $DIR/f60c- 5000
4925 lctl set_param fail_loc=0
4927 run_test 60c "unlink file when mds full"
4930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4931 SAVEPRINTK=$(lctl get_param -n printk)
4933 # verify "lctl mark" is even working"
4934 MESSAGE="test message ID $RANDOM $$"
4935 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4936 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4938 lctl set_param printk=0 || error "set lnet.printk failed"
4939 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4940 MESSAGE="new test message ID $RANDOM $$"
4941 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4942 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4943 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4945 lctl set_param -n printk="$SAVEPRINTK"
4947 run_test 60d "test printk console message masking"
4950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4952 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4953 cancel_lru_locks osc
4954 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4957 run_test 61 "mmap() writes don't make sync hang ================"
4959 # bug 2330 - insufficient obd_match error checking causes LBUG
4961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4964 cancel_lru_locks osc
4965 lctl set_param fail_loc=0x405
4966 cat $f && error "cat succeeded, expect -EIO"
4967 lctl set_param fail_loc=0
4969 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4970 # match every page all of the time.
4971 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4973 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4974 # Though this test is irrelevant anymore, it helped to reveal some
4975 # other grant bugs (LU-4482), let's keep it.
4976 test_63a() { # was test_63
4977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4978 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4979 for i in `seq 10` ; do
4980 dd if=/dev/zero of=$DIR/f63 bs=8k &
4986 rm -f $DIR/f63 || true
4988 run_test 63a "Verify oig_wait interruption does not crash ======="
4990 # bug 2248 - async write errors didn't return to application on sync
4991 # bug 3677 - async write errors left page locked
4993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4995 lctl set_param debug=-1
4997 # ensure we have a grant to do async writes
4998 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5001 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5002 lctl set_param fail_loc=0x80000406
5003 $MULTIOP $DIR/$tfile Owy && \
5004 error "sync didn't return ENOMEM"
5005 sync; sleep 2; sync # do a real sync this time to flush page
5006 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5007 error "locked page left in cache after async error" || true
5010 run_test 63b "async write errors should be returned to fsync ==="
5013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5015 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5017 run_test 64a "verify filter grant calculations (in kernel) ====="
5020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5021 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5023 run_test 64b "check out-of-space detection on client ==========="
5026 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5028 run_test 64c "verify grant shrink ========================------"
5030 # bug 1414 - set/get directories' stripe info
5032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5033 test_mkdir -p $DIR/$tdir
5035 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5037 run_test 65a "directory with no stripe info ===================="
5040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5041 test_mkdir -p $DIR/$tdir
5042 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5045 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5047 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5051 if [[ $OSTCOUNT -gt 1 ]]; then
5052 test_mkdir -p $DIR/$tdir
5053 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5054 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5056 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5059 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5063 test_mkdir -p $DIR/$tdir
5064 if [[ $STRIPECOUNT -le 0 ]]; then
5066 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5067 #LOV_MAX_STRIPE_COUNT is 2000
5068 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5070 sc=$(($STRIPECOUNT - 1))
5072 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5073 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5074 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5075 error "lverify failed"
5077 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5081 test_mkdir -p $DIR/$tdir
5083 $SETSTRIPE $DIR/$tdir || error "setstripe"
5084 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5085 error "no stripe info failed"
5087 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5089 run_test 65e "directory setstripe defaults ======================="
5092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5093 test_mkdir -p $DIR/${tdir}f
5094 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5096 run_test 65f "dir setstripe permission (should return error) ==="
5099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5100 test_mkdir -p $DIR/$tdir
5101 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5103 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5104 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5105 error "delete default stripe failed"
5107 run_test 65g "directory setstripe -d ==========================="
5110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5111 test_mkdir -p $DIR/$tdir
5112 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5114 test_mkdir -p $DIR/$tdir/dd1
5115 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5116 error "stripe info inherit failed"
5118 run_test 65h "directory stripe info inherit ===================="
5120 test_65i() { # bug6367
5121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5122 $SETSTRIPE -S 65536 -c -1 $MOUNT
5124 run_test 65i "set non-default striping on root directory (bug 6367)="
5126 test_65ia() { # bug12836
5127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5128 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5130 run_test 65ia "getstripe on -1 default directory striping"
5132 test_65ib() { # bug12836
5133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5134 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5136 run_test 65ib "getstripe -v on -1 default directory striping"
5138 test_65ic() { # bug12836
5139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5140 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5142 run_test 65ic "new find on -1 default directory striping"
5144 test_65j() { # bug6367
5145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5147 # if we aren't already remounting for each test, do so for this test
5148 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5149 cleanup || error "failed to unmount"
5152 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5154 run_test 65j "set default striping on root directory (bug 6367)="
5156 test_65k() { # bug11679
5157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5158 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5159 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5161 echo "Check OST status: "
5162 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5163 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5165 for OSC in $MDS_OSCS; do
5166 echo $OSC "is activate"
5167 do_facet $SINGLEMDS lctl --device %$OSC activate
5171 for INACTIVE_OSC in $MDS_OSCS; do
5172 echo "Deactivate: " $INACTIVE_OSC
5173 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5174 for STRIPE_OSC in $MDS_OSCS; do
5175 OST=`osc_to_ost $STRIPE_OSC`
5176 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5177 awk -F: /$OST/'{ print $1 }' | head -n 1`
5179 [ -f $DIR/$tdir/$IDX ] && continue
5180 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5181 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5183 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5186 echo $INACTIVE_OSC "is Activate."
5187 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5190 run_test 65k "validate manual striping works properly with deactivated OSCs"
5192 test_65l() { # bug 12836
5193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5194 test_mkdir -p $DIR/$tdir/test_dir
5195 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5196 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5198 run_test 65l "lfs find on -1 stripe dir ========================"
5200 # bug 2543 - update blocks count on client
5202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5204 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5205 sync; sync_all_data; sync; sync_all_data
5206 cancel_lru_locks osc
5207 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5208 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5210 run_test 66 "update inode blocks count on client ==============="
5215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5217 if [ ! -z "$LLOOP" ]; then
5218 if swapon -s | grep -q $LLOOP; then
5219 swapoff $LLOOP || error "swapoff failed"
5222 $LCTL blockdev_detach $LLOOP || error "detach failed"
5226 if [ ! -z "$LLITELOOPLOAD" ]; then
5234 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5238 swapon -s | awk '($1 == "'$1'") { print $4 }'
5241 # test case for lloop driver, basic function
5243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5244 [ "$UID" != 0 ] && skip_env "must run as root" && return
5245 llite_lloop_enabled || \
5246 { skip_env "llite_lloop module disabled" && return; }
5248 trap cleanup_68 EXIT
5250 if ! module_loaded llite_lloop; then
5251 if load_module llite/llite_lloop; then
5254 skip_env "can't find module llite_lloop"
5259 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5260 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5261 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5263 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5264 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5268 run_test 68a "lloop driver - basic test ========================"
5270 # excercise swapping to lustre by adding a high priority swapfile entry
5271 # and then consuming memory until it is used.
5272 test_68b() { # was test_68
5273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5274 [ "$UID" != 0 ] && skip_env "must run as root" && return
5275 lctl get_param -n devices | grep -q obdfilter && \
5276 skip "local OST" && return
5278 grep -q llite_lloop /proc/modules
5279 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5281 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5282 skip "can't reliably test swap with TCP" && return
5284 MEMTOTAL=`meminfo MemTotal`
5285 NR_BLOCKS=$((MEMTOTAL>>8))
5286 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5288 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5289 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5292 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5294 trap cleanup_68 EXIT
5296 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5298 echo "before: `swapon -s | grep $LLOOP`"
5299 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5300 echo "after: `swapon -s | grep $LLOOP`"
5301 SWAPUSED=`swap_used $LLOOP`
5305 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5307 run_test 68b "support swapping to Lustre ========================"
5309 # bug5265, obdfilter oa2dentry return -ENOENT
5310 # #define OBD_FAIL_OST_ENOENT 0x217
5312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5313 remote_ost_nodsh && skip "remote OST with nodsh" && return
5316 $SETSTRIPE -c 1 -i 0 $f
5318 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5320 do_facet ost1 lctl set_param fail_loc=0x217
5321 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5322 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5324 do_facet ost1 lctl set_param fail_loc=0
5325 $DIRECTIO write $f 0 2 || error "write error"
5327 cancel_lru_locks osc
5328 $DIRECTIO read $f 0 1 || error "read error"
5330 do_facet ost1 lctl set_param fail_loc=0x217
5331 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5333 do_facet ost1 lctl set_param fail_loc=0
5336 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5339 test_mkdir -p $DIR/$tdir
5340 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5342 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5344 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5345 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5346 [ "$RUNAS_ID" = "$UID" ] &&
5347 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5349 # Check that testing environment is properly set up. Skip if not
5350 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5351 skip_env "User $RUNAS_ID does not exist - skipping"
5354 # We had better clear the $DIR to get enough space for dd
5357 chmod 777 $DIR/$tfile
5358 chmod ug+s $DIR/$tfile
5359 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5360 error "$RUNAS dd $DIR/$tfile failed"
5361 # See if we are still setuid/sgid
5362 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5363 error "S/gid is not dropped on write"
5364 # Now test that MDS is updated too
5365 cancel_lru_locks mdc
5366 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5367 error "S/gid is not dropped on MDS"
5370 run_test 72a "Test that remove suid works properly (bug5695) ===="
5372 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5375 [ "$RUNAS_ID" = "$UID" ] && \
5376 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5377 [ "$RUNAS_ID" -eq 0 ] && \
5378 skip_env "RUNAS_ID = 0 -- skipping" && return
5380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5381 # Check that testing environment is properly set up. Skip if not
5382 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5383 skip_env "User $RUNAS_ID does not exist - skipping"
5386 touch $DIR/${tfile}-f{g,u}
5387 test_mkdir $DIR/${tfile}-dg
5388 test_mkdir $DIR/${tfile}-du
5389 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5390 chmod g+s $DIR/${tfile}-{f,d}g
5391 chmod u+s $DIR/${tfile}-{f,d}u
5392 for perm in 777 2777 4777; do
5393 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5394 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5395 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5396 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5400 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5402 # bug 3462 - multiple simultaneous MDC requests
5404 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5405 test_mkdir $DIR/d73-1
5406 test_mkdir $DIR/d73-2
5407 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5410 lctl set_param fail_loc=0x80000129
5411 $MULTIOP $DIR/d73-1/f73-2 Oc &
5413 lctl set_param fail_loc=0
5415 $MULTIOP $DIR/d73-2/f73-3 Oc &
5419 wait $pid1 || return 1
5423 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5424 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5425 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5429 run_test 73 "multiple MDC requests (should not deadlock)"
5431 test_74a() { # bug 6149, 6184
5432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5433 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5435 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5436 # will spin in a tight reconnection loop
5438 $LCTL set_param fail_loc=0x8000030e
5439 # get any lock that won't be difficult - lookup works.
5441 $LCTL set_param fail_loc=0
5445 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5447 test_74b() { # bug 13310
5448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5449 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5451 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5452 # will spin in a tight reconnection loop
5453 $LCTL set_param fail_loc=0x8000030e
5454 # get a "difficult" lock
5456 $LCTL set_param fail_loc=0
5460 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5463 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5464 #define OBD_FAIL_LDLM_NEW_LOCK
5465 $LCTL set_param fail_loc=0x319
5466 touch $DIR/$tfile && error "touch successful"
5467 $LCTL set_param fail_loc=0
5470 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5473 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5476 get_inode_slab_tunables() {
5477 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5480 set_inode_slab_tunables() {
5481 echo "lustre_inode_cache $1" > /proc/slabinfo
5484 test_76() { # Now for bug 20433, added originally in bug 1443
5485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5486 local SLAB_SETTINGS=`get_inode_slab_tunables`
5487 local CPUS=`getconf _NPROCESSORS_ONLN`
5488 # we cannot set limit below 1 which means 1 inode in each
5489 # per-cpu cache is still allowed
5490 set_inode_slab_tunables "1 1 0"
5491 cancel_lru_locks osc
5492 BEFORE_INODES=$(num_inodes)
5493 echo "before inodes: $BEFORE_INODES"
5495 [ "$SLOW" = "no" ] && COUNT=100
5496 for i in $(seq $COUNT); do
5500 cancel_lru_locks osc
5501 AFTER_INODES=$(num_inodes)
5502 echo "after inodes: $AFTER_INODES"
5504 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5506 AFTER_INODES=$(num_inodes)
5508 echo "wait $wait seconds inodes: $AFTER_INODES"
5509 if [ $wait -gt 30 ]; then
5510 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5513 set_inode_slab_tunables "$SLAB_SETTINGS"
5515 run_test 76 "confirm clients recycle inodes properly ===="
5521 # Note: in sptlrpc modes which enable its own bulk checksum, the
5522 # original crc32_le bulk checksum will be automatically disabled,
5523 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5524 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5525 # In this case set_checksums() will not be no-op, because sptlrpc
5526 # bulk checksum will be enabled all through the test.
5528 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5529 lctl set_param -n osc.*.checksums $1
5533 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5534 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5535 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5536 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5539 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5540 log "set checksum type to $1"
5543 F77_TMP=$TMP/f77-temp
5546 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5547 error "error writing to $F77_TMP"
5550 test_77a() { # bug 10889
5551 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5552 $GSS && skip "could not run with gss" && return
5553 [ ! -f $F77_TMP ] && setup_f77
5555 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5559 run_test 77a "normal checksum read/write operation"
5561 test_77b() { # bug 10889
5562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5563 $GSS && skip "could not run with gss" && return
5564 [ ! -f $F77_TMP ] && setup_f77
5565 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5566 $LCTL set_param fail_loc=0x80000409
5569 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5570 error "dd error: $?"
5571 $LCTL set_param fail_loc=0
5573 for algo in $CKSUM_TYPES; do
5574 cancel_lru_locks osc
5575 set_checksum_type $algo
5576 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5577 $LCTL set_param fail_loc=0x80000408
5578 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5579 $LCTL set_param fail_loc=0
5582 set_checksum_type $ORIG_CSUM_TYPE
5585 run_test 77b "checksum error on client write, read"
5587 test_77d() { # bug 10889
5588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5589 $GSS && skip "could not run with gss" && return
5590 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5591 $LCTL set_param fail_loc=0x80000409
5593 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5594 error "direct write: rc=$?"
5595 $LCTL set_param fail_loc=0
5598 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5599 $LCTL set_param fail_loc=0x80000408
5601 cancel_lru_locks osc
5602 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5603 error "direct read: rc=$?"
5604 $LCTL set_param fail_loc=0
5607 run_test 77d "checksum error on OST direct write, read"
5609 test_77f() { # bug 10889
5610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5611 $GSS && skip "could not run with gss" && return
5613 for algo in $CKSUM_TYPES; do
5614 cancel_lru_locks osc
5615 set_checksum_type $algo
5616 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5617 $LCTL set_param fail_loc=0x409
5618 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5619 error "direct write succeeded"
5620 $LCTL set_param fail_loc=0
5622 set_checksum_type $ORIG_CSUM_TYPE
5625 run_test 77f "repeat checksum error on write (expect error)"
5627 test_77g() { # bug 10889
5628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5629 $GSS && skip "could not run with gss" && return
5630 remote_ost_nodsh && skip "remote OST with nodsh" && return
5632 [ ! -f $F77_TMP ] && setup_f77
5634 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5635 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5636 do_facet ost1 lctl set_param fail_loc=0x8000021a
5638 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5639 error "write error: rc=$?"
5640 do_facet ost1 lctl set_param fail_loc=0
5643 cancel_lru_locks osc
5644 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5645 do_facet ost1 lctl set_param fail_loc=0x8000021b
5647 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5648 do_facet ost1 lctl set_param fail_loc=0
5651 run_test 77g "checksum error on OST write, read"
5653 test_77i() { # bug 13805
5654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5655 $GSS && skip "could not run with gss" && return
5656 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5657 lctl set_param fail_loc=0x40b
5658 remount_client $MOUNT
5659 lctl set_param fail_loc=0
5660 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5661 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5662 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5663 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5665 remount_client $MOUNT
5667 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5669 test_77j() { # bug 13805
5670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5671 $GSS && skip "could not run with gss" && return
5672 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5673 lctl set_param fail_loc=0x40c
5674 remount_client $MOUNT
5675 lctl set_param fail_loc=0
5676 sleep 2 # wait async osc connect to finish
5677 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5678 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5679 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5680 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5682 remount_client $MOUNT
5684 run_test 77j "client only supporting ADLER32"
5686 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5690 test_78() { # bug 10901
5691 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5692 remote_ost || { skip_env "local OST" && return; }
5695 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5696 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5697 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5698 echo "MemTotal: $MEMTOTAL"
5700 # reserve 256MB of memory for the kernel and other running processes,
5701 # and then take 1/2 of the remaining memory for the read/write buffers.
5702 if [ $MEMTOTAL -gt 512 ] ;then
5703 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5705 # for those poor memory-starved high-end clusters...
5706 MEMTOTAL=$((MEMTOTAL / 2))
5708 echo "Mem to use for directio: $MEMTOTAL"
5710 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5711 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5712 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5713 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5715 echo "Smallest OST: $SMALLESTOST"
5716 [[ $SMALLESTOST -lt 10240 ]] &&
5717 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5719 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5720 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5722 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5723 echo "File size: $F78SIZE"
5724 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5725 for i in $(seq 1 $NSEQ); do
5726 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5727 echo directIO rdwr round $i of $NSEQ
5728 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5733 run_test 78 "handle large O_DIRECT writes correctly ============"
5735 test_79() { # bug 12743
5736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5737 wait_delete_completed
5739 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5740 BKFREE=$(calc_osc_kbytes kbytesfree)
5741 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5743 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5744 DFTOTAL=`echo $STRING | cut -d, -f1`
5745 DFUSED=`echo $STRING | cut -d, -f2`
5746 DFAVAIL=`echo $STRING | cut -d, -f3`
5747 DFFREE=$(($DFTOTAL - $DFUSED))
5749 ALLOWANCE=$((64 * $OSTCOUNT))
5751 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5752 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5753 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5755 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5756 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5757 error "df free($DFFREE) mismatch OST free($BKFREE)"
5759 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5760 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5761 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5764 run_test 79 "df report consistency check ======================="
5766 test_80() { # bug 10718
5767 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5768 # relax strong synchronous semantics for slow backends like ZFS
5769 local soc="obdfilter.*.sync_on_lock_cancel"
5770 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5772 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5773 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5774 facet_active_host $host; done | sort -u)
5775 do_nodes $hosts lctl set_param $soc=never
5778 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5780 local BEFORE=`date +%s`
5781 cancel_lru_locks osc
5782 local AFTER=`date +%s`
5783 local DIFF=$((AFTER-BEFORE))
5784 if [ $DIFF -gt 1 ] ; then
5785 error "elapsed for 1M@1T = $DIFF"
5788 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5792 run_test 80 "Page eviction is equally fast at high offsets too ===="
5794 test_81a() { # LU-456
5795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5796 remote_ost_nodsh && skip "remote OST with nodsh" && return
5797 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5798 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5799 do_facet ost1 lctl set_param fail_loc=0x80000228
5801 # write should trigger a retry and success
5802 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5803 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5805 if [ $RC -ne 0 ] ; then
5806 error "write should success, but failed for $RC"
5809 run_test 81a "OST should retry write when get -ENOSPC ==============="
5811 test_81b() { # LU-456
5812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5813 remote_ost_nodsh && skip "remote OST with nodsh" && return
5814 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5815 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5816 do_facet ost1 lctl set_param fail_loc=0x228
5818 # write should retry several times and return -ENOSPC finally
5819 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5820 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5823 if [ $RC -ne $ENOSPC ] ; then
5824 error "dd should fail for -ENOSPC, but succeed."
5827 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5829 test_82() { # LU-1031
5830 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5834 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5836 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5838 kill -USR1 $MULTIPID2
5840 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5841 error "First grouplock does not block second one"
5843 echo "Second grouplock blocks first one"
5845 kill -USR1 $MULTIPID1
5849 run_test 82 "Basic grouplock test ==============================="
5852 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5854 test_mkdir -p $DIR/d99cvsroot
5855 chown $RUNAS_ID $DIR/d99cvsroot
5856 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5859 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5862 run_test 99a "cvs init ========================================="
5865 [ -z "$(which cvs 2>/dev/null)" ] &&
5866 skip_env "could not find cvs" && return
5867 [ ! -d $DIR/d99cvsroot ] && test_99a
5869 # some versions of cvs import exit(1) when asked to import links or
5870 # files they can't read. ignore those files.
5871 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5872 ! -perm +4 -printf '-I %f\n')
5873 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5874 d99reposname vtag rtag
5876 run_test 99b "cvs import ======================================="
5879 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5880 [ ! -d $DIR/d99cvsroot ] && test_99b
5882 test_mkdir -p $DIR/d99reposname
5883 chown $RUNAS_ID $DIR/d99reposname
5884 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5886 run_test 99c "cvs checkout ====================================="
5889 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5890 [ ! -d $DIR/d99cvsroot ] && test_99c
5891 cd $DIR/d99reposname
5893 $RUNAS cvs add -m 'addmsg' foo99
5895 run_test 99d "cvs add =========================================="
5898 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5899 [ ! -d $DIR/d99cvsroot ] && test_99c
5900 cd $DIR/d99reposname
5903 run_test 99e "cvs update ======================================="
5906 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5907 [ ! -d $DIR/d99cvsroot ] && test_99d
5908 cd $DIR/d99reposname
5909 $RUNAS cvs commit -m 'nomsg' foo99
5910 rm -fr $DIR/d99cvsroot
5912 run_test 99f "cvs commit ======================================="
5915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5916 [ "$NETTYPE" = tcp ] || \
5917 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5920 remote_ost_nodsh && skip "remote OST with nodsh" && return
5921 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5923 { skip "useless for local single node setup" && return; }
5925 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5926 [ "$PROT" != "tcp" ] && continue
5927 RPORT=$(echo $REMOTE | cut -d: -f2)
5928 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5931 LPORT=`echo $LOCAL | cut -d: -f2`
5932 if [ $LPORT -ge 1024 ]; then
5933 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5935 error_exit "local: $LPORT > 1024, remote: $RPORT"
5938 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5940 run_test 100 "check local port using privileged port ==========="
5942 function get_named_value()
5951 echo $line | sed "s/^$tag[ ]*//"
5958 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5959 awk '/^max_cached_mb/ { print $2 }')
5962 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5968 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
5972 local cache_limit=32
5974 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5975 trap cleanup_101a EXIT
5976 $LCTL set_param -n llite.*.read_ahead_stats 0
5977 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5980 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5982 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5983 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5986 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
5987 get_named_value 'read but discarded' | cut -d" " -f1); do
5988 discard=$(($discard + $s))
5992 if [[ $(($discard * 10)) -gt $nreads ]]; then
5993 $LCTL get_param osc.*-osc*.rpc_stats
5994 $LCTL get_param llite.*.read_ahead_stats
5995 error "too many ($discard) discarded pages"
5997 rm -f $DIR/$tfile || true
5999 run_test 101a "check read-ahead for random reads ================"
6002 test_mkdir -p $DIR/$tdir
6003 local STRIPE_SIZE=$1
6004 local FILE_LENGTH=$2
6007 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6009 local list=$(comma_list $(osts_nodes))
6010 set_osd_param $list '' read_cache_enable 0
6011 set_osd_param $list '' writethrough_cache_enable 0
6013 trap cleanup_test101bc EXIT
6014 # prepare the read-ahead file
6015 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6017 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6018 count=$FILE_SIZE_MB 2> /dev/null
6022 cleanup_test101bc() {
6027 local list=$(comma_list $(osts_nodes))
6028 set_osd_param $list '' read_cache_enable 1
6029 set_osd_param $list '' writethrough_cache_enable 1
6033 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6038 local STRIPE_SIZE=$2
6039 local FILE_LENGTH=$3
6040 local RA_INC=1048576
6041 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6042 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6043 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6044 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6045 get_named_value 'read but discarded' |
6046 cut -d" " -f1 | calc_total)
6047 if [[ $DISCARD -gt $discard_limit ]]; then
6048 $LCTL get_param llite.*.read_ahead_stats
6049 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6051 echo "Read-ahead success for size ${READ_SIZE}"
6056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6057 [[ $OSTCOUNT -lt 2 ]] &&
6058 skip_env "skipping stride IO stride-ahead test" && return
6059 local STRIPE_SIZE=1048576
6060 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6061 if [ $SLOW == "yes" ]; then
6062 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6064 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6067 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6069 # prepare the read-ahead file
6070 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6071 cancel_lru_locks osc
6072 for BIDX in 2 4 8 16 32 64 128 256
6074 local BSIZE=$((BIDX*4096))
6075 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6076 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6077 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6078 $LCTL set_param -n llite.*.read_ahead_stats 0
6079 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6080 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6081 cancel_lru_locks osc
6082 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6087 run_test 101b "check stride-io mode read-ahead ================="
6090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6091 local STRIPE_SIZE=1048576
6092 local FILE_LENGTH=$((STRIPE_SIZE*100))
6096 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6098 cancel_lru_locks osc
6099 $LCTL set_param osc.*.rpc_stats 0
6100 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6101 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6102 local stats=$($LCTL get_param -n $osc_rpc_stats)
6103 local lines=$(echo "$stats" | awk 'END {print NR;}')
6106 if [ $lines -le 20 ]; then
6109 for size in 1 2 4 8; do
6110 local rpc=$(echo "$stats" |
6111 awk '($1 == "'$size':") {print $2; exit; }')
6113 error "Small $((size*4))k read IO $rpc !"
6115 echo "$osc_rpc_stats check passed!"
6120 run_test 101c "check stripe_size aligned read-ahead ================="
6123 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6124 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6129 local file=$DIR/$tfile
6130 local sz_MB=${FILESIZE_101d:-500}
6131 local ra_MB=${READAHEAD_MB:-40}
6133 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6134 [ $free_MB -lt $sz_MB ] &&
6135 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6137 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6138 $SETSTRIPE -c -1 $file || error "setstripe failed"
6140 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6141 echo Cancel LRU locks on lustre client to flush the client cache
6142 cancel_lru_locks osc
6144 echo Disable read-ahead
6145 local old_READAHEAD=$(set_read_ahead 0)
6147 echo Reading the test file $file with read-ahead disabled
6148 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6150 echo Cancel LRU locks on lustre client to flush the client cache
6151 cancel_lru_locks osc
6152 echo Enable read-ahead with ${ra_MB}MB
6153 set_read_ahead $ra_MB
6155 echo Reading the test file $file with read-ahead enabled
6156 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6158 echo "read-ahead disabled time read $raOFF"
6159 echo "read-ahead enabled time read $raON"
6161 set_read_ahead $old_READAHEAD
6163 wait_delete_completed
6165 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6166 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6168 run_test 101d "file read with and without read-ahead enabled"
6171 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6172 local file=$DIR/$tfile
6173 local size_KB=500 #KB
6177 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6178 local need_KB=$((count * size_KB))
6179 [[ $free_KB -le $need_KB ]] &&
6180 skip_env "Need free space $need_KB, have $free_KB" && return
6182 echo "Creating $count ${size_KB}K test files"
6183 for ((i = 0; i < $count; i++)); do
6184 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6187 echo "Cancel LRU locks on lustre client to flush the client cache"
6188 cancel_lru_locks osc
6190 echo "Reset readahead stats"
6191 $LCTL set_param -n llite.*.read_ahead_stats 0
6193 for ((i = 0; i < $count; i++)); do
6194 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6197 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6198 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6200 for ((i = 0; i < $count; i++)); do
6201 rm -rf $file.$i 2>/dev/null
6204 #10000 means 20% reads are missing in readahead
6205 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6207 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6209 cleanup_test101f() {
6211 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6212 rm -rf $DIR/$tfile 2>/dev/null
6216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6217 local file=$DIR/$tfile
6220 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6221 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6222 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6223 trap cleanup_test101f EXIT
6225 echo Cancel LRU locks on lustre client to flush the client cache
6226 cancel_lru_locks osc
6228 echo Reset readahead stats
6229 $LCTL set_param -n llite.*.read_ahead_stats 0
6230 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6231 # readahead should read in 2M file on second read, so only miss
6233 echo Random 4K reads on 2M file for 1000 times
6234 $READS -f $file -s 2097152 -b 4096 -n $nreads
6236 echo checking missing pages
6237 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6238 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6240 [ $miss -lt 3 ] || error "misses too much pages!"
6243 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6246 test_mkdir -p $DIR/$tdir
6247 chown $RUNAS_ID $DIR/$tdir
6250 STRIPE_COUNT=$OSTCOUNT
6251 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6253 trap cleanup_test102 EXIT
6255 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6257 for num in 1 2 3 4; do
6258 for count in $(seq 1 $STRIPE_COUNT); do
6259 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6260 local size=`expr $STRIPE_SIZE \* $num`
6261 local file=file"$num-$idx-$count"
6262 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6268 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6274 rm -rf $DIR/d0.sanity/d102
6278 local testfile=$DIR/xattr_testfile
6282 [ "$UID" != 0 ] && skip_env "must run as root" && return
6283 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6284 skip_env "must have user_xattr" && return
6286 [ -z "$(which setfattr 2>/dev/null)" ] &&
6287 skip_env "could not find setfattr" && return
6289 echo "set/get xattr..."
6290 setfattr -n trusted.name1 -v value1 $testfile ||
6291 error "setfattr -n trusted.name1=value1 $testfile failed"
6292 getfattr -n trusted.name1 $testfile 2> /dev/null |
6293 grep "trusted.name1=.value1" ||
6294 error "$testfile missing trusted.name1=value1"
6296 setfattr -n user.author1 -v author1 $testfile ||
6297 error "setfattr -n user.author1=author1 $testfile failed"
6298 getfattr -n user.author1 $testfile 2> /dev/null |
6299 grep "user.author1=.author1" ||
6300 error "$testfile missing trusted.author1=author1"
6303 setfattr -n trusted.name2 -v value2 $testfile ||
6304 error "$testfile unable to set trusted.name2"
6305 setfattr -n trusted.name3 -v value3 $testfile ||
6306 error "$testfile unable to set trusted.name3"
6307 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6308 grep "trusted.name" | wc -l) -eq 3 ] ||
6309 error "$testfile missing 3 trusted.name xattrs"
6311 setfattr -n user.author2 -v author2 $testfile ||
6312 error "$testfile unable to set user.author2"
6313 setfattr -n user.author3 -v author3 $testfile ||
6314 error "$testfile unable to set user.author3"
6315 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6316 grep "user.author" | wc -l) -eq 3 ] ||
6317 error "$testfile missing 3 user.author xattrs"
6319 echo "remove xattr..."
6320 setfattr -x trusted.name1 $testfile ||
6321 error "$testfile error deleting trusted.name1"
6322 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6323 error "$testfile did not delete trusted.name1 xattr"
6325 setfattr -x user.author1 $testfile ||
6326 error "$testfile error deleting user.author1"
6327 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6328 error "$testfile did not delete trusted.name1 xattr"
6330 # b10667: setting lustre special xattr be silently discarded
6331 echo "set lustre special xattr ..."
6332 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6333 error "$testfile allowed setting trusted.lov"
6335 run_test 102a "user xattr test =================================="
6338 [ -z "$(which setfattr 2>/dev/null)" ] &&
6339 skip_env "could not find setfattr" && return
6341 # b10930: get/set/list trusted.lov xattr
6342 echo "get/set/list trusted.lov xattr ..."
6343 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6344 local testfile=$DIR/$tfile
6345 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6346 error "setstripe failed"
6347 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6348 error "getstripe failed"
6349 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6350 error "can't get trusted.lov from $testfile"
6352 local testfile2=${testfile}2
6353 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6354 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6357 setfattr -n trusted.lov -v $value $testfile2
6358 local stripe_size=$($GETSTRIPE -S $testfile2)
6359 local stripe_count=$($GETSTRIPE -c $testfile2)
6360 [[ $stripe_size -eq 65536 ]] ||
6361 error "stripe size $stripe_size != 65536"
6362 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6363 error "stripe count $stripe_count != $STRIPECOUNT"
6366 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6369 [ -z "$(which setfattr 2>/dev/null)" ] &&
6370 skip_env "could not find setfattr" && return
6372 # b10930: get/set/list lustre.lov xattr
6373 echo "get/set/list lustre.lov xattr ..."
6374 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6375 test_mkdir -p $DIR/$tdir
6376 chown $RUNAS_ID $DIR/$tdir
6377 local testfile=$DIR/$tdir/$tfile
6378 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6379 error "setstripe failed"
6380 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6381 error "getstripe failed"
6382 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6383 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6385 local testfile2=${testfile}2
6386 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6387 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6389 $RUNAS $MCREATE $testfile2
6390 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6391 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6392 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6393 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6394 [ $stripe_count -eq $STRIPECOUNT ] ||
6395 error "stripe count $stripe_count != $STRIPECOUNT"
6397 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6399 compare_stripe_info1() {
6400 local stripe_index_all_zero=true
6402 for num in 1 2 3 4; do
6403 for count in $(seq 1 $STRIPE_COUNT); do
6404 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6405 local size=$((STRIPE_SIZE * num))
6406 local file=file"$num-$offset-$count"
6407 stripe_size=$(lfs getstripe -S $PWD/$file)
6408 [[ $stripe_size -ne $size ]] &&
6409 error "$file: size $stripe_size != $size"
6410 stripe_count=$(lfs getstripe -c $PWD/$file)
6411 # allow fewer stripes to be created, ORI-601
6412 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6413 error "$file: count $stripe_count != $count"
6414 stripe_index=$(lfs getstripe -i $PWD/$file)
6415 [[ $stripe_index -ne 0 ]] &&
6416 stripe_index_all_zero=false
6420 $stripe_index_all_zero &&
6421 error "all files are being extracted starting from OST index 0"
6426 [ -n "$(which tar 2>/dev/null)" ] &&
6427 strings $(which tar) | grep -q "lustre" && echo tar
6431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6432 # b10930: tar test for trusted.lov xattr
6433 TAR=$(find_lustre_tar)
6434 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6435 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6437 test_mkdir -p $DIR/d102d
6438 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6440 compare_stripe_info1
6442 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6446 # b10930: tar test for trusted.lov xattr
6447 TAR=$(find_lustre_tar)
6448 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6449 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6451 test_mkdir -p $DIR/d102f
6453 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6455 compare_stripe_info1
6457 run_test 102f "tar copy files, not keep osts ==========="
6460 local xsize=${1:-1024} # in bytes
6461 local file=$DIR/$tfile
6463 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6464 skip "must have user_xattr" && return 0
6465 [ -z "$(which setfattr 2>/dev/null)" ] &&
6466 skip_env "could not find setfattr" && return 0
6467 [ -z "$(which getfattr 2>/dev/null)" ] &&
6468 skip_env "could not find getfattr" && return 0
6472 local value="$(generate_string $xsize)"
6474 local xbig=trusted.big
6475 log "save $xbig on $file"
6476 setfattr -n $xbig -v $value $file ||
6477 error "saving $xbig on $file failed"
6479 local orig=$(get_xattr_value $xbig $file)
6480 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6482 local xsml=trusted.sml
6483 log "save $xsml on $file"
6484 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6486 local new=$(get_xattr_value $xbig $file)
6487 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6489 log "grow $xsml on $file"
6490 setfattr -n $xsml -v "$value" $file ||
6491 error "growing $xsml on $file failed"
6493 new=$(get_xattr_value $xbig $file)
6494 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6495 log "$xbig still valid after growing $xsml"
6500 test_102h() { # bug 15777
6503 run_test 102h "grow xattr from inside inode to external block"
6506 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6507 grow_xattr $(max_xattr_size)
6509 run_test 102ha "grow xattr from inside inode to external inode"
6511 test_102i() { # bug 17038
6512 [ -z "$(which getfattr 2>/dev/null)" ] &&
6513 skip "could not find getfattr" && return
6515 ln -s $DIR/$tfile $DIR/${tfile}link
6516 getfattr -n trusted.lov $DIR/$tfile ||
6517 error "lgetxattr on $DIR/$tfile failed"
6518 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6519 grep -i "no such attr" ||
6520 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6521 rm -f $DIR/$tfile $DIR/${tfile}link
6523 run_test 102i "lgetxattr test on symbolic link ============"
6526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6527 TAR=$(find_lustre_tar)
6528 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6529 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6530 setup_test102 "$RUNAS"
6531 test_mkdir -p $DIR/d102j
6532 chown $RUNAS_ID $DIR/d102j
6533 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6535 compare_stripe_info1 "$RUNAS"
6537 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6540 [ -z "$(which setfattr 2>/dev/null)" ] &&
6541 skip "could not find setfattr" && return
6543 # b22187 just check that does not crash for regular file.
6544 setfattr -n trusted.lov $DIR/$tfile
6545 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6546 local test_kdir=$DIR/d102k
6547 test_mkdir $test_kdir
6548 local default_size=`$GETSTRIPE -S $test_kdir`
6549 local default_count=`$GETSTRIPE -c $test_kdir`
6550 local default_offset=`$GETSTRIPE -i $test_kdir`
6551 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6552 error 'dir setstripe failed'
6553 setfattr -n trusted.lov $test_kdir
6554 local stripe_size=`$GETSTRIPE -S $test_kdir`
6555 local stripe_count=`$GETSTRIPE -c $test_kdir`
6556 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6557 [ $stripe_size -eq $default_size ] ||
6558 error "stripe size $stripe_size != $default_size"
6559 [ $stripe_count -eq $default_count ] ||
6560 error "stripe count $stripe_count != $default_count"
6561 [ $stripe_offset -eq $default_offset ] ||
6562 error "stripe offset $stripe_offset != $default_offset"
6563 rm -rf $DIR/$tfile $test_kdir
6565 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6568 [ -z "$(which getfattr 2>/dev/null)" ] &&
6569 skip "could not find getfattr" && return
6571 # LU-532 trusted. xattr is invisible to non-root
6572 local testfile=$DIR/$tfile
6576 echo "listxattr as user..."
6577 chown $RUNAS_ID $testfile
6578 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6579 grep -q "trusted" &&
6580 error "$testfile trusted xattrs are user visible"
6584 run_test 102l "listxattr size test =================================="
6586 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6587 local path=$DIR/$tfile
6590 listxattr_size_check $path || error "listattr_size_check $path failed"
6592 run_test 102m "Ensure listxattr fails on small bufffer ========"
6596 getxattr() { # getxattr path name
6597 # Return the base64 encoding of the value of xattr name on path.
6601 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6603 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6605 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6607 getfattr --absolute-names --encoding=base64 --name=$name $path |
6608 awk -F= -v name=$name '$1 == name {
6609 print substr($0, index($0, "=") + 1);
6613 test_102n() { # LU-4101 mdt: protect internal xattrs
6614 local file0=$DIR/$tfile.0
6615 local file1=$DIR/$tfile.1
6616 local xattr0=$TMP/$tfile.0
6617 local xattr1=$TMP/$tfile.1
6621 [ -z "$(which setfattr 2>/dev/null)" ] &&
6622 skip "could not find setfattr" && return
6624 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6626 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6630 rm -rf $file0 $file1 $xattr0 $xattr1
6633 # Get 'before' xattrs of $file1.
6634 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6636 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6637 # Try to copy xattr from $file0 to $file1.
6638 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6640 setfattr --name=trusted.$name --value="$value" $file1 ||
6641 error "setxattr 'trusted.$name' failed"
6643 # Try to set a garbage xattr.
6644 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6646 setfattr --name=trusted.$name --value="$value" $file1 ||
6647 error "setxattr 'trusted.$name' failed"
6649 # Try to remove the xattr from $file1. We don't care if this
6650 # appears to succeed or fail, we just don't want there to be
6651 # any changes or crashes.
6652 setfattr --remove=$trusted.$name $file1 2> /dev/null
6655 # Get 'after' xattrs of file1.
6656 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6658 if ! diff $xattr0 $xattr1; then
6659 error "before and after xattrs of '$file1' differ"
6662 rm -rf $file0 $file1 $xattr0 $xattr1
6666 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6668 test_102p() { # LU-4703 setxattr did not check ownership
6669 local testfile=$DIR/$tfile
6671 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6672 skip "MDS needs to be at least 2.5.56" && return
6676 echo "setfacl as user..."
6677 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6678 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6680 echo "setfattr as user..."
6681 setfacl -m "u:$RUNAS_ID:---" $testfile
6682 $RUNAS setfattr -x system.posix_acl_access $testfile
6683 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6685 run_test 102p "check setxattr(2) correctly fails without permission"
6689 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6694 [ "$UID" != 0 ] && skip_env "must run as root" && return
6695 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6696 skip "must have acl enabled" && return
6697 [ -z "$(which setfacl 2>/dev/null)" ] &&
6698 skip_env "could not find setfacl" && return
6699 $GSS && skip "could not run under gss" && return
6701 declare -a identity_old
6703 for num in $(seq $MDSCOUNT); do
6704 switch_identity $num true || identity_old[$num]=$?
6711 echo "performing cp ..."
6712 run_acl_subtest cp || error "run_acl_subtest cp failed"
6713 echo "performing getfacl-noacl..."
6714 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6715 echo "performing misc..."
6716 run_acl_subtest misc || error "misc test failed"
6717 echo "performing permissions..."
6718 run_acl_subtest permissions || error "permissions failed"
6719 echo "performing setfacl..."
6720 run_acl_subtest setfacl || error "setfacl test failed"
6722 # inheritance test got from HP
6723 echo "performing inheritance..."
6724 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6725 chmod +x make-tree || error "chmod +x failed"
6726 run_acl_subtest inheritance || error "inheritance test failed"
6729 echo "LU-974 ignore umask when acl is enabled..."
6730 run_acl_subtest 974 || error "LU-974 umask test failed"
6731 if [ $MDSCOUNT -ge 2 ]; then
6732 run_acl_subtest 974_remote ||
6733 error "LU-974 umask test failed under remote dir"
6736 echo "LU-2561 newly created file is same size as directory..."
6737 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6738 run_acl_subtest 2561 || error "LU-2561 test failed"
6740 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6743 run_acl_subtest 4924 || error "LU-4924 test failed"
6748 for num in $(seq $MDSCOUNT); do
6749 if [ "${identity_old[$num]}" = 1 ]; then
6750 switch_identity $num false || identity_old[$num]=$?
6754 run_test 103 "acl test ========================================="
6757 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6759 lfs df || error "lfs df failed"
6760 lfs df -ih || error "lfs df -ih failed"
6761 lfs df -h $DIR || error "lfs df -h $DIR failed"
6762 lfs df -i $DIR || error "lfs df -i $DIR failed"
6763 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6764 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6766 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6767 lctl --device %$OSC deactivate
6768 lfs df || error "lfs df with deactivated OSC failed"
6769 lctl --device %$OSC activate
6770 # wait the osc back to normal
6771 wait_osc_import_state client ost FULL
6773 lfs df || error "lfs df with reactivated OSC failed"
6776 run_test 104a "lfs df [-ih] [path] test ========================="
6779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6780 [ $RUNAS_ID -eq $UID ] &&
6781 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6783 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6784 grep "Permission denied" | wc -l)))
6785 if [ $denied_cnt -ne 0 ]; then
6786 error "lfs check servers test failed"
6789 run_test 104b "$RUNAS lfs check servers test ===================="
6792 # doesn't work on 2.4 kernels
6794 if $(flock_is_enabled); then
6795 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6797 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6801 run_test 105a "flock when mounted without -o flock test ========"
6805 if $(flock_is_enabled); then
6806 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6808 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6812 run_test 105b "fcntl when mounted without -o flock test ========"
6816 if $(flock_is_enabled); then
6817 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6819 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6823 run_test 105c "lockf when mounted without -o flock test ========"
6825 test_105d() { # bug 15924
6826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6827 test_mkdir -p $DIR/$tdir
6828 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6829 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6830 $LCTL set_param fail_loc=0x80000315
6831 flocks_test 2 $DIR/$tdir
6833 run_test 105d "flock race (should not freeze) ========"
6835 test_105e() { # bug 22660 && 22040
6836 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
6838 flocks_test 3 $DIR/$tfile
6840 run_test 105e "Two conflicting flocks from same process ======="
6842 test_106() { #bug 10921
6843 test_mkdir -p $DIR/$tdir
6844 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6845 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6847 run_test 106 "attempt exec of dir followed by chown of that dir"
6850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6857 local save_pattern=$(sysctl -n kernel.core_pattern)
6858 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6859 sysctl -w kernel.core_pattern=$file
6860 sysctl -w kernel.core_uses_pid=0
6868 kill -s 11 $SLEEPPID
6870 if [ -e $file ]; then
6871 size=`stat -c%s $file`
6872 [ $size -eq 0 ] && error "Fail to create core file $file"
6874 error "Fail to create core file $file"
6877 sysctl -w kernel.core_pattern=$save_pattern
6878 sysctl -w kernel.core_uses_pid=$save_uses_pid
6881 run_test 107 "Coredump on SIG"
6884 test_mkdir -p $DIR/$tdir
6885 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6886 error "mkdir with 255 char failed"
6887 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6888 error "mkdir with 256 char should fail, but did not"
6889 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6890 error "create with 255 char failed"
6891 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6892 error "create with 256 char should fail, but did not"
6897 run_test 110 "filename length checking"
6900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6901 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
6902 tail -1 | cut -c11-20)
6903 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
6904 echo "Starting with $OSTIO_pre threads"
6907 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
6908 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
6909 echo "$NUMTEST creates/unlinks"
6910 test_mkdir -p $DIR/$tdir
6911 createmany -o $DIR/$tdir/$tfile $NUMTEST
6912 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6914 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
6915 tail -1 | cut -c11-20)
6917 # don't return an error
6918 [ $OSTIO_post == $OSTIO_pre ] && echo \
6919 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6920 echo "This may be fine, depending on what ran before this test" &&
6921 echo "and how fast this system is." && return
6923 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6925 run_test 115 "verify dynamic thread creation===================="
6928 wait_delete_completed
6929 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6930 echo OST kbytes available: ${AVAIL[@]}
6931 MAXI=0; MAXV=${AVAIL[0]}
6932 MINI=0; MINV=${AVAIL[0]}
6933 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6934 #echo OST $i: ${AVAIL[i]}kb
6935 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
6936 MAXV=${AVAIL[i]}; MAXI=$i
6938 if [[ ${AVAIL[i]} -lt $MINV ]]; then
6939 MINV=${AVAIL[i]}; MINI=$i
6942 echo Min free space: OST $MINI: $MINV
6943 echo Max free space: OST $MAXI: $MAXV
6946 test_116a() { # was previously test_116()
6947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6948 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
6950 echo -n "Free space priority "
6951 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6956 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6957 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
6959 trap simple_cleanup_common EXIT
6962 # Check if we need to generate uneven OSTs
6963 test_mkdir -p $DIR/$tdir/OST${MINI}
6964 local FILL=$(($MINV / 4))
6965 local DIFF=$(($MAXV - $MINV))
6966 local DIFF2=$(($DIFF * 100 / $MINV))
6968 local threshold=$(do_facet $SINGLEMDS \
6969 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
6970 threshold=${threshold%%%}
6971 echo -n "Check for uneven OSTs: "
6972 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6974 if [[ $DIFF2 -gt $threshold ]]; then
6976 echo "Don't need to fill OST$MINI"
6978 # generate uneven OSTs. Write 2% over the QOS threshold value
6980 DIFF=$(($threshold - $DIFF2 + 2))
6981 DIFF2=$(( ($MINV * $DIFF)/100 ))
6982 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6983 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6984 error "setstripe failed"
6985 DIFF=$(($DIFF2 / 2048))
6987 while [ $i -lt $DIFF ]; do
6989 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6990 bs=2M count=1 2>/dev/null
6999 DIFF=$(($MAXV - $MINV))
7000 DIFF2=$(($DIFF * 100 / $MINV))
7001 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7002 if [[ $DIFF2 -gt $threshold ]]; then
7005 echo "failed - QOS mode won't be used"
7006 skip "QOS imbalance criteria not met"
7007 simple_cleanup_common
7011 MINI1=$MINI; MINV1=$MINV
7012 MAXI1=$MAXI; MAXV1=$MAXV
7014 # now fill using QOS
7015 $SETSTRIPE -c 1 $DIR/$tdir
7016 FILL=$(($FILL / 200))
7017 if [ $FILL -gt 600 ]; then
7020 echo "writing $FILL files to QOS-assigned OSTs"
7022 while [ $i -lt $FILL ]; do
7024 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7028 echo "wrote $i 200k files"
7032 echo "Note: free space may not be updated, so measurements might be off"
7034 DIFF2=$(($MAXV - $MINV))
7035 echo "free space delta: orig $DIFF final $DIFF2"
7036 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7037 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7038 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7039 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7040 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7041 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7043 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7045 # Figure out which files were written where
7046 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7047 awk '/'$MINI1': / {print $2; exit}')
7049 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7050 echo "$MINC files created on smaller OST $MINI1"
7051 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7052 awk '/'$MAXI1': / {print $2; exit}')
7054 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7055 echo "$MAXC files created on larger OST $MAXI1"
7056 FILL=$(($MAXC * 100 / $MINC - 100))
7057 [[ $MINC -gt 0 ]] &&
7058 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7059 [[ $MAXC -gt $MINC ]] ||
7060 error_ignore LU-9 "stripe QOS didn't balance free space"
7061 simple_cleanup_common
7063 run_test 116a "stripe QOS: free space balance ==================="
7065 test_116b() { # LU-2093
7066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7067 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7068 head -1 2>/dev/null)" ] && skip "no QOS" && return
7069 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7071 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7072 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7073 do_facet $SINGLEMDS lctl set_param \
7074 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7076 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7077 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7078 do_facet $SINGLEMDS lctl set_param fail_loc=0
7080 do_facet $SINGLEMDS lctl set_param \
7081 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7083 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7085 test_117() # bug 10891
7087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7088 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7089 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7090 lctl set_param fail_loc=0x21e
7091 > $DIR/$tfile || error "truncate failed"
7092 lctl set_param fail_loc=0
7093 echo "Truncate succeeded."
7096 run_test 117 "verify osd extend =========="
7098 NO_SLOW_RESENDCOUNT=4
7099 export OLD_RESENDCOUNT=""
7100 set_resend_count () {
7101 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7102 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7103 lctl set_param -n $PROC_RESENDCOUNT $1
7104 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7107 # for reduce test_118* time (b=14842)
7108 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7110 # Reset async IO behavior after error case
7112 FILE=$DIR/reset_async
7114 # Ensure all OSCs are cleared
7115 $SETSTRIPE -c -1 $FILE
7116 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7121 test_118a() #bug 11710
7123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7126 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7127 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7128 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7130 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7131 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7136 run_test 118a "verify O_SYNC works =========="
7140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7141 remote_ost_nodsh && skip "remote OST with nodsh" && return
7145 #define OBD_FAIL_OST_ENOENT 0x217
7146 set_nodes_failloc "$(osts_nodes)" 0x217
7147 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7149 set_nodes_failloc "$(osts_nodes)" 0
7150 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7151 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7154 if [[ $RC -eq 0 ]]; then
7155 error "Must return error due to dropped pages, rc=$RC"
7159 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7160 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7164 echo "Dirty pages not leaked on ENOENT"
7166 # Due to the above error the OSC will issue all RPCs syncronously
7167 # until a subsequent RPC completes successfully without error.
7168 $MULTIOP $DIR/$tfile Ow4096yc
7173 run_test 118b "Reclaim dirty pages on fatal error =========="
7177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7179 # for 118c, restore the original resend count, LU-1940
7180 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7181 set_resend_count $OLD_RESENDCOUNT
7182 remote_ost_nodsh && skip "remote OST with nodsh" && return
7186 #define OBD_FAIL_OST_EROFS 0x216
7187 set_nodes_failloc "$(osts_nodes)" 0x216
7189 # multiop should block due to fsync until pages are written
7190 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7194 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7195 error "Multiop failed to block on fsync, pid=$MULTIPID"
7198 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7200 if [[ $WRITEBACK -eq 0 ]]; then
7201 error "No page in writeback, writeback=$WRITEBACK"
7204 set_nodes_failloc "$(osts_nodes)" 0
7207 if [[ $RC -ne 0 ]]; then
7208 error "Multiop fsync failed, rc=$RC"
7211 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7212 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7214 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7215 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7219 echo "Dirty pages flushed via fsync on EROFS"
7222 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7224 # continue to use small resend count to reduce test_118* time (b=14842)
7225 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7230 remote_ost_nodsh && skip "remote OST with nodsh" && return
7234 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7235 set_nodes_failloc "$(osts_nodes)" 0x214
7236 # multiop should block due to fsync until pages are written
7237 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7241 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7242 error "Multiop failed to block on fsync, pid=$MULTIPID"
7245 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7247 if [[ $WRITEBACK -eq 0 ]]; then
7248 error "No page in writeback, writeback=$WRITEBACK"
7251 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7252 set_nodes_failloc "$(osts_nodes)" 0
7254 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7255 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7257 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7258 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7262 echo "Dirty pages gaurenteed flushed via fsync"
7265 run_test 118d "Fsync validation inject a delay of the bulk =========="
7268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7271 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7272 lctl set_param fail_loc=0x8000040a
7274 # Should simulate EINVAL error which is fatal
7275 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7277 if [[ $RC -eq 0 ]]; then
7278 error "Must return error due to dropped pages, rc=$RC"
7281 lctl set_param fail_loc=0x0
7283 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7284 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7285 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7287 if [[ $LOCKED -ne 0 ]]; then
7288 error "Locked pages remain in cache, locked=$LOCKED"
7291 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7292 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7296 echo "No pages locked after fsync"
7301 run_test 118f "Simulate unrecoverable OSC side error =========="
7304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7307 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7308 lctl set_param fail_loc=0x406
7310 # simulate local -ENOMEM
7311 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7314 lctl set_param fail_loc=0
7315 if [[ $RC -eq 0 ]]; then
7316 error "Must return error due to dropped pages, rc=$RC"
7319 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7320 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7321 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7323 if [[ $LOCKED -ne 0 ]]; then
7324 error "Locked pages remain in cache, locked=$LOCKED"
7327 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7328 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7332 echo "No pages locked after fsync"
7337 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7341 remote_ost_nodsh && skip "remote OST with nodsh" && return
7345 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7346 set_nodes_failloc "$(osts_nodes)" 0x20e
7347 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7348 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7351 set_nodes_failloc "$(osts_nodes)" 0
7352 if [[ $RC -eq 0 ]]; then
7353 error "Must return error due to dropped pages, rc=$RC"
7356 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7357 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7358 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7360 if [[ $LOCKED -ne 0 ]]; then
7361 error "Locked pages remain in cache, locked=$LOCKED"
7364 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7365 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7369 echo "No pages locked after fsync"
7373 run_test 118h "Verify timeout in handling recoverables errors =========="
7375 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7379 remote_ost_nodsh && skip "remote OST with nodsh" && return
7383 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7384 set_nodes_failloc "$(osts_nodes)" 0x20e
7386 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7387 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7390 set_nodes_failloc "$(osts_nodes)" 0
7394 if [[ $RC -ne 0 ]]; then
7395 error "got error, but should be not, rc=$RC"
7398 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7399 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7400 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7401 if [[ $LOCKED -ne 0 ]]; then
7402 error "Locked pages remain in cache, locked=$LOCKED"
7405 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7406 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7410 echo "No pages locked after fsync"
7414 run_test 118i "Fix error before timeout in recoverable error =========="
7416 [ "$SLOW" = "no" ] && set_resend_count 4
7419 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7420 remote_ost_nodsh && skip "remote OST with nodsh" && return
7424 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7425 set_nodes_failloc "$(osts_nodes)" 0x220
7427 # return -EIO from OST
7428 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7430 set_nodes_failloc "$(osts_nodes)" 0x0
7431 if [[ $RC -eq 0 ]]; then
7432 error "Must return error due to dropped pages, rc=$RC"
7435 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7436 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7437 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7438 if [[ $LOCKED -ne 0 ]]; then
7439 error "Locked pages remain in cache, locked=$LOCKED"
7442 # in recoverable error on OST we want resend and stay until it finished
7443 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7444 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7448 echo "No pages locked after fsync"
7452 run_test 118j "Simulate unrecoverable OST side error =========="
7456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7457 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7459 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7460 set_nodes_failloc "$(osts_nodes)" 0x20e
7461 test_mkdir -p $DIR/$tdir
7463 for ((i=0;i<10;i++)); do
7464 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7465 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7472 set_nodes_failloc "$(osts_nodes)" 0
7475 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7481 test_mkdir -p $DIR/$tdir
7482 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7485 run_test 118l "fsync dir ========="
7487 test_118m() # LU-3066
7489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7490 test_mkdir -p $DIR/$tdir
7491 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7494 run_test 118m "fdatasync dir ========="
7496 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7498 test_119a() # bug 11737
7500 BSIZE=$((512 * 1024))
7501 directio write $DIR/$tfile 0 1 $BSIZE
7502 # We ask to read two blocks, which is more than a file size.
7503 # directio will indicate an error when requested and actual
7504 # sizes aren't equeal (a normal situation in this case) and
7505 # print actual read amount.
7506 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7507 if [ "$NOB" != "$BSIZE" ]; then
7508 error "read $NOB bytes instead of $BSIZE"
7512 run_test 119a "Short directIO read must return actual read amount"
7514 test_119b() # bug 11737
7516 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7518 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7519 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7521 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7522 error "direct read failed"
7525 run_test 119b "Sparse directIO read must return actual read amount"
7527 test_119c() # bug 13099
7530 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7531 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7534 run_test 119c "Testing for direct read hitting hole"
7536 test_119d() # bug 15950
7538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7539 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7540 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7542 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7543 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7544 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7545 lctl set_param fail_loc=0x40d
7546 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7549 cat $DIR/$tfile > /dev/null &
7550 lctl set_param fail_loc=0
7553 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7555 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7556 error "the read rpcs have not completed in 2s"
7558 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7560 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7564 test_mkdir -p $DIR/$tdir
7565 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7566 skip "no early lock cancel on server" && return 0
7568 lru_resize_disable mdc
7569 lru_resize_disable osc
7570 cancel_lru_locks mdc
7571 # asynchronous object destroy at MDT could cause bl ast to client
7572 cancel_lru_locks osc
7574 stat $DIR/$tdir > /dev/null
7575 can1=$(do_facet $SINGLEMDS \
7576 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7577 awk '/ldlm_cancel/ {print $2}')
7578 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7579 awk '/ldlm_bl_callback/ {print $2}')
7580 test_mkdir -c1 $DIR/$tdir/d1
7581 can2=$(do_facet $SINGLEMDS \
7582 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7583 awk '/ldlm_cancel/ {print $2}')
7584 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7585 awk '/ldlm_bl_callback/ {print $2}')
7586 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7587 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7588 lru_resize_enable mdc
7589 lru_resize_enable osc
7591 run_test 120a "Early Lock Cancel: mkdir test"
7594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7595 test_mkdir $DIR/$tdir
7596 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7597 skip "no early lock cancel on server" && return 0
7598 lru_resize_disable mdc
7599 lru_resize_disable osc
7600 cancel_lru_locks mdc
7601 stat $DIR/$tdir > /dev/null
7602 can1=$(do_facet $SINGLEMDS \
7603 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7604 awk '/ldlm_cancel/ {print $2}')
7605 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7606 awk '/ldlm_bl_callback/ {print $2}')
7608 can2=$(do_facet $SINGLEMDS \
7609 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7610 awk '/ldlm_cancel/ {print $2}')
7611 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7612 awk '/ldlm_bl_callback/ {print $2}')
7613 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7614 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7615 lru_resize_enable mdc
7616 lru_resize_enable osc
7618 run_test 120b "Early Lock Cancel: create test"
7621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7622 test_mkdir -c1 $DIR/$tdir
7623 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7624 skip "no early lock cancel on server" && return 0
7625 lru_resize_disable mdc
7626 lru_resize_disable osc
7627 test_mkdir -p -c1 $DIR/$tdir/d1
7628 test_mkdir -p -c1 $DIR/$tdir/d2
7629 touch $DIR/$tdir/d1/f1
7630 cancel_lru_locks mdc
7631 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7632 can1=$(do_facet $SINGLEMDS \
7633 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7634 awk '/ldlm_cancel/ {print $2}')
7635 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7636 awk '/ldlm_bl_callback/ {print $2}')
7637 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7638 can2=$(do_facet $SINGLEMDS \
7639 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7640 awk '/ldlm_cancel/ {print $2}')
7641 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7642 awk '/ldlm_bl_callback/ {print $2}')
7643 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7644 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7645 lru_resize_enable mdc
7646 lru_resize_enable osc
7648 run_test 120c "Early Lock Cancel: link test"
7651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7652 test_mkdir -p -c1 $DIR/$tdir
7653 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7654 skip "no early lock cancel on server" && return 0
7655 lru_resize_disable mdc
7656 lru_resize_disable osc
7658 cancel_lru_locks mdc
7659 stat $DIR/$tdir > /dev/null
7660 can1=$(do_facet $SINGLEMDS \
7661 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7662 awk '/ldlm_cancel/ {print $2}')
7663 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7664 awk '/ldlm_bl_callback/ {print $2}')
7665 chmod a+x $DIR/$tdir
7666 can2=$(do_facet $SINGLEMDS \
7667 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7668 awk '/ldlm_cancel/ {print $2}')
7669 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7670 awk '/ldlm_bl_callback/ {print $2}')
7671 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7672 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7673 lru_resize_enable mdc
7674 lru_resize_enable osc
7676 run_test 120d "Early Lock Cancel: setattr test"
7679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7680 test_mkdir -p -c1 $DIR/$tdir
7681 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7682 skip "no early lock cancel on server" && return 0
7683 lru_resize_disable mdc
7684 lru_resize_disable osc
7685 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7686 cancel_lru_locks mdc
7687 cancel_lru_locks osc
7688 dd if=$DIR/$tdir/f1 of=/dev/null
7689 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7690 # XXX client can not do early lock cancel of OST lock
7691 # during unlink (LU-4206), so cancel osc lock now.
7692 cancel_lru_locks osc
7693 can1=$(do_facet $SINGLEMDS \
7694 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7695 awk '/ldlm_cancel/ {print $2}')
7696 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7697 awk '/ldlm_bl_callback/ {print $2}')
7698 unlink $DIR/$tdir/f1
7700 can2=$(do_facet $SINGLEMDS \
7701 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7702 awk '/ldlm_cancel/ {print $2}')
7703 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7704 awk '/ldlm_bl_callback/ {print $2}')
7705 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7706 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7707 lru_resize_enable mdc
7708 lru_resize_enable osc
7710 run_test 120e "Early Lock Cancel: unlink test"
7713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7714 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7715 skip "no early lock cancel on server" && return 0
7716 test_mkdir -p -c1 $DIR/$tdir
7717 lru_resize_disable mdc
7718 lru_resize_disable osc
7719 test_mkdir -p -c1 $DIR/$tdir/d1
7720 test_mkdir -p -c1 $DIR/$tdir/d2
7721 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7722 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7723 cancel_lru_locks mdc
7724 cancel_lru_locks osc
7725 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7726 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7727 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7728 # XXX client can not do early lock cancel of OST lock
7729 # during rename (LU-4206), so cancel osc lock now.
7730 cancel_lru_locks osc
7731 can1=$(do_facet $SINGLEMDS \
7732 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7733 awk '/ldlm_cancel/ {print $2}')
7734 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7735 awk '/ldlm_bl_callback/ {print $2}')
7736 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7738 can2=$(do_facet $SINGLEMDS \
7739 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7740 awk '/ldlm_cancel/ {print $2}')
7741 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7742 awk '/ldlm_bl_callback/ {print $2}')
7743 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7744 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7745 lru_resize_enable mdc
7746 lru_resize_enable osc
7748 run_test 120f "Early Lock Cancel: rename test"
7751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7752 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7753 skip "no early lock cancel on server" && return 0
7754 lru_resize_disable mdc
7755 lru_resize_disable osc
7757 echo create $count files
7758 test_mkdir -p $DIR/$tdir
7759 cancel_lru_locks mdc
7760 cancel_lru_locks osc
7763 can0=$(do_facet $SINGLEMDS \
7764 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7765 awk '/ldlm_cancel/ {print $2}')
7766 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7767 awk '/ldlm_bl_callback/ {print $2}')
7768 createmany -o $DIR/$tdir/f $count
7770 can1=$(do_facet $SINGLEMDS \
7771 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7772 awk '/ldlm_cancel/ {print $2}')
7773 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7774 awk '/ldlm_bl_callback/ {print $2}')
7776 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7777 echo rm $count files
7780 can2=$(do_facet $SINGLEMDS \
7781 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7782 awk '/ldlm_cancel/ {print $2}')
7783 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7784 awk '/ldlm_bl_callback/ {print $2}')
7786 echo total: $count removes in $((t2-t1))
7787 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7789 # wait for commitment of removal
7790 lru_resize_enable mdc
7791 lru_resize_enable osc
7793 run_test 120g "Early Lock Cancel: performance test"
7795 test_121() { #bug #10589
7796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7798 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7799 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7800 lctl set_param fail_loc=0x310
7801 cancel_lru_locks osc > /dev/null
7802 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7803 lctl set_param fail_loc=0
7804 [[ $reads -eq $writes ]] ||
7805 error "read $reads blocks, must be $writes blocks"
7807 run_test 121 "read cancel race ========="
7809 test_123a() { # was test 123, statahead(bug 11401)
7810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7812 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7813 log "testing on UP system. Performance may be not as good as expected."
7818 test_mkdir -p $DIR/$tdir
7819 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7820 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7822 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7823 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7825 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7826 lctl set_param -n llite.*.statahead_max 0
7827 lctl get_param llite.*.statahead_max
7828 cancel_lru_locks mdc
7829 cancel_lru_locks osc
7831 time ls -l $DIR/$tdir | wc -l
7833 delta=$((etime - stime))
7834 log "ls $i files without statahead: $delta sec"
7835 lctl set_param llite.*.statahead_max=$max
7837 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7838 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7839 cancel_lru_locks mdc
7840 cancel_lru_locks osc
7842 time ls -l $DIR/$tdir | wc -l
7844 delta_sa=$((etime - stime))
7845 log "ls $i files with statahead: $delta_sa sec"
7846 lctl get_param -n llite.*.statahead_stats
7847 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7849 [[ $swrong -lt $ewrong ]] &&
7850 log "statahead was stopped, maybe too many locks held!"
7851 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
7853 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7854 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7855 lctl set_param -n llite.*.statahead_max 0
7856 lctl get_param llite.*.statahead_max
7857 cancel_lru_locks mdc
7858 cancel_lru_locks osc
7860 time ls -l $DIR/$tdir | wc -l
7862 delta=$((etime - stime))
7863 log "ls $i files again without statahead: $delta sec"
7864 lctl set_param llite.*.statahead_max=$max
7865 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7866 if [ $SLOWOK -eq 0 ]; then
7867 error "ls $i files is slower with statahead!"
7869 log "ls $i files is slower with statahead!"
7875 [ $delta -gt 20 ] && break
7876 [ $delta -gt 8 ] && MULT=$((50 / delta))
7877 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7885 delta=$((etime - stime))
7886 log "rm -r $DIR/$tdir/: $delta seconds"
7888 lctl get_param -n llite.*.statahead_stats
7890 run_test 123a "verify statahead work"
7892 test_123b () { # statahead(bug 15027)
7893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7894 test_mkdir -p $DIR/$tdir
7895 createmany -o $DIR/$tdir/$tfile-%d 1000
7897 cancel_lru_locks mdc
7898 cancel_lru_locks osc
7900 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7901 lctl set_param fail_loc=0x80000803
7902 ls -lR $DIR/$tdir > /dev/null
7904 lctl set_param fail_loc=0x0
7905 lctl get_param -n llite.*.statahead_stats
7910 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7913 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7914 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
7915 skip "no lru resize on server" && return 0
7917 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7919 log "create $NR files at $DIR/$tdir"
7920 createmany -o $DIR/$tdir/f $NR ||
7921 error "failed to create $NR files in $DIR/$tdir"
7923 cancel_lru_locks mdc
7924 ls -l $DIR/$tdir > /dev/null
7928 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
7929 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
7930 LRU_SIZE=$($LCTL get_param -n $PARAM)
7931 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
7932 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7934 log "NS=$(basename $NSDIR)"
7939 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
7940 skip "Not enough cached locks created!"
7947 # We know that lru resize allows one client to hold $LIMIT locks
7948 # for 10h. After that locks begin to be killed by client.
7950 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
7953 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7954 # killing locks. Some time was spent for creating locks. This means
7955 # that up to the moment of sleep finish we must have killed some of
7956 # them (10-100 locks). This depends on how fast ther were created.
7957 # Many of them were touched in almost the same moment and thus will
7958 # be killed in groups.
7959 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7961 # Use $LRU_SIZE_B here to take into account real number of locks
7962 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7963 local LRU_SIZE_B=$LRU_SIZE
7965 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
7966 log "OLD_LVF=$OLD_LVF"
7967 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
7969 # Let's make sure that we really have some margin. Client checks
7970 # cached locks every 10 sec.
7972 log "Sleep ${SLEEP} sec"
7974 while ((SEC<$SLEEP)); do
7978 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
7982 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7983 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
7985 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
7986 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7987 unlinkmany $DIR/$tdir/f $NR
7991 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7992 log "unlink $NR files at $DIR/$tdir"
7993 unlinkmany $DIR/$tdir/f $NR
7995 run_test 124a "lru resize ======================================="
7997 get_max_pool_limit()
7999 local limit=$($LCTL get_param \
8000 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8003 if [[ $l -gt $max ]]; then
8011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8012 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8013 skip "no lru resize on server" && return 0
8015 LIMIT=$(get_max_pool_limit)
8017 NR=$(($(default_lru_size)*20))
8018 if [[ $NR -gt $LIMIT ]]; then
8019 log "Limit lock number by $LIMIT locks"
8022 lru_resize_disable mdc
8023 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8024 error "failed to create $DIR/$tdir/disable_lru_resize"
8026 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8027 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8028 cancel_lru_locks mdc
8031 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8034 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8037 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8041 nolruresize_delta=$((etime-stime))
8042 log "ls -la time: $nolruresize_delta seconds"
8043 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8044 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8046 lru_resize_enable mdc
8047 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8048 error "failed to create $DIR/$tdir/enable_lru_resize"
8050 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8051 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8052 cancel_lru_locks mdc
8055 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8058 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8061 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8065 lruresize_delta=$((etime-stime))
8066 log "ls -la time: $lruresize_delta seconds"
8067 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8069 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8070 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8071 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8072 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8074 log "lru resize performs the same with no lru resize"
8076 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8078 run_test 124b "lru resize (performance test) ======================="
8080 test_125() { # 13358
8081 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8082 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8083 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8084 test_mkdir -p $DIR/d125 || error "mkdir failed"
8085 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8086 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8087 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8089 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8091 test_126() { # bug 12829/13455
8092 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8093 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8094 $GSS && skip "must run as gss disabled" && return
8096 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8097 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8099 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8101 run_test 126 "check that the fsgid provided by the client is taken into account"
8103 test_127a() { # bug 15521
8104 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8105 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8106 $LCTL set_param osc.*.stats=0
8107 FSIZE=$((2048 * 1024))
8108 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8109 cancel_lru_locks osc
8110 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8112 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8113 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8114 echo "got $COUNT $NAME"
8115 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8116 eval $NAME=$COUNT || error "Wrong proc format"
8119 read_bytes|write_bytes)
8120 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8121 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8122 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8123 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8124 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8125 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8126 error "sumsquare is too small: $SUMSQ"
8127 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8128 error "sumsquare is too big: $SUMSQ"
8132 done < $DIR/${tfile}.tmp
8134 #check that we actually got some stats
8135 [ "$read_bytes" ] || error "Missing read_bytes stats"
8136 [ "$write_bytes" ] || error "Missing write_bytes stats"
8137 [ "$read_bytes" != 0 ] || error "no read done"
8138 [ "$write_bytes" != 0 ] || error "no write done"
8140 run_test 127a "verify the client stats are sane"
8142 test_127b() { # bug LU-333
8143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8144 $LCTL set_param llite.*.stats=0
8145 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8146 # perform 2 reads and writes so MAX is different from SUM.
8147 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8148 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8149 cancel_lru_locks osc
8150 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8151 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8153 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8154 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8155 echo "got $COUNT $NAME"
8156 eval $NAME=$COUNT || error "Wrong proc format"
8160 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8161 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8162 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8163 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8166 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8167 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8168 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8169 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8173 done < $TMP/${tfile}.tmp
8175 #check that we actually got some stats
8176 [ "$read_bytes" ] || error "Missing read_bytes stats"
8177 [ "$write_bytes" ] || error "Missing write_bytes stats"
8178 [ "$read_bytes" != 0 ] || error "no read done"
8179 [ "$write_bytes" != 0 ] || error "no write done"
8181 run_test 127b "verify the llite client stats are sane"
8183 test_128() { # bug 15212
8185 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8190 result=$(grep error $TMP/$tfile.log)
8192 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8194 run_test 128 "interactive lfs for 2 consecutive find's"
8201 local LDPROC=/proc/fs/ldiskfs
8202 local facets=$(get_facets MDS)
8204 for facet in ${facets//,/ }; do
8205 canondev=$(ldiskfs_canon \
8206 *.$(convert_facet2label $facet).mntdev $facet)
8207 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8208 LDPROC=/sys/fs/ldiskfs
8209 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8215 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8216 skip "Only applicable to ldiskfs-based MDTs"
8219 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8224 test_mkdir -p $DIR/$tdir
8226 # block size of mds1
8227 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8228 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8229 local MAX=$((MDSBLOCKSIZE * 3))
8231 local I=$(stat -c%s "$DIR/$tdir")
8233 local STRIPE_COUNT=1
8234 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8235 MAX=$((MAX*STRIPE_COUNT))
8236 while [[ $I -le $MAX ]]; do
8237 $MULTIOP $DIR/$tdir/$J Oc
8239 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8240 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8241 #and EFBIG for previous versions
8242 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8244 echo "return code $rc received as expected"
8245 multiop $DIR/$tdir/$J Oc ||
8246 error_exit "multiop failed w/o dir size limit"
8248 I=$(stat -c%s "$DIR/$tdir")
8250 if [ $(lustre_version_code $SINGLEMDS) -lt \
8251 $(version_code 2.4.51) ]
8253 [[ $I -eq $MAX ]] && return 0
8255 [[ $I -gt $MAX ]] && return 0
8257 error_exit "current dir size $I, previous limit $MAX"
8258 elif [ $rc -ne 0 ]; then
8260 error_exit "return code $rc received instead of expected " \
8261 "$EFBIG or $ENOSPC, files in dir $I"
8264 I=$(stat -c%s "$DIR/$tdir")
8268 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8270 run_test 129 "test directory size limit ========================"
8279 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8280 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8283 trap cleanup_130 EXIT RETURN
8285 local fm_file=$DIR/$tfile
8286 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8287 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8288 error "dd failed for $fm_file"
8290 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8291 filefrag -ves $fm_file
8293 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8294 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8295 [ $RC != 0 ] && error "filefrag $fm_file failed"
8297 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8298 grep -v "ext:" | grep -v "found")
8299 lun=$($GETSTRIPE -i $fm_file)
8301 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8304 for line in $filefrag_op
8306 frag_lun=`echo $line | cut -d: -f5`
8307 ext_len=`echo $line | cut -d: -f4`
8308 if (( $frag_lun != $lun )); then
8310 error "FIEMAP on 1-stripe file($fm_file) failed"
8313 (( tot_len += ext_len ))
8316 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8318 error "FIEMAP on 1-stripe file($fm_file) failed;"
8324 echo "FIEMAP on single striped file succeeded"
8326 run_test 130a "FIEMAP (1-stripe file)"
8329 [ "$OSTCOUNT" -lt "2" ] &&
8330 skip_env "skipping FIEMAP on 2-stripe file test" && return
8332 [ "$OSTCOUNT" -ge "10" ] &&
8333 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8335 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8336 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8339 trap cleanup_130 EXIT RETURN
8341 local fm_file=$DIR/$tfile
8342 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8343 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8344 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8346 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8347 error "dd failed on $fm_file"
8349 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8350 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8351 grep -v "ext:" | grep -v "found")
8353 last_lun=$(echo $filefrag_op | cut -d: -f5)
8358 for line in $filefrag_op
8360 frag_lun=`echo $line | cut -d: -f5`
8361 ext_len=`echo $line | cut -d: -f4`
8362 if (( $frag_lun != $last_lun )); then
8363 if (( tot_len != 1024 )); then
8365 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8372 (( tot_len += ext_len ))
8375 if (( num_luns != 2 || tot_len != 1024 )); then
8377 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8383 echo "FIEMAP on 2-stripe file succeeded"
8385 run_test 130b "FIEMAP (2-stripe file)"
8388 [ "$OSTCOUNT" -lt "2" ] &&
8389 skip_env "skipping FIEMAP on 2-stripe file" && return
8391 [ "$OSTCOUNT" -ge "10" ] &&
8392 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8394 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8395 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8398 trap cleanup_130 EXIT RETURN
8400 local fm_file=$DIR/$tfile
8401 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8402 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8403 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8405 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8407 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8408 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8410 last_lun=`echo $filefrag_op | cut -d: -f5`
8415 for line in $filefrag_op
8417 frag_lun=`echo $line | cut -d: -f5`
8418 ext_len=`echo $line | cut -d: -f4`
8419 if (( $frag_lun != $last_lun )); then
8420 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8421 if (( logical != 512 )); then
8423 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8426 if (( tot_len != 512 )); then
8428 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8435 (( tot_len += ext_len ))
8438 if (( num_luns != 2 || tot_len != 512 )); then
8440 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8446 echo "FIEMAP on 2-stripe file with hole succeeded"
8448 run_test 130c "FIEMAP (2-stripe file with hole)"
8451 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8453 [ "$OSTCOUNT" -ge "10" ] &&
8454 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8456 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8457 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8459 trap cleanup_130 EXIT RETURN
8461 local fm_file=$DIR/$tfile
8462 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8463 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8464 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8466 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8467 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8468 error "dd failed on $fm_file"
8470 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8471 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8472 grep -v "ext:" | grep -v "found"`
8474 last_lun=`echo $filefrag_op | cut -d: -f5`
8479 for line in $filefrag_op
8481 frag_lun=`echo $line | cut -d: -f5`
8482 ext_len=`echo $line | cut -d: -f4`
8483 if (( $frag_lun != $last_lun )); then
8484 if (( tot_len != 1024 )); then
8486 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8493 (( tot_len += ext_len ))
8496 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8498 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8504 echo "FIEMAP on N-stripe file succeeded"
8506 run_test 130d "FIEMAP (N-stripe file)"
8509 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8511 [ "$OSTCOUNT" -ge "10" ] &&
8512 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8514 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8515 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8517 trap cleanup_130 EXIT RETURN
8519 local fm_file=$DIR/$tfile
8520 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8521 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8522 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8525 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8526 for ((i = 0; i < $NUM_BLKS; i++))
8528 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8531 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8532 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8534 last_lun=`echo $filefrag_op | cut -d: -f5`
8539 for line in $filefrag_op
8541 frag_lun=`echo $line | cut -d: -f5`
8542 ext_len=`echo $line | cut -d: -f4`
8543 if (( $frag_lun != $last_lun )); then
8544 if (( tot_len != $EXPECTED_LEN )); then
8546 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8553 (( tot_len += ext_len ))
8556 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8558 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8564 echo "FIEMAP with continuation calls succeeded"
8566 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8568 # Test for writev/readv
8570 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8571 error "writev test failed"
8572 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8573 error "readv failed"
8576 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8579 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8580 error "append writev test failed"
8581 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8582 error "append writev test failed"
8585 run_test 131b "test append writev"
8588 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8591 run_test 131c "test read/write on file w/o objects"
8594 rwv -f $DIR/$tfile -w -n 1 1572864
8595 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8596 if [ "$NOB" != 1572864 ]; then
8597 error "Short read filed: read $NOB bytes instead of 1572864"
8601 run_test 131d "test short read"
8604 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8605 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8606 error "read hitting hole failed"
8609 run_test 131e "test read hitting hole"
8614 for node in $(osts_nodes); do
8615 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8616 [ x$gl = x"" ] && gl=0
8617 gl_sum=$((gl_sum + gl))
8627 if [ x$som = x"enabled" ]; then
8628 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8629 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8630 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8632 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8633 MOUNTOPT="$MOUNTOPT,som_preview"
8634 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8637 # do remount to make new mount-conf parameters actual
8644 test_132() { #1028, SOM
8645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8647 local num=$(get_mds_dir $DIR)
8648 local mymds=mds${num}
8649 local MOUNTOPT_SAVE=$MOUNTOPT
8651 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8652 cancel_lru_locks osc
8654 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8656 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8657 stat $DIR/$tfile >/dev/null
8658 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8659 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8661 som_mode_switch $som1 $gl1 $gl2
8663 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8664 cancel_lru_locks osc
8666 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8667 if [ $som1 == $som2 ]; then
8668 error "som is still "$som2
8669 if [ x$som2 = x"enabled" ]; then
8676 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8677 stat $DIR/$tfile >/dev/null
8678 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8679 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8680 som_mode_switch $som2 $gl1 $gl2
8681 MOUNTOPT=$MOUNTOPT_SAVE
8683 run_test 132 "som avoids glimpse rpc"
8689 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8691 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8693 *) error "Wrong argument $1" ;;
8696 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8697 # if the argument $3 is zero, it means any stat increment is ok.
8698 if [[ $3 -gt 0 ]]; then
8699 count=$(echo $res | awk '{ print $2 }')
8700 [[ $count -ne $3 ]] &&
8701 error "The $2 counter on $1 is wrong - expected $3"
8706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8707 remote_ost_nodsh && skip "remote OST with nodsh" && return
8708 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8710 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8711 { skip "MDS doesn't support rename stats"; return; }
8712 local testdir=$DIR/${tdir}/stats_testdir
8713 mkdir -p $DIR/${tdir}
8716 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8717 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8719 # verify mdt stats first.
8720 mkdir ${testdir} || error "mkdir failed"
8721 check_stats $SINGLEMDS "mkdir" 1
8722 touch ${testdir}/${tfile} || "touch failed"
8723 check_stats $SINGLEMDS "open" 1
8724 check_stats $SINGLEMDS "close" 1
8725 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8726 check_stats $SINGLEMDS "mknod" 1
8727 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8728 check_stats $SINGLEMDS "unlink" 1
8729 rm -f ${testdir}/${tfile} || error "file remove failed"
8730 check_stats $SINGLEMDS "unlink" 2
8732 # remove working dir and check mdt stats again.
8733 rmdir ${testdir} || error "rmdir failed"
8734 check_stats $SINGLEMDS "rmdir" 1
8736 local testdir1=$DIR/${tdir}/stats_testdir1
8738 mkdir -p ${testdir1}
8739 touch ${testdir1}/test1
8740 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8741 check_stats $SINGLEMDS "crossdir_rename" 1
8743 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8744 check_stats $SINGLEMDS "samedir_rename" 1
8748 run_test 133a "Verifying MDT stats ========================================"
8751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8752 remote_ost_nodsh && skip "remote OST with nodsh" && return
8753 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8754 local testdir=$DIR/${tdir}/stats_testdir
8755 mkdir -p ${testdir} || error "mkdir failed"
8756 touch ${testdir}/${tfile} || "touch failed"
8757 cancel_lru_locks mdc
8760 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8761 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8763 # extra mdt stats verification.
8764 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8765 check_stats $SINGLEMDS "setattr" 1
8766 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8767 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8769 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8770 check_stats $SINGLEMDS "getattr" 1
8772 $LFS df || error "lfs failed"
8773 check_stats $SINGLEMDS "statfs" 1
8777 run_test 133b "Verifying extra MDT stats =================================="
8780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8781 remote_ost_nodsh && skip "remote OST with nodsh" && return
8782 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8783 local testdir=$DIR/${tdir}/stats_testdir
8784 test_mkdir -p ${testdir} || error "mkdir failed"
8786 # verify obdfilter stats.
8787 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8789 cancel_lru_locks osc
8790 wait_delete_completed
8793 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8794 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8796 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8798 cancel_lru_locks osc
8799 check_stats ost "write" 1
8801 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8802 check_stats ost "read" 1
8804 > ${testdir}/${tfile} || error "truncate failed"
8805 check_stats ost "punch" 1
8807 rm -f ${testdir}/${tfile} || error "file remove failed"
8808 wait_delete_completed
8809 check_stats ost "destroy" 1
8813 run_test 133c "Verifying OST stats ========================================"
8820 while [ $value -ge 2 ]; do
8825 if [ $orig -gt $order ]; then
8833 local size=('K' 'M' 'G' 'T');
8835 local size_string=$value
8837 while [ $value -ge 1024 ]; do
8838 if [ $i -gt 3 ]; then
8839 #T is the biggest unit we get here, if that is bigger,
8841 size_string=${value}T
8844 value=$((value >> 10))
8845 if [ $value -lt 1024 ]; then
8846 size_string=${value}${size[$i]}
8857 local context=${2:-.}
8858 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8860 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8866 remote_ost_nodsh && skip "remote OST with nodsh" && return
8867 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8868 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8869 { skip "MDS doesn't support rename stats"; return; }
8871 local testdir1=$DIR/${tdir}/stats_testdir1
8872 local testdir2=$DIR/${tdir}/stats_testdir2
8874 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8876 mkdir -p ${testdir1} || error "mkdir failed"
8877 mkdir -p ${testdir2} || error "mkdir failed"
8879 createmany -o $testdir1/test 512 || error "createmany failed"
8881 # check samedir rename size
8882 mv ${testdir1}/test0 ${testdir1}/test_0
8884 local testdir1_size=$(ls -l $DIR/${tdir} |
8885 awk '/stats_testdir1/ {print $5}')
8886 local testdir2_size=$(ls -l $DIR/${tdir} |
8887 awk '/stats_testdir2/ {print $5}')
8889 testdir1_size=$(order_2 $testdir1_size)
8890 testdir2_size=$(order_2 $testdir2_size)
8892 testdir1_size=$(size_in_KMGT $testdir1_size)
8893 testdir2_size=$(size_in_KMGT $testdir2_size)
8895 echo "source rename dir size: ${testdir1_size}"
8896 echo "target rename dir size: ${testdir2_size}"
8898 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8899 eval $cmd || error "$cmd failed"
8900 local samedir=$($cmd | grep 'same_dir')
8901 local same_sample=$(get_rename_size $testdir1_size)
8902 [ -z "$samedir" ] && error "samedir_rename_size count error"
8903 [[ $same_sample -eq 1 ]] ||
8904 error "samedir_rename_size error $same_sample"
8905 echo "Check same dir rename stats success"
8907 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8909 # check crossdir rename size
8910 mv ${testdir1}/test_0 ${testdir2}/test_0
8912 testdir1_size=$(ls -l $DIR/${tdir} |
8913 awk '/stats_testdir1/ {print $5}')
8914 testdir2_size=$(ls -l $DIR/${tdir} |
8915 awk '/stats_testdir2/ {print $5}')
8917 testdir1_size=$(order_2 $testdir1_size)
8918 testdir2_size=$(order_2 $testdir2_size)
8920 testdir1_size=$(size_in_KMGT $testdir1_size)
8921 testdir2_size=$(size_in_KMGT $testdir2_size)
8923 echo "source rename dir size: ${testdir1_size}"
8924 echo "target rename dir size: ${testdir2_size}"
8926 eval $cmd || error "$cmd failed"
8927 local crossdir=$($cmd | grep 'crossdir')
8928 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8929 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8930 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8931 [[ $src_sample -eq 1 ]] ||
8932 error "crossdir_rename_size error $src_sample"
8933 [[ $tgt_sample -eq 1 ]] ||
8934 error "crossdir_rename_size error $tgt_sample"
8935 echo "Check cross dir rename stats success"
8938 run_test 133d "Verifying rename_stats ========================================"
8941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8942 local testdir=$DIR/${tdir}/stats_testdir
8943 local ctr f0 f1 bs=32768 count=42 sum
8945 remote_ost_nodsh && skip "remote OST with nodsh" && return
8946 mkdir -p ${testdir} || error "mkdir failed"
8948 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8950 for ctr in {write,read}_bytes; do
8952 cancel_lru_locks osc
8954 do_facet ost1 $LCTL set_param -n \
8955 "obdfilter.*.exports.clear=clear"
8957 if [ $ctr = write_bytes ]; then
8959 f1=${testdir}/${tfile}
8961 f0=${testdir}/${tfile}
8965 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8968 cancel_lru_locks osc
8970 sum=$(do_facet ost1 $LCTL get_param \
8971 "obdfilter.*.exports.*.stats" |
8972 awk -v ctr=$ctr 'BEGIN { sum = 0 }
8973 $1 == ctr { sum += $7 }
8974 END { printf("%0.0f", sum) }')
8976 if ((sum != bs * count)); then
8977 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8983 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8986 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8989 # First without trusting modes.
8990 find $proc_dirs -exec cat '{}' \; &> /dev/null
8992 # Second verifying readability.
8995 -exec cat '{}' \; &> /dev/null ||
8996 error "proc file read failed"
8998 for facet in $SINGLEMDS ost1; do
8999 do_facet $facet find $proc_dirs \
9000 ! -name req_history \
9001 -exec cat '{}' \\\; &> /dev/null
9003 do_facet $facet find $proc_dirs \
9004 ! -name req_history \
9006 -exec cat '{}' \\\; &> /dev/null ||
9007 error "proc file read failed"
9010 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9013 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9016 # Second verifying readability.
9019 -not -name force_lbug \
9020 -not -name changelog_mask \
9021 -exec badarea_io '{}' \; &> /dev/null ||
9022 error "find $proc_dirs failed"
9024 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9025 skip "Too old lustre on MDS"
9027 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9028 skip "Too old lustre on ost1"
9030 for facet in $SINGLEMDS ost1; do
9031 do_facet $facet find $proc_dirs \
9033 -not -name force_lbug \
9034 -not -name changelog_mask \
9035 -exec badarea_io '{}' \\\; &> /dev/null ||
9036 error "$facet find $proc_dirs failed"
9040 # remount the FS in case writes/reads /proc break the FS
9041 cleanup || error "failed to unmount"
9042 setup || error "failed to setup"
9045 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9047 test_140() { #bug-17379
9048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9049 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9050 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9051 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9053 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9054 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9056 while i=`expr $i + 1`; do
9057 test_mkdir -p $i || error "Creating dir $i"
9058 cd $i || error "Changing to $i"
9059 ln -s ../stat stat || error "Creating stat symlink"
9060 # Read the symlink until ELOOP present,
9061 # not LBUGing the system is considered success,
9062 # we didn't overrun the stack.
9063 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9065 if [ $ret -eq 40 ]; then
9068 error "Open stat symlink"
9074 echo "The symlink depth = $i"
9075 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9076 error "Invalid symlink depth"
9078 # Test recursive symlink
9079 ln -s symlink_self symlink_self
9080 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9081 echo "open symlink_self returns $ret"
9082 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9084 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9088 local TF="$TMP/$tfile"
9090 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9092 cancel_lru_locks osc
9093 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9094 remount_client $MOUNT
9096 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9099 $TRUNCATE $DIR/$tfile 6000
9100 cancel_lru_locks osc
9101 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9104 echo "12345" >>$DIR/$tfile
9105 cancel_lru_locks osc
9106 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9109 echo "12345" >>$DIR/$tfile
9110 cancel_lru_locks osc
9111 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9116 run_test 150 "truncate/append tests"
9118 #LU-2902 roc_hit was not able to read all values from lproc
9119 function roc_hit_init() {
9120 local list=$(comma_list $(osts_nodes))
9121 local dir=$DIR/$tdir-check
9122 local file=$dir/file
9128 #use setstripe to do a write to every ost
9129 for i in $(seq 0 $((OSTCOUNT-1))); do
9130 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9131 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9132 idx=$(printf %04x $i)
9133 BEFORE=$(get_osd_param $list *OST*$idx stats |
9134 awk '$1 == "cache_access" {sum += $2}
9135 END { printf("%0.0f", sum) }')
9137 cancel_lru_locks osc
9138 cat $file >/dev/null
9140 AFTER=$(get_osd_param $list *OST*$idx stats |
9141 awk '$1 == "cache_access" {sum += $2}
9142 END { printf("%0.0f", sum) }')
9144 echo BEFORE:$BEFORE AFTER:$AFTER
9145 if ! let "AFTER - BEFORE == 4"; then
9147 error "roc_hit is not safe to use"
9155 function roc_hit() {
9156 local list=$(comma_list $(osts_nodes))
9157 echo $(get_osd_param $list '' stats |
9158 awk '$1 == "cache_hit" {sum += $2}
9159 END { printf("%0.0f", sum) }')
9162 function set_cache() {
9165 if [ "$2" == "off" ]; then
9168 local list=$(comma_list $(osts_nodes))
9169 set_osd_param $list '' $1_cache_enable $on
9171 cancel_lru_locks osc
9175 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9176 remote_ost_nodsh && skip "remote OST with nodsh" && return
9179 local list=$(comma_list $(osts_nodes))
9181 # check whether obdfilter is cache capable at all
9182 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9183 echo "not cache-capable obdfilter"
9187 # check cache is enabled on all obdfilters
9188 if get_osd_param $list '' read_cache_enable | grep 0; then
9189 echo "oss cache is disabled"
9193 set_osd_param $list '' writethrough_cache_enable 1
9195 # check write cache is enabled on all obdfilters
9196 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9197 echo "oss write cache is NOT enabled"
9203 #define OBD_FAIL_OBD_NO_LRU 0x609
9204 do_nodes $list $LCTL set_param fail_loc=0x609
9206 # pages should be in the case right after write
9207 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9210 local BEFORE=$(roc_hit)
9211 cancel_lru_locks osc
9212 cat $DIR/$tfile >/dev/null
9213 local AFTER=$(roc_hit)
9215 do_nodes $list $LCTL set_param fail_loc=0
9217 if ! let "AFTER - BEFORE == CPAGES"; then
9218 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9221 # the following read invalidates the cache
9222 cancel_lru_locks osc
9223 set_osd_param $list '' read_cache_enable 0
9224 cat $DIR/$tfile >/dev/null
9226 # now data shouldn't be found in the cache
9228 cancel_lru_locks osc
9229 cat $DIR/$tfile >/dev/null
9231 if let "AFTER - BEFORE != 0"; then
9232 error "IN CACHE: before: $BEFORE, after: $AFTER"
9235 set_osd_param $list '' read_cache_enable 1
9238 run_test 151 "test cache on oss and controls ==============================="
9241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9242 local TF="$TMP/$tfile"
9244 # simulate ENOMEM during write
9245 #define OBD_FAIL_OST_NOMEM 0x226
9246 lctl set_param fail_loc=0x80000226
9247 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9249 sync || error "sync failed"
9250 lctl set_param fail_loc=0
9252 # discard client's cache
9253 cancel_lru_locks osc
9255 # simulate ENOMEM during read
9256 lctl set_param fail_loc=0x80000226
9257 cmp $TF $DIR/$tfile || error "cmp failed"
9258 lctl set_param fail_loc=0
9262 run_test 152 "test read/write with enomem ============================"
9265 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9267 run_test 153 "test if fdatasync does not crash ======================="
9269 dot_lustre_fid_permission_check() {
9271 local ffid=$MOUNT/.lustre/fid/$fid
9274 echo "stat fid $fid"
9275 stat $ffid > /dev/null || error "stat $ffid failed."
9276 echo "touch fid $fid"
9277 touch $ffid || error "touch $ffid failed."
9278 echo "write to fid $fid"
9279 cat /etc/hosts > $ffid || error "write $ffid failed."
9280 echo "read fid $fid"
9281 diff /etc/hosts $ffid || error "read $ffid failed."
9282 echo "append write to fid $fid"
9283 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9284 echo "rename fid $fid"
9285 mv $ffid $test_dir/$tfile.1 &&
9286 error "rename $ffid to $tfile.1 should fail."
9287 touch $test_dir/$tfile.1
9288 mv $test_dir/$tfile.1 $ffid &&
9289 error "rename $tfile.1 to $ffid should fail."
9290 rm -f $test_dir/$tfile.1
9291 echo "truncate fid $fid"
9292 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9293 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9294 echo "link fid $fid"
9295 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9297 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9298 echo "setfacl fid $fid"
9299 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9300 echo "getfacl fid $fid"
9301 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9303 echo "unlink fid $fid"
9304 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9305 echo "mknod fid $fid"
9306 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9308 fid=[0xf00000400:0x1:0x0]
9309 ffid=$MOUNT/.lustre/fid/$fid
9311 echo "stat non-exist fid $fid"
9312 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9313 echo "write to non-exist fid $fid"
9314 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9315 echo "link new fid $fid"
9316 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9318 mkdir -p $test_dir/$tdir
9319 touch $test_dir/$tdir/$tfile
9320 fid=$($LFS path2fid $test_dir/$tdir)
9323 error "error: could not get fid for $test_dir/$dir/$tfile."
9325 ffid=$MOUNT/.lustre/fid/$fid
9328 ls $ffid > /dev/null || error "ls $ffid failed."
9329 echo "touch $fid/$tfile.1"
9330 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9332 echo "touch $MOUNT/.lustre/fid/$tfile"
9333 touch $MOUNT/.lustre/fid/$tfile && \
9334 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9336 echo "setxattr to $MOUNT/.lustre/fid"
9337 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9339 echo "listxattr for $MOUNT/.lustre/fid"
9340 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9342 echo "delxattr from $MOUNT/.lustre/fid"
9343 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9345 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9346 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9347 error "touch invalid fid should fail."
9349 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9350 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9351 error "touch non-normal fid should fail."
9353 echo "rename $tdir to $MOUNT/.lustre/fid"
9354 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9355 error "rename to $MOUNT/.lustre/fid should fail."
9357 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9359 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9360 local new_obf_mode=777
9362 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9363 chmod $new_obf_mode $DIR/.lustre/fid ||
9364 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9366 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9367 [ $obf_mode -eq $new_obf_mode ] ||
9368 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9370 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9371 chmod $old_obf_mode $DIR/.lustre/fid ||
9372 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9375 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9376 fid=$($LFS path2fid $test_dir/$tfile-2)
9377 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9378 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9379 error "create lov data thru .lustre should fail."
9380 echo "cp /etc/passwd $test_dir/$tfile-2"
9381 cp /etc/passwd $test_dir/$tfile-2 ||
9382 error "copy to $test_dir/$tfile-2 failed."
9383 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9384 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9385 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9387 rm -rf $test_dir/tfile.lnk
9388 rm -rf $test_dir/$tfile-2
9392 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9393 skip "Need MDS version at least 2.4.1" && return
9396 local FID=$($LFS path2fid $DIR/$tfile)
9397 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9399 # check that we get the same pathname back
9400 local FOUND=$($LFS fid2path $MOUNT $FID)
9401 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9402 [ "$FOUND" != "$DIR/$tfile" ] &&
9403 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9407 run_test 154A "lfs path2fid and fid2path basic checks"
9410 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9411 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9412 { skip "Need MDS version at least 2.2.51"; return 0; }
9413 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9415 cp /etc/hosts $DIR/$tfile
9417 fid=$($LFS path2fid $DIR/$tfile)
9419 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9421 dot_lustre_fid_permission_check "$fid" $DIR ||
9422 error "dot lustre permission check $fid failed"
9424 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9426 touch $MOUNT/.lustre/file &&
9427 error "creation is not allowed under .lustre"
9429 mkdir $MOUNT/.lustre/dir &&
9430 error "mkdir is not allowed under .lustre"
9434 run_test 154a "Open-by-FID"
9437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9438 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9439 { skip "Need MDS version at least 2.2.51"; return 0; }
9441 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9443 local remote_dir=$DIR/$tdir/remote_dir
9448 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9449 error "create remote directory failed"
9451 cp /etc/hosts $remote_dir/$tfile
9453 fid=$($LFS path2fid $remote_dir/$tfile)
9455 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9457 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9458 error "dot lustre permission check $fid failed"
9461 run_test 154b "Open-by-FID for remote directory"
9464 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9465 skip "Need MDS version at least 2.4.1" && return
9467 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9468 local FID1=$($LFS path2fid $DIR/$tfile.1)
9469 local FID2=$($LFS path2fid $DIR/$tfile.2)
9470 local FID3=$($LFS path2fid $DIR/$tfile.3)
9473 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9474 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9475 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9477 [ "$FID" = "${!want}" ] ||
9478 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9482 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9483 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9484 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9488 run_test 154c "lfs path2fid and fid2path multiple arguments"
9491 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9492 skip "Need MDS version at least 2.5.53" && return
9495 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9499 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9506 fid=$($LFS path2fid $DIR/$tfile)
9509 cmd="exec $fd<$DIR/$tfile"
9511 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9512 echo $fid_list | grep $fid
9515 cmd="exec $fd>/dev/null"
9517 if [ $rc -ne 0 ]; then
9518 error "FID $fid not found in open files list $fid_list"
9521 run_test 154d "Verify open file fid"
9523 test_155_small_load() {
9524 local temp=$TMP/$tfile
9525 local file=$DIR/$tfile
9527 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9528 error "dd of=$temp bs=6096 count=1 failed"
9530 cancel_lru_locks osc
9531 cmp $temp $file || error "$temp $file differ"
9533 $TRUNCATE $temp 6000
9534 $TRUNCATE $file 6000
9535 cmp $temp $file || error "$temp $file differ (truncate1)"
9537 echo "12345" >>$temp
9538 echo "12345" >>$file
9539 cmp $temp $file || error "$temp $file differ (append1)"
9541 echo "12345" >>$temp
9542 echo "12345" >>$file
9543 cmp $temp $file || error "$temp $file differ (append2)"
9549 test_155_big_load() {
9550 remote_ost_nodsh && skip "remote OST with nodsh" && return
9551 local temp=$TMP/$tfile
9552 local file=$DIR/$tfile
9555 local cache_size=$(do_facet ost$((MAXI+1)) \
9556 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9557 local large_file_size=$((cache_size * 2))
9559 echo "OSS cache size: $cache_size KB"
9560 echo "Large file size: $large_file_size KB"
9562 [ $MAXV -le $large_file_size ] && \
9563 skip_env "max available OST size needs > $large_file_size KB" && \
9566 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9568 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9569 error "dd of=$temp bs=$large_file_size count=1k failed"
9572 cancel_lru_locks osc
9573 cmp $temp $file || error "$temp $file differ"
9580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9582 set_cache writethrough on
9585 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9590 set_cache writethrough off
9593 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9598 set_cache writethrough on
9601 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9606 set_cache writethrough off
9609 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9614 set_cache writethrough on
9617 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9622 set_cache writethrough off
9625 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9630 set_cache writethrough on
9633 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9638 set_cache writethrough off
9641 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9648 local file="$DIR/$tfile"
9650 [ "$(facet_fstype ost1)" = "zfs" ] &&
9651 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9656 log "Turn on read and write cache"
9658 set_cache writethrough on
9660 log "Write data and read it back."
9661 log "Read should be satisfied from the cache."
9662 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9664 cancel_lru_locks osc
9665 cat $file >/dev/null
9667 if ! let "AFTER - BEFORE == CPAGES"; then
9668 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9670 log "cache hits:: before: $BEFORE, after: $AFTER"
9673 log "Read again; it should be satisfied from the cache."
9675 cancel_lru_locks osc
9676 cat $file >/dev/null
9678 if ! let "AFTER - BEFORE == CPAGES"; then
9679 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9681 log "cache hits:: before: $BEFORE, after: $AFTER"
9685 log "Turn off the read cache and turn on the write cache"
9687 set_cache writethrough on
9689 log "Read again; it should be satisfied from the cache."
9691 cancel_lru_locks osc
9692 cat $file >/dev/null
9694 if ! let "AFTER - BEFORE == CPAGES"; then
9695 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9697 log "cache hits:: before: $BEFORE, after: $AFTER"
9700 log "Read again; it should not be satisfied from the cache."
9702 cancel_lru_locks osc
9703 cat $file >/dev/null
9705 if ! let "AFTER - BEFORE == 0"; then
9706 error "IN CACHE: before: $BEFORE, after: $AFTER"
9708 log "cache hits:: before: $BEFORE, after: $AFTER"
9711 log "Write data and read it back."
9712 log "Read should be satisfied from the cache."
9713 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9715 cancel_lru_locks osc
9716 cat $file >/dev/null
9718 if ! let "AFTER - BEFORE == CPAGES"; then
9719 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9721 log "cache hits:: before: $BEFORE, after: $AFTER"
9724 log "Read again; it should not be satisfied from the cache."
9726 cancel_lru_locks osc
9727 cat $file >/dev/null
9729 if ! let "AFTER - BEFORE == 0"; then
9730 error "IN CACHE: before: $BEFORE, after: $AFTER"
9732 log "cache hits:: before: $BEFORE, after: $AFTER"
9736 log "Turn off read and write cache"
9738 set_cache writethrough off
9740 log "Write data and read it back"
9741 log "It should not be satisfied from the cache."
9743 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9744 cancel_lru_locks osc
9746 cat $file >/dev/null
9748 if ! let "AFTER - BEFORE == 0"; then
9749 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9751 log "cache hits:: before: $BEFORE, after: $AFTER"
9754 log "Turn on the read cache and turn off the write cache"
9756 set_cache writethrough off
9758 log "Write data and read it back"
9759 log "It should not be satisfied from the cache."
9761 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9763 cancel_lru_locks osc
9764 cat $file >/dev/null
9766 if ! let "AFTER - BEFORE == 0"; then
9767 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9769 log "cache hits:: before: $BEFORE, after: $AFTER"
9772 log "Read again; it should be satisfied from the cache."
9774 cancel_lru_locks osc
9775 cat $file >/dev/null
9777 if ! let "AFTER - BEFORE == CPAGES"; then
9778 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9780 log "cache hits:: before: $BEFORE, after: $AFTER"
9785 run_test 156 "Verification of tunables ============================"
9789 if [[ $MDSCOUNT -gt 1 ]]; then
9790 error_ignore bz17935 $*
9798 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9800 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9802 if [ $MASK -eq 1 ]; then
9803 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9805 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9809 changelog_extract_field() {
9815 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9816 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9822 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9823 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9824 { skip "Need MDS version at least 2.2.0"; return; }
9826 local CL_USERS="mdd.$MDT0.changelog_users"
9827 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9828 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9829 echo "Registered as changelog user $USER"
9830 $GET_CL_USERS | grep -q $USER ||
9831 error "User $USER not found in changelog_users"
9834 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9835 touch $DIR/$tdir/pics/2008/zachy/timestamp
9836 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9837 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9838 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9839 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9840 rm $DIR/$tdir/pics/desktop.jpg
9842 $LFS changelog $MDT0 | tail -5
9844 echo "verifying changelog mask"
9845 changelog_chmask "MKDIR"
9846 changelog_chmask "CLOSE"
9848 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9849 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9851 changelog_chmask "MKDIR"
9852 changelog_chmask "CLOSE"
9854 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9855 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9857 $LFS changelog $MDT0
9858 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9859 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9860 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9861 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9864 echo "verifying target fid"
9865 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9866 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9867 [ "$fidc" == "$fidf" ] ||
9868 err17935 "fid in changelog $fidc != file fid $fidf"
9869 echo "verifying parent fid"
9870 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9871 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9872 [ "$fidc" == "$fidf" ] ||
9873 err17935 "pfid in changelog $fidc != dir fid $fidf"
9875 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9876 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9877 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9878 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9879 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9880 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9882 MIN_REC=$($GET_CL_USERS |
9883 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9884 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
9885 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9886 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9887 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9889 # LU-3446 changelog index reset on MDT restart
9890 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9891 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9892 $LFS changelog_clear $MDT0 $USER 0
9893 stop $SINGLEMDS || error "Fail to stop MDT."
9894 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9895 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9896 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9897 [ $CUR_REC1 == $CUR_REC2 ] ||
9898 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9900 echo "verifying user deregister"
9901 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9902 $GET_CL_USERS | grep -q $USER &&
9903 error "User $USER still in changelog_users"
9905 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9906 if [ $USERS -eq 0 ]; then
9907 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9908 touch $DIR/$tdir/chloe
9909 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
9910 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9911 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9913 echo "$USERS other changelog users; can't verify off"
9916 run_test 160a "changelog sanity"
9918 test_160b() { # LU-3587
9919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9920 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9921 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9922 { skip "Need MDS version at least 2.2.0"; return; }
9924 local CL_USERS="mdd.$MDT0.changelog_users"
9925 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9926 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9927 echo "Registered as changelog user $USER"
9928 $GET_CL_USERS | grep -q $USER ||
9929 error "User $USER not found in changelog_users"
9931 local LONGNAME1=$(str_repeat a 255)
9932 local LONGNAME2=$(str_repeat b 255)
9935 echo "creating very long named file"
9936 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9937 echo "moving very long named file"
9938 mv $LONGNAME1 $LONGNAME2
9940 $LFS changelog $MDT0 | grep RENME
9942 echo "deregistering $USER"
9943 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9947 run_test 160b "Verify that very long rename doesn't crash in changelog"
9951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9954 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9955 changelog_register -n)
9959 $MCREATE $DIR/$tdir/foo_160c
9960 changelog_chmask "TRUNC"
9961 $TRUNCATE $DIR/$tdir/foo_160c 200
9962 changelog_chmask "TRUNC"
9963 $TRUNCATE $DIR/$tdir/foo_160c 199
9964 $LFS changelog $MDT0
9965 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
9966 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
9967 $LFS changelog_clear $MDT0 $USER 0
9969 # Deregistration step
9970 echo "deregistering $USER"
9971 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9973 run_test 160c "verify that changelog log catch the truncate event"
9976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9977 test_mkdir -p -c1 $DIR/$tdir
9978 cp /etc/hosts $DIR/$tdir/$tfile
9979 test_mkdir -c1 $DIR/$tdir/foo1
9980 test_mkdir -c1 $DIR/$tdir/foo2
9981 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9982 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9983 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9984 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9985 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9986 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9987 $LFS fid2path $DIR $FID
9988 err17935 "bad link ea"
9991 rm $DIR/$tdir/foo2/zachary
9993 rm $DIR/$tdir/foo2/thor
9995 rm $DIR/$tdir/$tfile
9997 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9998 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10000 $LFS fid2path $DIR $FID
10001 err17935 "bad link rename"
10003 rm $DIR/$tdir/foo2/maggie
10006 local longname=filename_avg_len_is_thirty_two_
10007 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10008 error "failed to hardlink many files"
10009 links=$($LFS fid2path $DIR $FID | wc -l)
10010 echo -n "${links}/1000 links in link EA"
10011 [[ $links -gt 60 ]] ||
10012 err17935 "expected at least 60 links in link EA"
10013 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10014 error "failed to unlink many hardlinks"
10016 run_test 161a "link ea sanity"
10019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10020 [ $MDSCOUNT -lt 2 ] &&
10021 skip "skipping remote directory test" && return
10023 local remote_dir=$DIR/$tdir/remote_dir
10025 mkdir -p $DIR/$tdir
10026 $LFS mkdir -i $MDTIDX $remote_dir ||
10027 error "create remote directory failed"
10029 cp /etc/hosts $remote_dir/$tfile
10030 mkdir -p $remote_dir/foo1
10031 mkdir -p $remote_dir/foo2
10032 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10033 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10034 ln $remote_dir/$tfile $remote_dir/foo1/luna
10035 ln $remote_dir/$tfile $remote_dir/foo2/thor
10037 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10039 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10040 $LFS fid2path $DIR $FID
10041 err17935 "bad link ea"
10044 rm $remote_dir/foo2/zachary
10046 rm $remote_dir/foo2/thor
10048 rm $remote_dir/$tfile
10050 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10051 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10052 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10053 $LFS fid2path $DIR $FID
10054 err17935 "bad link rename"
10056 rm $remote_dir/foo2/maggie
10059 local longname=filename_avg_len_is_thirty_two_
10060 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10061 error "failed to hardlink many files"
10062 links=$($LFS fid2path $DIR $FID | wc -l)
10063 echo -n "${links}/1000 links in link EA"
10064 [[ ${links} -gt 60 ]] ||
10065 err17935 "expected at least 60 links in link EA"
10066 unlinkmany $remote_dir/foo2/$longname 1000 ||
10067 error "failed to unlink many hardlinks"
10069 run_test 161b "link ea sanity under remote directory"
10072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10073 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10074 skip "Need MDS version at least 2.1.5" && return
10076 # define CLF_RENAME_LAST 0x0001
10077 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10078 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10079 changelog_register -n)
10081 mkdir -p $DIR/$tdir
10082 touch $DIR/$tdir/foo_161c
10083 touch $DIR/$tdir/bar_161c
10084 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10085 $LFS changelog $MDT0 | grep RENME
10086 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10088 $LFS changelog_clear $MDT0 $USER 0
10089 if [ x$flags != "x0x1" ]; then
10090 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10092 error "flag $flags is not 0x1"
10094 echo "rename overwrite a target having nlink = 1," \
10095 "changelog record has flags of $flags"
10097 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10098 touch $DIR/$tdir/foo_161c
10099 touch $DIR/$tdir/bar_161c
10100 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10101 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10102 $LFS changelog $MDT0 | grep RENME
10103 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10104 $LFS changelog_clear $MDT0 $USER 0
10105 if [ x$flags != "x0x0" ]; then
10106 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10108 error "flag $flags is not 0x0"
10110 echo "rename overwrite a target having nlink > 1," \
10111 "changelog record has flags of $flags"
10113 # rename doesn't overwrite a target (changelog flag 0x0)
10114 touch $DIR/$tdir/foo_161c
10115 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10116 $LFS changelog $MDT0 | grep RENME
10117 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10118 $LFS changelog_clear $MDT0 $USER 0
10119 if [ x$flags != "x0x0" ]; then
10120 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10122 error "flag $flags is not 0x0"
10124 echo "rename doesn't overwrite a target," \
10125 "changelog record has flags of $flags"
10127 # define CLF_UNLINK_LAST 0x0001
10128 # unlink a file having nlink = 1 (changelog flag 0x1)
10129 rm -f $DIR/$tdir/foo2_161c
10130 $LFS changelog $MDT0 | grep UNLNK
10131 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10132 $LFS changelog_clear $MDT0 $USER 0
10133 if [ x$flags != "x0x1" ]; then
10134 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10136 error "flag $flags is not 0x1"
10138 echo "unlink a file having nlink = 1," \
10139 "changelog record has flags of $flags"
10141 # unlink a file having nlink > 1 (changelog flag 0x0)
10142 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10143 rm -f $DIR/$tdir/foobar_161c
10144 $LFS changelog $MDT0 | grep UNLNK
10145 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10146 $LFS changelog_clear $MDT0 $USER 0
10147 if [ x$flags != "x0x0" ]; then
10148 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10150 error "flag $flags is not 0x0"
10152 echo "unlink a file having nlink > 1," \
10153 "changelog record has flags of $flags"
10154 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10156 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10163 local path=$(${LFS} fid2path $*)
10166 if [ $RC -ne 0 ]; then
10167 err17935 "path looked up of $expected failed. Error $RC"
10169 elif [ "${path}" != "${expected}" ]; then
10170 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10173 echo "fid $fid resolves to path $path (expected $expected)"
10177 # Make changes to filesystem
10178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10179 test_mkdir -p -c1 $DIR/$tdir/d2
10180 touch $DIR/$tdir/d2/$tfile
10181 touch $DIR/$tdir/d2/x1
10182 touch $DIR/$tdir/d2/x2
10183 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10184 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10186 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10187 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
10190 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10191 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10192 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
10194 # softlink to wrong file
10195 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10196 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10197 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
10200 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10201 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10202 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10203 # fid2path dir/fsname should both work
10204 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
10205 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
10207 # hardlink count: check that there are 2 links
10208 # Doesnt work with CMD yet: 17935
10209 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10210 err17935 "expected 2 links"
10212 # hardlink indexing: remove the first link
10213 rm $DIR/$tdir/d2/p/q/r/hlink
10214 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
10218 run_test 162 "path lookup sanity"
10221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10222 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10225 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10226 error "create striped dir failed"
10228 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10229 tail -n 1 | awk '{print $2}')
10230 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10232 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10233 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10236 for ((i=0;i<5;i++)); do
10237 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10238 error "get fid for f$i failed"
10239 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
10241 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10242 error "get fid for d$i failed"
10243 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
10248 run_test 162b "striped directory path lookup sanity"
10251 # do directio so as not to populate the page cache
10252 log "creating a 10 Mb file"
10253 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10254 log "starting reads"
10255 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10256 log "truncating the file"
10257 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10259 kill %+ || true # reads might have finished
10260 echo "wait until dd is finished"
10262 log "removing the temporary file"
10263 rm -rf $DIR/$tfile || error "tmp file removal failed"
10265 run_test 169 "parallel read and truncate should not deadlock"
10268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10269 $LCTL clear # bug 18514
10270 $LCTL debug_daemon start $TMP/${tfile}_log_good
10272 $LCTL debug_daemon stop
10273 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10274 error "sed failed to read log_good"
10276 $LCTL debug_daemon start $TMP/${tfile}_log_good
10278 $LCTL debug_daemon stop
10280 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10281 error "lctl df log_bad failed"
10283 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10284 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10286 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10287 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10289 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10290 error "bad_line good_line1 good_line2 are empty"
10292 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10293 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10294 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10296 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10297 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10298 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10300 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10301 error "bad_line_new good_line_new are empty"
10303 local expected_good=$((good_line1 + good_line2*2))
10305 rm -f $TMP/${tfile}*
10306 # LU-231, short malformed line may not be counted into bad lines
10307 if [ $bad_line -ne $bad_line_new ] &&
10308 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10309 error "expected $bad_line bad lines, but got $bad_line_new"
10313 if [ $expected_good -ne $good_line_new ]; then
10314 error "expected $expected_good good lines, but got $good_line_new"
10319 run_test 170 "test lctl df to handle corrupted log ====================="
10321 test_171() { # bug20592
10322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10323 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10324 $LCTL set_param fail_loc=0x50e
10325 $LCTL set_param fail_val=3000
10326 multiop_bg_pause $DIR/$tfile O_s || true
10328 kill -USR1 $MULTIPID
10332 if dmesg | grep "recursive fault"; then
10333 error "caught a recursive fault"
10335 $LCTL set_param fail_loc=0
10338 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10340 # it would be good to share it with obdfilter-survey/libecho code
10341 setup_obdecho_osc () {
10344 local obdfilter_name=$2
10345 echo "Creating new osc for $obdfilter_name on $ost_nid"
10346 # make sure we can find loopback nid
10347 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10349 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10350 ${obdfilter_name}_osc_UUID || rc=2; }
10351 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10352 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10356 cleanup_obdecho_osc () {
10357 local obdfilter_name=$1
10358 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10359 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10366 local pages=${3:-64}
10371 local obd_size=$(get_obd_size $node $OBD)
10372 local page_size=$(get_page_size $node)
10373 if [[ -n "$obd_size" ]]; then
10374 local new_count=$((obd_size / (pages * page_size / 1024)))
10375 [[ $new_count -ge $count ]] || count=$new_count
10378 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10379 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10381 if [ $rc -eq 0 ]; then
10382 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10383 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10385 echo "New object id is $id"
10386 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10388 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10389 "test_brw $count w v $pages $id" || rc=4; }
10390 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10392 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10393 "cleanup" || rc=5; }
10394 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10395 "detach" || rc=6; }
10396 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10402 remote_ost_nodsh && skip "remote OST with nodsh" && return
10404 local rmmod_local=0
10406 if ! module_loaded obdecho; then
10407 load_module obdecho/obdecho
10411 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10412 local host=$(lctl get_param -n osc.$osc.import |
10413 awk '/current_connection:/ {print $2}' )
10414 local target=$(lctl get_param -n osc.$osc.import |
10415 awk '/target:/ {print $2}' )
10416 target=${target%_UUID}
10418 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10419 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10420 [[ -n $target ]] && cleanup_obdecho_osc $target
10421 [ $rmmod_local -eq 1 ] && rmmod obdecho
10424 run_test 180a "test obdecho on osc"
10427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10428 remote_ost_nodsh && skip "remote OST with nodsh" && return
10430 local rmmod_remote=0
10432 do_facet ost1 "lsmod | grep -q obdecho || " \
10433 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10434 "modprobe obdecho; }" && rmmod_remote=1
10435 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10436 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10437 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10440 run_test 180b "test obdecho directly on obdfilter"
10442 test_180c() { # LU-2598
10443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10444 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10445 skip "Need MDS version at least 2.4.0" && return
10448 local rmmod_remote=false
10449 local pages=16384 # 64MB bulk I/O RPC size
10452 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10453 rmmod_remote=true || error "failed to load module obdecho"
10455 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10457 if [ -n "$target" ]; then
10458 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10460 echo "there is no obdfilter target on ost1"
10463 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10466 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10468 test_181() { # bug 22177
10469 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10470 # create enough files to index the directory
10471 createmany -o $DIR/$tdir/foobar 4000
10472 # print attributes for debug purpose
10475 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10477 # remove the files & current working dir
10478 unlinkmany $DIR/$tdir/foobar 4000
10480 kill -USR1 $MULTIPID
10482 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10485 run_test 181 "Test open-unlinked dir ========================"
10488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10489 # disable MDC RPC lock wouldn't crash client
10493 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10494 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10495 $LCTL set_param fail_loc=0x804
10497 for (( i=0; i < $tcount; i++ )) ; do
10498 mkdir $DIR/$tdir/$i
10499 createmany -o $DIR/$tdir/$i/f- $fcount &
10503 for (( i=0; i < $tcount; i++ )) ; do
10504 unlinkmany $DIR/$tdir/$i/f- $fcount &
10510 $LCTL set_param fail_loc=0
10512 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10514 test_183() { # LU-2275
10515 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10516 skip "Need MDS version at least 2.3.56" && return
10518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10519 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10520 echo aaa > $DIR/$tdir/$tfile
10522 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10523 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10525 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10526 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10528 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10530 # Flush negative dentry cache
10531 touch $DIR/$tdir/$tfile
10533 # We are not checking for any leaked references here, they'll
10534 # become evident next time we do cleanup with module unload.
10537 run_test 183 "No crash or request leak in case of strange dispositions ========"
10539 # test suite 184 is for LU-2016, LU-2017
10541 check_swap_layouts_support && return 0
10543 dir0=$DIR/$tdir/$testnum
10544 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10549 $SETSTRIPE -c1 $file1
10551 $SETSTRIPE -c2 $file2
10553 gen1=$($GETSTRIPE -g $file1)
10554 gen2=$($GETSTRIPE -g $file2)
10556 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10557 gen=$($GETSTRIPE -g $file1)
10558 [[ $gen1 != $gen ]] ||
10559 "Layout generation on $file1 does not change"
10560 gen=$($GETSTRIPE -g $file2)
10561 [[ $gen2 != $gen ]] ||
10562 "Layout generation on $file2 does not change"
10564 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10565 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10567 run_test 184a "Basic layout swap"
10570 check_swap_layouts_support && return 0
10572 dir0=$DIR/$tdir/$testnum
10573 mkdir -p $dir0 || error "creating dir $dir0"
10580 $SETSTRIPE -c1 $file1
10581 $SETSTRIPE -c2 $file2
10582 $SETSTRIPE -c1 $file3
10583 chown $RUNAS_ID $file3
10584 gen1=$($GETSTRIPE -g $file1)
10585 gen2=$($GETSTRIPE -g $file2)
10587 $LFS swap_layouts $dir1 $dir2 &&
10588 error "swap of directories layouts should fail"
10589 $LFS swap_layouts $dir1 $file1 &&
10590 error "swap of directory and file layouts should fail"
10591 $RUNAS $LFS swap_layouts $file1 $file2 &&
10592 error "swap of file we cannot write should fail"
10593 $LFS swap_layouts $file1 $file3 &&
10594 error "swap of file with different owner should fail"
10595 /bin/true # to clear error code
10597 run_test 184b "Forbidden layout swap (will generate errors)"
10600 check_swap_layouts_support && return 0
10602 local dir0=$DIR/$tdir/$testnum
10603 mkdir -p $dir0 || error "creating dir $dir0"
10605 local ref1=$dir0/ref1
10606 local ref2=$dir0/ref2
10607 local file1=$dir0/file1
10608 local file2=$dir0/file2
10609 # create a file large enough for the concurent test
10610 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10611 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10612 echo "ref file size: ref1($(stat -c %s $ref1))," \
10613 "ref2($(stat -c %s $ref2))"
10616 dd if=$ref1 of=$file1 bs=16k &
10619 # Make sure dd starts to copy file
10620 while [ ! -f $file1 ]; do sleep 0.1; done
10622 $LFS swap_layouts $file1 $file2
10625 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10626 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10628 # how many bytes copied before swapping layout
10629 local copied=$(stat -c %s $file2)
10630 local remaining=$(stat -c %s $ref1)
10631 remaining=$((remaining - copied))
10632 echo "Copied $copied bytes before swapping layout..."
10634 cmp -n $copied $file1 $ref2 | grep differ &&
10635 error "Content mismatch [0, $copied) of ref2 and file1"
10636 cmp -n $copied $file2 $ref1 ||
10637 error "Content mismatch [0, $copied) of ref1 and file2"
10638 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10639 error "Content mismatch [$copied, EOF) of ref1 and file1"
10642 rm -f $ref1 $ref2 $file1 $file2
10644 run_test 184c "Concurrent write and layout swap"
10647 check_swap_layouts_support && return 0
10648 [ -z "$(which getfattr 2>/dev/null)" ] &&
10649 skip "no getfattr command" && return 0
10651 local file1=$DIR/$tdir/$tfile-1
10652 local file2=$DIR/$tdir/$tfile-2
10653 local file3=$DIR/$tdir/$tfile-3
10657 mkdir -p $DIR/$tdir
10658 touch $file1 || error "create $file1 failed"
10659 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10660 error "create $file2 failed"
10661 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10662 error "create $file3 failed"
10663 lovea1=$($LFS getstripe $file1 | sed 1d)
10665 $LFS swap_layouts $file2 $file3 ||
10666 error "swap $file2 $file3 layouts failed"
10667 $LFS swap_layouts $file1 $file2 ||
10668 error "swap $file1 $file2 layouts failed"
10670 lovea2=$($LFS getstripe $file2 | sed 1d)
10671 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10673 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10674 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10676 run_test 184d "allow stripeless layouts swap"
10679 test_185() { # LU-2441
10680 # LU-3553 - no volatile file support in old servers
10681 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10682 { skip "Need MDS version at least 2.3.60"; return 0; }
10684 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10685 touch $DIR/$tdir/spoo
10686 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10687 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10688 error "cannot create/write a volatile file"
10689 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10690 error "FID is still valid after close"
10692 multiop_bg_pause $DIR/$tdir vVw4096_c
10699 # assume that the next FID for this client is sequential, since stdout
10700 # is unfortunately eaten by multiop_bg_pause
10701 local n=$((${fidv[1]} + 1))
10702 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10703 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10704 error "FID is missing before close"
10705 kill -USR1 $multi_pid
10706 # 1 second delay, so if mtime change we will see it
10708 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10709 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10711 run_test 185 "Volatile file support"
10714 local dir0=$DIR/$tdir/$testnum
10715 mkdir -p $dir0 || error "creating dir $dir0"
10717 local file=$dir0/file1
10718 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10719 local dv1=$($LFS data_version $file)
10720 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10721 local dv2=$($LFS data_version $file)
10722 [[ $dv1 != $dv2 ]] ||
10723 error "data version did not change on write $dv1 == $dv2"
10728 run_test 187a "Test data version change"
10731 local dir0=$DIR/$tdir/$testnum
10732 mkdir -p $dir0 || error "creating dir $dir0"
10734 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10735 [[ ${DV[0]} != ${DV[1]} ]] ||
10736 error "data version did not change on write"\
10737 " ${DV[0]} == ${DV[1]}"
10742 run_test 187b "Test data version change on volatile file"
10745 check_file_in_pool()
10750 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10753 for t in $tlist ; do
10754 [ "$i" -eq "$t" ] && continue 2
10757 echo "pool list: $tlist"
10758 echo "striping: $res"
10759 error_noexit "$file not allocated in $pool"
10766 echo "Creating new pool"
10769 create_pool $FSNAME.$pool ||
10770 { error_noexit "No pool created, result code $?"; return 1; }
10771 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10772 { error_noexit "$pool not in lfs pool_list"; return 2; }
10775 pool_add_targets() {
10776 echo "Adding targets to pool"
10782 local list=$(seq $first $step $last)
10784 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10785 do_facet mgs $LCTL pool_add \
10786 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10787 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10788 | sort -u | tr '\n' ' ' " "$t" || {
10789 error_noexit "Add to pool failed"
10792 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10793 local addcount=$(((last - first) / step + 1))
10794 [ $lfscount -eq $addcount ] || {
10795 error_noexit "lfs pool_list bad ost count" \
10796 "$lfscount != $addcount"
10804 echo "Setting pool on directory $tdir"
10806 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10808 error_noexit "Cannot set pool $pool to $tdir"
10815 echo "Checking pool on directory $tdir"
10817 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10818 [ "$res" = "$pool" ] && return 0
10820 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10824 pool_dir_rel_path() {
10825 echo "Testing relative path works well"
10830 mkdir -p $root/$tdir/$tdir
10832 pool_set_dir $pool $tdir || return 1
10833 pool_set_dir $pool ./$tdir || return 2
10834 pool_set_dir $pool ../$tdir || return 3
10835 pool_set_dir $pool ../$tdir/$tdir || return 4
10836 rm -rf $tdir; cd - > /dev/null
10839 pool_alloc_files() {
10840 echo "Checking files allocation from directory pool"
10847 for i in $(seq -w 1 $count)
10849 local file=$tdir/file-$i
10851 check_file_in_pool $file $pool "$tlist" || \
10852 failed=$((failed + 1))
10854 [ "$failed" = 0 ] && return 0
10856 error_noexit "$failed files not allocated in $pool"
10860 pool_create_files() {
10861 echo "Creating files in pool"
10869 for i in $(seq -w 1 $count)
10871 local file=$tdir/spoo-$i
10872 $SETSTRIPE -p $pool $file
10873 check_file_in_pool $file $pool "$tlist" || \
10874 failed=$((failed + 1))
10876 [ "$failed" = 0 ] && return 0
10878 error_noexit "$failed files not allocated in $pool"
10883 echo "Checking 'lfs df' output"
10886 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10888 local res=$($LFS df --pool $FSNAME.$pool |
10890 grep "$FSNAME-OST" |
10892 [ "$res" = "$t" ] && return 0
10894 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10898 pool_file_rel_path() {
10899 echo "Creating files in a pool with relative pathname"
10904 { error_noexit "unable to create $tdir"; return 1 ; }
10905 local file="/..$tdir/$tfile-1"
10906 $SETSTRIPE -p $pool $file ||
10907 { error_noexit "unable to create $file" ; return 2 ; }
10910 $SETSTRIPE -p $pool $tfile-2 || {
10911 error_noexit "unable to create $tfile-2 in $tdir"
10916 pool_remove_first_target() {
10917 echo "Removing first target from a pool"
10920 local pname="lov.$FSNAME-*.pools.$pool"
10921 local t=$($LCTL get_param -n $pname | head -n1)
10922 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10923 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10924 error_noexit "$t not removed from $FSNAME.$pool"
10929 pool_remove_all_targets() {
10930 echo "Removing all targets from pool"
10933 local pname="lov.$FSNAME-*.pools.$pool"
10934 for t in $($LCTL get_param -n $pname | sort -u)
10936 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10938 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10939 error_noexit "Pool $FSNAME.$pool cannot be drained"
10942 # striping on an empty/nonexistant pool should fall back
10943 # to "pool of everything"
10945 error_noexit "failed to use fallback striping for empty pool"
10948 # setstripe on an empty pool should fail
10949 $SETSTRIPE -p $pool $file 2>/dev/null && {
10950 error_noexit "expected failure when creating file" \
10958 echo "Destroying pool"
10962 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10965 # striping on an empty/nonexistant pool should fall back
10966 # to "pool of everything"
10968 error_noexit "failed to use fallback striping for missing pool"
10971 # setstripe on an empty pool should fail
10972 $SETSTRIPE -p $pool $file 2>/dev/null && {
10973 error_noexit "expected failure when creating file" \
10974 "with missing pool"
10978 # get param should return err once pool is gone
10979 if wait_update $HOSTNAME "lctl get_param -n \
10980 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10982 remove_pool_from_list $FSNAME.$pool
10985 error_noexit "Pool $FSNAME.$pool is not destroyed"
10990 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10991 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10993 local POOL=${POOL:-cea1}
10994 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10995 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10998 local last_ost=$(($OSTCOUNT - 1))
11000 local ost_list=$(seq $first_ost $ost_step $last_ost)
11001 local ost_range="$first_ost $last_ost $ost_step"
11002 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11003 local file_dir=$POOL_ROOT/file_tst
11007 # former test_200a test_200b
11008 pool_add $POOL || { rc=$? ; break; }
11009 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11010 # former test_200c test_200d
11011 mkdir -p $test_path
11012 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11013 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11014 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11015 || { rc=$? ; break; }
11016 # former test_200e test_200f
11017 local files=$((OSTCOUNT*3))
11018 pool_alloc_files $POOL $test_path $files "$ost_list" \
11019 || { rc=$? ; break; }
11020 pool_create_files $POOL $file_dir $files "$ost_list" \
11021 || { rc=$? ; break; }
11022 # former test_200g test_200h
11023 pool_lfs_df $POOL || { rc=$? ; break; }
11024 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11026 # former test_201a test_201b test_201c
11027 pool_remove_first_target $POOL || { rc=$? ; break; }
11029 local f=$test_path/$tfile
11030 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11031 pool_remove $POOL $f || { rc=$? ; break; }
11038 run_test 200 "OST pools"
11040 # usage: default_attr <count | size | offset>
11042 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11045 # usage: check_default_stripe_attr
11046 check_default_stripe_attr() {
11047 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11049 --stripe-count|--count)
11050 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11051 --stripe-size|--size)
11052 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11053 --stripe-index|--index)
11056 error "unknown getstripe attr '$1'"
11059 [ $ACTUAL != $EXPECTED ] &&
11060 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11064 test_mkdir -p $DIR/$tdir
11065 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11067 check_default_stripe_attr --stripe-count
11068 check_default_stripe_attr --stripe-size
11069 check_default_stripe_attr --stripe-index
11073 run_test 204a "Print default stripe attributes ================="
11076 test_mkdir -p $DIR/$tdir
11077 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11079 check_default_stripe_attr --stripe-size
11080 check_default_stripe_attr --stripe-index
11084 run_test 204b "Print default stripe size and offset ==========="
11087 test_mkdir -p $DIR/$tdir
11088 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11090 check_default_stripe_attr --stripe-count
11091 check_default_stripe_attr --stripe-index
11095 run_test 204c "Print default stripe count and offset ==========="
11098 test_mkdir -p $DIR/$tdir
11099 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11101 check_default_stripe_attr --stripe-count
11102 check_default_stripe_attr --stripe-size
11106 run_test 204d "Print default stripe count and size ============="
11109 test_mkdir -p $DIR/$tdir
11110 $SETSTRIPE -d $DIR/$tdir
11112 check_default_stripe_attr --stripe-count --raw
11113 check_default_stripe_attr --stripe-size --raw
11114 check_default_stripe_attr --stripe-index --raw
11118 run_test 204e "Print raw stripe attributes ================="
11121 test_mkdir -p $DIR/$tdir
11122 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11124 check_default_stripe_attr --stripe-size --raw
11125 check_default_stripe_attr --stripe-index --raw
11129 run_test 204f "Print raw stripe size and offset ==========="
11132 test_mkdir -p $DIR/$tdir
11133 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11135 check_default_stripe_attr --stripe-count --raw
11136 check_default_stripe_attr --stripe-index --raw
11140 run_test 204g "Print raw stripe count and offset ==========="
11143 test_mkdir -p $DIR/$tdir
11144 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11146 check_default_stripe_attr --stripe-count --raw
11147 check_default_stripe_attr --stripe-size --raw
11151 run_test 204h "Print raw stripe count and size ============="
11153 # Figure out which job scheduler is being used, if any,
11154 # or use a fake one
11155 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11156 JOBENV=SLURM_JOB_ID
11157 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11159 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11161 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11162 JOBENV=LOADL_STEP_ID
11163 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11169 verify_jobstats() {
11173 # clear old jobstats
11174 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11175 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11177 # use a new JobID for this test, or we might see an old one
11178 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11182 log "Using JobID environment variable $JOBENV=$JOBVAL"
11184 if [ $JOBENV = "FAKE_JOBID" ]; then
11185 FAKE_JOBID=$JOBVAL $cmd
11190 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11191 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11192 do_facet $FACET lctl get_param mdt.*.job_stats |
11193 grep $JOBVAL || error "No job stats found on MDT $FACET"
11195 if [ "$target" = "ost" -o "$target" = "both" ]; then
11197 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11198 grep $JOBVAL || error "No job stats found on OST $FACET"
11204 NEW_JOBENV=${1:-$OLD_JOBENV}
11205 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11206 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11209 test_205() { # Job stats
11210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11211 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11212 skip "Server doesn't support jobstats" && return 0
11213 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11216 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11217 if [ $OLD_JOBENV != $JOBENV ]; then
11218 jobstats_set $JOBENV
11219 trap jobstats_set EXIT
11223 cmd="mkdir $DIR/$tfile"
11224 verify_jobstats "$cmd" "mdt"
11226 cmd="rm -fr $DIR/$tfile"
11227 verify_jobstats "$cmd" "mdt"
11229 cmd="mknod $DIR/$tfile c 1 3"
11230 verify_jobstats "$cmd" "mdt"
11232 cmd="rm -f $DIR/$tfile"
11233 verify_jobstats "$cmd" "mdt"
11235 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11236 verify_jobstats "$cmd" "mdt"
11238 cmd="touch $DIR/$tfile"
11239 verify_jobstats "$cmd" "both"
11241 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11242 verify_jobstats "$cmd" "ost"
11244 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11245 verify_jobstats "$cmd" "ost"
11247 cmd="$TRUNCATE $DIR/$tfile 0"
11248 verify_jobstats "$cmd" "both"
11250 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11251 verify_jobstats "$cmd" "mdt"
11254 rm -f $DIR/jobstats_test_rename
11256 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11258 run_test 205 "Verify job stats"
11260 # LU-1480, LU-1773 and LU-1657
11262 mkdir -p $DIR/$tdir
11263 $SETSTRIPE -c -1 $DIR/$tdir
11264 #define OBD_FAIL_LOV_INIT 0x1403
11265 $LCTL set_param fail_loc=0xa0001403
11266 $LCTL set_param fail_val=1
11267 touch $DIR/$tdir/$tfile || true
11269 run_test 206 "fail lov_init_raid0() doesn't lbug"
11272 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11273 local fsz=`stat -c %s $DIR/$tfile`
11274 cancel_lru_locks mdc
11276 # do not return layout in getattr intent
11277 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11278 $LCTL set_param fail_loc=0x170
11279 local sz=`stat -c %s $DIR/$tfile`
11281 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11285 run_test 207a "can refresh layout at glimpse"
11288 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11289 local cksum=`md5sum $DIR/$tfile`
11290 local fsz=`stat -c %s $DIR/$tfile`
11291 cancel_lru_locks mdc
11292 cancel_lru_locks osc
11294 # do not return layout in getattr intent
11295 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11296 $LCTL set_param fail_loc=0x171
11298 # it will refresh layout after the file is opened but before read issues
11299 echo checksum is "$cksum"
11300 echo "$cksum" |md5sum -c --quiet || error "file differs"
11304 run_test 207b "can refresh layout at open"
11307 # FIXME: in this test suite, only RD lease is used. This is okay
11308 # for now as only exclusive open is supported. After generic lease
11309 # is done, this test suite should be revised. - Jinshan
11311 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11312 { skip "Need MDS version at least 2.4.52"; return 0; }
11314 echo "==== test 1: verify get lease work"
11315 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11317 echo "==== test 2: verify lease can be broken by upcoming open"
11318 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11322 $MULTIOP $DIR/$tfile oO_RDONLY:c
11323 kill -USR1 $PID && wait $PID || error "break lease error"
11325 echo "==== test 3: verify lease can't be granted if an open already exists"
11326 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11330 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11331 kill -USR1 $PID && wait $PID || error "open file error"
11333 echo "==== test 4: lease can sustain over recovery"
11334 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11340 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11342 echo "==== test 5: lease broken can't be regained by replay"
11343 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11347 # open file to break lease and then recovery
11348 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11351 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11355 run_test 208 "Exclusive open"
11358 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11359 skip_env "must have disp_stripe" && return
11362 sync; sleep 5; sync;
11364 echo 3 > /proc/sys/vm/drop_caches
11365 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11367 # open/close 500 times
11368 for i in $(seq 500); do
11372 echo 3 > /proc/sys/vm/drop_caches
11373 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11375 echo "before: $req_before, after: $req_after"
11376 [ $((req_after - req_before)) -ge 300 ] &&
11377 error "open/close requests are not freed"
11380 run_test 209 "read-only open/close requests should be freed promptly"
11384 size=$((size % 8192 + 1))
11385 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11386 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11387 rm -f $DIR/f212 $DIR/f212.xyz
11389 run_test 212 "Sendfile test ============================================"
11392 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11393 cancel_lru_locks osc
11394 lctl set_param fail_loc=0x8000040f
11395 # generate a read lock
11396 cat $DIR/$tfile > /dev/null
11397 # write to the file, it will try to cancel the above read lock.
11398 cat /etc/hosts >> $DIR/$tfile
11400 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11402 test_214() { # for bug 20133
11403 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11404 for (( i=0; i < 340; i++ )) ; do
11405 touch $DIR/$tdir/d214c/a$i
11408 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11409 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11410 ls $DIR/d214c || error "ls $DIR/d214c failed"
11411 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11412 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11414 run_test 214 "hash-indexed directory test - bug 20133"
11416 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11417 create_lnet_proc_files() {
11418 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11419 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11421 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11422 rm -f "$TMP/lnet_$1.sys_tmp"
11425 # counterpart of create_lnet_proc_files
11426 remove_lnet_proc_files() {
11427 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11430 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11431 # 3rd arg as regexp for body
11432 check_lnet_proc_stats() {
11433 local l=$(cat "$TMP/lnet_$1" |wc -l)
11434 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11436 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11439 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11440 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11441 # optional and can be regexp for 2nd line (lnet.routes case)
11442 check_lnet_proc_entry() {
11443 local blp=2 # blp stands for 'position of 1st line of body'
11444 [ -z "$5" ] || blp=3 # lnet.routes case
11446 local l=$(cat "$TMP/lnet_$1" |wc -l)
11447 # subtracting one from $blp because the body can be empty
11448 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11450 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11451 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11453 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11454 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11456 # bail out if any unexpected line happened
11457 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11458 [ "$?" != 0 ] || error "$2 misformatted"
11461 test_215() { # for bugs 18102, 21079, 21517
11462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11463 local N='(0|[1-9][0-9]*)' # non-negative numeric
11464 local P='[1-9][0-9]*' # positive numeric
11465 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11466 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11467 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11468 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11470 local L1 # regexp for 1st line
11471 local L2 # regexp for 2nd line (optional)
11472 local BR # regexp for the rest (body)
11474 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11475 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11476 create_lnet_proc_files "stats"
11477 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11478 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11479 remove_lnet_proc_files "stats"
11481 # /proc/sys/lnet/routes should look like this:
11482 # Routing disabled/enabled
11483 # net hops priority state router
11484 # where net is a string like tcp0, hops > 0, priority >= 0,
11485 # state is up/down,
11486 # router is a string like 192.168.1.1@tcp2
11487 L1="^Routing (disabled|enabled)$"
11488 L2="^net +hops +priority +state +router$"
11489 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11490 create_lnet_proc_files "routes"
11491 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11492 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11493 remove_lnet_proc_files "routes"
11495 # /proc/sys/lnet/routers should look like this:
11496 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11497 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11498 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11499 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11500 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11501 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11502 create_lnet_proc_files "routers"
11503 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11504 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11505 remove_lnet_proc_files "routers"
11507 # /proc/sys/lnet/peers should look like this:
11508 # nid refs state last max rtr min tx min queue
11509 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11510 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11511 # numeric (0 or >0 or <0), queue >= 0.
11512 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11513 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11514 create_lnet_proc_files "peers"
11515 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11516 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11517 remove_lnet_proc_files "peers"
11519 # /proc/sys/lnet/buffers should look like this:
11520 # pages count credits min
11521 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11522 L1="^pages +count +credits +min$"
11523 BR="^ +$N +$N +$I +$I$"
11524 create_lnet_proc_files "buffers"
11525 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11526 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11527 remove_lnet_proc_files "buffers"
11529 # /proc/sys/lnet/nis should look like this:
11530 # nid status alive refs peer rtr max tx min
11531 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11532 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11533 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11534 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11535 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11536 create_lnet_proc_files "nis"
11537 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11538 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11539 remove_lnet_proc_files "nis"
11541 # can we successfully write to /proc/sys/lnet/stats?
11542 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11543 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11545 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11547 test_216() { # bug 20317
11548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11549 remote_ost_nodsh && skip "remote OST with nodsh" && return
11552 local facets=$(get_facets OST)
11553 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11555 save_lustre_params client "osc.*.contention_seconds" > $p
11556 save_lustre_params $facets \
11557 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11558 save_lustre_params $facets \
11559 "ldlm.namespaces.filter-*.contended_locks" >> $p
11560 save_lustre_params $facets \
11561 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11564 # agressive lockless i/o settings
11565 for node in $(osts_nodes); do
11566 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'
11568 lctl set_param -n osc.*.contention_seconds 60
11570 $DIRECTIO write $DIR/$tfile 0 10 4096
11571 $CHECKSTAT -s 40960 $DIR/$tfile
11573 # disable lockless i/o
11574 for node in $(osts_nodes); do
11575 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'
11577 lctl set_param -n osc.*.contention_seconds 0
11580 dd if=/dev/zero of=$DIR/$tfile count=0
11581 $CHECKSTAT -s 0 $DIR/$tfile
11583 restore_lustre_params <$p
11587 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11589 test_217() { # bug 22430
11590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11594 for node in $(nodes_list); do
11595 nid=$(host_nids_address $node $NETTYPE)
11596 if [[ $nid = *-* ]] ; then
11597 echo "lctl ping $nid@$NETTYPE"
11598 lctl ping $nid@$NETTYPE
11600 echo "skipping $node (no hyphen detected)"
11604 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11607 # do directio so as not to populate the page cache
11608 log "creating a 10 Mb file"
11609 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11610 log "starting reads"
11611 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11612 log "truncating the file"
11613 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11615 kill %+ || true # reads might have finished
11616 echo "wait until dd is finished"
11618 log "removing the temporary file"
11619 rm -rf $DIR/$tfile || error "tmp file removal failed"
11621 run_test 218 "parallel read and truncate should not deadlock ======================="
11624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11625 # write one partial page
11626 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11627 # set no grant so vvp_io_commit_write will do sync write
11628 $LCTL set_param fail_loc=0x411
11629 # write a full page at the end of file
11630 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11632 $LCTL set_param fail_loc=0
11633 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11634 $LCTL set_param fail_loc=0x411
11635 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11638 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11639 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11641 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11643 test_220() { #LU-325
11644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11645 remote_ost_nodsh && skip "remote OST with nodsh" && return
11648 test_mkdir -p $DIR/$tdir
11649 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11650 awk '{print $2}' | sed -e 's/_UUID$//')
11653 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11654 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11655 osc.$mdtosc_proc1.prealloc_last_id)
11656 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11657 osc.$mdtosc_proc1.prealloc_next_id)
11661 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11662 #define OBD_FAIL_OST_ENOINO 0x229
11663 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11664 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11665 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11667 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11669 MDSOBJS=$((last_id - next_id))
11670 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11672 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11673 echo "OST still has $count kbytes free"
11675 echo "create $MDSOBJS files @next_id..."
11676 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11678 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11679 osc.$mdtosc_proc1.prealloc_last_id)
11680 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11681 osc.$mdtosc_proc1.prealloc_next_id)
11683 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11688 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11689 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11691 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11692 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11693 echo "unlink $MDSOBJS files @$next_id..."
11694 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11696 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11700 dd if=`which date` of=$MOUNT/date oflag=sync
11701 chmod +x $MOUNT/date
11703 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11704 $LCTL set_param fail_loc=0x80001401
11706 $MOUNT/date > /dev/null
11709 run_test 221 "make sure fault and truncate race to not cause OOM"
11712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11714 test_mkdir -p $DIR/$tdir
11715 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11716 createmany -o $DIR/$tdir/$tfile 10
11717 cancel_lru_locks mdc
11718 cancel_lru_locks osc
11719 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11720 $LCTL set_param fail_loc=0x31a
11721 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11722 $LCTL set_param fail_loc=0
11725 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11730 test_mkdir -p $DIR/$tdir
11731 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11732 createmany -o $DIR/$tdir/$tfile 10
11733 cancel_lru_locks mdc
11734 cancel_lru_locks osc
11735 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11736 $LCTL set_param fail_loc=0x31a
11737 rm -r $DIR/$tdir || "AGL for rmdir failed"
11738 $LCTL set_param fail_loc=0
11740 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11745 test_mkdir -p $DIR/$tdir
11746 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11747 createmany -o $DIR/$tdir/$tfile 10
11748 cancel_lru_locks mdc
11749 cancel_lru_locks osc
11750 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11751 $LCTL set_param fail_loc=0x31b
11752 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11753 $LCTL set_param fail_loc=0
11756 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11758 test_224a() { # LU-1039, MRP-303
11759 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11760 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11761 $LCTL set_param fail_loc=0x508
11762 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11763 $LCTL set_param fail_loc=0
11766 run_test 224a "Don't panic on bulk IO failure"
11768 test_224b() { # LU-1039, MRP-303
11769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11770 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11771 cancel_lru_locks osc
11772 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11773 $LCTL set_param fail_loc=0x515
11774 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11775 $LCTL set_param fail_loc=0
11778 run_test 224b "Don't panic on bulk IO failure"
11780 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11783 if [ -z ${MDSSURVEY} ]; then
11784 skip_env "mds-survey not found" && return
11787 [ $MDSCOUNT -ge 2 ] &&
11788 skip "skipping now for more than one MDT" && return
11790 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11791 { skip "Need MDS version at least 2.2.51"; return; }
11793 local mds=$(facet_host $SINGLEMDS)
11794 local target=$(do_nodes $mds 'lctl dl' | \
11795 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11797 local cmd1="file_count=1000 thrhi=4"
11798 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11799 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11800 local cmd="$cmd1 $cmd2 $cmd3"
11802 rm -f ${TMP}/mds_survey*
11804 eval $cmd || error "mds-survey with zero-stripe failed"
11805 cat ${TMP}/mds_survey*
11806 rm -f ${TMP}/mds_survey*
11808 run_test 225a "Metadata survey sanity with zero-stripe"
11811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11813 if [ -z ${MDSSURVEY} ]; then
11814 skip_env "mds-survey not found" && return
11816 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11817 { skip "Need MDS version at least 2.2.51"; return; }
11819 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11820 skip_env "Need to mount OST to test" && return
11823 [ $MDSCOUNT -ge 2 ] &&
11824 skip "skipping now for more than one MDT" && return
11825 local mds=$(facet_host $SINGLEMDS)
11826 local target=$(do_nodes $mds 'lctl dl' | \
11827 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11829 local cmd1="file_count=1000 thrhi=4"
11830 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11831 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11832 local cmd="$cmd1 $cmd2 $cmd3"
11834 rm -f ${TMP}/mds_survey*
11836 eval $cmd || error "mds-survey with stripe_count failed"
11837 cat ${TMP}/mds_survey*
11838 rm -f ${TMP}/mds_survey*
11840 run_test 225b "Metadata survey sanity with stripe_count = 1"
11842 mcreate_path2fid () {
11848 local path=$DIR/$tdir/$name
11853 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11854 error "cannot create $desc"
11856 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11858 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11860 fid_path=$($LFS fid2path $MOUNT $fid)
11862 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11864 [ "$path" == "$fid_path" ] ||
11865 error "fid2path returned $fid_path, expected $path"
11867 echo "pass with $path and $fid"
11872 mkdir -p $DIR/$tdir
11874 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11875 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11876 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11877 mcreate_path2fid 0040666 0 0 dir "directory"
11878 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11879 mcreate_path2fid 0100666 0 0 file "regular file"
11880 mcreate_path2fid 0120666 0 0 link "symbolic link"
11881 mcreate_path2fid 0140666 0 0 sock "socket"
11883 run_test 226a "call path2fid and fid2path on files of all type"
11886 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11890 mkdir -p $DIR/$tdir
11891 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11892 error "create remote directory failed"
11893 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11894 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11895 "character special file (null)"
11896 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11897 "character special file (no device)"
11898 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11899 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11900 "block special file (loop)"
11901 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11902 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11903 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11905 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11907 # LU-1299 Executing or running ldd on a truncated executable does not
11908 # cause an out-of-memory condition.
11910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11911 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
11912 dd if=$(which date) of=$MOUNT/date bs=1k count=1
11913 chmod +x $MOUNT/date
11915 $MOUNT/date > /dev/null
11916 ldd $MOUNT/date > /dev/null
11919 run_test 227 "running truncated executable does not cause OOM"
11921 # LU-1512 try to reuse idle OI blocks
11923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11924 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11925 skip "non-ldiskfs backend" && return
11927 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11928 local myDIR=$DIR/$tdir
11931 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11932 $LCTL set_param fail_loc=0x80001002
11933 createmany -o $myDIR/t- 10000
11934 $LCTL set_param fail_loc=0
11935 # The guard is current the largest FID holder
11937 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11939 local IDX=$(($SEQ % 64))
11941 do_facet $SINGLEMDS sync
11942 # Make sure journal flushed.
11944 local blk1=$(do_facet $SINGLEMDS \
11945 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11946 grep Blockcount | awk '{print $4}')
11948 # Remove old files, some OI blocks will become idle.
11949 unlinkmany $myDIR/t- 10000
11950 # Create new files, idle OI blocks should be reused.
11951 createmany -o $myDIR/t- 2000
11952 do_facet $SINGLEMDS sync
11953 # Make sure journal flushed.
11955 local blk2=$(do_facet $SINGLEMDS \
11956 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11957 grep Blockcount | awk '{print $4}')
11959 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11961 run_test 228a "try to reuse idle OI blocks"
11964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11965 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11966 skip "non-ldiskfs backend" && return
11968 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11969 local myDIR=$DIR/$tdir
11972 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11973 $LCTL set_param fail_loc=0x80001002
11974 createmany -o $myDIR/t- 10000
11975 $LCTL set_param fail_loc=0
11976 # The guard is current the largest FID holder
11978 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11980 local IDX=$(($SEQ % 64))
11982 do_facet $SINGLEMDS sync
11983 # Make sure journal flushed.
11985 local blk1=$(do_facet $SINGLEMDS \
11986 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11987 grep Blockcount | awk '{print $4}')
11989 # Remove old files, some OI blocks will become idle.
11990 unlinkmany $myDIR/t- 10000
11993 stop $SINGLEMDS || error "Fail to stop MDT."
11995 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11997 df $MOUNT || error "Fail to df."
11998 # Create new files, idle OI blocks should be reused.
11999 createmany -o $myDIR/t- 2000
12000 do_facet $SINGLEMDS sync
12001 # Make sure journal flushed.
12003 local blk2=$(do_facet $SINGLEMDS \
12004 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12005 grep Blockcount | awk '{print $4}')
12007 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12009 run_test 228b "idle OI blocks can be reused after MDT restart"
12013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12014 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12015 skip "non-ldiskfs backend" && return
12017 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12018 local myDIR=$DIR/$tdir
12021 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12022 $LCTL set_param fail_loc=0x80001002
12023 # 20000 files can guarantee there are index nodes in the OI file
12024 createmany -o $myDIR/t- 20000
12025 $LCTL set_param fail_loc=0
12026 # The guard is current the largest FID holder
12028 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12030 local IDX=$(($SEQ % 64))
12032 do_facet $SINGLEMDS sync
12033 # Make sure journal flushed.
12035 local blk1=$(do_facet $SINGLEMDS \
12036 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12037 grep Blockcount | awk '{print $4}')
12039 # Remove old files, some OI blocks will become idle.
12040 unlinkmany $myDIR/t- 20000
12042 # The OI file should become empty now
12044 # Create new files, idle OI blocks should be reused.
12045 createmany -o $myDIR/t- 2000
12046 do_facet $SINGLEMDS sync
12047 # Make sure journal flushed.
12049 local blk2=$(do_facet $SINGLEMDS \
12050 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12051 grep Blockcount | awk '{print $4}')
12053 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12055 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12057 test_229() { # LU-2482, LU-3448
12058 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12059 skip "No HSM support on MDS of $(get_lustre_version)," \
12060 "need 2.4.53 at least" && return
12061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12062 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12066 # Create a file with a released layout and stripe count 2.
12067 $MULTIOP $DIR/$tfile H2c ||
12068 error "failed to create file with released layout"
12070 $GETSTRIPE -v $DIR/$tfile
12072 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12073 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12075 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12076 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12077 stat $DIR/$tfile || error "failed to stat released file"
12079 chown $RUNAS_ID $DIR/$tfile ||
12080 error "chown $RUNAS_ID $DIR/$tfile failed"
12082 chgrp $RUNAS_ID $DIR/$tfile ||
12083 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12085 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12086 rm $DIR/$tfile || error "failed to remove released file"
12088 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12092 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12095 mkdir -p $DIR/$tdir/test_230_local
12096 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12097 [ $mdt_idx -ne 0 ] &&
12098 error "create local directory on wrong MDT $mdt_idx"
12100 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12101 error "create remote directory failed"
12102 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12103 [ $mdt_idx -ne $MDTIDX ] &&
12104 error "create remote directory on wrong MDT $mdt_idx"
12106 createmany -o $DIR/$tdir/test_230/t- 10 ||
12107 error "create files on remote directory failed"
12108 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12109 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12110 rm -r $DIR/$tdir || error "unlink remote directory failed"
12112 run_test 230a "Create remote directory and files under the remote directory"
12115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12123 local migrate_dir=$DIR/$tdir/migrate_dir
12124 local other_dir=$DIR/$tdir/other_dir
12126 mkdir -p $migrate_dir
12127 mkdir -p $other_dir
12128 for ((i=0; i<10; i++)); do
12129 mkdir -p $migrate_dir/dir_${i}
12130 createmany -o $migrate_dir/dir_${i}/f 10 ||
12131 error "create files under remote dir failed $i"
12134 cp /etc/passwd $migrate_dir/$tfile
12135 cp /etc/passwd $other_dir/$tfile
12136 chattr +SAD $migrate_dir
12137 chattr +SAD $migrate_dir/$tfile
12139 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12140 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12141 local old_dir_mode=$(stat -c%f $migrate_dir)
12142 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12144 mkdir -p $migrate_dir/dir_default_stripe2
12145 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12146 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12148 mkdir -p $other_dir
12149 ln $migrate_dir/$tfile $other_dir/luna
12150 ln $migrate_dir/$tfile $migrate_dir/sofia
12151 ln $other_dir/$tfile $migrate_dir/david
12152 ln -s $migrate_dir/$tfile $other_dir/zachary
12153 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12154 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12156 $LFS mv -v -M $MDTIDX $migrate_dir ||
12157 error "migrate remote dir error"
12159 echo "migratate to MDT1, then checking.."
12160 for ((i=0; i<10; i++)); do
12161 for file in $(find $migrate_dir/dir_${i}); do
12162 mdt_index=$($LFS getstripe -M $file)
12163 [ $mdt_index == $MDTIDX ] ||
12164 error "$file is not on MDT${MDTIDX}"
12168 # the multiple link file should still in MDT0
12169 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12170 [ $mdt_index == 0 ] ||
12171 error "$file is not on MDT${MDTIDX}"
12173 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12174 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12175 error " expect $old_dir_flag get $new_dir_flag"
12177 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12178 [ "$old_file_flag" = "$new_file_flag" ] ||
12179 error " expect $old_file_flag get $new_file_flag"
12181 local new_dir_mode=$(stat -c%f $migrate_dir)
12182 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12183 error "expect mode $old_dir_mode get $new_dir_mode"
12185 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12186 [ "$old_file_mode" = "$new_file_mode" ] ||
12187 error "expect mode $old_file_mode get $new_file_mode"
12189 diff /etc/passwd $migrate_dir/$tfile ||
12190 error "$tfile different after migration"
12192 diff /etc/passwd $other_dir/luna ||
12193 error "luna different after migration"
12195 diff /etc/passwd $migrate_dir/sofia ||
12196 error "sofia different after migration"
12198 diff /etc/passwd $migrate_dir/david ||
12199 error "david different after migration"
12201 diff /etc/passwd $other_dir/zachary ||
12202 error "zachary different after migration"
12204 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12205 error "${tfile}_ln different after migration"
12207 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12208 error "${tfile}_ln_other different after migration"
12210 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12211 [ $stripe_count = 2 ] ||
12212 error "dir strpe_count $d != 2 after migration."
12214 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12215 [ $stripe_count = 2 ] ||
12216 error "file strpe_count $d != 2 after migration."
12218 #migrate back to MDT0
12220 $LFS mv -v -M $MDTIDX $migrate_dir ||
12221 error "migrate remote dir error"
12223 echo "migrate back to MDT0, checking.."
12224 for file in $(find $migrate_dir); do
12225 mdt_index=$($LFS getstripe -M $file)
12226 [ $mdt_index == $MDTIDX ] ||
12227 error "$file is not on MDT${MDTIDX}"
12230 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12231 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12232 error " expect $old_dir_flag get $new_dir_flag"
12234 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12235 [ "$old_file_flag" = "$new_file_flag" ] ||
12236 error " expect $old_file_flag get $new_file_flag"
12238 local new_dir_mode=$(stat -c%f $migrate_dir)
12239 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12240 error "expect mode $old_dir_mode get $new_dir_mode"
12242 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12243 [ "$old_file_mode" = "$new_file_mode" ] ||
12244 error "expect mode $old_file_mode get $new_file_mode"
12246 diff /etc/passwd ${migrate_dir}/$tfile ||
12247 error "$tfile different after migration"
12249 diff /etc/passwd ${other_dir}/luna ||
12250 error "luna different after migration"
12252 diff /etc/passwd ${migrate_dir}/sofia ||
12253 error "sofia different after migration"
12255 diff /etc/passwd ${other_dir}/zachary ||
12256 error "zachary different after migration"
12258 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12259 error "${tfile}_ln different after migration"
12261 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12262 error "${tfile}_ln_other different after migration"
12264 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12265 [ $stripe_count = 2 ] ||
12266 error "dir strpe_count $d != 2 after migration."
12268 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12269 [ $stripe_count = 2 ] ||
12270 error "file strpe_count $d != 2 after migration."
12272 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12274 run_test 230b "migrate directory"
12277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12278 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12283 #If migrating directory fails in the middle, all entries of
12284 #the directory is still accessiable.
12285 mkdir -p $DIR/$tdir
12287 createmany -o $DIR/$tdir/f 10 ||
12288 error "create files under ${tdir} failed"
12290 #failed after migrating 5 entries
12291 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12292 do_facet mds1 lctl set_param fail_loc=0x20001801
12293 do_facet mds1 lctl set_param fail_val=5
12294 local t=`ls $DIR/$tdir | wc -l`
12295 $LFS mv -M $MDTIDX $DIR/$tdir &&
12296 error "migrate should failed after 5 entries"
12297 local u=`ls $DIR/$tdir | wc -l`
12298 [ "$u" == "$t" ] || error "$u != $t during migration"
12300 for file in $(find $DIR/$tdir); do
12301 stat $file || error "stat $file failed"
12304 do_facet mds1 lctl set_param fail_loc=0
12305 do_facet mds1 lctl set_param fail_val=0
12307 $LFS mv -M $MDTIDX $DIR/$tdir ||
12308 error "migrate open files should failed with open files"
12310 echo "Finish migration, then checking.."
12311 for file in $(find $DIR/$tdir); do
12312 mdt_index=$($LFS getstripe -M $file)
12313 [ $mdt_index == $MDTIDX ] ||
12314 error "$file is not on MDT${MDTIDX}"
12317 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12319 run_test 230c "check directory accessiblity if migration is failed"
12322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12323 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12329 mkdir -p $DIR/$tdir
12331 for ((i=0; i<100; i++)); do
12332 mkdir -p $DIR/$tdir/dir_${i}
12333 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12334 error "create files under remote dir failed $i"
12337 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12339 echo "Finish migration, then checking.."
12340 for file in $(find $DIR/$tdir); do
12341 mdt_index=$($LFS getstripe -M $file)
12342 [ $mdt_index == $MDTIDX ] ||
12343 error "$file is not on MDT${MDTIDX}"
12346 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12348 run_test 230d "check migrate big directory"
12352 # For simplicity this test assumes that max_pages_per_rpc
12353 # is the same across all OSCs
12354 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12355 local bulk_size=$((max_pages * 4096))
12357 mkdir -p $DIR/$tdir
12359 # clear the OSC stats
12360 $LCTL set_param osc.*.stats=0 &>/dev/null
12362 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12363 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12364 oflag=direct &>/dev/null || error "dd failed"
12366 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12367 if [ x$nrpcs != "x1" ]; then
12368 error "found $nrpc ost_write RPCs, not 1 as expected"
12371 # Drop the OSC cache, otherwise we will read from it
12372 cancel_lru_locks osc
12374 # clear the OSC stats
12375 $LCTL set_param osc.*.stats=0 &>/dev/null
12377 # Client reads $bulk_size.
12378 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12379 iflag=direct &>/dev/null || error "dd failed"
12381 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12382 if [ x$nrpcs != "x1" ]; then
12383 error "found $nrpc ost_read RPCs, not 1 as expected"
12386 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12389 mkdir -p $DIR/$tdir
12391 for i in {0..1023}; do
12392 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12393 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12394 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12398 run_test 231b "must not assert on fully utilized OST request buffer"
12401 mkdir -p $DIR/$tdir
12402 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12403 $LCTL set_param fail_loc=0x31c
12405 # ignore dd failure
12406 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12408 $LCTL set_param fail_loc=0
12409 umount_client $MOUNT || error "umount failed"
12410 mount_client $MOUNT || error "mount failed"
12412 run_test 232 "failed lock should not block umount"
12415 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12416 { skip "Need MDS version at least 2.3.64"; return; }
12418 local fid=$($LFS path2fid $MOUNT)
12419 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12420 error "cannot access $MOUNT using its FID '$fid'"
12422 run_test 233a "checking that OBF of the FS root succeeds"
12425 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12426 { skip "Need MDS version at least 2.5.90"; return; }
12428 local fid=$($LFS path2fid $MOUNT/.lustre)
12429 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12430 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12432 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12433 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12434 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12436 run_test 233b "checking that OBF of the FS .lustre succeeds"
12439 local p="$TMP/sanityN-$TESTNAME.parameters"
12440 save_lustre_params client "llite.*.xattr_cache" > $p
12441 lctl set_param llite.*.xattr_cache 1 ||
12442 { skip "xattr cache is not supported"; return 0; }
12444 mkdir -p $DIR/$tdir || error "mkdir failed"
12445 touch $DIR/$tdir/$tfile || error "touch failed"
12446 # OBD_FAIL_LLITE_XATTR_ENOMEM
12447 $LCTL set_param fail_loc=0x1405
12448 if [ ! -f /etc/SuSE-release ]; then
12449 # attr pre-2.4.44-7 had a bug with rc
12450 # LU-3703 - SLES clients have older attr
12451 getfattr -n user.attr $DIR/$tdir/$tfile &&
12452 error "getfattr should have failed with ENOMEM"
12454 $LCTL set_param fail_loc=0x0
12457 restore_lustre_params < $p
12460 run_test 234 "xattr cache should not crash on ENOMEM"
12463 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12464 skip "Need MDS version at least 2.4.52" && return
12465 flock_deadlock $DIR/$tfile
12470 124) error "process hangs on a deadlock"
12472 *) error "error executing flock_deadlock $DIR/$tfile"
12476 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12480 check_swap_layouts_support && return 0
12481 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12483 local ref1=/etc/passwd
12484 local ref2=/etc/group
12485 local file1=$DIR/$tdir/f1
12486 local file2=$DIR/$tdir/f2
12488 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12489 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12490 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12491 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12492 local fd=$(free_fd)
12493 local cmd="exec $fd<>$file2"
12496 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12497 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12500 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12505 run_test 236 "Layout swap on open unlinked file"
12507 # test to verify file handle related system calls
12508 # (name_to_handle_at/open_by_handle_at)
12509 # The new system calls are supported in glibc >= 2.14.
12512 echo "Test file_handle syscalls" > $DIR/$tfile
12513 check_fhandle_syscalls $DIR/$tfile ||
12514 error "check_fhandle_syscalls failed"
12516 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12518 # LU-4659 linkea consistency
12521 ln $DIR/$tfile $DIR/$tfile.lnk
12522 touch $DIR/$tfile.new
12523 mv $DIR/$tfile.new $DIR/$tfile
12524 local fid1=$(lfs path2fid $DIR/$tfile)
12525 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12526 local path1=$(lfs fid2path $FSNAME $fid1)
12527 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12528 local path2=$(lfs fid2path $FSNAME $fid2)
12529 [ $tfile.lnk == $path2 ] ||
12530 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12533 run_test 238 "Verify linkea consistency"
12535 test_striped_dir() {
12540 mkdir -p $DIR/$tdir
12541 $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
12542 error "set striped dir error"
12544 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12545 if [ "$stripe_count" != "2" ]; then
12546 error "stripe_count is $stripe_count, expect 2"
12549 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12550 if [ "$stripe_index" != "$mdt_index" ]; then
12551 error "stripe_index is $stripe_index, expect $mdt_index"
12554 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12555 error "nlink error after create striped dir"
12557 mkdir $DIR/$tdir/striped_dir/a
12558 mkdir $DIR/$tdir/striped_dir/b
12560 stat $DIR/$tdir/striped_dir/a ||
12561 error "create dir under striped dir failed"
12562 stat $DIR/$tdir/striped_dir/b ||
12563 error "create dir under striped dir failed"
12565 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12566 error "nlink error after mkdir"
12568 rmdir $DIR/$tdir/striped_dir/a
12569 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12570 error "nlink error after rmdir"
12572 rmdir $DIR/$tdir/striped_dir/b
12573 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12574 error "nlink error after rmdir"
12576 rmdir $DIR/$tdir/striped_dir ||
12577 error "rmdir striped dir error"
12582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12583 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12585 test_striped_dir 0 || error "failed on striped dir on MDT0"
12586 test_striped_dir 1 || error "failed on striped dir on MDT0"
12588 run_test 300a "basic striped dir sanity test"
12591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12592 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12598 test_mkdir $DIR/$tdir || error "mkdir fail"
12599 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12600 error "set striped dir error"
12601 for ((i=0; i<10; i++)); do
12602 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12604 touch $DIR/$tdir/striped_dir/file_$i ||
12605 error "touch error $i"
12606 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12607 [ $mtime1 -eq $mtime2 ] &&
12608 error "mtime not change after create"
12610 rm -f $DIR/$tdir/striped_dir/file_$i ||
12611 error "unlink error $i"
12612 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12613 [ $mtime2 -eq $mtime3 ] &&
12614 error "mtime did not change after unlink"
12618 run_test 300b "check ctime/mtime for striped dir"
12621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12622 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12625 mkdir -p $DIR/$tdir
12626 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12627 error "set striped dir error"
12629 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12630 error "chown striped dir failed"
12632 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12633 error "create 5k files failed"
12635 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12637 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12641 run_test 300c "chown && check ls under striped directory"
12644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12649 mkdir -p $DIR/$tdir
12650 $SETSTRIPE -c 2 $DIR/$tdir
12652 #local striped directory
12653 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12654 error "set striped dir error"
12655 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12656 error "create 10 files failed"
12658 #remote striped directory
12659 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12660 error "set striped dir error"
12661 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12662 error "create 10 files failed"
12664 for file in $(find $DIR/$tdir); do
12665 stripe_count=$($GETSTRIPE -c $file)
12666 [ $stripe_count -eq 2 ] ||
12667 error "wrong stripe $stripe_count for $file"
12672 run_test 300d "check default stripe under striped directory"
12675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12676 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12680 mkdir -p $DIR/$tdir
12682 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12683 error "set striped dir error"
12685 touch $DIR/$tdir/striped_dir/a
12686 touch $DIR/$tdir/striped_dir/b
12687 touch $DIR/$tdir/striped_dir/c
12689 mkdir $DIR/$tdir/striped_dir/dir_a
12690 mkdir $DIR/$tdir/striped_dir/dir_b
12691 mkdir $DIR/$tdir/striped_dir/dir_c
12693 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12694 error "set striped dir under striped dir error"
12696 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12697 error "set striped dir under striped dir error"
12699 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12700 error "set striped dir under striped dir error"
12702 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12703 error "rename file under striped dir should fail"
12705 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12706 error "rename dir under striped dir should fail"
12708 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12709 error "rename dir under different stripes should fail"
12711 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12712 error "rename file under striped dir should succeed"
12714 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12715 error "rename dir under striped dir should succeed"
12719 run_test 300e "check rename under striped directory"
12722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12723 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12728 mkdir -p $DIR/$tdir
12730 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12731 error "set striped dir error"
12733 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12734 error "set striped dir error"
12736 touch $DIR/$tdir/striped_dir/a
12737 mkdir $DIR/$tdir/striped_dir/dir_a
12738 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12739 error "create striped dir under striped dir fails"
12741 touch $DIR/$tdir/striped_dir1/b
12742 mkdir $DIR/$tdir/striped_dir1/dir_b
12743 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12744 error "create striped dir under striped dir fails"
12746 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12747 error "rename file under different striped dir should fail"
12749 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12750 error "rename dir under different striped dir should fail"
12752 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12753 error "rename striped dir under diff striped dir should fail"
12755 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12756 error "rename file under diff striped dirs fails"
12758 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12759 error "rename dir under diff striped dirs fails"
12763 run_test 300f "check rename cross striped directory"
12766 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12771 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12772 $DIR/$tdir/striped_dir ||
12773 error "set striped dir error"
12775 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12776 error "set default stripe on striped dir error"
12778 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12780 for dir in $(find $DIR/$tdir/striped_dir/*); do
12781 stripe_count=$($LFS getdirstripe -c $dir)
12782 [ $stripe_count -eq $MDSCOUNT ] ||
12783 error "expect $MDSCOUNT get $stripe_count for $dir"
12786 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12787 #change default stripe count to 2
12788 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12789 error "set default stripe on striped dir error"
12791 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12793 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12795 #change default stripe count to 1
12796 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
12797 error "set default stripe on striped dir error"
12799 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12800 for dir in $(find $DIR/$tdir/striped_dir/*); do
12801 stripe_count=$($LFS getdirstripe -c $dir)
12802 [ $stripe_count -eq 1 ] ||
12803 error "expect 1 get $stripe_count for $dir"
12805 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
12807 run_test 300g "check default striped directory for striped directory"
12809 test_400a() { # LU-1606, was conf-sanity test_74
12810 local extra_flags=''
12811 local out=$TMP/$tfile
12812 local prefix=/usr/include/lustre
12815 if ! which $CC > /dev/null 2>&1; then
12816 skip_env "$CC is not installed"
12820 if ! [[ -d $prefix ]]; then
12821 # Assume we're running in tree and fixup the include path.
12822 extra_flags+=" -I$LUSTRE/../libcfs/include"
12823 extra_flags+=" -I$LUSTRE/include"
12824 extra_flags+=" -L$LUSTRE/utils"
12827 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
12828 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
12829 error "client api broken"
12832 run_test 400a "Lustre client api program can compile and link"
12834 test_400b() { # LU-1606, LU-5011
12836 local out=$TMP/$tfile
12837 local prefix=/usr/include/lustre
12839 # We use a hard coded prefix so that this test will not fail
12840 # when run in tree. There are headers in lustre/include/lustre/
12841 # that are not packaged (like lustre_idl.h) and have more
12842 # complicated include dependencies (like config.h and lnet/types.h).
12843 # Since this test about correct packaging we just skip them when
12844 # they don't exist (see below) rather than try to fixup cppflags.
12846 if ! which $CC > /dev/null 2>&1; then
12847 skip_env "$CC is not installed"
12851 for header in $prefix/*.h; do
12852 if ! [[ -f "$header" ]]; then
12856 if [[ "$(basename $header)" == liblustreapi.h ]]; then
12857 continue # liblustreapi.h is deprecated.
12860 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
12861 error "cannot compile '$header'"
12864 run_test 400b "packaged headers can be compiled"
12867 # tests that do cleanup/setup should be run at the end
12871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12873 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12874 $LCTL set_param fail_loc=0x903
12875 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12876 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12879 FAIL_ON_ERROR=true cleanup
12880 FAIL_ON_ERROR=true setup
12882 run_test 900 "umount should not race with any mgc requeue thread"
12885 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
12886 check_and_cleanup_lustre
12887 if [ "$I_MOUNTED" != "yes" ]; then
12888 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true