2 # -*- tab-width: 4; 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"
20 SRCDIR=$(cd $(dirname $0); echo $PWD)
21 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 MCREATE=${MCREATE:-mcreate}
32 OPENFILE=${OPENFILE:-openfile}
33 OPENUNLINK=${OPENUNLINK:-openunlink}
34 export MULTIOP=${MULTIOP:-multiop}
35 READS=${READS:-"reads"}
36 MUNLINK=${MUNLINK:-munlink}
37 SOCKETSERVER=${SOCKETSERVER:-socketserver}
38 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
39 MEMHOG=${MEMHOG:-memhog}
40 DIRECTIO=${DIRECTIO:-directio}
41 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
42 UMOUNT=${UMOUNT:-"umount -d"}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
110 awk '{gsub(/_UUID/,""); print $1}' | head -1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
148 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
150 run_test 0a "touch; rm ====================="
153 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
154 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" ||
160 error "import not FULL"
161 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
164 run_test 0c "check import proc ============================="
167 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
168 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
169 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
170 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
173 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
175 run_test 1 "mkdir; remkdir; rmdir =============================="
178 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
179 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
182 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
184 run_test 2 "mkdir; touch; rmdir; check file ===================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
189 touch $DIR/$tdir/$tfile
190 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
192 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
194 run_test 3 "mkdir; touch; rmdir; check dir ====================="
196 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
199 local remote_dir=remote_dir
201 test_mkdir $DIR/$remote_dir ||
202 error "Create remote directory failed"
204 touch $DIR/$remote_dir/$tfile ||
205 error "Create file under remote directory failed"
207 rmdir $DIR/$remote_dir &&
208 error "Expect error removing in-use dir $DIR/$remote_dir"
210 test -d $DIR/$remote_dir || error "Remote directory disappeared"
212 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
215 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
216 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
217 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
218 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
219 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
221 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
224 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
225 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
226 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
227 error "$tfile does not have perm 0666 or UID $UID"
228 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
230 error "$tfile should be 0666 and owned by UID $UID"
232 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
235 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
237 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
238 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
239 error "$tfile should be owned by UID $RUNAS_ID"
240 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
241 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
242 error "$tfile should be owned by UID $RUNAS_ID"
244 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
247 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
249 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
250 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
251 error "$tfile should be owned by GID $UID"
252 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
253 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
254 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
256 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
259 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
260 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
261 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
262 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
263 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
264 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
265 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
266 error "$tdir/d/subdir should be GID $RUNAS_GID"
268 run_test 6g "Is new dir in sgid dir inheriting group?"
270 test_6h() { # bug 7331
271 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
272 touch $DIR/$tfile || error "touch failed"
273 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
274 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
275 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
276 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
277 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
279 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
282 test_mkdir $DIR/$tdir
283 $MCREATE $DIR/$tdir/$tfile
284 chmod 0666 $DIR/$tdir/$tfile
285 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
286 error "$tdir/$tfile should be mode 0666"
288 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
291 if [ ! -d $DIR/$tdir ]; then
294 $MCREATE $DIR/$tdir/$tfile
295 echo -n foo > $DIR/$tdir/$tfile
296 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
297 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
299 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
302 test_mkdir $DIR/$tdir
303 touch $DIR/$tdir/$tfile
304 chmod 0666 $DIR/$tdir/$tfile
305 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
306 error "$tfile mode not 0666"
308 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
311 test_mkdir $DIR/$tdir
312 test_mkdir $DIR/$tdir/d2
313 test_mkdir $DIR/$tdir/d2/d3
314 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
316 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
319 test_mkdir $DIR/$tdir
320 test_mkdir $DIR/$tdir/d2
321 touch $DIR/$tdir/d2/$tfile
322 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
323 error "$tdir/d2/$tfile not a file"
325 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
328 test_mkdir $DIR/$tdir
329 test_mkdir $DIR/$tdir/d2
330 chmod 0666 $DIR/$tdir/d2
331 chmod 0705 $DIR/$tdir/d2
332 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
333 error "$tdir/d2 mode not 0705"
335 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
338 test_mkdir $DIR/$tdir
339 touch $DIR/$tdir/$tfile
340 chmod 0666 $DIR/$tdir/$tfile
341 chmod 0654 $DIR/$tdir/$tfile
342 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
343 error "$tdir/d2 mode not 0654"
345 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
348 test_mkdir $DIR/$tdir
349 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
351 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
352 error "$tdir/$tfile size not 0 after truncate"
354 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
357 test_mkdir $DIR/$tdir
358 touch $DIR/$tdir/$tfile
360 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
362 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
365 test_mkdir $DIR/$tdir
366 touch $DIR/$tdir/$tfile
367 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
368 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
369 error "$tdir/${tfile_2} not a file after rename"
371 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
376 rm -rf $DIR/$tdir/$tfile
377 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
379 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
382 test_mkdir -p $DIR/$tdir
383 touch $DIR/$tdir/$tfile
384 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
386 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
387 error "$tdir/l-exist not a symlink"
388 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
389 error "$tdir/l-exist not referencing a file"
390 rm -f $DIR/$tdir/l-exist
391 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
393 run_test 17a "symlinks: create, remove (real) =================="
396 test_mkdir -p $DIR/$tdir
397 ln -s no-such-file $DIR/$tdir/l-dangle
399 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
400 error "$tdir/l-dangle not referencing no-such-file"
401 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
402 error "$tdir/l-dangle not referencing non-existent file"
403 rm -f $DIR/$tdir/l-dangle
404 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
406 run_test 17b "symlinks: create, remove (dangling) =============="
408 test_17c() { # bug 3440 - don't save failed open RPC for replay
409 test_mkdir -p $DIR/$tdir
410 ln -s foo $DIR/$tdir/$tfile
411 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
413 run_test 17c "symlinks: open dangling (should return error) ===="
416 test_mkdir -p $DIR/$tdir
417 ln -s foo $DIR/$tdir/$tfile
418 touch $DIR/$tdir/$tfile || error "creating to new symlink"
420 run_test 17d "symlinks: create dangling ========================"
423 test_mkdir -p $DIR/$tdir
424 local foo=$DIR/$tdir/$tfile
425 ln -s $foo $foo || error "create symlink failed"
426 ls -l $foo || error "ls -l failed"
427 ls $foo && error "ls not failed" || true
429 run_test 17e "symlinks: create recursive symlink (should return error) ===="
432 test_mkdir -p $DIR/d17f
433 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
434 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
438 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
441 run_test 17f "symlinks: long and very long symlink name ========================"
443 # str_repeat(S, N) generate a string that is string S repeated N times
448 while [ $((n -= 1)) -ge 0 ]; do
454 # Long symlinks and LU-2241
456 test_mkdir -p $DIR/$tdir
457 local TESTS="59 60 61 4094 4095"
459 # Fix for inode size boundary in 2.1.4
460 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
463 # Patch not applied to 2.2 or 2.3 branches
464 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
465 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
468 # skip long symlink name for rhel6.5.
469 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
470 grep -q '6.5' /etc/redhat-release && TESTS="59 60 61 4062 4063"
473 local SYMNAME=$(str_repeat 'x' $i)
474 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
475 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
478 run_test 17g "symlinks: really long symlink name and inode boundaries"
480 test_17h() { #bug 17378
481 remote_mds_nodsh && skip "remote MDS with nodsh" && return
482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
484 test_mkdir -p $DIR/$tdir
485 if [ $MDSCOUNT -gt 1 ]; then
486 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
490 $SETSTRIPE -c -1 $DIR/$tdir
491 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
492 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
493 touch $DIR/$tdir/$tfile || true
495 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
497 test_17i() { #bug 20018
498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
499 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
500 test_mkdir -p $DIR/$tdir
501 local foo=$DIR/$tdir/$tfile
503 if [ $MDSCOUNT -gt 1 ]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 ln -s $foo $foo || error "create symlink failed"
509 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
511 ls -l $foo && error "error not detected"
514 run_test 17i "don't panic on short symlink"
516 test_17k() { #bug 22301
517 rsync --help | grep -q xattr ||
518 skip_env "$(rsync --version| head -1) does not support xattrs"
519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
520 test_mkdir -p $DIR/$tdir
521 test_mkdir -p $DIR/$tdir.new
522 touch $DIR/$tdir/$tfile
523 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
524 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
525 error "rsync failed with xattrs enabled"
527 run_test 17k "symlinks: rsync with xattrs enabled ========================="
529 test_17l() { # LU-279
531 touch $DIR/$tdir/$tfile
532 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
533 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
534 # -h to not follow symlinks. -m '' to list all the xattrs.
535 # grep to remove first line: '# file: $path'.
536 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
538 lgetxattr_size_check $path $xattr ||
539 error "lgetxattr_size_check $path $xattr failed"
543 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
547 local short_sym="0123456789"
548 local WDIR=$DIR/${tdir}m
555 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
556 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
557 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
559 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
560 skip "only for ldiskfs MDT" && return 0
562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
566 # create a long symlink file
567 for ((i = 0; i < 4; ++i)); do
568 long_sym=${long_sym}${long_sym}
571 echo "create 512 short and long symlink files under $WDIR"
572 for ((i = 0; i < 256; ++i)); do
573 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
574 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
580 wait_delete_completed
582 echo "recreate the 512 symlink files with a shorter string"
583 for ((i = 0; i < 512; ++i)); do
584 # rewrite the symlink file with a shorter string
585 ln -sf ${long_sym} $WDIR/long-$i
586 ln -sf ${short_sym} $WDIR/short-$i
589 mds_index=$($LFS getstripe -M $WDIR)
590 mds_index=$((mds_index+1))
591 devname=$(mdsdevname $mds_index)
592 cmd="$E2FSCK -fnvd $devname"
594 echo "stop and checking mds${mds_index}: $cmd"
595 # e2fsck should not return error
597 do_facet mds${mds_index} $cmd || rc=$?
599 start mds${mds_index} $devname $MDS_MOUNT_OPTS
600 df $MOUNT > /dev/null 2>&1
601 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
602 "short/long symlink MDT: rc=$rc"
605 run_test 17m "run e2fsck against MDT which contains short/long symlink"
607 check_fs_consistency_17n() {
613 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
614 # so it only check MDT1/MDT2 instead of all of MDTs.
615 for mdt_index in $(seq 1 2); do
616 devname=$(mdsdevname $mdt_index)
617 cmd="$E2FSCK -fnvd $devname"
619 echo "stop and checking mds${mdt_index}: $cmd"
620 # e2fsck should not return error
622 do_facet mds${mdt_index} $cmd || rc=$?
624 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
625 df $MOUNT > /dev/null 2>&1
626 [ $rc -ne 0 ] && break
634 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
635 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
636 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
638 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
639 skip "only for ldiskfs MDT" && return 0
641 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
646 for ((i=0; i<10; i++)); do
647 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
648 error "create remote dir error $i"
649 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
650 error "create files under remote dir failed $i"
653 check_fs_consistency_17n ||
654 error "e2fsck report error after create files under remote dir"
656 for ((i=0;i<10;i++)); do
657 rm -rf $DIR/$tdir/remote_dir_${i} ||
658 error "destroy remote dir error $i"
661 check_fs_consistency_17n ||
662 error "e2fsck report error after unlink files under remote dir"
664 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
665 skip "lustre < 2.4.50 does not support migrate mv " && return
667 for ((i=0; i<10; i++)); do
668 mkdir -p $DIR/$tdir/remote_dir_${i}
669 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
670 error "create files under remote dir failed $i"
671 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
672 error "migrate remote dir error $i"
674 check_fs_consistency_17n || error "e2fsck report error after migration"
676 for ((i=0;i<10;i++)); do
677 rm -rf $DIR/$tdir/remote_dir_${i} ||
678 error "destroy remote dir error $i"
681 check_fs_consistency_17n || error "e2fsck report error after unlink"
683 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
686 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ]] &&
687 skip "Need MDS version at least 2.3.64" && return
689 local WDIR=$DIR/${tdir}o
695 mdt_index=$($LFS getstripe -M $WDIR)
696 mdt_index=$((mdt_index+1))
697 mdtdevname=$(mdsdevname $mdt_index)
701 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
703 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
704 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
705 ls -l $WDIR/$tfile && rc=1
706 do_facet mds${mdt_index} lctl set_param fail_loc=0
707 [[ $rc -ne 0 ]] && error "stat file should fail"
710 run_test 17o "stat file with incompat LMA feature"
713 touch $DIR/f || error "Failed to touch $DIR/f: $?"
714 ls $DIR || error "Failed to ls $DIR: $?"
716 run_test 18 "touch .../f ; ls ... =============================="
722 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
724 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
727 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
729 run_test 19b "ls -l .../f19 (should return error) =============="
732 [ $RUNAS_ID -eq $UID ] &&
733 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
734 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
736 run_test 19c "$RUNAS touch .../f19 (should return error) =="
739 cat $DIR/f19 && error || true
741 run_test 19d "cat .../f19 (should return error) =============="
753 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
755 run_test 20 "touch .../f ; ls -l ... ==========================="
758 test_mkdir -p $DIR/$tdir
759 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
760 ln -s dangle $DIR/$tdir/link
761 echo foo >> $DIR/$tdir/link
762 cat $DIR/$tdir/dangle
763 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
764 $CHECKSTAT -f -t file $DIR/$tdir/link ||
765 error "$tdir/link not linked to a file"
767 run_test 21 "write to dangling link ============================"
771 test_mkdir -p $DIR/$tdir
772 chown $RUNAS_ID:$RUNAS_GID $WDIR
773 (cd $WDIR || error "cd $WDIR failed";
774 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
776 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
777 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
778 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
780 run_test 22 "unpack tar archive as non-root user ==============="
784 test_mkdir -p $DIR/$tdir
785 local file=$DIR/$tdir/$tfile
787 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
788 openfile -f O_CREAT:O_EXCL $file &&
789 error "$file recreate succeeded" || true
791 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
793 test_23b() { # bug 18988
794 test_mkdir -p $DIR/$tdir
795 local file=$DIR/$tdir/$tfile
798 echo foo > $file || error "write filed"
799 echo bar >> $file || error "append filed"
800 $CHECKSTAT -s 8 $file || error "wrong size"
803 run_test 23b "O_APPEND check =========================="
807 echo '-- same directory rename'
808 test_mkdir $DIR/$tdir
809 touch $DIR/$tdir/$tfile.1
810 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
811 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
813 run_test 24a "rename file to non-existent target"
816 test_mkdir $DIR/$tdir
817 touch $DIR/$tdir/$tfile.{1,2}
818 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
819 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
820 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
822 run_test 24b "rename file to existing target"
825 test_mkdir $DIR/$tdir
826 test_mkdir $DIR/$tdir/d$testnum.1
827 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
828 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
829 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
831 run_test 24c "rename directory to non-existent target"
834 test_mkdir -c1 $DIR/$tdir
835 test_mkdir -c1 $DIR/$tdir/d$testnum.1
836 test_mkdir -c1 $DIR/$tdir/d$testnum.2
837 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
838 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
839 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
841 run_test 24d "rename directory to existing target"
844 echo '-- cross directory renames --'
848 mv $DIR/R5a/f $DIR/R5b/g
849 $CHECKSTAT -a $DIR/R5a/f || error
850 $CHECKSTAT -t file $DIR/R5b/g || error
852 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
857 touch $DIR/R6a/f $DIR/R6b/g
858 mv $DIR/R6a/f $DIR/R6b/g
859 $CHECKSTAT -a $DIR/R6a/f || error
860 $CHECKSTAT -t file $DIR/R6b/g || error
862 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
867 test_mkdir $DIR/R7a/d
868 mv $DIR/R7a/d $DIR/R7b/e
869 $CHECKSTAT -a $DIR/R7a/d || error
870 $CHECKSTAT -t dir $DIR/R7b/e || error
872 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
875 test_mkdir -c1 $DIR/R8a
876 test_mkdir -c1 $DIR/R8b
877 test_mkdir -c1 $DIR/R8a/d
878 test_mkdir -c1 $DIR/R8b/e
879 mrename $DIR/R8a/d $DIR/R8b/e
880 $CHECKSTAT -a $DIR/R8a/d || error
881 $CHECKSTAT -t dir $DIR/R8b/e || error
883 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
886 echo "-- rename error cases"
890 mrename $DIR/R9/f $DIR/R9/a
891 $CHECKSTAT -t file $DIR/R9/f || error
892 $CHECKSTAT -t dir $DIR/R9/a || error
893 $CHECKSTAT -a $DIR/R9/a/f || error
895 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
899 mrename $DIR/R10/f $DIR/R10/g
900 $CHECKSTAT -t dir $DIR/R10 || error
901 $CHECKSTAT -a $DIR/R10/f || error
902 $CHECKSTAT -a $DIR/R10/g || error
904 run_test 24j "source does not exist ============================"
908 test_mkdir $DIR/R11a/d
910 mv $DIR/R11a/f $DIR/R11a/d
911 $CHECKSTAT -a $DIR/R11a/f || error
912 $CHECKSTAT -t file $DIR/R11a/d/f || error
914 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
916 # bug 2429 - rename foo foo foo creates invalid file
919 $MULTIOP $f OcNs || error
921 run_test 24l "Renaming a file to itself ========================"
925 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
926 # on ext3 this does not remove either the source or target files
927 # though the "expected" operation would be to remove the source
928 $CHECKSTAT -t file ${f} || error "${f} missing"
929 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
931 run_test 24m "Renaming a file to a hard link to itself ========="
935 # this stats the old file after it was renamed, so it should fail
939 $CHECKSTAT ${f}.rename
942 run_test 24n "Statting the old file after renaming (Posix rename 2)"
945 check_kernel_version 37 || return 0
946 test_mkdir -p $DIR/d24o
947 rename_many -s random -v -n 10 $DIR/d24o
949 run_test 24o "rename of files during htree split ==============="
954 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
955 mrename $DIR/R12a $DIR/R12b
956 $CHECKSTAT -a $DIR/R12a || error
957 $CHECKSTAT -t dir $DIR/R12b || error
958 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
959 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
961 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
963 cleanup_multiop_pause() {
969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
972 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
973 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
976 trap cleanup_multiop_pause EXIT
977 mrename $DIR/R13a $DIR/R13b
978 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
979 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
980 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
981 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
982 cleanup_multiop_pause
983 wait $MULTIPID || error "multiop close failed"
985 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
987 test_24r() { #bug 3789
989 test_mkdir $DIR/R14a/b
990 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
991 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
992 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
994 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
998 test_mkdir $DIR/R15a/b
999 test_mkdir $DIR/R15a/b/c
1000 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1001 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1002 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1004 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1006 test_mkdir $DIR/R16a
1007 test_mkdir $DIR/R16a/b
1008 test_mkdir $DIR/R16a/b/c
1009 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1010 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1011 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1013 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1015 test_24u() { # bug12192
1017 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1018 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1020 run_test 24u "create stripe file"
1026 simple_cleanup_common() {
1029 wait_delete_completed
1032 max_pages_per_rpc() {
1033 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
1037 local NRFILES=100000
1038 local FREE_INODES=$(mdt_free_inodes 0)
1039 [ $FREE_INODES -lt $NRFILES ] && \
1040 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1044 trap simple_cleanup_common EXIT
1046 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1047 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1050 createmany -m $DIR/$tdir/$tfile $NRFILES
1052 cancel_lru_locks mdc
1053 lctl set_param mdc.*.stats clear
1055 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1057 # LU-5 large readdir
1058 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1059 # 8 bytes for name(filename is mostly 5 in this test) +
1060 # 8 bytes for luda_type
1061 # take into account of overhead in lu_dirpage header and end mark in
1062 # each page, plus one in RPC_NUM calculation.
1064 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1065 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1066 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1067 awk '/^mds_readpage/ {print $2}')
1068 [ $mds_readpage -gt $RPC_NUM ] && \
1069 error "large readdir doesn't take effect"
1071 simple_cleanup_common
1073 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1075 test_24w() { # bug21506
1077 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1078 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1079 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1080 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1081 [ "$SZ1" = "$SZ2" ] || \
1082 error "Error reading at the end of the file $tfile"
1084 run_test 24w "Reading a file larger than 4Gb"
1087 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1088 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1090 local remote_dir=$DIR/$tdir/remote_dir
1093 $LFS mkdir -i $MDTIDX $remote_dir ||
1094 error "create remote directory failed"
1096 mkdir -p $DIR/$tdir/src_dir
1097 touch $DIR/$tdir/src_file
1098 mkdir -p $remote_dir/tgt_dir
1099 touch $remote_dir/tgt_file
1101 mrename $remote_dir $DIR/ &&
1102 error "rename dir cross MDT works!"
1104 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1105 error "rename dir cross MDT works!"
1107 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1108 error "rename file cross MDT works!"
1110 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1111 error "ln file cross MDT should not work!"
1113 rm -rf $DIR/$tdir || error "Can not delete directories"
1115 run_test 24x "cross rename/link should be failed"
1118 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1121 local remote_dir=$DIR/$tdir/remote_dir
1124 $LFS mkdir -i $MDTIDX $remote_dir ||
1125 error "create remote directory failed"
1127 mkdir -p $remote_dir/src_dir
1128 touch $remote_dir/src_file
1129 mkdir -p $remote_dir/tgt_dir
1130 touch $remote_dir/tgt_file
1132 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1133 error "rename subdir in the same remote dir failed!"
1135 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1136 error "rename files in the same remote dir failed!"
1138 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1139 error "link files in the same remote dir failed!"
1141 rm -rf $DIR/$tdir || error "Can not delete directories"
1143 run_test 24y "rename/link on the same dir should succeed"
1146 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1149 local remote_src=$DIR/$tdir/remote_dir
1150 local remote_tgt=$DIR/$tdir/remote_tgt
1153 $LFS mkdir -i $MDTIDX $remote_src ||
1154 error "create remote directory failed"
1156 $LFS mkdir -i $MDTIDX $remote_tgt ||
1157 error "create remote directory failed"
1159 mrename $remote_src $remote_tgt &&
1160 error "rename remote dirs should not work!"
1162 # If target dir does not exists, it should succeed
1164 mrename $remote_src $remote_tgt ||
1165 error "rename remote dirs(tgt dir does not exists) failed!"
1167 rm -rf $DIR/$tdir || error "Can not delete directories"
1169 run_test 24z "rename one remote dir to another remote dir should fail"
1171 test_24A() { # LU-3182
1176 createmany -m $DIR/$tdir/$tfile $NFILES
1177 local t=`ls $DIR/$tdir | wc -l`
1178 local u=`ls $DIR/$tdir | sort -u | wc -l`
1179 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1180 error "Expected $NFILES files, got $t ($u unique)"
1183 rm -rf $DIR/$tdir || error "Can not delete directories"
1185 run_test 24A "readdir() returns correct number of entries."
1188 echo '== symlink sanity ============================================='
1192 touch $DIR/s25/foo || error
1194 run_test 25a "create file in symlinked directory ==============="
1197 [ ! -d $DIR/d25 ] && test_25a
1198 $CHECKSTAT -t file $DIR/s25/foo || error
1200 run_test 25b "lookup file in symlinked directory ==============="
1204 test_mkdir $DIR/d26/d26-2
1205 ln -s d26/d26-2 $DIR/s26
1206 touch $DIR/s26/foo || error
1208 run_test 26a "multiple component symlink ======================="
1211 test_mkdir -p $DIR/d26b/d26-2
1212 ln -s d26b/d26-2/foo $DIR/s26-2
1213 touch $DIR/s26-2 || error
1215 run_test 26b "multiple component symlink at end of lookup ======"
1218 test_mkdir $DIR/d26.2
1219 touch $DIR/d26.2/foo
1220 ln -s d26.2 $DIR/s26.2-1
1221 ln -s s26.2-1 $DIR/s26.2-2
1222 ln -s s26.2-2 $DIR/s26.2-3
1223 chmod 0666 $DIR/s26.2-3/foo
1225 run_test 26c "chain of symlinks ================================"
1227 # recursive symlinks (bug 439)
1229 ln -s d26-3/foo $DIR/d26-3
1231 run_test 26d "create multiple component recursive symlink ======"
1234 [ ! -h $DIR/d26-3 ] && test_26d
1237 run_test 26e "unlink multiple component recursive symlink ======"
1239 # recursive symlinks (bug 7022)
1241 test_mkdir -p $DIR/$tdir
1242 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1243 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1244 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1245 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1246 cd $tfile || error "cd $tfile failed"
1247 ln -s .. dotdot || error "ln dotdot failed"
1248 ln -s dotdot/lndir lndir || error "ln lndir failed"
1249 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1250 output=`ls $tfile/$tfile/lndir/bar1`
1251 [ "$output" = bar1 ] && error "unexpected output"
1252 rm -r $tfile || error "rm $tfile failed"
1253 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1255 run_test 26f "rm -r of a directory which has recursive symlink ="
1258 echo '== stripe sanity =============================================='
1259 test_mkdir -p $DIR/d27 || error "mkdir failed"
1261 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1262 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1264 log "== test_27a: write to one stripe file ========================="
1265 cp /etc/hosts $DIR/d27/f0 || error
1267 run_test 27a "one stripe file =================================="
1270 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1271 test_mkdir -p $DIR/d27
1272 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1273 $GETSTRIPE -c $DIR/d27/f01
1274 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1275 error "two-stripe file doesn't have two stripes"
1277 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1279 run_test 27b "create and write to two stripe file"
1282 test_mkdir -p $DIR/d27
1283 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1284 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1285 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1287 run_test 27d "create file with default settings ================"
1290 test_mkdir -p $DIR/d27
1291 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1292 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1293 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1295 run_test 27e "setstripe existing file (should return error) ======"
1298 test_mkdir -p $DIR/d27
1299 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1300 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1301 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1303 run_test 27f "setstripe with bad stripe size (should return error)"
1306 test_mkdir -p $DIR/d27
1307 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1308 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1309 error "$DIR/d27/fnone has object"
1311 run_test 27g "$GETSTRIPE with no objects"
1314 touch $DIR/d27/fsome || error "touch failed"
1315 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1317 run_test 27i "$GETSTRIPE with some objects"
1320 test_mkdir -p $DIR/d27
1321 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1323 run_test 27j "setstripe with bad stripe offset (should return error)"
1325 test_27k() { # bug 2844
1326 test_mkdir -p $DIR/d27
1328 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1329 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1330 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1331 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1332 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1333 dd if=/dev/zero of=$FILE bs=4k count=1
1334 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1335 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1337 run_test 27k "limit i_blksize for broken user apps ============="
1340 test_mkdir -p $DIR/d27
1341 mcreate $DIR/f27l || error "creating file"
1342 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1343 error "setstripe should have failed" || true
1345 run_test 27l "check setstripe permissions (should return error)"
1348 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1350 if [ $ORIGFREE -gt $MAXFREE ]; then
1351 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1354 trap simple_cleanup_common EXIT
1355 test_mkdir -p $DIR/$tdir
1356 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1357 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1358 error "dd should fill OST0"
1360 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1362 [ $i -gt 256 ] && break
1365 touch $DIR/$tdir/f27m_$i
1366 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1367 error "OST0 was full but new created file still use it"
1369 touch $DIR/$tdir/f27m_$i
1370 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1371 error "OST0 was full but new created file still use it"
1372 simple_cleanup_common
1374 run_test 27m "create file while OST0 was full =================="
1377 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1381 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1382 # if the OST isn't full anymore.
1384 local OSTIDX=${1:-""}
1386 local list=$(comma_list $(osts_nodes))
1387 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1389 do_nodes $list lctl set_param fail_loc=0
1390 sync # initiate all OST_DESTROYs from MDS to OST
1394 exhaust_precreations() {
1397 local FAILIDX=${3:-$OSTIDX}
1399 test_mkdir -p $DIR/$tdir
1400 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1401 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1403 local OST=$(ostname_from_index $OSTIDX)
1404 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1405 sed -e 's/_UUID$//;s/^.*-//')
1408 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1409 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1410 osc.$mdtosc_proc1.prealloc_last_id)
1411 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1412 osc.$mdtosc_proc1.prealloc_next_id)
1414 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1415 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1417 test_mkdir -p $DIR/$tdir/${OST}
1418 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1419 #define OBD_FAIL_OST_ENOSPC 0x215
1420 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1421 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1422 echo "Creating to objid $last_id on ost $OST..."
1423 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1424 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1425 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1429 exhaust_all_precreations() {
1431 for (( i=0; i < OSTCOUNT; i++ )) ; do
1432 exhaust_precreations $i $1 -1
1437 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1439 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1440 remote_ost_nodsh && skip "remote OST with nodsh" && return
1443 rm -f $DIR/$tdir/$tfile
1444 exhaust_precreations 0 0x80000215
1445 $SETSTRIPE -c -1 $DIR/$tdir
1446 touch $DIR/$tdir/$tfile || error
1447 $GETSTRIPE $DIR/$tdir/$tfile
1450 run_test 27n "create file with some full OSTs =================="
1453 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1455 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1456 remote_ost_nodsh && skip "remote OST with nodsh" && return
1459 rm -f $DIR/$tdir/$tfile
1460 exhaust_all_precreations 0x215
1462 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1467 run_test 27o "create file with all full OSTs (should error) ===="
1470 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1472 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1473 remote_ost_nodsh && skip "remote OST with nodsh" && return
1476 rm -f $DIR/$tdir/$tfile
1477 test_mkdir -p $DIR/$tdir
1479 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1480 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1481 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1483 exhaust_precreations 0 0x80000215
1484 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1485 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1486 $GETSTRIPE $DIR/$tdir/$tfile
1490 run_test 27p "append to a truncated file with some full OSTs ==="
1493 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1494 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1495 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1496 remote_ost_nodsh && skip "remote OST with nodsh" && return
1499 rm -f $DIR/$tdir/$tfile
1501 test_mkdir -p $DIR/$tdir
1502 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1503 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1504 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1506 exhaust_all_precreations 0x215
1508 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1509 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1513 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1516 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1518 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1519 remote_ost_nodsh && skip "remote OST with nodsh" && return
1522 rm -f $DIR/$tdir/$tfile
1523 exhaust_precreations 0 0x80000215
1525 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1529 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1531 test_27s() { # bug 10725
1532 test_mkdir -p $DIR/$tdir
1533 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1534 local stripe_count=0
1535 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1536 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1537 error "stripe width >= 2^32 succeeded" || true
1540 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1542 test_27t() { # bug 10864
1547 $WLFS getstripe $tfile
1550 run_test 27t "check that utils parse path correctly"
1552 test_27u() { # bug 4900
1553 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1554 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1556 local list=$(comma_list $(mdts_nodes))
1558 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1559 do_nodes $list $LCTL set_param fail_loc=0x139
1560 test_mkdir -p $DIR/$tdir
1562 createmany -o $DIR/$tdir/t- 1000
1563 do_nodes $list $LCTL set_param fail_loc=0
1565 TLOG=$DIR/$tfile.getstripe
1566 $GETSTRIPE $DIR/$tdir > $TLOG
1567 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1568 unlinkmany $DIR/$tdir/t- 1000
1569 [ $OBJS -gt 0 ] && \
1570 error "$OBJS objects created on OST-0. See $TLOG" || pass
1572 run_test 27u "skip object creation on OSC w/o objects =========="
1574 test_27v() { # bug 4900
1575 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1578 remote_ost_nodsh && skip "remote OST with nodsh" && return
1580 exhaust_all_precreations 0x215
1583 test_mkdir -p $DIR/$tdir
1584 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1586 touch $DIR/$tdir/$tfile
1587 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1589 for (( i=1; i < OSTCOUNT; i++ )); do
1590 do_facet ost$i lctl set_param fail_loc=0x705
1592 local START=`date +%s`
1593 createmany -o $DIR/$tdir/$tfile 32
1595 local FINISH=`date +%s`
1596 local TIMEOUT=`lctl get_param -n timeout`
1597 local PROCESS=$((FINISH - START))
1598 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1599 error "$FINISH - $START >= $TIMEOUT / 2"
1600 sleep $((TIMEOUT / 2 - PROCESS))
1603 run_test 27v "skip object creation on slow OST ================="
1605 test_27w() { # bug 10997
1606 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1607 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1608 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1609 error "stripe size $size != 65536" || true
1610 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1611 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1613 run_test 27w "check $SETSTRIPE -S option"
1616 [ "$OSTCOUNT" -lt "2" ] &&
1617 skip_env "skipping multiple stripe count/offset test" && return
1619 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1620 for i in $(seq 1 $OSTCOUNT); do
1622 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1623 error "setstripe -c $i -i $offset failed"
1624 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1625 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1626 [ $count -ne $i ] && error "stripe count $count != $i" || true
1627 [ $index -ne $offset ] &&
1628 error "stripe offset $index != $offset" || true
1631 run_test 27wa "check $SETSTRIPE -c -i options"
1634 remote_ost_nodsh && skip "remote OST with nodsh" && return
1635 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1637 OFFSET=$(($OSTCOUNT - 1))
1639 local OST=$(ostname_from_index $OSTIDX)
1641 test_mkdir -p $DIR/$tdir
1642 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1643 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1645 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1646 for i in `seq 0 $OFFSET`; do
1647 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1648 error "OST0 was degraded but new created file still use it"
1650 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1652 run_test 27x "create files while OST0 is degraded"
1655 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1656 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1657 remote_ost_nodsh && skip "remote OST with nodsh" && return
1658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1660 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1661 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1662 osc.$mdtosc.prealloc_last_id)
1663 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1664 osc.$mdtosc.prealloc_next_id)
1665 local fcount=$((last_id - next_id))
1666 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1667 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1669 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1670 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1671 local OST_DEACTIVE_IDX=-1
1676 for OSC in $MDS_OSCS; do
1677 OST=$(osc_to_ost $OSC)
1678 OSTIDX=$(index_from_ostuuid $OST)
1679 if [ $OST_DEACTIVE_IDX == -1 ]; then
1680 OST_DEACTIVE_IDX=$OSTIDX
1682 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1683 echo $OSC "is Deactivated:"
1684 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1688 OSTIDX=$(index_from_ostuuid $OST)
1690 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1692 for OSC in $MDS_OSCS; do
1693 OST=$(osc_to_ost $OSC)
1694 OSTIDX=$(index_from_ostuuid $OST)
1695 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1696 echo $OST "is degraded:"
1697 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1698 obdfilter.$OST.degraded=1
1703 createmany -o $DIR/$tdir/$tfile $fcount
1705 for OSC in $MDS_OSCS; do
1706 OST=$(osc_to_ost $OSC)
1707 OSTIDX=$(index_from_ostuuid $OST)
1708 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1709 echo $OST "is recovered from degraded:"
1710 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1711 obdfilter.$OST.degraded=0
1713 do_facet $SINGLEMDS lctl --device %$OSC activate
1717 # all osp devices get activated, hence -1 stripe count restored
1720 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1721 # devices get activated.
1723 $SETSTRIPE -c -1 $DIR/$tfile
1724 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1726 [ $stripecnt -ne $OSTCOUNT ] &&
1727 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1730 run_test 27y "create files while OST0 is degraded and the rest inactive"
1736 lmm_count=$($GETSTRIPE -c $1)
1737 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1738 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1740 local old_ifs="$IFS"
1742 fid=($($LFS path2fid $1))
1745 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1746 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1748 # compare lmm_seq and lu_fid->f_seq
1749 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1750 # compare lmm_object_id and lu_fid->oid
1751 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1753 # check the trusted.fid attribute of the OST objects of the file
1754 local have_obdidx=false
1756 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1757 # skip lines up to and including "obdidx"
1758 [ -z "$obdidx" ] && break
1759 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1760 $have_obdidx || continue
1762 local ost=$((obdidx + 1))
1763 local dev=$(ostdevname $ost)
1766 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1768 seq=$(echo $seq | sed -e "s/^0x//g")
1769 if [ $seq == 0 ]; then
1770 oid_hex=$(echo $oid)
1772 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1774 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1778 # Don't unmount/remount the OSTs if we don't need to do that.
1779 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1780 # update too, until that use mount/ll_decode_filter_fid/mount.
1781 # Re-enable when debugfs will understand new filter_fid.
1783 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1784 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1785 $dev 2>/dev/null" | grep "parent=")
1788 mount_fstype ost$ost
1789 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1790 $(facet_mntpt ost$ost)/$obj_file)
1791 unmount_fstype ost$ost
1792 start ost$ost $dev $OST_MOUNT_OPTS
1795 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1797 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1799 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1800 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1801 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1802 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1803 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1805 if echo $ff_parent | grep -q 'stripe='; then
1806 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1809 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1810 # into f_ver in this case. See the comment on
1813 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1817 # compare lmm_seq and filter_fid->ff_parent.f_seq
1818 [ $ff_pseq = $lmm_seq ] ||
1819 error "FF parent SEQ $ff_pseq != $lmm_seq"
1820 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1821 [ $ff_poid = $lmm_oid ] ||
1822 error "FF parent OID $ff_poid != $lmm_oid"
1823 (($ff_pstripe == $stripe_nr)) ||
1824 error "FF stripe $ff_pstripe != $stripe_nr"
1826 stripe_nr=$((stripe_nr + 1))
1831 remote_ost_nodsh && skip "remote OST with nodsh" && return
1832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1833 test_mkdir -p $DIR/$tdir
1835 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1836 { error "setstripe -c -1 failed"; return 1; }
1837 # We need to send a write to every object to get parent FID info set.
1838 # This _should_ also work for setattr, but does not currently.
1839 # touch $DIR/$tdir/$tfile-1 ||
1840 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1841 { error "dd $tfile-1 failed"; return 2; }
1842 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1843 { error "setstripe -c -1 failed"; return 3; }
1844 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1845 { error "dd $tfile-2 failed"; return 4; }
1847 # make sure write RPCs have been sent to OSTs
1850 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1851 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1853 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1855 test_27A() { # b=19102
1856 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1857 local restore_size=$($GETSTRIPE -S $MOUNT)
1858 local restore_count=$($GETSTRIPE -c $MOUNT)
1859 local restore_offset=$($GETSTRIPE -i $MOUNT)
1860 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1861 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1862 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1863 local default_size=$($GETSTRIPE -S $MOUNT)
1864 local default_offset=$($GETSTRIPE -i $MOUNT)
1865 local dsize=$((1024 * 1024))
1866 [ $default_size -eq $dsize ] ||
1867 error "stripe size $default_size != $dsize"
1868 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1869 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1871 run_test 27A "check filesystem-wide default LOV EA values"
1873 test_27B() { # LU-2523
1874 test_mkdir -p $DIR/$tdir
1875 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1877 # open f1 with O_LOV_DELAY_CREATE
1879 # call setstripe ioctl on open file descriptor for f1
1881 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1885 # open f1 with O_LOV_DELAY_CREATE
1887 # call setstripe ioctl on open file descriptor for f1
1889 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1891 # Allow multiop to fail in imitation of NFS's busted semantics.
1894 run_test 27B "call setstripe on open unlinked file/rename victim"
1896 test_27C() { #LU-2871
1897 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1905 test_mkdir -p $DIR/$tdir
1907 for i in $(seq 0 $((OSTCOUNT - 1))); do
1908 # set stripe across all OSTs starting from OST$i
1909 $SETSTRIPE -i $i -c -1 $tfile$i
1910 # get striping information
1911 ost_idx=($($GETSTRIPE $tfile$i |
1912 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1916 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1917 error "${#ost_idx[@]} != $OSTCOUNT"
1919 for index in $(seq 0 $((OSTCOUNT - 1))); do
1921 for j in $(echo ${ost_idx[@]}); do
1922 if [ $index -eq $j ]; then
1928 error "Can not find $index in ${ost_idx[@]}"
1932 run_test 27C "check full striping across all OSTs"
1934 # createtest also checks that device nodes are created and
1935 # then visible correctly (#2091)
1936 test_28() { # bug 2091
1938 $CREATETEST $DIR/d28/ct || error
1940 run_test 28 "create/mknod/mkdir with bad file types ============"
1943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1944 cancel_lru_locks mdc
1950 declare -i LOCKCOUNTORIG=0
1951 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1952 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1954 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1956 declare -i LOCKUNUSEDCOUNTORIG=0
1957 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1958 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1965 declare -i LOCKCOUNTCURRENT=0
1966 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1967 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1970 declare -i LOCKUNUSEDCOUNTCURRENT=0
1971 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1972 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1975 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1976 lctl set_param -n ldlm.dump_namespaces ""
1977 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1978 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1979 log "dumped log to $TMP/test_29.dk (bug 5793)"
1982 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1983 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1984 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1985 log "dumped log to $TMP/test_29.dk (bug 5793)"
1989 run_test 29 "IT_GETATTR regression ============================"
1991 test_30a() { # was test_30
1992 cp `which ls` $DIR || cp /bin/ls $DIR
1996 run_test 30a "execute binary from Lustre (execve) =============="
1999 cp `which ls` $DIR || cp /bin/ls $DIR
2001 $RUNAS $DIR/ls / || error
2004 run_test 30b "execute binary from Lustre as non-root ==========="
2006 test_30c() { # b=22376
2007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2008 cp `which ls` $DIR || cp /bin/ls $DIR
2010 cancel_lru_locks mdc
2011 cancel_lru_locks osc
2012 $RUNAS $DIR/ls / || error
2015 run_test 30c "execute binary from Lustre without read perms ===="
2018 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2019 $CHECKSTAT -a $DIR/f31 || error
2021 run_test 31a "open-unlink file =================================="
2024 touch $DIR/f31 || error
2025 ln $DIR/f31 $DIR/f31b || error
2026 $MULTIOP $DIR/f31b Ouc || error
2027 $CHECKSTAT -t file $DIR/f31 || error
2029 run_test 31b "unlink file with multiple links while open ======="
2032 touch $DIR/f31 || error
2033 ln $DIR/f31 $DIR/f31c || error
2034 multiop_bg_pause $DIR/f31 O_uc || return 1
2036 $MULTIOP $DIR/f31c Ouc
2037 kill -USR1 $MULTIPID
2040 run_test 31c "open-unlink file with multiple links ============="
2043 opendirunlink $DIR/d31d $DIR/d31d || error
2044 $CHECKSTAT -a $DIR/d31d || error
2046 run_test 31d "remove of open directory ========================="
2048 test_31e() { # bug 2904
2049 check_kernel_version 34 || return 0
2050 openfilleddirunlink $DIR/d31e || error
2052 run_test 31e "remove of open non-empty directory ==============="
2054 test_31f() { # bug 4554
2055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2057 test_mkdir $DIR/d31f
2058 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2059 cp /etc/hosts $DIR/d31f
2061 $GETSTRIPE $DIR/d31f/hosts
2062 multiop_bg_pause $DIR/d31f D_c || return 1
2065 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2066 test_mkdir $DIR/d31f
2067 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2068 cp /etc/hosts $DIR/d31f
2070 $GETSTRIPE $DIR/d31f/hosts
2071 multiop_bg_pause $DIR/d31f D_c || return 1
2074 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2075 wait $MULTIPID || error "first opendir $MULTIPID failed"
2079 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2080 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2083 run_test 31f "remove of open directory with open-unlink file ==="
2086 echo "-- cross directory link --"
2087 test_mkdir -c1 $DIR/${tdir}ga
2088 test_mkdir -c1 $DIR/${tdir}gb
2089 touch $DIR/${tdir}ga/f
2090 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2091 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2092 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2093 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2094 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2096 run_test 31g "cross directory link==============="
2099 echo "-- cross directory link --"
2100 test_mkdir -c1 $DIR/${tdir}
2101 test_mkdir -c1 $DIR/${tdir}/dir
2102 touch $DIR/${tdir}/f
2103 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2104 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2105 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2106 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2107 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2109 run_test 31h "cross directory link under child==============="
2112 echo "-- cross directory link --"
2113 test_mkdir -c1 $DIR/$tdir
2114 test_mkdir -c1 $DIR/$tdir/dir
2115 touch $DIR/$tdir/dir/f
2116 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2117 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2118 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2119 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2120 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2122 run_test 31i "cross directory link under parent==============="
2125 test_mkdir -c1 -p $DIR/$tdir
2126 test_mkdir -c1 -p $DIR/$tdir/dir1
2127 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2128 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2129 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2130 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2133 run_test 31j "link for directory==============="
2136 test_mkdir -c1 -p $DIR/$tdir
2138 touch $DIR/$tdir/exist
2139 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2140 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2141 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2142 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2143 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2144 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2145 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2148 run_test 31k "link to file: the same, non-existing, dir==============="
2154 touch $DIR/d31m2/exist
2155 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2156 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2157 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2158 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2159 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2160 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2163 run_test 31m "link to file: the same, non-existing, dir==============="
2166 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2167 nlink=$(stat --format=%h $DIR/$tfile)
2168 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2170 local cmd="exec $fd<$DIR/$tfile"
2173 trap "eval $cmd" EXIT
2174 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2175 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2176 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2177 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2178 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2181 run_test 31n "check link count of unlinked file"
2184 local TEMPNAME=$(mktemp $1_XXXXXX)
2185 mlink $TEMPNAME $1 2> /dev/null &&
2186 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2190 test_31o() { # LU-2901
2192 for LOOP in $(seq 100); do
2193 rm -f $DIR/$tdir/$tfile*
2194 for THREAD in $(seq 8); do
2195 link_one $DIR/$tdir/$tfile.$LOOP &
2198 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2199 [ $LINKS -gt 1 ] && ls $DIR/$tdir &&
2200 error "$LINKS duplicate links to $tfile.$LOOP" &&
2204 run_test 31o "duplicate hard links with same filename"
2206 cleanup_test32_mount() {
2208 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2213 echo "== more mountpoints and symlinks ================="
2214 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2215 trap cleanup_test32_mount EXIT
2216 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2217 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2218 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2219 cleanup_test32_mount
2221 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2225 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2226 trap cleanup_test32_mount EXIT
2227 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2228 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2229 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2230 cleanup_test32_mount
2232 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2236 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2237 trap cleanup_test32_mount EXIT
2238 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2239 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2240 test_mkdir -p $DIR/$tdir/d2/test_dir
2241 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2242 cleanup_test32_mount
2244 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2248 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2249 trap cleanup_test32_mount EXIT
2250 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2251 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2252 test_mkdir -p $DIR/$tdir/d2/test_dir
2253 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2254 cleanup_test32_mount
2256 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2259 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2260 test_mkdir -p $DIR/d32e/tmp
2261 TMP_DIR=$DIR/d32e/tmp
2262 ln -s $DIR/d32e $TMP_DIR/symlink11
2263 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2264 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2265 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2267 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2270 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2271 test_mkdir -p $DIR/d32f/tmp
2272 TMP_DIR=$DIR/d32f/tmp
2273 ln -s $DIR/d32f $TMP_DIR/symlink11
2274 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2275 ls $DIR/d32f/tmp/symlink11 || error
2276 ls $DIR/d32f/symlink01 || error
2278 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2281 TMP_DIR=$DIR/$tdir/tmp
2282 test_mkdir -p $DIR/$tdir/tmp
2283 test_mkdir $DIR/${tdir}2
2284 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2285 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2286 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2287 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2288 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2289 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2291 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2294 rm -fr $DIR/$tdir $DIR/${tdir}2
2295 TMP_DIR=$DIR/$tdir/tmp
2296 test_mkdir -p $DIR/$tdir/tmp
2297 test_mkdir $DIR/${tdir}2
2298 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2299 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2300 ls $TMP_DIR/symlink12 || error
2301 ls $DIR/$tdir/symlink02 || error
2303 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2307 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2308 trap cleanup_test32_mount EXIT
2309 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2310 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2311 touch $DIR/$tdir/test_file
2312 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2313 cleanup_test32_mount
2315 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2319 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2320 trap cleanup_test32_mount EXIT
2321 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2322 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2323 touch $DIR/$tdir/test_file
2324 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2325 cleanup_test32_mount
2327 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2332 trap cleanup_test32_mount EXIT
2333 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2334 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2335 test_mkdir -p $DIR/$tdir/d2
2336 touch $DIR/$tdir/d2/test_file || error
2337 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2338 cleanup_test32_mount
2340 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2345 trap cleanup_test32_mount EXIT
2346 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2347 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2348 test_mkdir -p $DIR/$tdir/d2
2349 touch $DIR/$tdir/d2/test_file
2350 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2351 cleanup_test32_mount
2353 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2357 test_mkdir -p $DIR/d32m/tmp
2358 TMP_DIR=$DIR/d32m/tmp
2359 ln -s $DIR $TMP_DIR/symlink11
2360 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2361 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2362 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2364 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2368 test_mkdir -p $DIR/d32n/tmp
2369 TMP_DIR=$DIR/d32n/tmp
2370 ln -s $DIR $TMP_DIR/symlink11
2371 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2372 ls -l $DIR/d32n/tmp/symlink11 || error
2373 ls -l $DIR/d32n/symlink01 || error
2375 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2378 rm -fr $DIR/d32o $DIR/$tfile
2380 test_mkdir -p $DIR/d32o/tmp
2381 TMP_DIR=$DIR/d32o/tmp
2382 ln -s $DIR/$tfile $TMP_DIR/symlink12
2383 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2384 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2385 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2386 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2387 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2389 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2399 test_mkdir -p $DIR/d32p/tmp
2401 TMP_DIR=$DIR/d32p/tmp
2403 ln -s $DIR/$tfile $TMP_DIR/symlink12
2405 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2407 cat $DIR/d32p/tmp/symlink12 || error
2409 cat $DIR/d32p/symlink02 || error
2412 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2414 cleanup_testdir_mount() {
2416 $UMOUNT -d $DIR/$tdir
2420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2421 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2422 trap cleanup_testdir_mount EXIT
2423 test_mkdir -p $DIR/$tdir
2424 touch $DIR/$tdir/under_the_mount
2425 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2426 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2427 cleanup_testdir_mount
2429 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2433 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2434 trap cleanup_testdir_mount EXIT
2435 test_mkdir -p $DIR/$tdir
2436 touch $DIR/$tdir/under_the_mount
2437 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2438 ls $DIR/$tdir | grep -q under_the_mount && error || true
2439 cleanup_testdir_mount
2441 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2446 chmod 444 $DIR/$tfile
2447 chown $RUNAS_ID $DIR/$tfile
2449 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2452 run_test 33aa "write file with mode 444 (should return error) ===="
2456 test_mkdir -p $DIR/d33
2457 chown $RUNAS_ID $DIR/d33
2458 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2459 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2460 error "open RDWR" || true
2462 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2466 test_mkdir -p $DIR/d33
2467 chown $RUNAS_ID $DIR/d33
2468 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2470 run_test 33b "test open file with malformed flags (No panic and return error)"
2473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2479 remote_ost_nodsh && skip "remote OST with nodsh" && return
2482 test_mkdir -p $DIR/d33
2483 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2486 for ostnum in $(seq $OSTCOUNT); do
2487 # test-framework's OST numbering is one-based, while Lustre's
2489 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2490 # Parsing llobdstat's output sucks; we could grep the /proc
2491 # path, but that's likely to not be as portable as using the
2492 # llobdstat utility. So we parse lctl output instead.
2493 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2494 obdfilter/$ostname/stats |
2495 awk '/^write_bytes/ {print $7}' )
2496 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2497 if (( ${write_bytes:-0} > 0 ))
2504 $all_zeros || return 0
2507 echo foo > $DIR/d33/bar
2511 # Total up write_bytes after writing. We'd better find non-zeros.
2512 for ostnum in $(seq $OSTCOUNT); do
2513 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2514 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2515 obdfilter/$ostname/stats |
2516 awk '/^write_bytes/ {print $7}' )
2517 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2518 if (( ${write_bytes:-0} > 0 ))
2527 for ostnum in $(seq $OSTCOUNT); do
2528 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2529 echo "Check that write_bytes is present in obdfilter/*/stats:"
2530 do_facet ost$ostnum lctl get_param -n \
2531 obdfilter/$ostname/stats
2533 error "OST not keeping write_bytes stats (b22312)"
2536 run_test 33c "test llobdstat and write_bytes"
2539 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2542 local remote_dir=$DIR/$tdir/remote_dir
2545 $LFS mkdir -i $MDTIDX $remote_dir ||
2546 error "create remote directory failed"
2548 touch $remote_dir/$tfile
2549 chmod 444 $remote_dir/$tfile
2550 chown $RUNAS_ID $remote_dir/$tfile
2552 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2554 chown $RUNAS_ID $remote_dir
2555 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2556 error "create" || true
2557 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2558 error "open RDWR" || true
2559 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2560 error "create" || true
2562 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2564 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2567 $MCREATE $DIR/f34 || error
2568 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2569 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2570 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2571 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2573 run_test 34a "truncate file that has not been opened ==========="
2576 [ ! -f $DIR/f34 ] && test_34a
2577 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2578 $OPENFILE -f O_RDONLY $DIR/f34
2579 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2580 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2582 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2585 [ ! -f $DIR/f34 ] && test_34a
2586 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2587 $OPENFILE -f O_RDWR $DIR/f34
2588 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2589 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2591 run_test 34c "O_RDWR opening file-with-size works =============="
2594 [ ! -f $DIR/f34 ] && test_34a
2595 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2596 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2599 run_test 34d "write to sparse file ============================="
2603 $MCREATE $DIR/f34e || error
2604 $TRUNCATE $DIR/f34e 1000 || error
2605 $CHECKSTAT -s 1000 $DIR/f34e || error
2606 $OPENFILE -f O_RDWR $DIR/f34e
2607 $CHECKSTAT -s 1000 $DIR/f34e || error
2609 run_test 34e "create objects, some with size and some without =="
2611 test_34f() { # bug 6242, 6243
2612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2615 $MCREATE $DIR/f34f || error
2616 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2617 dd if=$DIR/f34f of=$TMP/f34f
2618 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2619 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2620 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2621 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2622 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2624 run_test 34f "read from a file with no objects until EOF ======="
2627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2628 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2629 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2630 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2631 cancel_lru_locks osc
2632 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2633 error "wrong size after lock cancel"
2635 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2636 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2637 error "expanding truncate failed"
2638 cancel_lru_locks osc
2639 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2640 error "wrong expanded size after lock cancel"
2642 run_test 34g "truncate long file ==============================="
2645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2649 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2650 sync # Flush the cache so that multiop below does not block on cache
2651 # flush when getting the group lock
2652 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2655 # Since just timed wait is not good enough, let's do a sync write
2656 # that way we are sure enough time for a roundtrip + processing
2657 # passed + 2 seconds of extra margin.
2658 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2662 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2663 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2667 local nsz=`stat -c %s $DIR/$tfile`
2668 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2670 run_test 34h "ftruncate file under grouplock should not block"
2673 cp /bin/sh $DIR/f35a
2675 chown $RUNAS_ID $DIR/f35a
2676 $RUNAS $DIR/f35a && error || true
2679 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2683 utime $DIR/f36 || error
2685 run_test 36a "MDS utime check (mknod, utime) ==================="
2689 utime $DIR/f36 || error
2691 run_test 36b "OST utime check (open, utime) ===================="
2696 chown $RUNAS_ID $DIR/d36
2697 $RUNAS utime $DIR/d36/f36 || error
2699 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2702 [ ! -d $DIR/d36 ] && test_36c
2703 echo "" > $DIR/d36/f36
2704 $RUNAS utime $DIR/d36/f36 || error
2706 run_test 36d "non-root OST utime check (open, utime) ==========="
2709 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2710 test_mkdir -p $DIR/$tdir
2711 touch $DIR/$tdir/$tfile
2712 $RUNAS utime $DIR/$tdir/$tfile && \
2713 error "utime worked, expected failure" || true
2715 run_test 36e "utime on non-owned file (should return error) ===="
2719 local LANG_SAVE=$LANG
2720 local LC_LANG_SAVE=$LC_LANG
2721 export LANG=C LC_LANG=C # for date language
2723 DATESTR="Dec 20 2000"
2724 test_mkdir -p $DIR/$tdir
2725 lctl set_param fail_loc=$fl
2727 cp /etc/hosts $DIR/$tdir/$tfile
2728 sync & # write RPC generated with "current" inode timestamp, but delayed
2730 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2731 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2732 cancel_lru_locks osc
2733 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2735 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2736 echo "BEFORE: $LS_BEFORE" && \
2737 echo "AFTER : $LS_AFTER" && \
2738 echo "WANT : $DATESTR" && \
2739 error "$DIR/$tdir/$tfile timestamps changed" || true
2741 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2746 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2747 subr_36fh "0x80000214"
2749 run_test 36f "utime on file racing with OST BRW write =========="
2752 remote_ost_nodsh && skip "remote OST with nodsh" && return
2753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2758 test_mkdir -p $DIR/$tdir
2759 fmd_max_age=$(do_facet ost1 \
2760 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2763 fmd_before=$(do_facet ost1 \
2764 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2765 touch $DIR/$tdir/$tfile
2766 sleep $((fmd_max_age + 12))
2767 fmd_after=$(do_facet ost1 \
2768 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2770 echo "fmd_before: $fmd_before"
2771 echo "fmd_after: $fmd_after"
2772 [ "$fmd_after" -gt "$fmd_before" ] && \
2773 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2774 error "fmd didn't expire after ping" || true
2776 run_test 36g "filter mod data cache expiry ====================="
2779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2780 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2781 subr_36fh "0x80000227"
2783 run_test 36h "utime on file racing with OST BRW write =========="
2785 # test_37 - duplicate with tests 32q 32r
2788 local file=$DIR/$tfile
2790 openfile -f O_DIRECTORY $file
2793 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2794 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2796 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2800 touch $DIR/${tfile}2
2801 # ls -l $DIR/$tfile $DIR/${tfile}2
2802 # ls -lu $DIR/$tfile $DIR/${tfile}2
2803 # ls -lc $DIR/$tfile $DIR/${tfile}2
2805 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2806 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2808 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2810 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2812 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2813 error "O_TRUNC didn't change timestamps"
2816 run_test 39 "mtime changed on create ==========================="
2819 test_mkdir -p $DIR/$tdir
2820 cp -p /etc/passwd $DIR/$tdir/fopen
2821 cp -p /etc/passwd $DIR/$tdir/flink
2822 cp -p /etc/passwd $DIR/$tdir/funlink
2823 cp -p /etc/passwd $DIR/$tdir/frename
2824 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2827 echo "aaaaaa" >> $DIR/$tdir/fopen
2828 echo "aaaaaa" >> $DIR/$tdir/flink
2829 echo "aaaaaa" >> $DIR/$tdir/funlink
2830 echo "aaaaaa" >> $DIR/$tdir/frename
2832 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2833 local link_new=`stat -c %Y $DIR/$tdir/flink`
2834 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2835 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2837 cat $DIR/$tdir/fopen > /dev/null
2838 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2839 rm -f $DIR/$tdir/funlink2
2840 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2842 for (( i=0; i < 2; i++ )) ; do
2843 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2844 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2845 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2846 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2848 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2849 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2850 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2851 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2853 cancel_lru_locks osc
2854 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2857 run_test 39b "mtime change on open, link, unlink, rename ======"
2859 # this should be set to past
2860 TEST_39_MTIME=`date -d "1 year ago" +%s`
2866 local mtime0=`stat -c %Y $DIR1/$tfile`
2868 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2869 local mtime1=`stat -c %Y $DIR1/$tfile`
2870 [ "$mtime1" = $TEST_39_MTIME ] || \
2871 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2874 echo hello >> $DIR1/$tfile
2876 local mtime2=`stat -c %Y $DIR1/$tfile`
2877 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2878 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2880 mv $DIR1/$tfile $DIR1/$tfile-1
2882 for (( i=0; i < 2; i++ )) ; do
2883 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2884 [ "$mtime2" = "$mtime3" ] || \
2885 error "mtime ($mtime2) changed (to $mtime3) on rename"
2887 cancel_lru_locks osc
2888 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2891 run_test 39c "mtime change on rename ==========================="
2895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2898 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2900 for (( i=0; i < 2; i++ )) ; do
2901 local mtime=`stat -c %Y $DIR1/$tfile`
2902 [ $mtime = $TEST_39_MTIME ] || \
2903 error "mtime($mtime) is not set to $TEST_39_MTIME"
2905 cancel_lru_locks osc
2906 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2909 run_test 39d "create, utime, stat =============================="
2913 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2915 local mtime1=`stat -c %Y $DIR1/$tfile`
2917 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2919 for (( i=0; i < 2; i++ )) ; do
2920 local mtime2=`stat -c %Y $DIR1/$tfile`
2921 [ $mtime2 = $TEST_39_MTIME ] || \
2922 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2924 cancel_lru_locks osc
2925 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2928 run_test 39e "create, stat, utime, stat ========================"
2932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2934 mtime1=`stat -c %Y $DIR1/$tfile`
2937 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2939 for (( i=0; i < 2; i++ )) ; do
2940 local mtime2=`stat -c %Y $DIR1/$tfile`
2941 [ $mtime2 = $TEST_39_MTIME ] || \
2942 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2944 cancel_lru_locks osc
2945 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2948 run_test 39f "create, stat, sleep, utime, stat ================="
2952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2953 echo hello >> $DIR1/$tfile
2954 local mtime1=`stat -c %Y $DIR1/$tfile`
2957 chmod o+r $DIR1/$tfile
2959 for (( i=0; i < 2; i++ )) ; do
2960 local mtime2=`stat -c %Y $DIR1/$tfile`
2961 [ "$mtime1" = "$mtime2" ] || \
2962 error "lost mtime: $mtime2, should be $mtime1"
2964 cancel_lru_locks osc
2965 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2968 run_test 39g "write, chmod, stat ==============================="
2972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2977 echo hello >> $DIR1/$tfile
2978 local mtime1=`stat -c %Y $DIR1/$tfile`
2980 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2982 if [ "$d1" != "$d2" ]; then
2983 echo "write and touch not within one second"
2985 for (( i=0; i < 2; i++ )) ; do
2986 local mtime2=`stat -c %Y $DIR1/$tfile`
2987 [ "$mtime2" = $TEST_39_MTIME ] || \
2988 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2990 cancel_lru_locks osc
2991 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2995 run_test 39h "write, utime within one second, stat ============="
2998 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3002 echo hello >> $DIR1/$tfile
3003 local mtime1=`stat -c %Y $DIR1/$tfile`
3005 mv $DIR1/$tfile $DIR1/$tfile-1
3007 for (( i=0; i < 2; i++ )) ; do
3008 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3010 [ "$mtime1" = "$mtime2" ] || \
3011 error "lost mtime: $mtime2, should be $mtime1"
3013 cancel_lru_locks osc
3014 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3017 run_test 39i "write, rename, stat =============================="
3020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3021 start_full_debug_logging
3025 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3026 lctl set_param fail_loc=0x80000412
3027 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3028 error "multiop failed"
3030 local mtime1=`stat -c %Y $DIR1/$tfile`
3032 mv $DIR1/$tfile $DIR1/$tfile-1
3034 kill -USR1 $multipid
3035 wait $multipid || error "multiop close failed"
3037 for (( i=0; i < 2; i++ )) ; do
3038 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3039 [ "$mtime1" = "$mtime2" ] ||
3040 error "mtime is lost on close: $mtime2, " \
3043 cancel_lru_locks osc
3044 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3046 lctl set_param fail_loc=0
3047 stop_full_debug_logging
3049 run_test 39j "write, rename, close, stat ======================="
3052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3056 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3058 local mtime1=`stat -c %Y $DIR1/$tfile`
3060 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3062 kill -USR1 $multipid
3063 wait $multipid || error "multiop close failed"
3065 for (( i=0; i < 2; i++ )) ; do
3066 local mtime2=`stat -c %Y $DIR1/$tfile`
3068 [ "$mtime2" = $TEST_39_MTIME ] || \
3069 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3071 cancel_lru_locks osc
3072 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3075 run_test 39k "write, utime, close, stat ========================"
3077 # this should be set to future
3078 TEST_39_ATIME=`date -d "1 year" +%s`
3081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3082 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3083 local atime_diff=$(do_facet $SINGLEMDS \
3084 lctl get_param -n mdd.*MDT0000*.atime_diff)
3088 # test setting directory atime to future
3089 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3090 local atime=$(stat -c %X $DIR/$tdir)
3091 [ "$atime" = $TEST_39_ATIME ] || \
3092 error "atime is not set to future: $atime, $TEST_39_ATIME"
3094 # test setting directory atime from future to now
3095 local d1=$(date +%s)
3097 local d2=$(date +%s)
3099 cancel_lru_locks mdc
3100 atime=$(stat -c %X $DIR/$tdir)
3101 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3102 error "atime is not updated from future: $atime, $d1<atime<$d2"
3104 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3107 # test setting directory atime when now > dir atime + atime_diff
3111 cancel_lru_locks mdc
3112 atime=$(stat -c %X $DIR/$tdir)
3113 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3114 error "atime is not updated : $atime, should be $d2"
3116 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3119 # test not setting directory atime when now < dir atime + atime_diff
3121 cancel_lru_locks mdc
3122 atime=$(stat -c %X $DIR/$tdir)
3123 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3124 error "atime is updated to $atime, should remain $d1<atime<$d2"
3126 do_facet $SINGLEMDS \
3127 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3129 run_test 39l "directory atime update ==========================="
3132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3135 local far_past_mtime=$(date -d "May 29 1953" +%s)
3136 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3138 touch -m -d @$far_past_mtime $DIR1/$tfile
3139 touch -a -d @$far_past_atime $DIR1/$tfile
3141 for (( i=0; i < 2; i++ )) ; do
3142 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3143 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3144 error "atime or mtime set incorrectly"
3146 cancel_lru_locks osc
3147 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3150 run_test 39m "test atime and mtime before 1970"
3152 test_39n() { # LU-3832
3153 local atime_diff=$(do_facet $SINGLEMDS \
3154 lctl get_param -n mdd.*MDT0000*.atime_diff)
3159 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3162 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3163 atime0=$(stat -c %X $DIR/$tfile)
3166 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3167 atime1=$(stat -c %X $DIR/$tfile)
3170 cancel_lru_locks mdc
3171 cancel_lru_locks osc
3172 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3173 atime2=$(stat -c %X $DIR/$tfile)
3175 do_facet $SINGLEMDS \
3176 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3178 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3179 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3181 run_test 39n "check that O_NOATIME is honored"
3184 TESTDIR=$DIR/$tdir/$tfile
3185 [ -e $TESTDIR ] && rm -rf $TESTDIR
3186 test_mkdir -p $TESTDIR
3192 links2=$(stat -c %h .)
3193 [ $(($links1 + 2)) != $links2 ] &&
3194 error "wrong links count $(($links1 + 2)) != $links2"
3196 links3=$(stat -c %h .)
3197 [ $(($links1 + 1)) != $links3 ] &&
3198 error "wrong links count $links1 != $links3"
3201 run_test 39o "directory cached attributes updated after create ========"
3204 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3206 TESTDIR=$DIR/$tdir/$tfile
3207 [ -e $TESTDIR ] && rm -rf $TESTDIR
3212 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3213 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3215 links2=$(stat -c %h .)
3216 [ $(($links1 + 2)) != $links2 ] &&
3217 error "wrong links count $(($links1 + 2)) != $links2"
3219 links3=$(stat -c %h .)
3220 [ $(($links1 + 1)) != $links3 ] &&
3221 error "wrong links count $links1 != $links3"
3224 run_test 39p "remote directory cached attributes updated after create ========"
3228 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3229 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3230 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3231 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3232 error "$tfile is not 4096 bytes in size"
3234 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3238 small_write $DIR/f41 18
3240 run_test 41 "test small file write + fstat ====================="
3242 count_ost_writes() {
3243 lctl get_param -n osc.*.stats |
3244 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3251 BG_DIRTY_RATIO_SAVE=10
3252 MAX_BG_DIRTY_RATIO=25
3256 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3257 # dirty_ratio, dirty_background_ratio
3258 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3259 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3260 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3261 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3263 # if file not here, we are a 2.4 kernel
3264 kill -CONT `pidof kupdated`
3269 # setup the trap first, so someone cannot exit the test at the
3270 # exact wrong time and mess up a machine
3271 trap start_writeback EXIT
3272 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3273 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3274 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3275 sysctl -w vm.dirty_writeback_centisecs=0
3276 sysctl -w vm.dirty_writeback_centisecs=0
3277 # save and increase /proc/sys/vm/dirty_ratio
3278 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3279 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3280 # save and increase /proc/sys/vm/dirty_background_ratio
3281 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3282 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3284 # if file not here, we are a 2.4 kernel
3285 kill -STOP `pidof kupdated`
3289 # ensure that all stripes have some grant before we test client-side cache
3291 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3292 dd if=/dev/zero of=$i bs=4k count=1
3297 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3298 # file truncation, and file removal.
3300 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3302 cancel_lru_locks osc
3304 sync; sleep 1; sync # just to be safe
3305 BEFOREWRITES=`count_ost_writes`
3306 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3307 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3308 AFTERWRITES=`count_ost_writes`
3309 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3310 error "$BEFOREWRITES < $AFTERWRITES"
3313 run_test 42a "ensure that we don't flush on close =============="
3316 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3318 cancel_lru_locks osc
3321 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3322 BEFOREWRITES=`count_ost_writes`
3323 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3324 AFTERWRITES=`count_ost_writes`
3325 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3326 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3328 BEFOREWRITES=`count_ost_writes`
3329 sync || error "sync: $?"
3330 AFTERWRITES=`count_ost_writes`
3331 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3332 error "$BEFOREWRITES < $AFTERWRITES on sync"
3334 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3338 run_test 42b "test destroy of file with cached dirty data ======"
3340 # if these tests just want to test the effect of truncation,
3341 # they have to be very careful. consider:
3342 # - the first open gets a {0,EOF}PR lock
3343 # - the first write conflicts and gets a {0, count-1}PW
3344 # - the rest of the writes are under {count,EOF}PW
3345 # - the open for truncate tries to match a {0,EOF}PR
3346 # for the filesize and cancels the PWs.
3347 # any number of fixes (don't get {0,EOF} on open, match
3348 # composite locks, do smarter file size management) fix
3349 # this, but for now we want these tests to verify that
3350 # the cancellation with truncate intent works, so we
3351 # start the file with a full-file pw lock to match against
3352 # until the truncate.
3357 cancel_lru_locks osc
3359 # prime the file with 0,EOF PW to match
3363 # now the real test..
3364 dd if=/dev/zero of=$file bs=1024 count=100
3365 BEFOREWRITES=`count_ost_writes`
3366 $TRUNCATE $file $offset
3367 cancel_lru_locks osc
3368 AFTERWRITES=`count_ost_writes`
3373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3375 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3376 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3379 run_test 42c "test partial truncate of file with cached dirty data"
3382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3384 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3385 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3388 run_test 42d "test complete truncate of file with cached dirty data"
3390 test_42e() { # bug22074
3391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3392 local TDIR=$DIR/${tdir}e
3393 local pagesz=$(page_size)
3394 local pages=16 # hardcoded 16 pages, don't change it.
3395 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3396 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3400 test_mkdir -p $DIR/${tdir}e
3401 $SETSTRIPE -c 1 $TDIR
3402 createmany -o $TDIR/f $files
3404 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3406 # we assume that with $OSTCOUNT files, at least one of them will
3407 # be allocated on OST0.
3408 warmup_files=$((OSTCOUNT * max_dirty_mb))
3409 createmany -o $TDIR/w $warmup_files
3411 # write a large amount of data into one file and sync, to get good
3412 # avail_grant number from OST.
3413 for ((i=0; i<$warmup_files; i++)); do
3414 idx=$($GETSTRIPE -i $TDIR/w$i)
3415 [ $idx -ne 0 ] && continue
3416 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3419 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3421 $LCTL get_param $proc_osc0/cur_dirty_bytes
3422 $LCTL get_param $proc_osc0/cur_grant_bytes
3424 # create as much dirty pages as we can while not to trigger the actual
3425 # RPCs directly. but depends on the env, VFS may trigger flush during this
3426 # period, hopefully we are good.
3427 for ((i=0; i<$warmup_files; i++)); do
3428 idx=$($GETSTRIPE -i $TDIR/w$i)
3429 [ $idx -ne 0 ] && continue
3430 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3432 $LCTL get_param $proc_osc0/cur_dirty_bytes
3433 $LCTL get_param $proc_osc0/cur_grant_bytes
3435 # perform the real test
3436 $LCTL set_param $proc_osc0/rpc_stats 0
3437 for ((;i<$files; i++)); do
3438 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3439 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3442 $LCTL get_param $proc_osc0/rpc_stats
3445 local have_ppr=false
3446 $LCTL get_param $proc_osc0/rpc_stats |
3447 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3448 # skip lines until we are at the RPC histogram data
3449 [ "$PPR" == "pages" ] && have_ppr=true && continue
3450 $have_ppr || continue
3452 # we only want the percent stat for < 16 pages
3453 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3455 percent=$((percent + WPCT))
3456 if [ $percent -gt 15 ]; then
3457 error "less than 16-pages write RPCs" \
3464 run_test 42e "verify sub-RPC writes are not done synchronously"
3467 test_mkdir -p $DIR/$tdir
3468 cp -p /bin/ls $DIR/$tdir/$tfile
3469 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3471 # give multiop a chance to open
3474 $DIR/$tdir/$tfile && error || true
3477 run_test 43 "execution of file opened for write should return -ETXTBSY"
3480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3481 test_mkdir -p $DIR/$tdir
3482 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3483 cp -p multiop $DIR/$tdir/multiop
3484 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3487 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3488 kill -USR1 $MULTIOP_PID || return 2
3489 wait $MULTIOP_PID || return 3
3490 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3492 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3496 test_mkdir -p $DIR/$tdir
3497 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3498 cp -p multiop $DIR/$tdir/multiop
3499 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3502 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3503 kill -USR1 $MULTIOP_PID || return 2
3504 wait $MULTIOP_PID || return 3
3505 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3507 run_test 43b "truncate of file being executed should return -ETXTBSY"
3510 local testdir="$DIR/$tdir"
3511 test_mkdir -p $DIR/$tdir
3513 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3514 ( cd $testdir && md5sum -c)
3516 run_test 43c "md5sum of copy into lustre========================"
3519 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3520 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3521 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3523 run_test 44 "zero length read from a sparse stripe ============="
3526 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3528 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3529 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3530 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3532 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3533 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3536 OFFSETS="0 $((stride/2)) $((stride-1))"
3537 for offset in $OFFSETS ; do
3538 for i in `seq 0 $((nstripe-1))`; do
3539 local GLOBALOFFSETS=""
3540 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3541 local myfn=$DIR/d44a-$size
3542 echo "--------writing $myfn at $size"
3543 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3544 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3545 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3546 || error "ll_sparseness_verify $GLOBALOFFSETS"
3548 for j in `seq 0 $((nstripe-1))`; do
3549 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3550 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3551 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3553 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3554 || error "ll_sparseness_verify $GLOBALOFFSETS"
3559 run_test 44a "test sparse pwrite ==============================="
3563 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3569 before=`dirty_osc_total`
3570 echo executing "\"$*\""
3572 after=`dirty_osc_total`
3573 echo before $before, after $after
3576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3578 # Obtain grants from OST if it supports it
3579 echo blah > ${f}_grant
3582 do_dirty_record "echo blah > $f"
3583 [ $before -eq $after ] && error "write wasn't cached"
3584 do_dirty_record "> $f"
3585 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3586 do_dirty_record "echo blah > $f"
3587 [ $before -eq $after ] && error "write wasn't cached"
3588 do_dirty_record "sync"
3589 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3590 do_dirty_record "echo blah > $f"
3591 [ $before -eq $after ] && error "write wasn't cached"
3592 do_dirty_record "cancel_lru_locks osc"
3593 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3596 run_test 45 "osc io page accounting ============================"
3598 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3599 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3600 # objects offset and an assert hit when an rpc was built with 1023's mapped
3601 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3607 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3609 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3610 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3614 run_test 46 "dirtying a previously written page ================"
3616 # test_47 is removed "Device nodes check" is moved to test_28
3618 test_48a() { # bug 2399
3619 check_kernel_version 34 || return 0
3620 test_mkdir -p $DIR/$tdir
3622 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3623 test_mkdir $DIR/$tdir || error "recreate directory failed"
3624 touch foo || error "'touch foo' failed after recreating cwd"
3625 test_mkdir $DIR/$tdir/bar ||
3626 error "'mkdir foo' failed after recreating cwd"
3627 if check_kernel_version 44; then
3628 touch .foo || error "'touch .foo' failed after recreating cwd"
3629 test_mkdir $DIR/$tdir/.bar ||
3630 error "'mkdir .foo' failed after recreating cwd"
3632 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3633 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3634 cd . || error "'cd .' failed after recreating cwd"
3635 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3636 rmdir . && error "'rmdir .' worked after recreating cwd"
3637 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3638 cd .. || error "'cd ..' failed after recreating cwd"
3640 run_test 48a "Access renamed working dir (should return errors)="
3642 test_48b() { # bug 2399
3643 check_kernel_version 34 || return 0
3645 test_mkdir -p $DIR/$tdir
3647 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3648 touch foo && error "'touch foo' worked after removing cwd"
3649 test_mkdir $DIR/$tdir/foo &&
3650 error "'mkdir foo' worked after removing cwd"
3651 if check_kernel_version 44; then
3652 touch .foo && error "'touch .foo' worked after removing cwd"
3653 test_mkdir $DIR/$tdir/.foo &&
3654 error "'mkdir .foo' worked after removing cwd"
3656 ls . > /dev/null && error "'ls .' worked after removing cwd"
3657 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3658 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3659 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3660 rmdir . && error "'rmdir .' worked after removing cwd"
3661 ln -s . foo && error "'ln -s .' worked after removing cwd"
3662 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3664 run_test 48b "Access removed working dir (should return errors)="
3666 test_48c() { # bug 2350
3667 check_kernel_version 36 || return 0
3668 #lctl set_param debug=-1
3671 test_mkdir -p $DIR/$tdir/dir
3673 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3674 $TRACE touch foo && error "touch foo worked after removing cwd"
3675 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3676 if check_kernel_version 44; then
3677 touch .foo && error "touch .foo worked after removing cwd"
3678 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3680 $TRACE ls . && error "'ls .' worked after removing cwd"
3681 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3682 is_patchless || ( $TRACE cd . &&
3683 error "'cd .' worked after removing cwd" )
3684 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3685 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3686 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3687 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3689 run_test 48c "Access removed working subdir (should return errors)"
3691 test_48d() { # bug 2350
3692 check_kernel_version 36 || return 0
3693 #lctl set_param debug=-1
3696 test_mkdir -p $DIR/$tdir/dir
3698 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3699 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3700 $TRACE touch foo && error "'touch foo' worked after removing parent"
3701 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3702 if check_kernel_version 44; then
3703 touch .foo && error "'touch .foo' worked after removing parent"
3705 error "mkdir .foo worked after removing parent"
3707 $TRACE ls . && error "'ls .' worked after removing parent"
3708 $TRACE ls .. && error "'ls ..' worked after removing parent"
3709 is_patchless || ( $TRACE cd . &&
3710 error "'cd .' worked after recreate parent" )
3711 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3712 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3713 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3714 is_patchless || ( $TRACE cd .. &&
3715 error "'cd ..' worked after removing parent" || true )
3717 run_test 48d "Access removed parent subdir (should return errors)"
3719 test_48e() { # bug 4134
3720 check_kernel_version 41 || return 0
3721 #lctl set_param debug=-1
3724 test_mkdir -p $DIR/$tdir/dir
3726 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3727 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3728 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3729 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3730 # On a buggy kernel addition of "touch foo" after cd .. will
3731 # produce kernel oops in lookup_hash_it
3732 touch ../foo && error "'cd ..' worked after recreate parent"
3734 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3736 run_test 48e "Access to recreated parent subdir (should return errors)"
3738 test_49() { # LU-1030
3739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3740 # get ost1 size - lustre-OST0000
3741 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3742 # write 800M at maximum
3743 [ $ost1_size -gt 819200 ] && ost1_size=819200
3745 lfs setstripe -c 1 -i 0 $DIR/$tfile
3746 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3749 # change max_pages_per_rpc while writing the file
3750 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3751 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3752 # loop until dd process exits
3753 while ps ax -opid | grep -wq $dd_pid; do
3754 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3755 sleep $((RANDOM % 5 + 1))
3757 # restore original max_pages_per_rpc
3758 $LCTL set_param $osc1_mppc=$orig_mppc
3759 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3761 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3765 test_mkdir $DIR/$tdir
3767 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3769 run_test 50 "special situations: /proc symlinks ==============="
3771 test_51a() { # was test_51
3772 # bug 1516 - create an empty entry right after ".." then split dir
3773 test_mkdir -p $DIR/$tdir
3774 touch $DIR/$tdir/foo
3775 $MCREATE $DIR/$tdir/bar
3777 createmany -m $DIR/$tdir/longfile 201
3779 while [ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]; do
3780 $MCREATE $DIR/$tdir/longfile$FNUM
3785 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3787 run_test 51a "special situations: split htree with empty entry =="
3789 export NUMTEST=70000
3791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3792 local BASE=$DIR/d${base}.${TESTSUITE}
3794 # cleanup the directory
3799 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3800 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3801 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3804 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3805 echo "reduced count to $NUMTEST due to inodes"
3807 # need to check free space for the directories as well
3808 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3809 numfree=$((blkfree / 4))
3810 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3811 echo "reduced count to $NUMTEST due to blocks"
3813 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3814 echo "failed" > $BASE/fnum
3816 run_test 51b "exceed 64k subdirectory nlink limit"
3818 test_51ba() { # LU-993
3819 local BASE=$DIR/d${base}.${TESTSUITE}
3820 # unlink all but 100 subdirectories, then check it still works
3822 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3824 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3825 local DELETE=$((NUMTEST - LEFT))
3827 # continue on to run this test even if 51b didn't finish,
3828 # just to delete the many subdirectories created.
3829 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3831 # for ldiskfs the nlink count should be 1, but this is OSD specific
3832 # and so this is listed for informational purposes only
3833 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3834 unlinkmany -d $BASE/d $DELETE
3837 if [ $RC -ne 0 ]; then
3838 if [ "$NUMPREV" == "failed" ]; then
3839 skip "previous setup failed"
3842 error "unlink of first $DELETE subdirs failed"
3847 echo "nlink between: $(stat -c %h $BASE)"
3848 # trim the first line of ls output
3849 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3850 [ $FOUND -ne $LEFT ] &&
3851 error "can't find subdirs: found only $FOUND/$LEFT"
3853 unlinkmany -d $BASE/d $DELETE $LEFT ||
3854 error "unlink of second $LEFT subdirs failed"
3855 # regardless of whether the backing filesystem tracks nlink accurately
3856 # or not, the nlink count shouldn't be more than "." and ".." here
3857 local AFTER=$(stat -c %h $BASE)
3858 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3859 echo "nlink after: $AFTER"
3861 run_test 51ba "verify nlink for many subdirectory cleanup"
3864 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3865 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3866 test_mkdir -p $DIR/$tdir
3867 createmany -o $DIR/$tdir/t- 1000
3868 $GETSTRIPE $DIR/$tdir > $TMP/files
3869 for N in `seq 0 $((OSTCOUNT - 1))`; do
3870 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3871 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3872 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3874 unlinkmany $DIR/$tdir/t- 1000
3877 for N in `seq 1 $((OSTCOUNT - 1))`; do
3878 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3879 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3880 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3881 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3883 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3884 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3885 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3886 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3890 run_test 51d "check object distribution ===================="
3893 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3894 test_mkdir -p $DIR/$tdir
3895 touch $DIR/$tdir/foo
3896 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3897 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3898 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3899 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3900 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3902 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3903 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3904 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3906 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3907 cp -r $DIR/$tdir /tmp/
3908 rm -fr $DIR/$tdir || error "cleanup rm failed"
3910 run_test 52a "append-only flag test (should return errors) ====="
3913 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3914 test_mkdir -p $DIR/$tdir
3915 touch $DIR/$tdir/foo
3916 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3917 cat test > $DIR/$tdir/foo && error "cat test worked"
3918 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3919 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3920 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3922 echo foo >> $DIR/$tdir/foo && error "echo worked"
3923 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3924 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
3925 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
3926 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3928 chattr -i $DIR/$tdir/foo || error "chattr failed"
3930 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
3932 run_test 52b "immutable flag test (should return errors) ======="
3935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3936 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3937 remote_ost_nodsh && skip "remote OST with nodsh" && return
3950 local support_last_seq=true
3952 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
3953 support_last_seq=false
3956 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3958 for value in $(do_facet $SINGLEMDS \
3959 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
3960 param=$(echo ${value[0]} | cut -d "=" -f1)
3961 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
3963 if $support_last_seq; then
3964 param_seq=$(echo $param |
3965 sed -e s/prealloc_last_id/prealloc_last_seq/g)
3966 mds_last_seq=$(do_facet $SINGLEMDS \
3967 $LCTL get_param -n $param_seq)
3969 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
3971 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3972 node=$(facet_active_host ost$((ostnum+1)))
3973 param="obdfilter.$ostname.last_id"
3974 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
3975 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
3976 ost_last_id=$ost_last
3978 if $support_last_seq; then
3979 ost_last_id=$(echo $ost_last |
3980 awk -F':' '{print $2}' |
3982 ost_last_seq=$(echo $ost_last |
3983 awk -F':' '{print $1}')
3984 [[ $ost_last_seq = $mds_last_seq ]] || continue
3987 if [[ $ost_last_id != $mds_last ]]; then
3988 error "$ost_last_id != $mds_last"
3995 $found || error "can not match last_seq/last_id for $mdtosc"
3998 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4001 $SOCKETSERVER $DIR/socket ||
4002 error "$SOCKETSERVER $DIR/socket failed: $?"
4003 $SOCKETCLIENT $DIR/socket ||
4004 error "$SOCKETCLIENT $DIR/socket failed: $?"
4005 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4007 run_test 54a "unix domain socket test =========================="
4013 dd if=/dev/zero of=$f bs=$(page_size) count=1
4015 run_test 54b "char device works in lustre ======================"
4018 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4019 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4020 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4022 for i in $(seq 3 7); do
4023 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4031 loopdev="$DIR/loop54c"
4034 $UMOUNT -d $tdir || rc=$?
4035 losetup -d $loopdev || true
4041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4044 loopdev="$DIR/loop54c"
4047 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4048 mknod $loopdev b 7 $LOOPNUM
4049 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
4050 dd if=/dev/zero of=$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4051 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
4052 trap cleanup_54c EXIT
4053 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4055 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
4056 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
4058 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
4061 run_test 54c "block device works in lustre ====================="
4067 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4069 run_test 54d "fifo device works in lustre ======================"
4072 check_kernel_version 46 || return 0
4075 cp -aL /dev/console $f
4076 echo $string > $f || error "echo $string to $f failed"
4078 run_test 54e "console/tty device works in lustre ======================"
4080 #The test_55 used to be iopen test and it was removed by bz#24037.
4081 #run_test 55 "check iopen_connect_dentry() ======================"
4083 test_56a() { # was test_56
4086 test_mkdir -p $DIR/$tdir/dir
4088 NUMFILESx2=$(($NUMFILES * 2))
4089 for i in `seq 1 $NUMFILES` ; do
4090 touch $DIR/$tdir/file$i
4091 touch $DIR/$tdir/dir/file$i
4094 # test lfs getstripe with --recursive
4095 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
4096 [ $FILENUM -eq $NUMFILESx2 ] ||
4097 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4098 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
4099 [ $FILENUM -eq $NUMFILES ] ||
4100 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4101 echo "$GETSTRIPE --recursive passed."
4103 # test lfs getstripe with file instead of dir
4104 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
4105 [ $FILENUM -eq 1 ] || error \
4106 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4107 echo "$GETSTRIPE file1 passed."
4109 #test lfs getstripe with --verbose
4110 [ `$GETSTRIPE --verbose $DIR/$tdir |
4111 grep -c lmm_magic` -eq $NUMFILES ] ||
4112 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4113 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
4114 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4115 echo "$GETSTRIPE --verbose passed."
4117 #test lfs getstripe with --obd
4118 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4119 grep -q "unknown obduuid" ||
4120 error "$GETSTRIPE --obd wrong_uuid should return error message"
4122 [ "$OSTCOUNT" -lt 2 ] &&
4123 skip_env "skipping other $GETSTRIPE --obd test" && return
4126 OBDUUID=$(ostuuid_from_index $OSTIDX)
4127 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
4128 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
4129 [ $FOUND -eq $FILENUM ] ||
4130 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4131 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4132 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4133 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
4134 error "$GETSTRIPE --obd: should not show file on other obd"
4135 echo "$GETSTRIPE --obd passed"
4137 run_test 56a "check $GETSTRIPE"
4142 local LOCAL_NUMFILES="$1"
4143 local LOCAL_NUMDIRS="$2"
4144 local MKDIR_PARAMS="$3"
4145 local DIR_STRIPE_PARAMS="$4"
4147 if [ ! -d "$TDIR" ] ; then
4148 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4149 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4150 for i in `seq 1 $LOCAL_NUMFILES` ; do
4153 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4154 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4155 for j in `seq 1 $LOCAL_NUMFILES` ; do
4156 touch $TDIR/dir$i/file$j
4162 setup_56_special() {
4166 if [ ! -e "$TDIR/loop1b" ] ; then
4167 for i in `seq 1 $LOCAL_NUMFILES` ; do
4168 mknod $TDIR/loop${i}b b 7 $i
4169 mknod $TDIR/null${i}c c 1 3
4170 ln -s $TDIR/file1 $TDIR/link${i}l
4172 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4173 mknod $TDIR/dir$i/loop${i}b b 7 $i
4174 mknod $TDIR/dir$i/null${i}c c 1 3
4175 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4184 setup_56 $NUMFILES $NUMDIRS
4186 EXPECTED=$(($NUMDIRS + 2))
4187 # test lfs find with -name
4188 for i in $(seq 1 $NUMFILES) ; do
4189 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4190 [ $NUMS -eq $EXPECTED ] ||
4191 error "lfs find -name \"*$i\" $TDIR wrong: "\
4192 "found $NUMS, expected $EXPECTED"
4195 run_test 56g "check lfs find -name ============================="
4201 setup_56 $NUMFILES $NUMDIRS
4203 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4204 # test lfs find with ! -name
4205 for i in $(seq 1 $NUMFILES) ; do
4206 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4207 [ $NUMS -eq $EXPECTED ] ||
4208 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4209 "found $NUMS, expected $EXPECTED"
4212 run_test 56h "check lfs find ! -name ============================="
4216 test_mkdir -p $DIR/$tdir
4217 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4218 CMD="$LFIND -ost $UUID $DIR/$tdir"
4220 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4222 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4226 setup_56_special $NUMFILES $NUMDIRS
4228 EXPECTED=$((NUMDIRS + 1))
4229 CMD="$LFIND -type d $TDIR"
4230 NUMS=$($CMD | wc -l)
4231 [ $NUMS -eq $EXPECTED ] ||
4232 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4234 run_test 56j "check lfs find -type d ============================="
4238 setup_56_special $NUMFILES $NUMDIRS
4240 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4241 CMD="$LFIND -type f $TDIR"
4242 NUMS=$($CMD | wc -l)
4243 [ $NUMS -eq $EXPECTED ] ||
4244 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4246 run_test 56k "check lfs find -type f ============================="
4250 setup_56_special $NUMFILES $NUMDIRS
4252 EXPECTED=$((NUMDIRS + NUMFILES))
4253 CMD="$LFIND -type b $TDIR"
4254 NUMS=$($CMD | wc -l)
4255 [ $NUMS -eq $EXPECTED ] ||
4256 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4258 run_test 56l "check lfs find -type b ============================="
4262 setup_56_special $NUMFILES $NUMDIRS
4264 EXPECTED=$((NUMDIRS + NUMFILES))
4265 CMD="$LFIND -type c $TDIR"
4266 NUMS=$($CMD | wc -l)
4267 [ $NUMS -eq $EXPECTED ] ||
4268 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4270 run_test 56m "check lfs find -type c ============================="
4274 setup_56_special $NUMFILES $NUMDIRS
4276 EXPECTED=$((NUMDIRS + NUMFILES))
4277 CMD="$LFIND -type l $TDIR"
4278 NUMS=$($CMD | wc -l)
4279 [ $NUMS -eq $EXPECTED ] ||
4280 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4282 run_test 56n "check lfs find -type l ============================="
4286 setup_56 $NUMFILES $NUMDIRS
4287 utime $TDIR/file1 > /dev/null || error "utime (1)"
4288 utime $TDIR/file2 > /dev/null || error "utime (2)"
4289 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4290 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4291 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4292 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4295 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4296 [ $NUMS -eq $EXPECTED ] || \
4297 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4300 CMD="$LFIND -mtime 0 $TDIR"
4301 NUMS=$($CMD | wc -l)
4302 [ $NUMS -eq $EXPECTED ] ||
4303 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4305 run_test 56o "check lfs find -mtime for old files =========================="
4308 [ $RUNAS_ID -eq $UID ] &&
4309 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4312 setup_56 $NUMFILES $NUMDIRS
4314 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4316 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4317 NUMS=$($CMD | wc -l)
4318 [ $NUMS -eq $EXPECTED ] || \
4319 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4321 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4322 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4323 NUMS=$($CMD | wc -l)
4324 [ $NUMS -eq $EXPECTED ] || \
4325 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4327 run_test 56p "check lfs find -uid and ! -uid ==============================="
4330 [ $RUNAS_ID -eq $UID ] &&
4331 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4334 setup_56 $NUMFILES $NUMDIRS
4336 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4339 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4340 NUMS=$($CMD | wc -l)
4341 [ $NUMS -eq $EXPECTED ] ||
4342 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4344 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4345 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4346 NUMS=$($CMD | wc -l)
4347 [ $NUMS -eq $EXPECTED ] ||
4348 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4350 run_test 56q "check lfs find -gid and ! -gid ==============================="
4354 setup_56 $NUMFILES $NUMDIRS
4357 CMD="$LFIND -size 0 -type f $TDIR"
4358 NUMS=$($CMD | wc -l)
4359 [ $NUMS -eq $EXPECTED ] ||
4360 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4362 CMD="$LFIND ! -size 0 -type f $TDIR"
4363 NUMS=$($CMD | wc -l)
4364 [ $NUMS -eq $EXPECTED ] ||
4365 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4366 echo "test" > $TDIR/$tfile
4367 echo "test2" > $TDIR/$tfile.2 && sync
4369 CMD="$LFIND -size 5 -type f $TDIR"
4370 NUMS=$($CMD | wc -l)
4371 [ $NUMS -eq $EXPECTED ] ||
4372 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4374 CMD="$LFIND -size +5 -type f $TDIR"
4375 NUMS=$($CMD | wc -l)
4376 [ $NUMS -eq $EXPECTED ] ||
4377 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4379 CMD="$LFIND -size +0 -type f $TDIR"
4380 NUMS=$($CMD | wc -l)
4381 [ $NUMS -eq $EXPECTED ] ||
4382 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4384 CMD="$LFIND ! -size -5 -type f $TDIR"
4385 NUMS=$($CMD | wc -l)
4386 [ $NUMS -eq $EXPECTED ] ||
4387 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4389 CMD="$LFIND -size -5 -type f $TDIR"
4390 NUMS=$($CMD | wc -l)
4391 [ $NUMS -eq $EXPECTED ] ||
4392 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4394 run_test 56r "check lfs find -size works =========================="
4396 test_56s() { # LU-611
4398 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4400 if [ $OSTCOUNT -gt 1 ]; then
4401 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4405 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4409 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4410 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4411 NUMS=$($CMD | wc -l)
4412 [ $NUMS -eq $EXPECTED ] ||
4413 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4415 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4416 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4417 NUMS=$($CMD | wc -l)
4418 [ $NUMS -eq $EXPECTED ] ||
4419 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4422 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4423 NUMS=$($CMD | wc -l)
4424 [ $NUMS -eq $EXPECTED ] ||
4425 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4427 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4428 NUMS=$($CMD | wc -l)
4429 [ $NUMS -eq $EXPECTED ] ||
4430 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4433 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4434 NUMS=$($CMD | wc -l)
4435 [ $NUMS -eq $EXPECTED ] ||
4436 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4438 run_test 56s "check lfs find -stripe-count works"
4440 test_56t() { # LU-611
4442 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4444 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4446 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4447 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4448 NUMS=$($CMD | wc -l)
4449 [ $NUMS -eq $EXPECTED ] ||
4450 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4452 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4453 NUMS=$($CMD | wc -l)
4454 [ $NUMS -eq $EXPECTED ] ||
4455 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4457 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4458 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4459 NUMS=$($CMD | wc -l)
4460 [ $NUMS -eq $EXPECTED ] ||
4461 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4463 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4464 NUMS=$($CMD | wc -l)
4465 [ $NUMS -eq $EXPECTED ] ||
4466 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4469 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4470 NUMS=$($CMD | wc -l)
4471 [ $NUMS -eq $EXPECTED ] ||
4472 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4474 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4475 NUMS=$($CMD | wc -l)
4476 [ $NUMS -eq $EXPECTED ] ||
4477 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4480 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4481 NUMS=$($CMD | wc -l)
4482 [ $NUMS -eq $EXPECTED ] ||
4483 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4485 run_test 56t "check lfs find -stripe-size works"
4487 test_56u() { # LU-611
4489 setup_56 $NUMFILES $NUMDIRS "-i 0"
4491 if [ $OSTCOUNT -gt 1 ]; then
4492 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4498 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4499 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4500 NUMS=$($CMD | wc -l)
4501 [ $NUMS -eq $EXPECTED ] ||
4502 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4505 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4506 NUMS=$($CMD | wc -l)
4507 [ $NUMS -eq $EXPECTED ] ||
4508 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4510 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4511 NUMS=$($CMD | wc -l)
4512 [ $NUMS -eq $EXPECTED ] ||
4513 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4516 # This should produce an error and not return any files
4517 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4518 NUMS=$($CMD 2>/dev/null | wc -l)
4519 [ $NUMS -eq $EXPECTED ] ||
4520 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4522 if [ $OSTCOUNT -gt 1 ]; then
4523 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4524 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4525 NUMS=$($CMD | wc -l)
4526 [ $NUMS -eq $EXPECTED ] ||
4527 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4530 run_test 56u "check lfs find -stripe-index works"
4537 setup_56 $NUMFILES $NUMDIRS
4539 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4540 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4542 for file in $($LFIND -mdt $UUID $TDIR); do
4543 file_mdt_idx=$($GETSTRIPE -M $file)
4544 [ $file_mdt_idx -eq $MDT_IDX ] ||
4545 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4548 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4550 # Get and check the actual stripe count of one file.
4551 # Usage: check_stripe_count <file> <expected_stripe_count>
4552 check_stripe_count() {
4557 [[ -z "$file" || -z "$expected" ]] &&
4558 error "check_stripe_count: invalid argument!"
4560 local cmd="$GETSTRIPE -c $file"
4561 actual=$($cmd) || error "$cmd failed"
4562 actual=${actual%% *}
4564 if [[ $actual -ne $expected ]]; then
4565 [[ $expected -eq -1 ]] ||
4566 error "$cmd wrong: found $actual, expected $expected"
4567 [[ $actual -eq $OSTCOUNT ]] ||
4568 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4576 rm -rf $TDIR || error "remove $TDIR failed"
4577 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4580 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4581 error "$GETSTRIPE -S -d $TDIR failed"
4582 stripe_size=${stripe_size%% *}
4584 local file_size=$((stripe_size * OSTCOUNT))
4585 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4586 local required_space=$((file_num * file_size))
4587 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4588 [[ $free_space -le $((required_space / 1024)) ]] &&
4589 skip_env "need at least $required_space bytes free space," \
4590 "have $free_space kbytes" && return
4593 local dd_count=$((file_size / dd_bs))
4595 # write data into the files
4599 for i in $(seq 1 $NUMFILES); do
4601 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4602 error "write data into $file failed"
4604 for i in $(seq 1 $NUMDIRS); do
4605 for j in $(seq 1 $NUMFILES); do
4606 file=$TDIR/dir$i/file$j
4607 yes | dd bs=$dd_bs count=$dd_count of=$file \
4609 error "write data into $file failed"
4614 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4617 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4619 eval $cmd || error "$cmd failed"
4621 check_stripe_count $TDIR/file1 $expected
4624 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4626 eval $cmd || error "$cmd failed"
4628 for j in $(seq 1 $NUMFILES); do
4629 check_stripe_count $TDIR/dir1/file$j $expected
4632 # lfs_migrate works with lfs find
4633 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4634 $LFS_MIGRATE -y -c $expected"
4636 eval $cmd || error "$cmd failed"
4638 for i in $(seq 2 $NUMFILES); do
4639 check_stripe_count $TDIR/file$i $expected
4641 for i in $(seq 2 $NUMDIRS); do
4642 for j in $(seq 1 $NUMFILES); do
4643 check_stripe_count $TDIR/dir$i/file$j $expected
4647 run_test 56w "check lfs_migrate -c stripe_count works"
4650 check_swap_layouts_support && return 0
4651 [ "$OSTCOUNT" -lt "2" ] &&
4652 skip_env "need 2 OST, skipping test" && return
4654 local dir0=$DIR/$tdir/$testnum
4655 mkdir -p $dir0 || error "creating dir $dir0"
4657 local ref1=/etc/passwd
4658 local file1=$dir0/file1
4660 $SETSTRIPE -c 2 $file1
4662 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4663 stripe=$($GETSTRIPE -c $file1)
4664 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4665 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4670 run_test 56x "lfs migration support"
4673 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4674 skip "No HSM support on MDS of $(get_lustre_version)," \
4675 "need 2.4.53 at least" && return
4678 local dir0=$DIR/$tdir/$testnum
4679 mkdir -p $dir0 || error "creating dir $dir0"
4680 local f1=$dir0/file1
4681 local f2=$dir0/file2
4683 touch $f1 || error "creating std file $f1"
4684 $MULTIOP $f2 H2c || error "creating released file $f2"
4686 # a directory can be raid0, so ask only for files
4687 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4688 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4690 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4691 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4693 # only files can be released, so no need to force file search
4694 res=$($LFIND $dir0 -L released)
4695 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4697 res=$($LFIND $dir0 \! -L released)
4698 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4701 run_test 56y "lfs find -L raid0|released"
4704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4705 # note test will not do anything if MDS is not local
4706 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4707 skip "Only applicable to ldiskfs-based MDTs"
4711 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4712 local MNTDEV="osd*.*MDT*.mntdev"
4713 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4714 [ -z "$DEV" ] && error "can't access $MNTDEV"
4715 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4716 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4717 error "can't access $DEV"
4718 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4719 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4723 run_test 57a "verify MDS filesystem created with large inodes =="
4726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4727 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4728 skip "Only applicable to ldiskfs-based MDTs"
4732 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4737 local FILEN=$dir/f$FILECOUNT
4739 rm -rf $dir || error "removing $dir"
4740 test_mkdir -p $dir || error "creating $dir"
4741 local num=$(get_mds_dir $dir)
4744 echo "mcreating $FILECOUNT files"
4745 createmany -m $dir/f 1 $FILECOUNT || \
4746 error "creating files in $dir"
4748 # verify that files do not have EAs yet
4749 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4750 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4754 df $dir #make sure we get new statfs data
4755 local MDSFREE=$(do_facet $mymds \
4756 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4757 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4758 echo "opening files to create objects/EAs"
4760 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4761 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4764 # verify that files have EAs now
4765 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4766 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4768 sleep 1 #make sure we get new statfs data
4770 local MDSFREE2=$(do_facet $mymds \
4771 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4772 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4773 if [ "$MDCFREE2" -lt "$((MDCFREE - 16))" ]; then
4774 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4775 error "MDC before $MDCFREE != after $MDCFREE2"
4777 echo "MDC before $MDCFREE != after $MDCFREE2"
4778 echo "unable to confirm if MDS has large inodes"
4783 run_test 57b "default LOV EAs are stored inside large inodes ==="
4786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4787 [ -z "$(which wiretest 2>/dev/null)" ] &&
4788 skip_env "could not find wiretest" && return
4791 run_test 58 "verify cross-platform wire constants =============="
4794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4795 echo "touch 130 files"
4796 createmany -o $DIR/f59- 130
4798 unlinkmany $DIR/f59- 130
4800 # wait for commitment of removal
4801 wait_delete_completed
4803 run_test 59 "verify cancellation of llog records async ========="
4805 TEST60_HEAD="test_60 run $RANDOM"
4807 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4808 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4809 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4810 skip_env "missing subtest run-llog.sh" && return
4811 log "$TEST60_HEAD - from kernel mode"
4812 do_facet mgs sh run-llog.sh
4814 run_test 60a "llog sanity tests run from kernel module =========="
4816 test_60b() { # bug 6411
4817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4819 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4831 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4833 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4837 echo "create 5000 files"
4838 createmany -o $DIR/f60c- 5000
4839 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4840 lctl set_param fail_loc=0x80000137
4841 unlinkmany $DIR/f60c- 5000
4842 lctl set_param fail_loc=0
4844 run_test 60c "unlink file when mds full"
4847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4848 SAVEPRINTK=$(lctl get_param -n printk)
4850 # verify "lctl mark" is even working"
4851 MESSAGE="test message ID $RANDOM $$"
4852 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4853 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4855 lctl set_param printk=0 || error "set lnet.printk failed"
4856 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4857 MESSAGE="new test message ID $RANDOM $$"
4858 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4859 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4860 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4862 lctl set_param -n printk="$SAVEPRINTK"
4864 run_test 60d "test printk console message masking"
4867 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4869 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4870 cancel_lru_locks osc
4871 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4874 run_test 61 "mmap() writes don't make sync hang ================"
4876 # bug 2330 - insufficient obd_match error checking causes LBUG
4878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4881 cancel_lru_locks osc
4882 lctl set_param fail_loc=0x405
4883 cat $f && error "cat succeeded, expect -EIO"
4884 lctl set_param fail_loc=0
4886 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4887 # match every page all of the time.
4888 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4890 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4891 # Though this test is irrelevant anymore, it helped to reveal some
4892 # other grant bugs (LU-4482), let's keep it.
4893 test_63a() { # was test_63
4894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4895 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4896 for i in `seq 10` ; do
4897 dd if=/dev/zero of=$DIR/f63 bs=8k &
4903 rm -f $DIR/f63 || true
4905 run_test 63a "Verify oig_wait interruption does not crash ======="
4907 # bug 2248 - async write errors didn't return to application on sync
4908 # bug 3677 - async write errors left page locked
4910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4912 lctl set_param debug=-1
4914 # ensure we have a grant to do async writes
4915 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4918 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4919 lctl set_param fail_loc=0x80000406
4920 $MULTIOP $DIR/$tfile Owy && \
4921 error "sync didn't return ENOMEM"
4922 sync; sleep 2; sync # do a real sync this time to flush page
4923 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4924 error "locked page left in cache after async error" || true
4927 run_test 63b "async write errors should be returned to fsync ==="
4930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4932 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4934 run_test 64a "verify filter grant calculations (in kernel) ====="
4937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4938 sh oos.sh $MOUNT || error "oos.sh failed: $?"
4940 run_test 64b "check out-of-space detection on client ==========="
4943 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4945 run_test 64c "verify grant shrink ========================------"
4947 # bug 1414 - set/get directories' stripe info
4949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4950 test_mkdir -p $DIR/$tdir
4952 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4954 run_test 65a "directory with no stripe info ===================="
4957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4958 test_mkdir -p $DIR/$tdir
4959 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4962 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4964 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4968 if [ $OSTCOUNT -gt 1 ]; then
4969 test_mkdir -p $DIR/$tdir
4970 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4971 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4973 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4976 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4980 test_mkdir -p $DIR/$tdir
4981 if [ $STRIPECOUNT -le 0 ]; then
4983 elif [ $STRIPECOUNT -gt 2000 ]; then
4984 #LOV_MAX_STRIPE_COUNT is 2000
4985 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4987 sc=$(($STRIPECOUNT - 1))
4989 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4990 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4991 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4992 error "lverify failed"
4994 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4998 test_mkdir -p $DIR/$tdir
5000 $SETSTRIPE $DIR/$tdir || error "setstripe"
5001 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5002 error "no stripe info failed"
5004 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5006 run_test 65e "directory setstripe defaults ======================="
5009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5010 test_mkdir -p $DIR/${tdir}f
5011 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5013 run_test 65f "dir setstripe permission (should return error) ==="
5016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5017 test_mkdir -p $DIR/$tdir
5018 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5020 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5021 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5022 error "delete default stripe failed"
5024 run_test 65g "directory setstripe -d ==========================="
5027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5028 test_mkdir -p $DIR/$tdir
5029 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5031 test_mkdir -p $DIR/$tdir/dd1
5032 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5033 error "stripe info inherit failed"
5035 run_test 65h "directory stripe info inherit ===================="
5037 test_65i() { # bug6367
5038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5039 $SETSTRIPE -S 65536 -c -1 $MOUNT
5041 run_test 65i "set non-default striping on root directory (bug 6367)="
5043 test_65ia() { # bug12836
5044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5045 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5047 run_test 65ia "getstripe on -1 default directory striping"
5049 test_65ib() { # bug12836
5050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5051 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5053 run_test 65ib "getstripe -v on -1 default directory striping"
5055 test_65ic() { # bug12836
5056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5057 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5059 run_test 65ic "new find on -1 default directory striping"
5061 test_65j() { # bug6367
5062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5064 # if we aren't already remounting for each test, do so for this test
5065 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5066 cleanup || error "failed to unmount"
5069 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5071 run_test 65j "set default striping on root directory (bug 6367)="
5073 test_65k() { # bug11679
5074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5075 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
5076 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5078 echo "Check OST status: "
5079 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5080 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5082 for OSC in $MDS_OSCS; do
5083 echo $OSC "is activate"
5084 do_facet $SINGLEMDS lctl --device %$OSC activate
5088 for INACTIVE_OSC in $MDS_OSCS; do
5089 echo "Deactivate: " $INACTIVE_OSC
5090 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5091 for STRIPE_OSC in $MDS_OSCS; do
5092 OST=`osc_to_ost $STRIPE_OSC`
5093 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5094 awk -F: /$OST/'{ print $1 }' | head -n 1`
5096 [ -f $DIR/$tdir/$IDX ] && continue
5097 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5098 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5100 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5103 echo $INACTIVE_OSC "is Activate."
5104 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5107 run_test 65k "validate manual striping works properly with deactivated OSCs"
5109 test_65l() { # bug 12836
5110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5111 test_mkdir -p $DIR/$tdir/test_dir
5112 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5113 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5115 run_test 65l "lfs find on -1 stripe dir ========================"
5117 # bug 2543 - update blocks count on client
5119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5121 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5122 sync; sync_all_data; sync; sync_all_data
5123 cancel_lru_locks osc
5124 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5125 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5127 run_test 66 "update inode blocks count on client ==============="
5132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5134 if [ ! -z "$LLOOP" ]; then
5135 if swapon -s | grep -q $LLOOP; then
5136 swapoff $LLOOP || error "swapoff failed"
5139 $LCTL blockdev_detach $LLOOP || error "detach failed"
5143 if [ ! -z "$LLITELOOPLOAD" ]; then
5151 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5155 swapon -s | awk '($1 == "'$1'") { print $4 }'
5158 # test case for lloop driver, basic function
5160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5161 [ "$UID" != 0 ] && skip_env "must run as root" && return
5162 llite_lloop_enabled || \
5163 { skip_env "llite_lloop module disabled" && return; }
5165 trap cleanup_68 EXIT
5167 if ! module_loaded llite_lloop; then
5168 if load_module llite/llite_lloop; then
5171 skip_env "can't find module llite_lloop"
5176 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5177 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5178 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5180 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5181 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5185 run_test 68a "lloop driver - basic test ========================"
5187 # excercise swapping to lustre by adding a high priority swapfile entry
5188 # and then consuming memory until it is used.
5189 test_68b() { # was test_68
5190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5191 [ "$UID" != 0 ] && skip_env "must run as root" && return
5192 lctl get_param -n devices | grep -q obdfilter && \
5193 skip "local OST" && return
5195 grep -q llite_lloop /proc/modules
5196 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5198 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5199 skip "can't reliably test swap with TCP" && return
5201 MEMTOTAL=`meminfo MemTotal`
5202 NR_BLOCKS=$((MEMTOTAL>>8))
5203 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5205 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5206 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5209 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5211 trap cleanup_68 EXIT
5213 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5215 echo "before: `swapon -s | grep $LLOOP`"
5216 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5217 echo "after: `swapon -s | grep $LLOOP`"
5218 SWAPUSED=`swap_used $LLOOP`
5222 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5224 run_test 68b "support swapping to Lustre ========================"
5226 # bug5265, obdfilter oa2dentry return -ENOENT
5227 # #define OBD_FAIL_OST_ENOENT 0x217
5229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5230 remote_ost_nodsh && skip "remote OST with nodsh" && return
5233 $SETSTRIPE -c 1 -i 0 $f
5235 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5237 do_facet ost1 lctl set_param fail_loc=0x217
5238 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5239 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5241 do_facet ost1 lctl set_param fail_loc=0
5242 $DIRECTIO write $f 0 2 || error "write error"
5244 cancel_lru_locks osc
5245 $DIRECTIO read $f 0 1 || error "read error"
5247 do_facet ost1 lctl set_param fail_loc=0x217
5248 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5250 do_facet ost1 lctl set_param fail_loc=0
5253 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5256 test_mkdir -p $DIR/$tdir
5257 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5259 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5261 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5263 [ "$RUNAS_ID" = "$UID" ] &&
5264 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5266 # Check that testing environment is properly set up. Skip if not
5267 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5268 skip_env "User $RUNAS_ID does not exist - skipping"
5271 # We had better clear the $DIR to get enough space for dd
5274 chmod 777 $DIR/$tfile
5275 chmod ug+s $DIR/$tfile
5276 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5277 error "$RUNAS dd $DIR/$tfile failed"
5278 # See if we are still setuid/sgid
5279 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5280 error "S/gid is not dropped on write"
5281 # Now test that MDS is updated too
5282 cancel_lru_locks mdc
5283 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5284 error "S/gid is not dropped on MDS"
5287 run_test 72a "Test that remove suid works properly (bug5695) ===="
5289 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5292 [ "$RUNAS_ID" = "$UID" ] && \
5293 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5294 [ "$RUNAS_ID" -eq 0 ] && \
5295 skip_env "RUNAS_ID = 0 -- skipping" && return
5297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5298 # Check that testing environment is properly set up. Skip if not
5299 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5300 skip_env "User $RUNAS_ID does not exist - skipping"
5303 touch $DIR/${tfile}-f{g,u}
5304 test_mkdir $DIR/${tfile}-dg
5305 test_mkdir $DIR/${tfile}-du
5306 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5307 chmod g+s $DIR/${tfile}-{f,d}g
5308 chmod u+s $DIR/${tfile}-{f,d}u
5309 for perm in 777 2777 4777; do
5310 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5311 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5312 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5313 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5317 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5319 # bug 3462 - multiple simultaneous MDC requests
5321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5322 test_mkdir $DIR/d73-1
5323 test_mkdir $DIR/d73-2
5324 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5327 lctl set_param fail_loc=0x80000129
5328 $MULTIOP $DIR/d73-1/f73-2 Oc &
5330 lctl set_param fail_loc=0
5332 $MULTIOP $DIR/d73-2/f73-3 Oc &
5336 wait $pid1 || return 1
5340 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5341 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5342 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5346 run_test 73 "multiple MDC requests (should not deadlock)"
5348 test_74a() { # bug 6149, 6184
5349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5350 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5352 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5353 # will spin in a tight reconnection loop
5355 lctl set_param fail_loc=0x8000030e
5356 # get any lock that won't be difficult - lookup works.
5358 lctl set_param fail_loc=0
5362 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5364 test_74b() { # bug 13310
5365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5366 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5368 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5369 # will spin in a tight reconnection loop
5370 lctl set_param fail_loc=0x8000030e
5371 # get a "difficult" lock
5373 lctl set_param fail_loc=0
5377 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5381 #define OBD_FAIL_LDLM_NEW_LOCK
5382 lctl set_param fail_loc=0x80000319
5383 touch $DIR/$tfile && error "Touch successful"
5386 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5389 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5392 get_inode_slab_tunables() {
5393 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5396 set_inode_slab_tunables() {
5397 echo "lustre_inode_cache $1" > /proc/slabinfo
5400 test_76() { # Now for bug 20433, added originally in bug 1443
5401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5402 local SLAB_SETTINGS=`get_inode_slab_tunables`
5403 local CPUS=`getconf _NPROCESSORS_ONLN`
5404 # we cannot set limit below 1 which means 1 inode in each
5405 # per-cpu cache is still allowed
5406 set_inode_slab_tunables "1 1 0"
5407 cancel_lru_locks osc
5408 BEFORE_INODES=`num_inodes`
5409 echo "before inodes: $BEFORE_INODES"
5411 [ "$SLOW" = "no" ] && COUNT=100
5412 for i in `seq $COUNT`; do
5416 cancel_lru_locks osc
5417 AFTER_INODES=`num_inodes`
5418 echo "after inodes: $AFTER_INODES"
5420 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5422 AFTER_INODES=`num_inodes`
5424 echo "wait $wait seconds inodes: $AFTER_INODES"
5425 if [ $wait -gt 30 ]; then
5426 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5429 set_inode_slab_tunables "$SLAB_SETTINGS"
5431 run_test 76 "confirm clients recycle inodes properly ===="
5437 # Note: in sptlrpc modes which enable its own bulk checksum, the
5438 # original crc32_le bulk checksum will be automatically disabled,
5439 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5440 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5441 # In this case set_checksums() will not be no-op, because sptlrpc
5442 # bulk checksum will be enabled all through the test.
5444 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5445 lctl set_param -n osc.*.checksums $1
5449 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5450 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5451 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5452 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5455 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5456 log "set checksum type to $1"
5459 F77_TMP=$TMP/f77-temp
5462 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5463 error "error writing to $F77_TMP"
5466 test_77a() { # bug 10889
5467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5468 $GSS && skip "could not run with gss" && return
5469 [ ! -f $F77_TMP ] && setup_f77
5471 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5475 run_test 77a "normal checksum read/write operation"
5477 test_77b() { # bug 10889
5478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5479 $GSS && skip "could not run with gss" && return
5480 [ ! -f $F77_TMP ] && setup_f77
5481 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5482 $LCTL set_param fail_loc=0x80000409
5485 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5486 error "dd error: $?"
5487 $LCTL set_param fail_loc=0
5489 for algo in $CKSUM_TYPES; do
5490 cancel_lru_locks osc
5491 set_checksum_type $algo
5492 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5493 $LCTL set_param fail_loc=0x80000408
5494 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5495 $LCTL set_param fail_loc=0
5498 set_checksum_type $ORIG_CSUM_TYPE
5501 run_test 77b "checksum error on client write, read"
5503 test_77d() { # bug 10889
5504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5505 $GSS && skip "could not run with gss" && return
5506 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5507 $LCTL set_param fail_loc=0x80000409
5509 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5510 error "direct write: rc=$?"
5511 $LCTL set_param fail_loc=0
5514 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5515 $LCTL set_param fail_loc=0x80000408
5517 cancel_lru_locks osc
5518 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5519 error "direct read: rc=$?"
5520 $LCTL set_param fail_loc=0
5523 run_test 77d "checksum error on OST direct write, read"
5525 test_77f() { # bug 10889
5526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5527 $GSS && skip "could not run with gss" && return
5529 for algo in $CKSUM_TYPES; do
5530 cancel_lru_locks osc
5531 set_checksum_type $algo
5532 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5533 $LCTL set_param fail_loc=0x409
5534 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5535 error "direct write succeeded"
5536 $LCTL set_param fail_loc=0
5538 set_checksum_type $ORIG_CSUM_TYPE
5541 run_test 77f "repeat checksum error on write (expect error)"
5543 test_77g() { # bug 10889
5544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5545 $GSS && skip "could not run with gss" && return
5546 remote_ost_nodsh && skip "remote OST with nodsh" && return
5548 [ ! -f $F77_TMP ] && setup_f77
5550 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5551 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5552 do_facet ost1 lctl set_param fail_loc=0x8000021a
5554 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5555 error "write error: rc=$?"
5556 do_facet ost1 lctl set_param fail_loc=0
5559 cancel_lru_locks osc
5560 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5561 do_facet ost1 lctl set_param fail_loc=0x8000021b
5563 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5564 do_facet ost1 lctl set_param fail_loc=0
5567 run_test 77g "checksum error on OST write, read"
5569 test_77i() { # bug 13805
5570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5571 $GSS && skip "could not run with gss" && return
5572 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5573 lctl set_param fail_loc=0x40b
5574 remount_client $MOUNT
5575 lctl set_param fail_loc=0
5576 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5577 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5578 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5579 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5581 remount_client $MOUNT
5583 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5585 test_77j() { # bug 13805
5586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5587 $GSS && skip "could not run with gss" && return
5588 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5589 lctl set_param fail_loc=0x40c
5590 remount_client $MOUNT
5591 lctl set_param fail_loc=0
5592 sleep 2 # wait async osc connect to finish
5593 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5594 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5595 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5596 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5598 remount_client $MOUNT
5600 run_test 77j "client only supporting ADLER32"
5602 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5606 test_78() { # bug 10901
5607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5608 remote_ost || { skip_env "local OST" && return; }
5611 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5612 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5613 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5614 echo "MemTotal: $MEMTOTAL"
5615 # reserve 256MB of memory for the kernel and other running processes,
5616 # and then take 1/2 of the remaining memory for the read/write buffers.
5617 if [ $MEMTOTAL -gt 512 ] ;then
5618 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5620 # for those poor memory-starved high-end clusters...
5621 MEMTOTAL=$((MEMTOTAL / 2))
5623 echo "Mem to use for directio: $MEMTOTAL"
5624 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5625 [ $F78SIZE -gt 512 ] && F78SIZE=512
5626 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5627 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5628 echo "Smallest OST: $SMALLESTOST"
5629 [ $SMALLESTOST -lt 10240 ] && \
5630 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5632 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5633 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5635 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5636 echo "File size: $F78SIZE"
5637 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5638 for i in `seq 1 $NSEQ`
5640 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5641 echo directIO rdwr round $i of $NSEQ
5642 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5647 run_test 78 "handle large O_DIRECT writes correctly ============"
5649 test_79() { # bug 12743
5650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5651 wait_delete_completed
5653 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5654 BKFREE=$(calc_osc_kbytes kbytesfree)
5655 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5657 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5658 DFTOTAL=`echo $STRING | cut -d, -f1`
5659 DFUSED=`echo $STRING | cut -d, -f2`
5660 DFAVAIL=`echo $STRING | cut -d, -f3`
5661 DFFREE=$(($DFTOTAL - $DFUSED))
5663 ALLOWANCE=$((64 * $OSTCOUNT))
5665 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5666 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5667 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5669 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5670 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5671 error "df free($DFFREE) mismatch OST free($BKFREE)"
5673 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5674 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5675 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5678 run_test 79 "df report consistency check ======================="
5680 test_80() { # bug 10718
5681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5682 # relax strong synchronous semantics for slow backends like ZFS
5683 local soc="obdfilter.*.sync_on_lock_cancel"
5684 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5686 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5687 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5688 facet_active_host $host; done | sort -u)
5689 do_nodes $hosts lctl set_param $soc=never
5692 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5694 local BEFORE=`date +%s`
5695 cancel_lru_locks osc
5696 local AFTER=`date +%s`
5697 local DIFF=$((AFTER-BEFORE))
5698 if [ $DIFF -gt 1 ] ; then
5699 error "elapsed for 1M@1T = $DIFF"
5702 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5706 run_test 80 "Page eviction is equally fast at high offsets too ===="
5708 test_81a() { # LU-456
5709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5710 remote_ost_nodsh && skip "remote OST with nodsh" && return
5711 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5712 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5713 do_facet ost1 lctl set_param fail_loc=0x80000228
5715 # write should trigger a retry and success
5716 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5717 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5719 if [ $RC -ne 0 ] ; then
5720 error "write should success, but failed for $RC"
5723 run_test 81a "OST should retry write when get -ENOSPC ==============="
5725 test_81b() { # LU-456
5726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5727 remote_ost_nodsh && skip "remote OST with nodsh" && return
5728 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5729 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5730 do_facet ost1 lctl set_param fail_loc=0x228
5732 # write should retry several times and return -ENOSPC finally
5733 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5734 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5737 if [ $RC -ne $ENOSPC ] ; then
5738 error "dd should fail for -ENOSPC, but succeed."
5741 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5743 test_82() { # LU-1031
5744 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5748 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5750 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5752 kill -USR1 $MULTIPID2
5754 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5755 error "First grouplock does not block second one"
5757 echo "Second grouplock blocks first one"
5759 kill -USR1 $MULTIPID1
5763 run_test 82 "Basic grouplock test ==============================="
5766 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5768 test_mkdir -p $DIR/d99cvsroot
5769 chown $RUNAS_ID $DIR/d99cvsroot
5770 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5773 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5776 run_test 99a "cvs init ========================================="
5779 [ -z "$(which cvs 2>/dev/null)" ] &&
5780 skip_env "could not find cvs" && return
5781 [ ! -d $DIR/d99cvsroot ] && test_99a
5783 # some versions of cvs import exit(1) when asked to import links or
5784 # files they can't read. ignore those files.
5785 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5786 ! -perm +4 -printf '-I %f\n')
5787 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5788 d99reposname vtag rtag
5790 run_test 99b "cvs import ======================================="
5793 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5794 [ ! -d $DIR/d99cvsroot ] && test_99b
5796 test_mkdir -p $DIR/d99reposname
5797 chown $RUNAS_ID $DIR/d99reposname
5798 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5800 run_test 99c "cvs checkout ====================================="
5803 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5804 [ ! -d $DIR/d99cvsroot ] && test_99c
5805 cd $DIR/d99reposname
5807 $RUNAS cvs add -m 'addmsg' foo99
5809 run_test 99d "cvs add =========================================="
5812 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5813 [ ! -d $DIR/d99cvsroot ] && test_99c
5814 cd $DIR/d99reposname
5817 run_test 99e "cvs update ======================================="
5820 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5821 [ ! -d $DIR/d99cvsroot ] && test_99d
5822 cd $DIR/d99reposname
5823 $RUNAS cvs commit -m 'nomsg' foo99
5824 rm -fr $DIR/d99cvsroot
5826 run_test 99f "cvs commit ======================================="
5829 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5830 [ "$NETTYPE" = tcp ] || \
5831 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5834 remote_ost_nodsh && skip "remote OST with nodsh" && return
5835 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5837 { skip "useless for local single node setup" && return; }
5839 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5840 [ "$PROT" != "tcp" ] && continue
5841 RPORT=$(echo $REMOTE | cut -d: -f2)
5842 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5845 LPORT=`echo $LOCAL | cut -d: -f2`
5846 if [ $LPORT -ge 1024 ]; then
5847 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5849 error_exit "local: $LPORT > 1024, remote: $RPORT"
5852 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5854 run_test 100 "check local port using privileged port ==========="
5856 function get_named_value()
5865 echo $line | sed "s/^$tag[ ]*//"
5872 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5873 awk '/^max_cached_mb/ { print $2 }')
5876 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5882 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
5886 local cache_limit=32
5888 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5889 trap cleanup_101a EXIT
5890 $LCTL set_param -n llite.*.read_ahead_stats 0
5891 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5894 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5896 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5897 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5900 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5901 get_named_value 'read but discarded' | cut -d" " -f1`; do
5902 discard=$(($discard + $s))
5906 if [ $(($discard * 10)) -gt $nreads ] ;then
5907 $LCTL get_param osc.*-osc*.rpc_stats
5908 $LCTL get_param llite.*.read_ahead_stats
5909 error "too many ($discard) discarded pages"
5911 rm -f $DIR/$tfile || true
5913 run_test 101a "check read-ahead for random reads ================"
5916 test_mkdir -p $DIR/$tdir
5918 STRIPE_COUNT=$OSTCOUNT
5921 local list=$(comma_list $(osts_nodes))
5922 set_osd_param $list '' read_cache_enable 0
5923 set_osd_param $list '' writethrough_cache_enable 0
5925 trap cleanup_test101bc EXIT
5926 # prepare the read-ahead file
5927 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5929 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5932 cleanup_test101bc() {
5937 local list=$(comma_list $(osts_nodes))
5938 set_osd_param $list '' read_cache_enable 1
5939 set_osd_param $list '' writethrough_cache_enable 1
5943 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5948 local STRIPE_SIZE=1048576
5949 local RA_INC=1048576
5950 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5951 local FILE_LENGTH=$((64*100))
5952 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5953 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5954 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5955 get_named_value 'read but discarded' | \
5956 cut -d" " -f1 | calc_total`
5957 if [ $DISCARD -gt $discard_limit ]; then
5958 $LCTL get_param llite.*.read_ahead_stats
5959 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5961 echo "Read-ahead success for size ${READ_SIZE}"
5966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5967 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5968 local STRIPE_SIZE=1048576
5969 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5970 local FILE_LENGTH=$((STRIPE_SIZE*100))
5971 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5972 # prepare the read-ahead file
5974 cancel_lru_locks osc
5975 for BIDX in 2 4 8 16 32 64 128 256
5977 local BSIZE=$((BIDX*4096))
5978 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5979 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5980 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5981 $LCTL set_param -n llite.*.read_ahead_stats 0
5982 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5983 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5984 cancel_lru_locks osc
5990 run_test 101b "check stride-io mode read-ahead ================="
5993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5994 local STRIPE_SIZE=1048576
5995 local FILE_LENGTH=$((STRIPE_SIZE*100))
6001 cancel_lru_locks osc
6002 $LCTL set_param osc.*.rpc_stats 0
6003 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6004 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6005 local stats=$($LCTL get_param -n $osc_rpc_stats)
6006 local lines=$(echo "$stats" | awk 'END {print NR;}')
6009 if [ $lines -le 20 ]; then
6012 for size in 1 2 4 8; do
6013 local rpc=$(echo "$stats" |
6014 awk '($1 == "'$size':") {print $2; exit; }')
6016 error "Small $((size*4))k read IO $rpc !"
6018 echo "$osc_rpc_stats check passed!"
6023 run_test 101c "check stripe_size aligned read-ahead ================="
6026 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6027 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6032 local file=$DIR/$tfile
6033 local sz_MB=${FILESIZE_101d:-500}
6034 local ra_MB=${READAHEAD_MB:-40}
6036 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6037 [ $free_MB -lt $sz_MB ] &&
6038 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6040 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6041 $SETSTRIPE -c -1 $file || error "setstripe failed"
6043 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6044 echo Cancel LRU locks on lustre client to flush the client cache
6045 cancel_lru_locks osc
6047 echo Disable read-ahead
6048 local old_READAHEAD=$(set_read_ahead 0)
6050 echo Reading the test file $file with read-ahead disabled
6051 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6053 echo Cancel LRU locks on lustre client to flush the client cache
6054 cancel_lru_locks osc
6055 echo Enable read-ahead with ${ra_MB}MB
6056 set_read_ahead $ra_MB
6058 echo Reading the test file $file with read-ahead enabled
6059 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6061 echo "read-ahead disabled time read $raOFF"
6062 echo "read-ahead enabled time read $raON"
6064 set_read_ahead $old_READAHEAD
6066 wait_delete_completed
6068 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6069 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6071 run_test 101d "file read with and without read-ahead enabled"
6074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6075 local file=$DIR/$tfile
6076 local size_KB=500 #KB
6080 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6081 local need_KB=$((count * size_KB))
6082 [ $free_KB -le $need_KB ] &&
6083 skip_env "Need free space $need_KB, have $free_KB" && return
6085 echo "Creating $count ${size_KB}K test files"
6086 for ((i = 0; i < $count; i++)); do
6087 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6090 echo "Cancel LRU locks on lustre client to flush the client cache"
6091 cancel_lru_locks osc
6093 echo "Reset readahead stats"
6094 $LCTL set_param -n llite.*.read_ahead_stats 0
6096 for ((i = 0; i < $count; i++)); do
6097 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6100 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6101 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6103 for ((i = 0; i < $count; i++)); do
6104 rm -rf $file.$i 2>/dev/null
6107 #10000 means 20% reads are missing in readahead
6108 [ $miss -lt 10000 ] || error "misses too much for small reads"
6110 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6112 cleanup_test101f() {
6114 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6115 rm -rf $DIR/$tfile 2>/dev/null
6119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6120 local file=$DIR/$tfile
6123 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6124 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6125 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6126 trap cleanup_test101f EXIT
6128 echo Cancel LRU locks on lustre client to flush the client cache
6129 cancel_lru_locks osc
6131 echo Reset readahead stats
6132 $LCTL set_param -n llite.*.read_ahead_stats 0
6133 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6134 # readahead should read in 2M file on second read, so only miss
6136 echo Random 4K reads on 2M file for 1000 times
6137 $READS -f $file -s 2097152 -b 4096 -n $nreads
6139 echo checking missing pages
6140 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6141 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6143 [ $miss -lt 3 ] || error "misses too much pages!"
6146 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6149 test_mkdir -p $DIR/$tdir
6150 chown $RUNAS_ID $DIR/$tdir
6153 STRIPE_COUNT=$OSTCOUNT
6154 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
6156 trap cleanup_test102 EXIT
6158 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6160 for num in 1 2 3 4; do
6161 for count in $(seq 1 $STRIPE_COUNT); do
6162 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6163 local size=`expr $STRIPE_SIZE \* $num`
6164 local file=file"$num-$idx-$count"
6165 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6171 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6177 rm -rf $DIR/d0.sanity/d102
6181 local testfile=$DIR/xattr_testfile
6185 [ "$UID" != 0 ] && skip_env "must run as root" && return
6186 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6187 skip_env "must have user_xattr" && return
6189 [ -z "$(which setfattr 2>/dev/null)" ] &&
6190 skip_env "could not find setfattr" && return
6192 echo "set/get xattr..."
6193 setfattr -n trusted.name1 -v value1 $testfile ||
6194 error "setfattr -n trusted.name1=value1 $testfile failed"
6195 getfattr -n trusted.name1 $testfile 2> /dev/null |
6196 grep "trusted.name1=.value1" ||
6197 error "$testfile missing trusted.name1=value1"
6199 setfattr -n user.author1 -v author1 $testfile ||
6200 error "setfattr -n user.author1=author1 $testfile failed"
6201 getfattr -n user.author1 $testfile 2> /dev/null |
6202 grep "user.author1=.author1" ||
6203 error "$testfile missing trusted.author1=author1"
6206 setfattr -n trusted.name2 -v value2 $testfile ||
6207 error "$testfile unable to set trusted.name2"
6208 setfattr -n trusted.name3 -v value3 $testfile ||
6209 error "$testfile unable to set trusted.name3"
6210 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6211 grep "trusted.name" | wc -l) -eq 3 ] ||
6212 error "$testfile missing 3 trusted.name xattrs"
6214 setfattr -n user.author2 -v author2 $testfile ||
6215 error "$testfile unable to set user.author2"
6216 setfattr -n user.author3 -v author3 $testfile ||
6217 error "$testfile unable to set user.author3"
6218 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6219 grep "user.author" | wc -l) -eq 3 ] ||
6220 error "$testfile missing 3 user.author xattrs"
6222 echo "remove xattr..."
6223 setfattr -x trusted.name1 $testfile ||
6224 error "$testfile error deleting trusted.name1"
6225 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6226 error "$testfile did not delete trusted.name1 xattr"
6228 setfattr -x user.author1 $testfile ||
6229 error "$testfile error deleting user.author1"
6230 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6231 error "$testfile did not delete trusted.name1 xattr"
6233 # b10667: setting lustre special xattr be silently discarded
6234 echo "set lustre special xattr ..."
6235 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6236 error "$testfile allowed setting trusted.lov"
6238 run_test 102a "user xattr test =================================="
6241 # b10930: get/set/list trusted.lov xattr
6242 echo "get/set/list trusted.lov xattr ..."
6243 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6244 local testfile=$DIR/$tfile
6245 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6246 error "setstripe failed"
6247 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6248 error "getstripe failed"
6249 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
6250 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
6252 local testfile2=${testfile}2
6253 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
6254 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
6257 setfattr -n trusted.lov -v $value $testfile2
6258 local stripe_size=$($GETSTRIPE -S $testfile2)
6259 local stripe_count=$($GETSTRIPE -c $testfile2)
6260 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6261 [ $stripe_count -eq $STRIPECOUNT ] ||
6262 error "stripe count $stripe_count != $STRIPECOUNT"
6265 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6268 # b10930: get/set/list lustre.lov xattr
6269 echo "get/set/list lustre.lov xattr ..."
6270 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6271 test_mkdir -p $DIR/$tdir
6272 chown $RUNAS_ID $DIR/$tdir
6273 local testfile=$DIR/$tdir/$tfile
6274 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6275 error "setstripe failed"
6276 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6277 error "getstripe failed"
6278 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6279 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6281 local testfile2=${testfile}2
6282 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6283 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6285 $RUNAS $MCREATE $testfile2
6286 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6287 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6288 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6289 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6290 [ $stripe_count -eq $STRIPECOUNT ] ||
6291 error "stripe count $stripe_count != $STRIPECOUNT"
6293 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6295 compare_stripe_info1() {
6296 local stripe_index_all_zero=true
6298 for num in 1 2 3 4; do
6299 for count in $(seq 1 $STRIPE_COUNT); do
6300 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6301 local size=$((STRIPE_SIZE * num))
6302 local file=file"$num-$offset-$count"
6303 stripe_size=$(lfs getstripe -S $PWD/$file)
6304 [ $stripe_size -ne $size ] &&
6305 error "$file: size $stripe_size != $size"
6306 stripe_count=$(lfs getstripe -c $PWD/$file)
6307 # allow fewer stripes to be created, ORI-601
6308 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
6309 error "$file: count $stripe_count != $count"
6310 stripe_index=$(lfs getstripe -i $PWD/$file)
6311 [ $stripe_index -ne 0 ] &&
6312 stripe_index_all_zero=false
6316 $stripe_index_all_zero &&
6317 error "all files are being extracted starting from OST index 0"
6322 [ -n "$(which tar 2>/dev/null)" ] &&
6323 strings $(which tar) | grep -q "lustre" && echo tar
6327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6328 # b10930: tar test for trusted.lov xattr
6329 TAR=$(find_lustre_tar)
6330 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6331 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6333 test_mkdir -p $DIR/d102d
6334 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6336 compare_stripe_info1
6338 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6341 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6342 # b10930: tar test for trusted.lov xattr
6343 TAR=$(find_lustre_tar)
6344 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6345 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6347 test_mkdir -p $DIR/d102f
6349 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6351 compare_stripe_info1
6353 run_test 102f "tar copy files, not keep osts ==========="
6356 local xsize=${1:-1024} # in bytes
6357 local file=$DIR/$tfile
6359 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6360 skip "must have user_xattr" && return 0
6361 [ -z "$(which setfattr 2>/dev/null)" ] &&
6362 skip_env "could not find setfattr" && return 0
6363 [ -z "$(which getfattr 2>/dev/null)" ] &&
6364 skip_env "could not find getfattr" && return 0
6368 local value="$(generate_string $xsize)"
6370 local xbig=trusted.big
6371 log "save $xbig on $file"
6372 setfattr -n $xbig -v $value $file ||
6373 error "saving $xbig on $file failed"
6375 local orig=$(get_xattr_value $xbig $file)
6376 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6378 local xsml=trusted.sml
6379 log "save $xsml on $file"
6380 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6382 local new=$(get_xattr_value $xbig $file)
6383 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6385 log "grow $xsml on $file"
6386 setfattr -n $xsml -v "$value" $file ||
6387 error "growing $xsml on $file failed"
6389 new=$(get_xattr_value $xbig $file)
6390 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6391 log "$xbig still valid after growing $xsml"
6396 test_102h() { # bug 15777
6399 run_test 102h "grow xattr from inside inode to external block"
6402 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6403 grow_xattr $(max_xattr_size)
6405 run_test 102ha "grow xattr from inside inode to external inode"
6407 test_102i() { # bug 17038
6409 ln -s $DIR/$tfile $DIR/${tfile}link
6410 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6411 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 | grep -i "no such attr" || error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6412 rm -f $DIR/$tfile $DIR/${tfile}link
6414 run_test 102i "lgetxattr test on symbolic link ============"
6417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6418 TAR=$(find_lustre_tar)
6419 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6420 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6421 setup_test102 "$RUNAS"
6422 test_mkdir -p $DIR/d102j
6423 chown $RUNAS_ID $DIR/d102j
6424 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6426 compare_stripe_info1 "$RUNAS"
6428 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6432 # b22187 just check that does not crash for regular file.
6433 setfattr -n trusted.lov $DIR/$tfile
6434 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6435 local test_kdir=$DIR/d102k
6436 test_mkdir $test_kdir
6437 local default_size=`$GETSTRIPE -S $test_kdir`
6438 local default_count=`$GETSTRIPE -c $test_kdir`
6439 local default_offset=`$GETSTRIPE -i $test_kdir`
6440 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6441 error 'dir setstripe failed'
6442 setfattr -n trusted.lov $test_kdir
6443 local stripe_size=`$GETSTRIPE -S $test_kdir`
6444 local stripe_count=`$GETSTRIPE -c $test_kdir`
6445 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6446 [ $stripe_size -eq $default_size ] ||
6447 error "stripe size $stripe_size != $default_size"
6448 [ $stripe_count -eq $default_count ] ||
6449 error "stripe count $stripe_count != $default_count"
6450 [ $stripe_offset -eq $default_offset ] ||
6451 error "stripe offset $stripe_offset != $default_offset"
6452 rm -rf $DIR/$tfile $test_kdir
6454 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6457 # LU-532 trusted. xattr is invisible to non-root
6458 local testfile=$DIR/$tfile
6462 echo "listxattr as user..."
6463 chown $RUNAS_ID $testfile
6464 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6465 grep -q "trusted" &&
6466 error "$testfile trusted xattrs are user visible"
6470 run_test 102l "listxattr size test =================================="
6472 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6473 local path=$DIR/$tfile
6476 listxattr_size_check $path || error "listattr_size_check $path failed"
6478 run_test 102m "Ensure listxattr fails on small bufffer ========"
6482 getxattr() { # getxattr path name
6483 # Return the base64 encoding of the value of xattr name on path.
6487 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6489 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6491 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6493 getfattr --absolute-names --encoding=base64 --name=$name $path |
6494 awk -F= -v name=$name '$1 == name {
6495 print substr($0, index($0, "=") + 1);
6499 test_102n() { # LU-4101 mdt: protect internal xattrs
6500 local file0=$DIR/$tfile.0
6501 local file1=$DIR/$tfile.1
6502 local xattr0=$TMP/$tfile.0
6503 local xattr1=$TMP/$tfile.1
6507 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6509 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6513 rm -rf $file0 $file1 $xattr0 $xattr1
6516 # Get 'before' xattrs of $file1.
6517 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6519 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6520 # Try to copy xattr from $file0 to $file1.
6521 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6523 setfattr --name=trusted.$name --value="$value" $file1 ||
6524 error "setxattr 'trusted.$name' failed"
6526 # Try to set a garbage xattr.
6527 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6529 setfattr --name=trusted.$name --value="$value" $file1 ||
6530 error "setxattr 'trusted.$name' failed"
6532 # Try to remove the xattr from $file1. We don't care if this
6533 # appears to succeed or fail, we just don't want there to be
6534 # any changes or crashes.
6535 setfattr --remove=$trusted.$name $file1 2> /dev/null
6538 # Get 'after' xattrs of file1.
6539 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6541 if ! diff $xattr0 $xattr1; then
6542 error "before and after xattrs of '$file1' differ"
6545 rm -rf $file0 $file1 $xattr0 $xattr1
6549 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6553 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6558 [ "$UID" != 0 ] && skip_env "must run as root" && return
6559 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6560 skip "must have acl enabled" && return
6561 [ -z "$(which setfacl 2>/dev/null)" ] &&
6562 skip_env "could not find setfacl" && return
6563 $GSS && skip "could not run under gss" && return
6565 declare -a identity_old
6567 for num in $(seq $MDSCOUNT); do
6568 switch_identity $num true || identity_old[$num]=$?
6575 echo "performing cp ..."
6576 run_acl_subtest cp || error "run_acl_subtest cp failed"
6577 echo "performing getfacl-noacl..."
6578 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6579 echo "performing misc..."
6580 run_acl_subtest misc || error "misc test failed"
6581 echo "performing permissions..."
6582 run_acl_subtest permissions || error "permissions failed"
6583 echo "performing setfacl..."
6584 run_acl_subtest setfacl || error "setfacl test failed"
6586 # inheritance test got from HP
6587 echo "performing inheritance..."
6588 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6589 chmod +x make-tree || error "chmod +x failed"
6590 run_acl_subtest inheritance || error "inheritance test failed"
6593 echo "LU-974 ignore umask when acl is enabled..."
6594 run_acl_subtest 974 || error "LU-974 umask test failed"
6595 if [ $MDSCOUNT -ge 2 ]; then
6596 run_acl_subtest 974_remote ||
6597 error "LU-974 umask test failed under remote dir"
6600 echo "LU-2561 newly created file is same size as directory..."
6601 run_acl_subtest 2561 || error "LU-2561 test failed"
6606 for num in $(seq $MDSCOUNT); do
6607 if [ "${identity_old[$num]}" = 1 ]; then
6608 switch_identity $num false || identity_old[$num]=$?
6612 run_test 103 "acl test ========================================="
6615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6617 lfs df || error "lfs df failed"
6618 lfs df -ih || error "lfs df -ih failed"
6619 lfs df -h $DIR || error "lfs df -h $DIR failed"
6620 lfs df -i $DIR || error "lfs df -i $DIR failed"
6621 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6622 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6624 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6625 lctl --device %$OSC deactivate
6626 lfs df || error "lfs df with deactivated OSC failed"
6627 lctl --device %$OSC activate
6628 # wait the osc back to normal
6629 wait_osc_import_state client ost FULL
6631 lfs df || error "lfs df with reactivated OSC failed"
6634 run_test 104a "lfs df [-ih] [path] test ========================="
6637 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6638 [ $RUNAS_ID -eq $UID ] &&
6639 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6641 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6642 grep "Permission denied" | wc -l)))
6643 if [ $denied_cnt -ne 0 ]; then
6644 error "lfs check servers test failed"
6647 run_test 104b "$RUNAS lfs check servers test ===================="
6650 # doesn't work on 2.4 kernels
6652 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6653 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6655 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6659 run_test 105a "flock when mounted without -o flock test ========"
6663 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6664 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6666 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6670 run_test 105b "fcntl when mounted without -o flock test ========"
6674 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6675 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6677 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6681 run_test 105c "lockf when mounted without -o flock test ========"
6683 test_105d() { # bug 15924
6684 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6685 test_mkdir -p $DIR/$tdir
6686 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6687 skip "mount w/o flock enabled" && return
6688 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6689 $LCTL set_param fail_loc=0x80000315
6690 flocks_test 2 $DIR/$tdir
6692 run_test 105d "flock race (should not freeze) ========"
6694 test_105e() { # bug 22660 && 22040
6695 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6696 skip "mount w/o flock enabled" && return
6698 flocks_test 3 $DIR/$tfile
6700 run_test 105e "Two conflicting flocks from same process ======="
6702 test_106() { #bug 10921
6703 test_mkdir -p $DIR/$tdir
6704 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6705 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6707 run_test 106 "attempt exec of dir followed by chown of that dir"
6710 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6717 local save_pattern=$(sysctl -n kernel.core_pattern)
6718 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6719 sysctl -w kernel.core_pattern=$file
6720 sysctl -w kernel.core_uses_pid=0
6728 kill -s 11 $SLEEPPID
6730 if [ -e $file ]; then
6731 size=`stat -c%s $file`
6732 [ $size -eq 0 ] && error "Fail to create core file $file"
6734 error "Fail to create core file $file"
6737 sysctl -w kernel.core_pattern=$save_pattern
6738 sysctl -w kernel.core_uses_pid=$save_uses_pid
6741 run_test 107 "Coredump on SIG"
6744 test_mkdir -p $DIR/$tdir
6745 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6746 error "mkdir with 255 char failed"
6747 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6748 error "mkdir with 256 char should fail, but did not"
6749 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6750 error "create with 255 char failed"
6751 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6752 error "create with 256 char should fail, but did not"
6757 run_test 110 "filename length checking"
6760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6761 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6763 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6765 echo "Starting with $OSTIO_pre threads"
6768 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6769 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6770 echo "$NUMTEST creates/unlinks"
6771 test_mkdir -p $DIR/$tdir
6772 createmany -o $DIR/$tdir/$tfile $NUMTEST
6773 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6775 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6778 # don't return an error
6779 [ $OSTIO_post == $OSTIO_pre ] && echo \
6780 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6781 echo "This may be fine, depending on what ran before this test" &&
6782 echo "and how fast this system is." && return
6784 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6786 run_test 115 "verify dynamic thread creation===================="
6789 wait_delete_completed
6790 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6791 echo OST kbytes available: ${AVAIL[@]}
6792 MAXI=0; MAXV=${AVAIL[0]}
6793 MINI=0; MINV=${AVAIL[0]}
6794 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6795 #echo OST $i: ${AVAIL[i]}kb
6796 if [ ${AVAIL[i]} -gt $MAXV ]; then
6797 MAXV=${AVAIL[i]}; MAXI=$i
6799 if [ ${AVAIL[i]} -lt $MINV ]; then
6800 MINV=${AVAIL[i]}; MINI=$i
6803 echo Min free space: OST $MINI: $MINV
6804 echo Max free space: OST $MAXI: $MAXV
6807 test_116a() { # was previously test_116()
6808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6809 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6811 echo -n "Free space priority "
6812 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6817 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6818 trap simple_cleanup_common EXIT
6820 # Check if we need to generate uneven OSTs
6821 test_mkdir -p $DIR/$tdir/OST${MINI}
6822 local FILL=$(($MINV / 4))
6823 local DIFF=$(($MAXV - $MINV))
6824 local DIFF2=$(($DIFF * 100 / $MINV))
6826 local threshold=$(do_facet $SINGLEMDS \
6827 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -1)
6828 threshold=${threshold%%%}
6829 echo -n "Check for uneven OSTs: "
6830 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6832 if [ $DIFF2 -gt $threshold ]; then
6834 echo "Don't need to fill OST$MINI"
6836 # generate uneven OSTs. Write 2% over the QOS threshold value
6838 DIFF=$(($threshold - $DIFF2 + 2))
6839 DIFF2=$(( ($MINV * $DIFF)/100 ))
6840 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6841 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6842 error "setstripe failed"
6843 DIFF=$(($DIFF2 / 2048))
6845 while [ $i -lt $DIFF ]; do
6847 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6848 bs=2M count=1 2>/dev/null
6857 DIFF=$(($MAXV - $MINV))
6858 DIFF2=$(($DIFF * 100 / $MINV))
6859 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
6860 if [ $DIFF2 -gt $threshold ]; then
6863 echo "failed - QOS mode won't be used"
6864 skip "QOS imbalance criteria not met"
6865 simple_cleanup_common
6869 MINI1=$MINI; MINV1=$MINV
6870 MAXI1=$MAXI; MAXV1=$MAXV
6872 # now fill using QOS
6873 $SETSTRIPE -c 1 $DIR/$tdir
6874 FILL=$(($FILL / 200))
6875 if [ $FILL -gt 600 ]; then
6878 echo "writing $FILL files to QOS-assigned OSTs"
6880 while [ $i -lt $FILL ]; do
6882 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
6886 echo "wrote $i 200k files"
6890 echo "Note: free space may not be updated, so measurements might be off"
6892 DIFF2=$(($MAXV - $MINV))
6893 echo "free space delta: orig $DIFF final $DIFF2"
6894 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6895 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6896 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
6897 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6898 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
6899 FILL=$(($DIFF2 * 100 / $DIFF - 100))
6901 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
6903 # Figure out which files were written where
6904 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6905 awk '/'$MINI1': / {print $2; exit}')
6907 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6908 echo "$MINC files created on smaller OST $MINI1"
6909 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6910 awk '/'$MAXI1': / {print $2; exit}')
6912 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6913 echo "$MAXC files created on larger OST $MAXI1"
6914 FILL=$(($MAXC * 100 / $MINC - 100))
6916 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
6917 [ $MAXC -gt $MINC ] ||
6918 error_ignore LU-9 "stripe QOS didn't balance free space"
6919 simple_cleanup_common
6921 run_test 116a "stripe QOS: free space balance ==================="
6923 test_116b() { # LU-2093
6924 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6925 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6927 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6928 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6930 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6931 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6932 do_facet $SINGLEMDS lctl set_param fail_loc=0
6934 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6936 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6938 test_117() # bug 10891
6940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6941 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6942 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6943 lctl set_param fail_loc=0x21e
6944 > $DIR/$tfile || error "truncate failed"
6945 lctl set_param fail_loc=0
6946 echo "Truncate succeeded."
6949 run_test 117 "verify osd extend =========="
6951 NO_SLOW_RESENDCOUNT=4
6952 export OLD_RESENDCOUNT=""
6953 set_resend_count () {
6954 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6955 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6956 lctl set_param -n $PROC_RESENDCOUNT $1
6957 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6960 # for reduce test_118* time (b=14842)
6961 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6963 # Reset async IO behavior after error case
6965 FILE=$DIR/reset_async
6967 # Ensure all OSCs are cleared
6968 $SETSTRIPE -c -1 $FILE
6969 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6974 test_118a() #bug 11710
6976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6979 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6980 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6981 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6983 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6984 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6989 run_test 118a "verify O_SYNC works =========="
6993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6994 remote_ost_nodsh && skip "remote OST with nodsh" && return
6998 #define OBD_FAIL_OST_ENOENT 0x217
6999 set_nodes_failloc "$(osts_nodes)" 0x217
7000 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7002 set_nodes_failloc "$(osts_nodes)" 0
7003 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7004 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7007 if [[ $RC -eq 0 ]]; then
7008 error "Must return error due to dropped pages, rc=$RC"
7012 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7013 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7017 echo "Dirty pages not leaked on ENOENT"
7019 # Due to the above error the OSC will issue all RPCs syncronously
7020 # until a subsequent RPC completes successfully without error.
7021 $MULTIOP $DIR/$tfile Ow4096yc
7026 run_test 118b "Reclaim dirty pages on fatal error =========="
7030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7032 # for 118c, restore the original resend count, LU-1940
7033 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7034 set_resend_count $OLD_RESENDCOUNT
7035 remote_ost_nodsh && skip "remote OST with nodsh" && return
7039 #define OBD_FAIL_OST_EROFS 0x216
7040 set_nodes_failloc "$(osts_nodes)" 0x216
7042 # multiop should block due to fsync until pages are written
7043 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7047 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7048 error "Multiop failed to block on fsync, pid=$MULTIPID"
7051 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7053 if [[ $WRITEBACK -eq 0 ]]; then
7054 error "No page in writeback, writeback=$WRITEBACK"
7057 set_nodes_failloc "$(osts_nodes)" 0
7060 if [[ $RC -ne 0 ]]; then
7061 error "Multiop fsync failed, rc=$RC"
7064 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7065 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7067 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7068 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7072 echo "Dirty pages flushed via fsync on EROFS"
7075 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7077 # continue to use small resend count to reduce test_118* time (b=14842)
7078 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7083 remote_ost_nodsh && skip "remote OST with nodsh" && return
7087 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7088 set_nodes_failloc "$(osts_nodes)" 0x214
7089 # multiop should block due to fsync until pages are written
7090 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7094 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7095 error "Multiop failed to block on fsync, pid=$MULTIPID"
7098 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7100 if [[ $WRITEBACK -eq 0 ]]; then
7101 error "No page in writeback, writeback=$WRITEBACK"
7104 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7105 set_nodes_failloc "$(osts_nodes)" 0
7107 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7108 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7110 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7111 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7115 echo "Dirty pages gaurenteed flushed via fsync"
7118 run_test 118d "Fsync validation inject a delay of the bulk =========="
7121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7124 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7125 lctl set_param fail_loc=0x8000040a
7127 # Should simulate EINVAL error which is fatal
7128 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7130 if [[ $RC -eq 0 ]]; then
7131 error "Must return error due to dropped pages, rc=$RC"
7134 lctl set_param fail_loc=0x0
7136 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7137 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7138 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7140 if [[ $LOCKED -ne 0 ]]; then
7141 error "Locked pages remain in cache, locked=$LOCKED"
7144 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7145 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7149 echo "No pages locked after fsync"
7154 run_test 118f "Simulate unrecoverable OSC side error =========="
7157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7160 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7161 lctl set_param fail_loc=0x406
7163 # simulate local -ENOMEM
7164 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7167 lctl set_param fail_loc=0
7168 if [[ $RC -eq 0 ]]; then
7169 error "Must return error due to dropped pages, rc=$RC"
7172 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7173 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7174 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7176 if [[ $LOCKED -ne 0 ]]; then
7177 error "Locked pages remain in cache, locked=$LOCKED"
7180 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7181 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7185 echo "No pages locked after fsync"
7190 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7194 remote_ost_nodsh && skip "remote OST with nodsh" && return
7198 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7199 set_nodes_failloc "$(osts_nodes)" 0x20e
7200 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7201 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7204 set_nodes_failloc "$(osts_nodes)" 0
7205 if [[ $RC -eq 0 ]]; then
7206 error "Must return error due to dropped pages, rc=$RC"
7209 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7210 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7211 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7213 if [[ $LOCKED -ne 0 ]]; then
7214 error "Locked pages remain in cache, locked=$LOCKED"
7217 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7218 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7222 echo "No pages locked after fsync"
7226 run_test 118h "Verify timeout in handling recoverables errors =========="
7228 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7232 remote_ost_nodsh && skip "remote OST with nodsh" && return
7236 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7237 set_nodes_failloc "$(osts_nodes)" 0x20e
7239 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7240 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7243 set_nodes_failloc "$(osts_nodes)" 0
7247 if [[ $RC -ne 0 ]]; then
7248 error "got error, but should be not, rc=$RC"
7251 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7252 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7253 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7254 if [[ $LOCKED -ne 0 ]]; then
7255 error "Locked pages remain in cache, locked=$LOCKED"
7258 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7259 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7263 echo "No pages locked after fsync"
7267 run_test 118i "Fix error before timeout in recoverable error =========="
7269 [ "$SLOW" = "no" ] && set_resend_count 4
7272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7273 remote_ost_nodsh && skip "remote OST with nodsh" && return
7277 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7278 set_nodes_failloc "$(osts_nodes)" 0x220
7280 # return -EIO from OST
7281 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7283 set_nodes_failloc "$(osts_nodes)" 0x0
7284 if [[ $RC -eq 0 ]]; then
7285 error "Must return error due to dropped pages, rc=$RC"
7288 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7289 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7290 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7291 if [[ $LOCKED -ne 0 ]]; then
7292 error "Locked pages remain in cache, locked=$LOCKED"
7295 # in recoverable error on OST we want resend and stay until it finished
7296 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7297 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7301 echo "No pages locked after fsync"
7305 run_test 118j "Simulate unrecoverable OST side error =========="
7309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7310 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7312 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7313 set_nodes_failloc "$(osts_nodes)" 0x20e
7314 test_mkdir -p $DIR/$tdir
7316 for ((i=0;i<10;i++)); do
7317 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7318 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7325 set_nodes_failloc "$(osts_nodes)" 0
7328 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7334 test_mkdir -p $DIR/$tdir
7335 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7338 run_test 118l "fsync dir ========="
7340 test_118m() # LU-3066
7342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7343 test_mkdir -p $DIR/$tdir
7344 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7347 run_test 118m "fdatasync dir ========="
7349 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7351 test_119a() # bug 11737
7353 BSIZE=$((512 * 1024))
7354 directio write $DIR/$tfile 0 1 $BSIZE
7355 # We ask to read two blocks, which is more than a file size.
7356 # directio will indicate an error when requested and actual
7357 # sizes aren't equeal (a normal situation in this case) and
7358 # print actual read amount.
7359 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7360 if [ "$NOB" != "$BSIZE" ]; then
7361 error "read $NOB bytes instead of $BSIZE"
7365 run_test 119a "Short directIO read must return actual read amount"
7367 test_119b() # bug 11737
7369 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7371 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7372 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7374 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7375 error "direct read failed"
7378 run_test 119b "Sparse directIO read must return actual read amount"
7380 test_119c() # bug 13099
7383 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7384 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7387 run_test 119c "Testing for direct read hitting hole"
7389 test_119d() # bug 15950
7391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7392 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7393 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7395 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7396 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7397 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7398 lctl set_param fail_loc=0x40d
7399 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7402 cat $DIR/$tfile > /dev/null &
7403 lctl set_param fail_loc=0
7406 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7408 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7409 error "the read rpcs have not completed in 2s"
7411 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7413 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7417 test_mkdir -p $DIR/$tdir
7418 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7419 skip "no early lock cancel on server" && return 0
7421 lru_resize_disable mdc
7422 lru_resize_disable osc
7423 cancel_lru_locks mdc
7424 # asynchronous object destroy at MDT could cause bl ast to client
7425 cancel_lru_locks osc
7427 stat $DIR/$tdir > /dev/null
7428 can1=$(lctl get_param -n ldlm.services.ldlm_canceld.stats |
7429 awk '/ldlm_cancel/ {print $2}')
7430 blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
7431 awk '/ldlm_bl_callback/ {print $2}')
7432 test_mkdir -c1 $DIR/$tdir/d1
7433 can2=$(lctl get_param -n ldlm.services.ldlm_canceld.stats |
7434 awk '/ldlm_cancel/ {print $2}')
7435 blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
7436 awk '/ldlm_bl_callback/ {print $2}')
7437 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7438 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7439 lru_resize_enable mdc
7440 lru_resize_enable osc
7442 run_test 120a "Early Lock Cancel: mkdir test"
7445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7446 test_mkdir $DIR/$tdir
7447 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7448 skip "no early lock cancel on server" && return 0
7449 lru_resize_disable mdc
7450 lru_resize_disable osc
7451 cancel_lru_locks mdc
7452 stat $DIR/$tdir > /dev/null
7453 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7454 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7456 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7457 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7458 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7459 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7460 lru_resize_enable mdc
7461 lru_resize_enable osc
7463 run_test 120b "Early Lock Cancel: create test"
7466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7467 test_mkdir -c1 $DIR/$tdir
7468 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7469 skip "no early lock cancel on server" && return 0
7470 lru_resize_disable mdc
7471 lru_resize_disable osc
7472 test_mkdir -p -c1 $DIR/$tdir/d1
7473 test_mkdir -p -c1 $DIR/$tdir/d2
7474 touch $DIR/$tdir/d1/f1
7475 cancel_lru_locks mdc
7476 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7477 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7478 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7479 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7480 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7481 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7482 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7483 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7484 lru_resize_enable mdc
7485 lru_resize_enable osc
7487 run_test 120c "Early Lock Cancel: link test"
7490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7491 test_mkdir -p -c1 $DIR/$tdir
7492 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7493 skip "no early lock cancel on server" && return 0
7494 lru_resize_disable mdc
7495 lru_resize_disable osc
7497 cancel_lru_locks mdc
7498 stat $DIR/$tdir > /dev/null
7499 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7500 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7501 chmod a+x $DIR/$tdir
7502 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7503 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7504 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7505 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7506 lru_resize_enable mdc
7507 lru_resize_enable osc
7509 run_test 120d "Early Lock Cancel: setattr test"
7512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7513 test_mkdir -p -c1 $DIR/$tdir
7514 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7515 skip "no early lock cancel on server" && return 0
7516 lru_resize_disable mdc
7517 lru_resize_disable osc
7518 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7519 cancel_lru_locks mdc
7520 cancel_lru_locks osc
7521 dd if=$DIR/$tdir/f1 of=/dev/null
7522 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7523 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7524 awk '/ldlm_cancel/ {print $2}'`
7525 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7526 awk '/ldlm_bl_callback/ {print $2}'`
7527 unlink $DIR/$tdir/f1
7528 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7529 awk '/ldlm_cancel/ {print $2}'`
7530 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7531 awk '/ldlm_bl_callback/ {print $2}'`
7532 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7533 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7534 lru_resize_enable mdc
7535 lru_resize_enable osc
7537 run_test 120e "Early Lock Cancel: unlink test"
7540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7541 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7542 skip "no early lock cancel on server" && return 0
7543 test_mkdir -p -c1 $DIR/$tdir
7544 lru_resize_disable mdc
7545 lru_resize_disable osc
7546 test_mkdir -p -c1 $DIR/$tdir/d1
7547 test_mkdir -p -c1 $DIR/$tdir/d2
7548 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7549 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7550 cancel_lru_locks mdc
7551 cancel_lru_locks osc
7552 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7553 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7554 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7555 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7556 awk '/ldlm_cancel/ {print $2}'`
7557 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7558 awk '/ldlm_bl_callback/ {print $2}'`
7559 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7560 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7561 awk '/ldlm_cancel/ {print $2}'`
7562 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7563 awk '/ldlm_bl_callback/ {print $2}'`
7564 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7565 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7566 lru_resize_enable mdc
7567 lru_resize_enable osc
7569 run_test 120f "Early Lock Cancel: rename test"
7572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7573 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7574 skip "no early lock cancel on server" && return 0
7575 lru_resize_disable mdc
7576 lru_resize_disable osc
7578 echo create $count files
7579 test_mkdir -p $DIR/$tdir
7580 cancel_lru_locks mdc
7581 cancel_lru_locks osc
7584 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7585 awk '/ldlm_cancel/ {print $2}'`
7586 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7587 awk '/ldlm_bl_callback/ {print $2}'`
7588 createmany -o $DIR/$tdir/f $count
7590 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7591 awk '/ldlm_cancel/ {print $2}'`
7592 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7593 awk '/ldlm_bl_callback/ {print $2}'`
7595 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7596 echo rm $count files
7599 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7600 awk '/ldlm_cancel/ {print $2}'`
7601 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7602 awk '/ldlm_bl_callback/ {print $2}'`
7604 echo total: $count removes in $((t2-t1))
7605 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7607 # wait for commitment of removal
7608 lru_resize_enable mdc
7609 lru_resize_enable osc
7611 run_test 120g "Early Lock Cancel: performance test"
7613 test_121() { #bug #10589
7614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7616 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7617 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7618 lctl set_param fail_loc=0x310
7619 cancel_lru_locks osc > /dev/null
7620 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7621 lctl set_param fail_loc=0
7622 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7624 run_test 121 "read cancel race ========="
7626 test_123a() { # was test 123, statahead(bug 11401)
7627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7629 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7630 log "testing on UP system. Performance may be not as good as expected."
7635 test_mkdir -p $DIR/$tdir
7636 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7637 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7639 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7640 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7642 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7643 lctl set_param -n llite.*.statahead_max 0
7644 lctl get_param llite.*.statahead_max
7645 cancel_lru_locks mdc
7646 cancel_lru_locks osc
7648 time ls -l $DIR/$tdir | wc -l
7650 delta=$((etime - stime))
7651 log "ls $i files without statahead: $delta sec"
7652 lctl set_param llite.*.statahead_max=$max
7654 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7655 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7656 cancel_lru_locks mdc
7657 cancel_lru_locks osc
7659 time ls -l $DIR/$tdir | wc -l
7661 delta_sa=$((etime - stime))
7662 log "ls $i files with statahead: $delta_sa sec"
7663 lctl get_param -n llite.*.statahead_stats
7664 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7666 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7667 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7669 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7670 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7671 lctl set_param -n llite.*.statahead_max 0
7672 lctl get_param llite.*.statahead_max
7673 cancel_lru_locks mdc
7674 cancel_lru_locks osc
7676 time ls -l $DIR/$tdir | wc -l
7678 delta=$((etime - stime))
7679 log "ls $i files again without statahead: $delta sec"
7680 lctl set_param llite.*.statahead_max=$max
7681 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7682 if [ $SLOWOK -eq 0 ]; then
7683 error "ls $i files is slower with statahead!"
7685 log "ls $i files is slower with statahead!"
7691 [ $delta -gt 20 ] && break
7692 [ $delta -gt 8 ] && MULT=$((50 / delta))
7693 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7701 delta=$((etime - stime))
7702 log "rm -r $DIR/$tdir/: $delta seconds"
7704 lctl get_param -n llite.*.statahead_stats
7706 run_test 123a "verify statahead work"
7708 test_123b () { # statahead(bug 15027)
7709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7710 test_mkdir -p $DIR/$tdir
7711 createmany -o $DIR/$tdir/$tfile-%d 1000
7713 cancel_lru_locks mdc
7714 cancel_lru_locks osc
7716 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7717 lctl set_param fail_loc=0x80000803
7718 ls -lR $DIR/$tdir > /dev/null
7720 lctl set_param fail_loc=0x0
7721 lctl get_param -n llite.*.statahead_stats
7726 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7730 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7731 skip "no lru resize on server" && return 0
7733 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7735 log "create $NR files at $DIR/$tdir"
7736 createmany -o $DIR/$tdir/f $NR ||
7737 error "failed to create $NR files in $DIR/$tdir"
7739 cancel_lru_locks mdc
7740 ls -l $DIR/$tdir > /dev/null
7744 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7745 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7746 LRU_SIZE=$(lctl get_param -n $PARAM)
7747 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7748 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7750 log "NS=$(basename $NSDIR)"
7755 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7756 skip "Not enough cached locks created!"
7763 # We know that lru resize allows one client to hold $LIMIT locks
7764 # for 10h. After that locks begin to be killed by client.
7766 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7769 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7770 # killing locks. Some time was spent for creating locks. This means
7771 # that up to the moment of sleep finish we must have killed some of
7772 # them (10-100 locks). This depends on how fast ther were created.
7773 # Many of them were touched in almost the same moment and thus will
7774 # be killed in groups.
7775 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7777 # Use $LRU_SIZE_B here to take into account real number of locks
7778 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7779 local LRU_SIZE_B=$LRU_SIZE
7781 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7782 log "OLD_LVF=$OLD_LVF"
7783 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7785 # Let's make sure that we really have some margin. Client checks
7786 # cached locks every 10 sec.
7788 log "Sleep ${SLEEP} sec"
7790 while ((SEC<$SLEEP)); do
7794 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7798 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7799 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7801 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7802 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7803 unlinkmany $DIR/$tdir/f $NR
7807 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7808 log "unlink $NR files at $DIR/$tdir"
7809 unlinkmany $DIR/$tdir/f $NR
7811 run_test 124a "lru resize ======================================="
7813 get_max_pool_limit()
7815 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7818 if test $l -gt $max; then
7826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7827 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7828 skip "no lru resize on server" && return 0
7830 LIMIT=`get_max_pool_limit`
7832 NR=$(($(default_lru_size)*20))
7833 if [ $NR -gt $LIMIT ]; then
7834 log "Limit lock number by $LIMIT locks"
7837 lru_resize_disable mdc
7838 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7839 error "failed to create $DIR/$tdir/disable_lru_resize"
7841 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7842 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7843 cancel_lru_locks mdc
7846 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7849 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7852 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7856 nolruresize_delta=$((etime-stime))
7857 log "ls -la time: $nolruresize_delta seconds"
7858 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7859 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7861 lru_resize_enable mdc
7862 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7863 error "failed to create $DIR/$tdir/enable_lru_resize"
7865 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7866 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7867 cancel_lru_locks mdc
7870 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7873 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7876 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7880 lruresize_delta=$((etime-stime))
7881 log "ls -la time: $lruresize_delta seconds"
7882 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7884 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7885 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7886 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7887 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7889 log "lru resize performs the same with no lru resize"
7891 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7893 run_test 124b "lru resize (performance test) ======================="
7895 test_125() { # 13358
7896 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7897 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7898 test_mkdir -p $DIR/d125 || error "mkdir failed"
7899 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7900 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7901 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7903 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7905 test_126() { # bug 12829/13455
7906 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7907 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7908 $GSS && skip "must run as gss disabled" && return
7910 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7911 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7913 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7915 run_test 126 "check that the fsgid provided by the client is taken into account"
7917 test_127a() { # bug 15521
7918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7919 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7920 $LCTL set_param osc.*.stats=0
7921 FSIZE=$((2048 * 1024))
7922 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7923 cancel_lru_locks osc
7924 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7926 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7927 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7928 echo "got $COUNT $NAME"
7929 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7930 eval $NAME=$COUNT || error "Wrong proc format"
7933 read_bytes|write_bytes)
7934 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7935 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7936 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7937 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7938 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7939 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7940 error "sumsquare is too small: $SUMSQ"
7941 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7942 error "sumsquare is too big: $SUMSQ"
7946 done < $DIR/${tfile}.tmp
7948 #check that we actually got some stats
7949 [ "$read_bytes" ] || error "Missing read_bytes stats"
7950 [ "$write_bytes" ] || error "Missing write_bytes stats"
7951 [ "$read_bytes" != 0 ] || error "no read done"
7952 [ "$write_bytes" != 0 ] || error "no write done"
7954 run_test 127a "verify the client stats are sane"
7956 test_127b() { # bug LU-333
7957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7958 $LCTL set_param llite.*.stats=0
7959 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7960 # perform 2 reads and writes so MAX is different from SUM.
7961 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7962 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7963 cancel_lru_locks osc
7964 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7965 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7967 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7968 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7969 echo "got $COUNT $NAME"
7970 eval $NAME=$COUNT || error "Wrong proc format"
7974 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7975 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7976 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7977 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7980 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7981 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7982 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7983 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7987 done < $TMP/${tfile}.tmp
7989 #check that we actually got some stats
7990 [ "$read_bytes" ] || error "Missing read_bytes stats"
7991 [ "$write_bytes" ] || error "Missing write_bytes stats"
7992 [ "$read_bytes" != 0 ] || error "no read done"
7993 [ "$write_bytes" != 0 ] || error "no write done"
7995 run_test 127b "verify the llite client stats are sane"
7997 test_128() { # bug 15212
7999 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8004 result=$(grep error $TMP/$tfile.log)
8006 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8008 run_test 128 "interactive lfs for 2 consecutive find's"
8015 local LDPROC=/proc/fs/ldiskfs
8016 local facets=$(get_facets MDS)
8018 for facet in ${facets//,/ }; do
8019 canondev=$(ldiskfs_canon \
8020 *.$(convert_facet2label $facet).mntdev $facet)
8021 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8022 LDPROC=/sys/fs/ldiskfs
8023 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8029 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8030 skip "Only applicable to ldiskfs-based MDTs"
8033 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8038 test_mkdir -p $DIR/$tdir
8040 # block size of mds1
8041 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8042 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8043 local MAX=$((MDSBLOCKSIZE * 3))
8045 local I=$(stat -c%s "$DIR/$tdir")
8047 local STRIPE_COUNT=1
8048 [ $MDSCOUNT -ge 2 ] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8049 MAX=$((MAX*STRIPE_COUNT))
8050 while [ ! $I -gt $MAX ]; do
8051 $MULTIOP $DIR/$tdir/$J Oc
8053 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8054 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8055 #and EFBIG for previous versions
8056 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8058 echo "return code $rc received as expected"
8059 multiop $DIR/$tdir/$J Oc ||
8060 error_exit "multiop failed w/o dir size limit"
8062 I=$(stat -c%s "$DIR/$tdir")
8064 if [ $(lustre_version_code $SINGLEMDS) -lt \
8065 $(version_code 2.4.51) ]
8067 [ $I -eq $MAX ] && return 0
8069 [ $I -gt $MAX ] && return 0
8071 error_exit "current dir size $I, previous limit $MAX"
8072 elif [ $rc -ne 0 ]; then
8074 error_exit "return code $rc received instead of expected " \
8075 "$EFBIG or $ENOSPC, files in dir $I"
8078 I=$(stat -c%s "$DIR/$tdir")
8082 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8084 run_test 129 "test directory size limit ========================"
8093 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8094 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8097 trap cleanup_130 EXIT RETURN
8099 local fm_file=$DIR/$tfile
8100 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8101 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8102 error "dd failed for $fm_file"
8104 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8105 filefrag -ves $fm_file
8107 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8108 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8109 [ $RC != 0 ] && error "filefrag $fm_file failed"
8111 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8112 grep -v "ext:" | grep -v "found")
8113 lun=$($GETSTRIPE -i $fm_file)
8115 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8118 for line in $filefrag_op
8120 frag_lun=`echo $line | cut -d: -f5`
8121 ext_len=`echo $line | cut -d: -f4`
8122 if (( $frag_lun != $lun )); then
8124 error "FIEMAP on 1-stripe file($fm_file) failed"
8127 (( tot_len += ext_len ))
8130 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8132 error "FIEMAP on 1-stripe file($fm_file) failed;"
8138 echo "FIEMAP on single striped file succeeded"
8140 run_test 130a "FIEMAP (1-stripe file)"
8143 [ "$OSTCOUNT" -lt "2" ] &&
8144 skip_env "skipping FIEMAP on 2-stripe file test" && return
8146 [ "$OSTCOUNT" -ge "10" ] &&
8147 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8149 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8150 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8153 trap cleanup_130 EXIT RETURN
8155 local fm_file=$DIR/$tfile
8156 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8157 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8158 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8160 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8161 error "dd failed on $fm_file"
8163 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8164 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8165 grep -v "ext:" | grep -v "found")
8167 last_lun=$(echo $filefrag_op | cut -d: -f5)
8172 for line in $filefrag_op
8174 frag_lun=`echo $line | cut -d: -f5`
8175 ext_len=`echo $line | cut -d: -f4`
8176 if (( $frag_lun != $last_lun )); then
8177 if (( tot_len != 1024 )); then
8179 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8186 (( tot_len += ext_len ))
8189 if (( num_luns != 2 || tot_len != 1024 )); then
8191 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8197 echo "FIEMAP on 2-stripe file succeeded"
8199 run_test 130b "FIEMAP (2-stripe file)"
8202 [ "$OSTCOUNT" -lt "2" ] &&
8203 skip_env "skipping FIEMAP on 2-stripe file" && return
8205 [ "$OSTCOUNT" -ge "10" ] &&
8206 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8208 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8209 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8212 trap cleanup_130 EXIT RETURN
8214 local fm_file=$DIR/$tfile
8215 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8216 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8217 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8219 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8221 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8222 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8224 last_lun=`echo $filefrag_op | cut -d: -f5`
8229 for line in $filefrag_op
8231 frag_lun=`echo $line | cut -d: -f5`
8232 ext_len=`echo $line | cut -d: -f4`
8233 if (( $frag_lun != $last_lun )); then
8234 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8235 if (( logical != 512 )); then
8237 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8240 if (( tot_len != 512 )); then
8242 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8249 (( tot_len += ext_len ))
8252 if (( num_luns != 2 || tot_len != 512 )); then
8254 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8260 echo "FIEMAP on 2-stripe file with hole succeeded"
8262 run_test 130c "FIEMAP (2-stripe file with hole)"
8265 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8267 [ "$OSTCOUNT" -ge "10" ] &&
8268 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8270 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8271 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8273 trap cleanup_130 EXIT RETURN
8275 local fm_file=$DIR/$tfile
8276 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8277 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8278 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8280 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8281 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8282 error "dd failed on $fm_file"
8284 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8285 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8286 grep -v "ext:" | grep -v "found"`
8288 last_lun=`echo $filefrag_op | cut -d: -f5`
8293 for line in $filefrag_op
8295 frag_lun=`echo $line | cut -d: -f5`
8296 ext_len=`echo $line | cut -d: -f4`
8297 if (( $frag_lun != $last_lun )); then
8298 if (( tot_len != 1024 )); then
8300 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8307 (( tot_len += ext_len ))
8310 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8312 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8318 echo "FIEMAP on N-stripe file succeeded"
8320 run_test 130d "FIEMAP (N-stripe file)"
8323 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8325 [ "$OSTCOUNT" -ge "10" ] &&
8326 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8328 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8329 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8331 trap cleanup_130 EXIT RETURN
8333 local fm_file=$DIR/$tfile
8334 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8335 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8336 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8339 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8340 for ((i = 0; i < $NUM_BLKS; i++))
8342 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8345 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8346 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8348 last_lun=`echo $filefrag_op | cut -d: -f5`
8353 for line in $filefrag_op
8355 frag_lun=`echo $line | cut -d: -f5`
8356 ext_len=`echo $line | cut -d: -f4`
8357 if (( $frag_lun != $last_lun )); then
8358 if (( tot_len != $EXPECTED_LEN )); then
8360 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8367 (( tot_len += ext_len ))
8370 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8372 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8378 echo "FIEMAP with continuation calls succeeded"
8380 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8382 # Test for writev/readv
8384 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8385 error "writev test failed"
8386 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8387 error "readv failed"
8390 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8393 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8394 error "append writev test failed"
8395 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8396 error "append writev test failed"
8399 run_test 131b "test append writev"
8402 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8405 run_test 131c "test read/write on file w/o objects"
8408 rwv -f $DIR/$tfile -w -n 1 1572864
8409 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8410 if [ "$NOB" != 1572864 ]; then
8411 error "Short read filed: read $NOB bytes instead of 1572864"
8415 run_test 131d "test short read"
8418 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8419 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8420 error "read hitting hole failed"
8423 run_test 131e "test read hitting hole"
8428 for node in $(osts_nodes); do
8429 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8430 [ x$gl = x"" ] && gl=0
8431 gl_sum=$((gl_sum + gl))
8441 if [ x$som = x"enabled" ]; then
8442 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8443 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8444 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8446 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8447 MOUNTOPT="$MOUNTOPT,som_preview"
8448 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8451 # do remount to make new mount-conf parameters actual
8458 test_132() { #1028, SOM
8459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8460 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8461 local num=$(get_mds_dir $DIR)
8462 local mymds=mds${num}
8463 local MOUNTOPT_SAVE=$MOUNTOPT
8465 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8466 cancel_lru_locks osc
8468 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8470 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8471 stat $DIR/$tfile >/dev/null
8472 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8473 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8475 som_mode_switch $som1 $gl1 $gl2
8477 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8478 cancel_lru_locks osc
8480 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8481 if [ $som1 == $som2 ]; then
8482 error "som is still "$som2
8483 if [ x$som2 = x"enabled" ]; then
8490 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8491 stat $DIR/$tfile >/dev/null
8492 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8493 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8494 som_mode_switch $som2 $gl1 $gl2
8495 MOUNTOPT=$MOUNTOPT_SAVE
8497 run_test 132 "som avoids glimpse rpc"
8503 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8505 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8507 *) error "Wrong argument $1" ;;
8510 count=`echo $res | awk '{print $2}'`
8511 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8512 # if the argument $3 is zero, it means any stat increment is ok.
8513 if [ $3 -gt 0 ] ; then
8514 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
8519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8520 remote_ost_nodsh && skip "remote OST with nodsh" && return
8521 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8523 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8524 { skip "MDS doesn't support rename stats"; return; }
8525 local testdir=$DIR/${tdir}/stats_testdir
8526 mkdir -p $DIR/${tdir}
8529 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8530 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8532 # verify mdt stats first.
8533 mkdir ${testdir} || error "mkdir failed"
8534 check_stats $SINGLEMDS "mkdir" 1
8535 touch ${testdir}/${tfile} || "touch failed"
8536 check_stats $SINGLEMDS "open" 1
8537 check_stats $SINGLEMDS "close" 1
8538 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8539 check_stats $SINGLEMDS "mknod" 1
8540 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8541 check_stats $SINGLEMDS "unlink" 1
8542 rm -f ${testdir}/${tfile} || error "file remove failed"
8543 check_stats $SINGLEMDS "unlink" 2
8545 # remove working dir and check mdt stats again.
8546 rmdir ${testdir} || error "rmdir failed"
8547 check_stats $SINGLEMDS "rmdir" 1
8549 local testdir1=$DIR/${tdir}/stats_testdir1
8551 mkdir -p ${testdir1}
8552 touch ${testdir1}/test1
8553 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8554 check_stats $SINGLEMDS "crossdir_rename" 1
8556 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8557 check_stats $SINGLEMDS "samedir_rename" 1
8561 run_test 133a "Verifying MDT stats ========================================"
8564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8565 remote_ost_nodsh && skip "remote OST with nodsh" && return
8566 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8567 local testdir=$DIR/${tdir}/stats_testdir
8568 mkdir -p ${testdir} || error "mkdir failed"
8569 touch ${testdir}/${tfile} || "touch failed"
8570 cancel_lru_locks mdc
8573 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8574 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8576 # extra mdt stats verification.
8577 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8578 check_stats $SINGLEMDS "setattr" 1
8579 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8580 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8582 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8583 check_stats $SINGLEMDS "getattr" 1
8585 $LFS df || error "lfs failed"
8586 check_stats $SINGLEMDS "statfs" 1
8590 run_test 133b "Verifying extra MDT stats =================================="
8593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8594 remote_ost_nodsh && skip "remote OST with nodsh" && return
8595 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8596 local testdir=$DIR/${tdir}/stats_testdir
8597 test_mkdir -p ${testdir} || error "mkdir failed"
8599 # verify obdfilter stats.
8600 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8602 cancel_lru_locks osc
8603 wait_delete_completed
8606 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8607 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8609 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8611 cancel_lru_locks osc
8612 check_stats ost "write" 1
8614 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8615 check_stats ost "read" 1
8617 > ${testdir}/${tfile} || error "truncate failed"
8618 check_stats ost "punch" 1
8620 rm -f ${testdir}/${tfile} || error "file remove failed"
8621 wait_delete_completed
8622 check_stats ost "destroy" 1
8626 run_test 133c "Verifying OST stats ========================================"
8633 while [ $value -ge 2 ]; do
8638 if [ $orig -gt $order ]; then
8646 local size=('K' 'M' 'G' 'T');
8648 local size_string=$value
8650 while [ $value -ge 1024 ]; do
8651 if [ $i -gt 3 ]; then
8652 #T is the biggest unit we get here, if that is bigger,
8654 size_string=${value}T
8657 value=$((value >> 10))
8658 if [ $value -lt 1024 ]; then
8659 size_string=${value}${size[$i]}
8670 local context=${2:-.}
8671 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8673 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8679 remote_ost_nodsh && skip "remote OST with nodsh" && return
8680 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8681 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8682 { skip "MDS doesn't support rename stats"; return; }
8684 local testdir1=$DIR/${tdir}/stats_testdir1
8685 local testdir2=$DIR/${tdir}/stats_testdir2
8687 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8689 mkdir -p ${testdir1} || error "mkdir failed"
8690 mkdir -p ${testdir2} || error "mkdir failed"
8692 createmany -o $testdir1/test 512 || error "createmany failed"
8694 # check samedir rename size
8695 mv ${testdir1}/test0 ${testdir1}/test_0
8697 local testdir1_size=$(ls -l $DIR/${tdir} |
8698 awk '/stats_testdir1/ {print $5}')
8699 local testdir2_size=$(ls -l $DIR/${tdir} |
8700 awk '/stats_testdir2/ {print $5}')
8702 testdir1_size=$(order_2 $testdir1_size)
8703 testdir2_size=$(order_2 $testdir2_size)
8705 testdir1_size=$(size_in_KMGT $testdir1_size)
8706 testdir2_size=$(size_in_KMGT $testdir2_size)
8708 echo "source rename dir size: ${testdir1_size}"
8709 echo "target rename dir size: ${testdir2_size}"
8711 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8712 eval $cmd || error "$cmd failed"
8713 local samedir=$($cmd | grep 'same_dir')
8714 local same_sample=$(get_rename_size $testdir1_size)
8715 [ -z "$samedir" ] && error "samedir_rename_size count error"
8716 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8717 echo "Check same dir rename stats success"
8719 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8721 # check crossdir rename size
8722 mv ${testdir1}/test_0 ${testdir2}/test_0
8724 testdir1_size=$(ls -l $DIR/${tdir} |
8725 awk '/stats_testdir1/ {print $5}')
8726 testdir2_size=$(ls -l $DIR/${tdir} |
8727 awk '/stats_testdir2/ {print $5}')
8729 testdir1_size=$(order_2 $testdir1_size)
8730 testdir2_size=$(order_2 $testdir2_size)
8732 testdir1_size=$(size_in_KMGT $testdir1_size)
8733 testdir2_size=$(size_in_KMGT $testdir2_size)
8735 echo "source rename dir size: ${testdir1_size}"
8736 echo "target rename dir size: ${testdir2_size}"
8738 eval $cmd || error "$cmd failed"
8739 local crossdir=$($cmd | grep 'crossdir')
8740 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8741 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8742 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8743 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8744 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8745 echo "Check cross dir rename stats success"
8748 run_test 133d "Verifying rename_stats ========================================"
8751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8752 local testdir=$DIR/${tdir}/stats_testdir
8753 local ctr f0 f1 bs=32768 count=42 sum
8755 remote_ost_nodsh && skip "remote OST with nodsh" && return
8756 mkdir -p ${testdir} || error "mkdir failed"
8758 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8760 for ctr in {write,read}_bytes; do
8762 cancel_lru_locks osc
8764 do_facet ost1 $LCTL set_param -n \
8765 "obdfilter.*.exports.clear=clear"
8767 if [ $ctr = write_bytes ]; then
8769 f1=${testdir}/${tfile}
8771 f0=${testdir}/${tfile}
8775 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8778 cancel_lru_locks osc
8780 sum=$(do_facet ost1 $LCTL get_param \
8781 "obdfilter.*.exports.*.stats" | \
8784 $1 == ctr { sum += $7 }
8787 if ((sum != bs * count)); then
8788 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8794 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8797 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8800 # First without trusting modes.
8802 -exec cat '{}' \; &> /dev/null
8804 # Second verifying readability.
8808 -exec cat '{}' \; > /dev/null ||
8809 error "proc file read failed"
8811 for facet in $SINGLEMDS ost1; do
8812 do_facet $facet find $proc_dirs \
8813 -not -name req_history \
8814 -exec cat '{}' \\\; &> /dev/null
8816 do_facet $facet find $proc_dirs \
8817 -not -name req_history \
8820 -exec cat '{}' \\\; > /dev/null ||
8821 error "proc file read failed"
8824 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8826 test_140() { #bug-17379
8827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8828 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8829 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8830 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8832 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8833 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8835 while i=`expr $i + 1`; do
8836 test_mkdir -p $i || error "Creating dir $i"
8837 cd $i || error "Changing to $i"
8838 ln -s ../stat stat || error "Creating stat symlink"
8839 # Read the symlink until ELOOP present,
8840 # not LBUGing the system is considered success,
8841 # we didn't overrun the stack.
8842 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8844 if [ $ret -eq 40 ]; then
8847 error "Open stat symlink"
8853 echo "The symlink depth = $i"
8854 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8855 error "Invalid symlink depth"
8857 # Test recursive symlink
8858 ln -s symlink_self symlink_self
8859 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8860 echo "open symlink_self returns $ret"
8861 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8863 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8867 local TF="$TMP/$tfile"
8869 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8871 cancel_lru_locks osc
8872 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8873 remount_client $MOUNT
8875 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8878 $TRUNCATE $DIR/$tfile 6000
8879 cancel_lru_locks osc
8880 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8883 echo "12345" >>$DIR/$tfile
8884 cancel_lru_locks osc
8885 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8888 echo "12345" >>$DIR/$tfile
8889 cancel_lru_locks osc
8890 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8895 run_test 150 "truncate/append tests"
8897 #LU-2902 roc_hit was not able to read all values from lproc
8898 function roc_hit_init() {
8899 local list=$(comma_list $(osts_nodes))
8900 local dir=$DIR/$tdir-check
8901 local file=$dir/file
8907 #use setstripe to do a write to every ost
8908 for i in $(seq 0 $((OSTCOUNT-1))); do
8909 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
8910 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
8911 idx=$(printf %04x $i)
8912 BEFORE=$(get_osd_param $list *OST*$idx stats |
8913 awk '$1 == "cache_access" {sum += $2} END { print sum }')
8914 if [ -z "$BEFORE" ]; then
8918 cancel_lru_locks osc
8919 cat $file >/dev/null
8921 AFTER=$(get_osd_param $list *OST*$idx stats |
8922 awk '$1 == "cache_access" {sum += $2} END { print sum }')
8924 echo BEFORE:$BEFORE AFTER:$AFTER
8925 if ! let "AFTER - BEFORE == 4"; then
8927 error "roc_hit is not safe to use"
8935 function roc_hit() {
8936 local list=$(comma_list $(osts_nodes))
8937 echo $(get_osd_param $list '' stats |
8938 awk '$1 == "cache_hit" {sum += $2} END { print sum }')
8941 function set_cache() {
8944 if [ "$2" == "off" ]; then
8947 local list=$(comma_list $(osts_nodes))
8948 set_osd_param $list '' $1_cache_enable $on
8950 cancel_lru_locks osc
8954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8955 remote_ost_nodsh && skip "remote OST with nodsh" && return
8958 local list=$(comma_list $(osts_nodes))
8960 # check whether obdfilter is cache capable at all
8961 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8962 echo "not cache-capable obdfilter"
8966 # check cache is enabled on all obdfilters
8967 if get_osd_param $list '' read_cache_enable | grep 0; then
8968 echo "oss cache is disabled"
8972 set_osd_param $list '' writethrough_cache_enable 1
8974 # check write cache is enabled on all obdfilters
8975 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
8976 echo "oss write cache is NOT enabled"
8982 #define OBD_FAIL_OBD_NO_LRU 0x609
8983 do_nodes $list $LCTL set_param fail_loc=0x609
8985 # pages should be in the case right after write
8986 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
8989 local BEFORE=$(roc_hit)
8990 cancel_lru_locks osc
8991 cat $DIR/$tfile >/dev/null
8992 local AFTER=$(roc_hit)
8994 do_nodes $list $LCTL set_param fail_loc=0
8996 if ! let "AFTER - BEFORE == CPAGES"; then
8997 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9000 # the following read invalidates the cache
9001 cancel_lru_locks osc
9002 set_osd_param $list '' read_cache_enable 0
9003 cat $DIR/$tfile >/dev/null
9005 # now data shouldn't be found in the cache
9007 cancel_lru_locks osc
9008 cat $DIR/$tfile >/dev/null
9010 if let "AFTER - BEFORE != 0"; then
9011 error "IN CACHE: before: $BEFORE, after: $AFTER"
9014 set_osd_param $list '' read_cache_enable 1
9017 run_test 151 "test cache on oss and controls ==============================="
9020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9021 local TF="$TMP/$tfile"
9023 # simulate ENOMEM during write
9024 #define OBD_FAIL_OST_NOMEM 0x226
9025 lctl set_param fail_loc=0x80000226
9026 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9028 sync || error "sync failed"
9029 lctl set_param fail_loc=0
9031 # discard client's cache
9032 cancel_lru_locks osc
9034 # simulate ENOMEM during read
9035 lctl set_param fail_loc=0x80000226
9036 cmp $TF $DIR/$tfile || error "cmp failed"
9037 lctl set_param fail_loc=0
9041 run_test 152 "test read/write with enomem ============================"
9044 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9046 run_test 153 "test if fdatasync does not crash ======================="
9048 dot_lustre_fid_permission_check() {
9050 local ffid=$MOUNT/.lustre/fid/$fid
9053 echo "stat fid $fid"
9054 stat $ffid > /dev/null || error "stat $ffid failed."
9055 echo "touch fid $fid"
9056 touch $ffid || error "touch $ffid failed."
9057 echo "write to fid $fid"
9058 cat /etc/hosts > $ffid || error "write $ffid failed."
9059 echo "read fid $fid"
9060 diff /etc/hosts $ffid || error "read $ffid failed."
9061 echo "append write to fid $fid"
9062 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9063 echo "rename fid $fid"
9064 mv $ffid $test_dir/$tfile.1 &&
9065 error "rename $ffid to $tfile.1 should fail."
9066 touch $test_dir/$tfile.1
9067 mv $test_dir/$tfile.1 $ffid &&
9068 error "rename $tfile.1 to $ffid should fail."
9069 rm -f $test_dir/$tfile.1
9070 echo "truncate fid $fid"
9071 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9072 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9073 echo "link fid $fid"
9074 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9076 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9077 echo "setfacl fid $fid"
9078 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9079 echo "getfacl fid $fid"
9080 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9082 echo "unlink fid $fid"
9083 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9084 echo "mknod fid $fid"
9085 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9087 fid=[0xf00000400:0x1:0x0]
9088 ffid=$MOUNT/.lustre/fid/$fid
9090 echo "stat non-exist fid $fid"
9091 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9092 echo "write to non-exist fid $fid"
9093 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9094 echo "link new fid $fid"
9095 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9097 mkdir -p $test_dir/$tdir
9098 touch $test_dir/$tdir/$tfile
9099 fid=$($LFS path2fid $test_dir/$tdir)
9102 error "error: could not get fid for $test_dir/$dir/$tfile."
9104 ffid=$MOUNT/.lustre/fid/$fid
9107 ls $ffid > /dev/null || error "ls $ffid failed."
9108 echo "touch $fid/$tfile.1"
9109 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9111 echo "touch $MOUNT/.lustre/fid/$tfile"
9112 touch $MOUNT/.lustre/fid/$tfile && \
9113 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9115 echo "setxattr to $MOUNT/.lustre/fid"
9116 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9118 echo "listxattr for $MOUNT/.lustre/fid"
9119 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9121 echo "delxattr from $MOUNT/.lustre/fid"
9122 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9124 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9125 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9126 error "touch invalid fid should fail."
9128 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9129 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9130 error "touch non-normal fid should fail."
9132 echo "rename $tdir to $MOUNT/.lustre/fid"
9133 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9134 error "rename to $MOUNT/.lustre/fid should fail."
9136 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9138 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9139 local new_obf_mode=777
9141 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9142 chmod $new_obf_mode $DIR/.lustre/fid ||
9143 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9145 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9146 [ $obf_mode -eq $new_obf_mode ] ||
9147 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9149 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9150 chmod $old_obf_mode $DIR/.lustre/fid ||
9151 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9154 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9155 fid=$($LFS path2fid $test_dir/$tfile-2)
9156 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9157 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9158 error "create lov data thru .lustre should fail."
9159 echo "cp /etc/passwd $test_dir/$tfile-2"
9160 cp /etc/passwd $test_dir/$tfile-2 ||
9161 error "copy to $test_dir/$tfile-2 failed."
9162 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9163 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9164 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9166 rm -rf $test_dir/tfile.lnk
9167 rm -rf $test_dir/$tfile-2
9171 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9172 skip "Need MDS version at least 2.4.1" && return
9175 local FID=$($LFS path2fid $DIR/$tfile)
9176 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9178 # check that we get the same pathname back
9179 local FOUND=$($LFS fid2path $MOUNT $FID)
9180 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9181 [ "$FOUND" != "$DIR/$tfile" ] &&
9182 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9186 run_test 154A "lfs path2fid and fid2path basic checks"
9189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9190 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9191 { skip "Need MDS version at least 2.2.51"; return 0; }
9193 cp /etc/hosts $DIR/$tfile
9195 fid=$($LFS path2fid $DIR/$tfile)
9197 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9199 dot_lustre_fid_permission_check "$fid" $DIR ||
9200 error "dot lustre permission check $fid failed"
9202 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9204 touch $MOUNT/.lustre/file &&
9205 error "creation is not allowed under .lustre"
9207 mkdir $MOUNT/.lustre/dir &&
9208 error "mkdir is not allowed under .lustre"
9212 run_test 154a "Open-by-FID"
9215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9216 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9217 { skip "Need MDS version at least 2.2.51"; return 0; }
9219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9221 local remote_dir=$DIR/$tdir/remote_dir
9226 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9227 error "create remote directory failed"
9229 cp /etc/hosts $remote_dir/$tfile
9231 fid=$($LFS path2fid $remote_dir/$tfile)
9233 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9235 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9236 error "dot lustre permission check $fid failed"
9239 run_test 154b "Open-by-FID for remote directory"
9242 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9243 skip "Need MDS version at least 2.4.1" && return
9245 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9246 local FID1=$($LFS path2fid $DIR/$tfile.1)
9247 local FID2=$($LFS path2fid $DIR/$tfile.2)
9248 local FID3=$($LFS path2fid $DIR/$tfile.3)
9251 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9252 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9253 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9255 [ "$FID" = "${!want}" ] ||
9256 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9260 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9261 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9262 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9266 run_test 154c "lfs path2fid and fid2path multiple arguments"
9269 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9270 skip "Need MDS version at least 2.5.53" && return
9273 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9277 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9284 fid=$($LFS path2fid $DIR/$tfile)
9287 cmd="exec $fd<$DIR/$tfile"
9289 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9290 echo $fid_list | grep $fid
9293 cmd="exec $fd>/dev/null"
9295 if [ $rc -ne 0 ]; then
9296 error "FID $fid not found in open files list $fid_list"
9299 run_test 154d "Verify open file fid"
9301 test_155_small_load() {
9302 local temp=$TMP/$tfile
9303 local file=$DIR/$tfile
9305 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9306 error "dd of=$temp bs=6096 count=1 failed"
9308 cancel_lru_locks osc
9309 cmp $temp $file || error "$temp $file differ"
9311 $TRUNCATE $temp 6000
9312 $TRUNCATE $file 6000
9313 cmp $temp $file || error "$temp $file differ (truncate1)"
9315 echo "12345" >>$temp
9316 echo "12345" >>$file
9317 cmp $temp $file || error "$temp $file differ (append1)"
9319 echo "12345" >>$temp
9320 echo "12345" >>$file
9321 cmp $temp $file || error "$temp $file differ (append2)"
9327 test_155_big_load() {
9328 remote_ost_nodsh && skip "remote OST with nodsh" && return
9329 local temp=$TMP/$tfile
9330 local file=$DIR/$tfile
9333 local cache_size=$(do_facet ost$((MAXI+1)) \
9334 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9335 local large_file_size=$((cache_size * 2))
9337 echo "OSS cache size: $cache_size KB"
9338 echo "Large file size: $large_file_size KB"
9340 [ $MAXV -le $large_file_size ] && \
9341 skip_env "max available OST size needs > $large_file_size KB" && \
9344 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9346 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9347 error "dd of=$temp bs=$large_file_size count=1k failed"
9350 cancel_lru_locks osc
9351 cmp $temp $file || error "$temp $file differ"
9358 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9360 set_cache writethrough on
9363 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9368 set_cache writethrough off
9371 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9376 set_cache writethrough on
9379 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9384 set_cache writethrough off
9387 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9392 set_cache writethrough on
9395 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9398 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9400 set_cache writethrough off
9403 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9406 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9408 set_cache writethrough on
9411 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9414 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9416 set_cache writethrough off
9419 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9426 local file="$DIR/$tfile"
9428 [ "$(facet_fstype ost1)" = "zfs" ] &&
9429 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9434 log "Turn on read and write cache"
9436 set_cache writethrough on
9438 log "Write data and read it back."
9439 log "Read should be satisfied from the cache."
9440 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9442 cancel_lru_locks osc
9443 cat $file >/dev/null
9445 if ! let "AFTER - BEFORE == CPAGES"; then
9446 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9448 log "cache hits:: before: $BEFORE, after: $AFTER"
9451 log "Read again; it should be satisfied from the cache."
9453 cancel_lru_locks osc
9454 cat $file >/dev/null
9456 if ! let "AFTER - BEFORE == CPAGES"; then
9457 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9459 log "cache hits:: before: $BEFORE, after: $AFTER"
9463 log "Turn off the read cache and turn on the write cache"
9465 set_cache writethrough on
9467 log "Read again; it should be satisfied from the cache."
9469 cancel_lru_locks osc
9470 cat $file >/dev/null
9472 if ! let "AFTER - BEFORE == CPAGES"; then
9473 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9475 log "cache hits:: before: $BEFORE, after: $AFTER"
9478 log "Read again; it should not be satisfied from the cache."
9480 cancel_lru_locks osc
9481 cat $file >/dev/null
9483 if ! let "AFTER - BEFORE == 0"; then
9484 error "IN CACHE: before: $BEFORE, after: $AFTER"
9486 log "cache hits:: before: $BEFORE, after: $AFTER"
9489 log "Write data and read it back."
9490 log "Read should be satisfied from the cache."
9491 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9493 cancel_lru_locks osc
9494 cat $file >/dev/null
9496 if ! let "AFTER - BEFORE == CPAGES"; then
9497 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9499 log "cache hits:: before: $BEFORE, after: $AFTER"
9502 log "Read again; it should not be satisfied from the cache."
9504 cancel_lru_locks osc
9505 cat $file >/dev/null
9507 if ! let "AFTER - BEFORE == 0"; then
9508 error "IN CACHE: before: $BEFORE, after: $AFTER"
9510 log "cache hits:: before: $BEFORE, after: $AFTER"
9514 log "Turn off read and write cache"
9516 set_cache writethrough off
9518 log "Write data and read it back"
9519 log "It should not be satisfied from the cache."
9521 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9522 cancel_lru_locks osc
9524 cat $file >/dev/null
9526 if ! let "AFTER - BEFORE == 0"; then
9527 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9529 log "cache hits:: before: $BEFORE, after: $AFTER"
9532 log "Turn on the read cache and turn off the write cache"
9534 set_cache writethrough off
9536 log "Write data and read it back"
9537 log "It should not be satisfied from the cache."
9539 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9541 cancel_lru_locks osc
9542 cat $file >/dev/null
9544 if ! let "AFTER - BEFORE == 0"; then
9545 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9547 log "cache hits:: before: $BEFORE, after: $AFTER"
9550 log "Read again; it should be satisfied from the cache."
9552 cancel_lru_locks osc
9553 cat $file >/dev/null
9555 if ! let "AFTER - BEFORE == CPAGES"; then
9556 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9558 log "cache hits:: before: $BEFORE, after: $AFTER"
9563 run_test 156 "Verification of tunables ============================"
9567 if [ $MDSCOUNT -gt 1 ]; then
9568 error_ignore bz17935 $*
9576 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9578 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9580 if [ $MASK -eq 1 ]; then
9581 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9583 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9587 changelog_extract_field() {
9593 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9594 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9600 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9601 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9602 { skip "Need MDS version at least 2.2.0"; return; }
9604 local CL_USERS="mdd.$MDT0.changelog_users"
9605 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9606 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9607 echo "Registered as changelog user $USER"
9608 $GET_CL_USERS | grep -q $USER ||
9609 error "User $USER not found in changelog_users"
9612 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9613 touch $DIR/$tdir/pics/2008/zachy/timestamp
9614 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9615 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9616 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9617 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9618 rm $DIR/$tdir/pics/desktop.jpg
9620 $LFS changelog $MDT0 | tail -5
9622 echo "verifying changelog mask"
9623 changelog_chmask "MKDIR"
9624 changelog_chmask "CLOSE"
9626 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9627 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9629 changelog_chmask "MKDIR"
9630 changelog_chmask "CLOSE"
9632 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9633 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9635 $LFS changelog $MDT0
9636 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9637 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9638 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9639 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9642 echo "verifying target fid"
9643 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9644 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9645 [ "$fidc" == "$fidf" ] ||
9646 err17935 "fid in changelog $fidc != file fid $fidf"
9647 echo "verifying parent fid"
9648 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9649 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9650 [ "$fidc" == "$fidf" ] ||
9651 err17935 "pfid in changelog $fidc != dir fid $fidf"
9653 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9654 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9655 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9656 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9657 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9658 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9660 MIN_REC=$($GET_CL_USERS |
9661 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9662 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
9663 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9664 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9665 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9667 # LU-3446 changelog index reset on MDT restart
9668 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9669 CUR_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9670 $LFS changelog_clear $MDT0 $USER 0
9671 stop $SINGLEMDS || error "Fail to stop MDT."
9672 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9673 CUR_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9674 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9675 [ $CUR_REC1 == $CUR_REC2 ] ||
9676 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9678 echo "verifying user deregister"
9679 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9680 $GET_CL_USERS | grep -q $USER &&
9681 error "User $USER still in changelog_users"
9683 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9684 if [ $USERS -eq 0 ]; then
9685 LAST_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9686 touch $DIR/$tdir/chloe
9687 LAST_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9688 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9689 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9691 echo "$USERS other changelog users; can't verify off"
9694 run_test 160a "changelog sanity"
9696 test_160b() { # LU-3587
9697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9698 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9699 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9700 { skip "Need MDS version at least 2.2.0"; return; }
9702 local CL_USERS="mdd.$MDT0.changelog_users"
9703 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9704 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9705 echo "Registered as changelog user $USER"
9706 $GET_CL_USERS | grep -q $USER ||
9707 error "User $USER not found in changelog_users"
9709 local LONGNAME1=$(str_repeat a 255)
9710 local LONGNAME2=$(str_repeat b 255)
9713 echo "creating very long named file"
9714 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9715 echo "moving very long named file"
9716 mv $LONGNAME1 $LONGNAME2
9718 $LFS changelog $MDT0 | grep RENME
9720 echo "deregistering $USER"
9721 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9725 run_test 160b "Verify that very long rename doesn't crash in changelog"
9728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9729 test_mkdir -p -c1 $DIR/$tdir
9730 cp /etc/hosts $DIR/$tdir/$tfile
9731 test_mkdir -c1 $DIR/$tdir/foo1
9732 test_mkdir -c1 $DIR/$tdir/foo2
9733 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9734 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9735 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9736 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9737 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9738 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9739 $LFS fid2path $DIR $FID
9740 err17935 "bad link ea"
9743 rm $DIR/$tdir/foo2/zachary
9745 rm $DIR/$tdir/foo2/thor
9747 rm $DIR/$tdir/$tfile
9749 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9750 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9752 $LFS fid2path $DIR $FID
9753 err17935 "bad link rename"
9755 rm $DIR/$tdir/foo2/maggie
9758 local longname=filename_avg_len_is_thirty_two_
9759 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
9760 error "failed to hardlink many files"
9761 links=$($LFS fid2path $DIR $FID | wc -l)
9762 echo -n "${links}/1000 links in link EA"
9763 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9764 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
9765 error "failed to unlink many hardlinks"
9767 run_test 161a "link ea sanity"
9770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9771 [ $MDSCOUNT -lt 2 ] &&
9772 skip "skipping remote directory test" && return
9774 local remote_dir=$DIR/$tdir/remote_dir
9777 $LFS mkdir -i $MDTIDX $remote_dir ||
9778 error "create remote directory failed"
9780 cp /etc/hosts $remote_dir/$tfile
9781 mkdir -p $remote_dir/foo1
9782 mkdir -p $remote_dir/foo2
9783 ln $remote_dir/$tfile $remote_dir/foo1/sofia
9784 ln $remote_dir/$tfile $remote_dir/foo2/zachary
9785 ln $remote_dir/$tfile $remote_dir/foo1/luna
9786 ln $remote_dir/$tfile $remote_dir/foo2/thor
9788 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
9790 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9791 $LFS fid2path $DIR $FID
9792 err17935 "bad link ea"
9795 rm $remote_dir/foo2/zachary
9797 rm $remote_dir/foo2/thor
9799 rm $remote_dir/$tfile
9801 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
9802 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
9803 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
9804 $LFS fid2path $DIR $FID
9805 err17935 "bad link rename"
9807 rm $remote_dir/foo2/maggie
9810 local longname=filename_avg_len_is_thirty_two_
9811 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
9812 error "failed to hardlink many files"
9813 links=$($LFS fid2path $DIR $FID | wc -l)
9814 echo -n "${links}/1000 links in link EA"
9815 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9816 unlinkmany $remote_dir/foo2/$longname 1000 ||
9817 error "failed to unlink many hardlinks"
9819 run_test 161b "link ea sanity under remote directory"
9822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9823 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
9824 skip "Need MDS version at least 2.1.5" && return
9826 # define CLF_RENAME_LAST 0x0001
9827 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
9828 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9829 changelog_register -n)
9832 touch $DIR/$tdir/foo_161c
9833 touch $DIR/$tdir/bar_161c
9834 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9835 $LFS changelog $MDT0 | grep RENME
9836 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
9838 $LFS changelog_clear $MDT0 $USER 0
9839 if [ x$flags != "x0x1" ]; then
9840 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9842 error "flag $flags is not 0x1"
9844 echo "rename overwrite a target having nlink = 1," \
9845 "changelog record has flags of $flags"
9847 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
9848 touch $DIR/$tdir/foo_161c
9849 touch $DIR/$tdir/bar_161c
9850 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9851 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9852 $LFS changelog $MDT0 | grep RENME
9853 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9854 $LFS changelog_clear $MDT0 $USER 0
9855 if [ x$flags != "x0x0" ]; then
9856 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9858 error "flag $flags is not 0x0"
9860 echo "rename overwrite a target having nlink > 1," \
9861 "changelog record has flags of $flags"
9863 # rename doesn't overwrite a target (changelog flag 0x0)
9864 touch $DIR/$tdir/foo_161c
9865 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
9866 $LFS changelog $MDT0 | grep RENME
9867 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9868 $LFS changelog_clear $MDT0 $USER 0
9869 if [ x$flags != "x0x0" ]; then
9870 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9872 error "flag $flags is not 0x0"
9874 echo "rename doesn't overwrite a target," \
9875 "changelog record has flags of $flags"
9877 # define CLF_UNLINK_LAST 0x0001
9878 # unlink a file having nlink = 1 (changelog flag 0x1)
9879 rm -f $DIR/$tdir/foo2_161c
9880 $LFS changelog $MDT0 | grep UNLNK
9881 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9882 $LFS changelog_clear $MDT0 $USER 0
9883 if [ x$flags != "x0x1" ]; then
9884 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9886 error "flag $flags is not 0x1"
9888 echo "unlink a file having nlink = 1," \
9889 "changelog record has flags of $flags"
9891 # unlink a file having nlink > 1 (changelog flag 0x0)
9892 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9893 rm -f $DIR/$tdir/foobar_161c
9894 $LFS changelog $MDT0 | grep UNLNK
9895 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9896 $LFS changelog_clear $MDT0 $USER 0
9897 if [ x$flags != "x0x0" ]; then
9898 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9900 error "flag $flags is not 0x0"
9902 echo "unlink a file having nlink > 1," \
9903 "changelog record has flags of $flags"
9904 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9906 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
9913 local path=$(${LFS} fid2path $*)
9916 if [ $RC -ne 0 ]; then
9917 err17935 "path looked up of $expected failed. Error $RC"
9919 elif [ "${path}" != "${expected}" ]; then
9920 err17935 "path looked up \"${path}\" instead of \"${expected}\""
9923 echo "fid $fid resolves to path $path (expected $expected)"
9927 # Make changes to filesystem
9928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9929 test_mkdir -p $DIR/$tdir/d2
9930 touch $DIR/$tdir/d2/$tfile
9931 touch $DIR/$tdir/d2/x1
9932 touch $DIR/$tdir/d2/x2
9933 test_mkdir -p $DIR/$tdir/d2/a/b/c
9934 test_mkdir -p $DIR/$tdir/d2/p/q/r
9936 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
9937 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
9940 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
9941 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
9942 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
9944 # softlink to wrong file
9945 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
9946 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
9947 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
9950 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
9951 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
9952 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
9953 # fid2path dir/fsname should both work
9954 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
9955 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
9957 # hardlink count: check that there are 2 links
9958 # Doesnt work with CMD yet: 17935
9959 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
9960 err17935 "expected 2 links"
9962 # hardlink indexing: remove the first link
9963 rm $DIR/$tdir/d2/p/q/r/hlink
9964 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9968 run_test 162 "path lookup sanity"
9971 # do directio so as not to populate the page cache
9972 log "creating a 10 Mb file"
9973 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9974 log "starting reads"
9975 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9976 log "truncating the file"
9977 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9979 kill %+ || true # reads might have finished
9980 echo "wait until dd is finished"
9982 log "removing the temporary file"
9983 rm -rf $DIR/$tfile || error "tmp file removal failed"
9985 run_test 169 "parallel read and truncate should not deadlock"
9988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9989 $LCTL clear # bug 18514
9990 $LCTL debug_daemon start $TMP/${tfile}_log_good
9992 $LCTL debug_daemon stop
9993 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9994 error "sed failed to read log_good"
9996 $LCTL debug_daemon start $TMP/${tfile}_log_good
9998 $LCTL debug_daemon stop
10000 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10001 error "lctl df log_bad failed"
10003 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10004 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10006 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10007 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10009 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10010 error "bad_line good_line1 good_line2 are empty"
10012 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10013 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10014 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10016 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10017 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10018 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10020 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10021 error "bad_line_new good_line_new are empty"
10023 local expected_good=$((good_line1 + good_line2*2))
10025 rm -f $TMP/${tfile}*
10026 # LU-231, short malformed line may not be counted into bad lines
10027 if [ $bad_line -ne $bad_line_new ] &&
10028 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10029 error "expected $bad_line bad lines, but got $bad_line_new"
10033 if [ $expected_good -ne $good_line_new ]; then
10034 error "expected $expected_good good lines, but got $good_line_new"
10039 run_test 170 "test lctl df to handle corrupted log ====================="
10041 test_171() { # bug20592
10042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10043 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10044 $LCTL set_param fail_loc=0x50e
10045 $LCTL set_param fail_val=3000
10046 multiop_bg_pause $DIR/$tfile O_s || true
10048 kill -USR1 $MULTIPID
10052 if dmesg | grep "recursive fault"; then
10053 error "caught a recursive fault"
10055 $LCTL set_param fail_loc=0
10058 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10060 # it would be good to share it with obdfilter-survey/libecho code
10061 setup_obdecho_osc () {
10064 local obdfilter_name=$2
10065 echo "Creating new osc for $obdfilter_name on $ost_nid"
10066 # make sure we can find loopback nid
10067 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10069 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10070 ${obdfilter_name}_osc_UUID || rc=2; }
10071 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10072 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10076 cleanup_obdecho_osc () {
10077 local obdfilter_name=$1
10078 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10079 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10086 local pages=${3:-64}
10091 local obd_size=$(get_obd_size $node $OBD)
10092 local page_size=$(get_page_size $node)
10093 if [[ -n "$obd_size" ]]; then
10094 local new_count=$((obd_size / (pages * page_size / 1024)))
10095 [[ $new_count -ge $count ]] || count=$new_count
10098 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10099 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10101 if [ $rc -eq 0 ]; then
10102 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10103 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10105 echo "New object id is $id"
10106 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10108 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10109 "test_brw $count w v $pages $id" || rc=4; }
10110 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10112 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10113 "cleanup" || rc=5; }
10114 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10115 "detach" || rc=6; }
10116 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10122 remote_ost_nodsh && skip "remote OST with nodsh" && return
10124 local rmmod_local=0
10126 if ! module_loaded obdecho; then
10127 load_module obdecho/obdecho
10131 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10132 local host=$(lctl get_param -n osc.$osc.import |
10133 awk '/current_connection:/ {print $2}' )
10134 local target=$(lctl get_param -n osc.$osc.import |
10135 awk '/target:/ {print $2}' )
10136 target=${target%_UUID}
10138 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10139 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10140 [[ -n $target ]] && cleanup_obdecho_osc $target
10141 [ $rmmod_local -eq 1 ] && rmmod obdecho
10144 run_test 180a "test obdecho on osc"
10147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10148 remote_ost_nodsh && skip "remote OST with nodsh" && return
10150 local rmmod_remote=0
10152 do_facet ost1 "lsmod | grep -q obdecho || " \
10153 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10154 "modprobe obdecho; }" && rmmod_remote=1
10155 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10156 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10157 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10160 run_test 180b "test obdecho directly on obdfilter"
10162 test_180c() { # LU-2598
10163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10164 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10165 skip "Need MDS version at least 2.4.0" && return
10168 local rmmod_remote=false
10169 local pages=16384 # 64MB bulk I/O RPC size
10172 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10173 rmmod_remote=true || error "failed to load module obdecho"
10175 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4}'|head -1)
10176 if [[ -n $target ]]; then
10177 obdecho_test "$target" ost1 "$pages" ||
10178 rc=${PIPESTATUS[0]}
10180 echo "there is no obdfilter target on ost1"
10183 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10186 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10188 test_181() { # bug 22177
10189 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10190 # create enough files to index the directory
10191 createmany -o $DIR/$tdir/foobar 4000
10192 # print attributes for debug purpose
10195 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10197 # remove the files & current working dir
10198 unlinkmany $DIR/$tdir/foobar 4000
10200 kill -USR1 $MULTIPID
10202 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10205 run_test 181 "Test open-unlinked dir ========================"
10208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10209 # disable MDC RPC lock wouldn't crash client
10213 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10214 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10215 $LCTL set_param fail_loc=0x804
10217 for (( i=0; i < $tcount; i++ )) ; do
10218 mkdir $DIR/$tdir/$i
10219 createmany -o $DIR/$tdir/$i/f- $fcount &
10223 for (( i=0; i < $tcount; i++ )) ; do
10224 unlinkmany $DIR/$tdir/$i/f- $fcount &
10230 $LCTL set_param fail_loc=0
10232 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10234 test_183() { # LU-2275
10235 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10236 skip "Need MDS version at least 2.3.56" && return
10238 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10239 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10240 echo aaa > $DIR/$tdir/$tfile
10242 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10243 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10245 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10246 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10248 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10250 # Flush negative dentry cache
10251 touch $DIR/$tdir/$tfile
10253 # We are not checking for any leaked references here, they'll
10254 # become evident next time we do cleanup with module unload.
10257 run_test 183 "No crash or request leak in case of strange dispositions ========"
10259 # test suite 184 is for LU-2016, LU-2017
10261 check_swap_layouts_support && return 0
10263 dir0=$DIR/$tdir/$testnum
10264 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10269 $SETSTRIPE -c1 $file1
10271 $SETSTRIPE -c2 $file2
10273 gen1=$($GETSTRIPE -g $file1)
10274 gen2=$($GETSTRIPE -g $file2)
10276 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10277 gen=$($GETSTRIPE -g $file1)
10278 [[ $gen1 != $gen ]] ||
10279 "Layout generation on $file1 does not change"
10280 gen=$($GETSTRIPE -g $file2)
10281 [[ $gen2 != $gen ]] ||
10282 "Layout generation on $file2 does not change"
10284 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10285 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10287 run_test 184a "Basic layout swap"
10290 check_swap_layouts_support && return 0
10292 dir0=$DIR/$tdir/$testnum
10293 mkdir -p $dir0 || error "creating dir $dir0"
10300 $SETSTRIPE -c1 $file1
10301 $SETSTRIPE -c2 $file2
10302 $SETSTRIPE -c1 $file3
10303 chown $RUNAS_ID $file3
10304 gen1=$($GETSTRIPE -g $file1)
10305 gen2=$($GETSTRIPE -g $file2)
10307 $LFS swap_layouts $dir1 $dir2 &&
10308 error "swap of directories layouts should fail"
10309 $LFS swap_layouts $dir1 $file1 &&
10310 error "swap of directory and file layouts should fail"
10311 $RUNAS $LFS swap_layouts $file1 $file2 &&
10312 error "swap of file we cannot write should fail"
10313 $LFS swap_layouts $file1 $file3 &&
10314 error "swap of file with different owner should fail"
10315 /bin/true # to clear error code
10317 run_test 184b "Forbidden layout swap (will generate errors)"
10320 check_swap_layouts_support && return 0
10322 local dir0=$DIR/$tdir/$testnum
10323 mkdir -p $dir0 || error "creating dir $dir0"
10325 local ref1=$dir0/ref1
10326 local ref2=$dir0/ref2
10327 local file1=$dir0/file1
10328 local file2=$dir0/file2
10329 # create a file large enough for the concurent test
10330 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10331 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10332 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
10335 dd if=$ref1 of=$file1 bs=16k &
10338 # Make sure dd starts to copy file
10339 while [ ! -f $file1 ]; do sleep 0.1; done
10341 $LFS swap_layouts $file1 $file2
10344 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10345 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10347 # how many bytes copied before swapping layout
10348 local copied=`stat -c %s $file2`
10349 local remaining=`stat -c %s $ref1`
10350 remaining=$((remaining - copied))
10351 echo "Copied $copied bytes before swapping layout..."
10353 cmp -n $copied $file1 $ref2 | grep differ &&
10354 error "Content mismatch [0, $copied) of ref2 and file1"
10355 cmp -n $copied $file2 $ref1 ||
10356 error "Content mismatch [0, $copied) of ref1 and file2"
10357 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10358 error "Content mismatch [$copied, EOF) of ref1 and file1"
10361 rm -f $ref1 $ref2 $file1 $file2
10363 run_test 184c "Concurrent write and layout swap"
10366 check_swap_layouts_support && return 0
10368 local file1=$DIR/$tdir/$tfile-1
10369 local file2=$DIR/$tdir/$tfile-2
10370 local file3=$DIR/$tdir/$tfile-3
10374 mkdir -p $DIR/$tdir
10375 touch $file1 || error "create $file1 failed"
10376 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10377 error "create $file2 failed"
10378 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10379 error "create $file3 failed"
10380 lovea1=$($LFS getstripe $file1 | sed 1d)
10382 $LFS swap_layouts $file2 $file3 ||
10383 error "swap $file2 $file3 layouts failed"
10384 $LFS swap_layouts $file1 $file2 ||
10385 error "swap $file1 $file2 layouts failed"
10387 lovea2=$($LFS getstripe $file2 | sed 1d)
10388 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10390 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10391 [ -z $lovea1 ] || error "$file1 shouldn't have lovea"
10393 run_test 184d "allow stripeless layouts swap"
10396 test_185() { # LU-2441
10397 # LU-3553 - no volatile file support in old servers
10398 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10399 { skip "Need MDS version at least 2.3.60"; return 0; }
10401 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10402 touch $DIR/$tdir/spoo
10403 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10404 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10405 error "cannot create/write a volatile file"
10406 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10407 error "FID is still valid after close"
10409 multiop_bg_pause $DIR/$tdir vVw4096_c
10416 # assume that the next FID for this client is sequential, since stdout
10417 # is unfortunately eaten by multiop_bg_pause
10418 local n=$((${fidv[1]} + 1))
10419 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10420 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10421 error "FID is missing before close"
10422 kill -USR1 $multi_pid
10423 # 1 second delay, so if mtime change we will see it
10425 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10426 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10428 run_test 185 "Volatile file support"
10431 local dir0=$DIR/$tdir/$testnum
10432 mkdir -p $dir0 || error "creating dir $dir0"
10434 local file=$dir0/file1
10435 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10436 local dv1=$($LFS data_version $file)
10437 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10438 local dv2=$($LFS data_version $file)
10439 [[ $dv1 != $dv2 ]] ||
10440 error "data version did not change on write $dv1 == $dv2"
10445 run_test 187a "Test data version change"
10448 local dir0=$DIR/$tdir/$testnum
10449 mkdir -p $dir0 || error "creating dir $dir0"
10451 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10452 [[ ${DV[0]} != ${DV[1]} ]] ||
10453 error "data version did not change on write"\
10454 " ${DV[0]} == ${DV[1]}"
10459 run_test 187b "Test data version change on volatile file"
10462 check_file_in_pool()
10467 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10470 for t in $tlist ; do
10471 [ "$i" -eq "$t" ] && continue 2
10474 echo "pool list: $tlist"
10475 echo "striping: $res"
10476 error_noexit "$file not allocated in $pool"
10483 echo "Creating new pool"
10486 create_pool $FSNAME.$pool ||
10487 { error_noexit "No pool created, result code $?"; return 1; }
10488 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10489 { error_noexit "$pool not in lfs pool_list"; return 2; }
10492 pool_add_targets() {
10493 echo "Adding targets to pool"
10499 local list=$(seq $first $step $last)
10501 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10502 do_facet mgs $LCTL pool_add \
10503 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10504 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10505 | sort -u | tr '\n' ' ' " "$t" || {
10506 error_noexit "Add to pool failed"
10509 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10510 local addcount=$(((last - first) / step + 1))
10511 [ $lfscount -eq $addcount ] || {
10512 error_noexit "lfs pool_list bad ost count" \
10513 "$lfscount != $addcount"
10521 echo "Setting pool on directory $tdir"
10523 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10525 error_noexit "Cannot set pool $pool to $tdir"
10532 echo "Checking pool on directory $tdir"
10534 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10535 [ "$res" = "$pool" ] && return 0
10537 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10541 pool_dir_rel_path() {
10542 echo "Testing relative path works well"
10547 mkdir -p $root/$tdir/$tdir
10549 pool_set_dir $pool $tdir || return 1
10550 pool_set_dir $pool ./$tdir || return 2
10551 pool_set_dir $pool ../$tdir || return 3
10552 pool_set_dir $pool ../$tdir/$tdir || return 4
10553 rm -rf $tdir; cd - > /dev/null
10556 pool_alloc_files() {
10557 echo "Checking files allocation from directory pool"
10564 for i in $(seq -w 1 $count)
10566 local file=$tdir/file-$i
10568 check_file_in_pool $file $pool "$tlist" || \
10569 failed=$((failed + 1))
10571 [ "$failed" = 0 ] && return 0
10573 error_noexit "$failed files not allocated in $pool"
10577 pool_create_files() {
10578 echo "Creating files in pool"
10586 for i in $(seq -w 1 $count)
10588 local file=$tdir/spoo-$i
10589 $SETSTRIPE -p $pool $file
10590 check_file_in_pool $file $pool "$tlist" || \
10591 failed=$((failed + 1))
10593 [ "$failed" = 0 ] && return 0
10595 error_noexit "$failed files not allocated in $pool"
10600 echo "Checking 'lfs df' output"
10603 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10605 local res=$($LFS df --pool $FSNAME.$pool |
10607 grep "$FSNAME-OST" |
10609 [ "$res" = "$t" ] && return 0
10611 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10615 pool_file_rel_path() {
10616 echo "Creating files in a pool with relative pathname"
10621 { error_noexit "unable to create $tdir"; return 1 ; }
10622 local file="/..$tdir/$tfile-1"
10623 $SETSTRIPE -p $pool $file ||
10624 { error_noexit "unable to create $file" ; return 2 ; }
10627 $SETSTRIPE -p $pool $tfile-2 || {
10628 error_noexit "unable to create $tfile-2 in $tdir"
10633 pool_remove_first_target() {
10634 echo "Removing first target from a pool"
10637 local pname="lov.$FSNAME-*.pools.$pool"
10638 local t=$($LCTL get_param -n $pname | head -1)
10639 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10640 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10641 error_noexit "$t not removed from $FSNAME.$pool"
10646 pool_remove_all_targets() {
10647 echo "Removing all targets from pool"
10650 local pname="lov.$FSNAME-*.pools.$pool"
10651 for t in $($LCTL get_param -n $pname | sort -u)
10653 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10655 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10656 error_noexit "Pool $FSNAME.$pool cannot be drained"
10659 # striping on an empty/nonexistant pool should fall back
10660 # to "pool of everything"
10662 error_noexit "failed to use fallback striping for empty pool"
10665 # setstripe on an empty pool should fail
10666 $SETSTRIPE -p $pool $file 2>/dev/null && {
10667 error_noexit "expected failure when creating file" \
10675 echo "Destroying pool"
10679 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10682 # striping on an empty/nonexistant pool should fall back
10683 # to "pool of everything"
10685 error_noexit "failed to use fallback striping for missing pool"
10688 # setstripe on an empty pool should fail
10689 $SETSTRIPE -p $pool $file 2>/dev/null && {
10690 error_noexit "expected failure when creating file" \
10691 "with missing pool"
10695 # get param should return err once pool is gone
10696 if wait_update $HOSTNAME "lctl get_param -n \
10697 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10699 remove_pool_from_list $FSNAME.$pool
10702 error_noexit "Pool $FSNAME.$pool is not destroyed"
10707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10708 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10710 local POOL=${POOL:-cea1}
10711 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10712 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10715 local last_ost=$(($OSTCOUNT - 1))
10717 local ost_list=$(seq $first_ost $ost_step $last_ost)
10718 local ost_range="$first_ost $last_ost $ost_step"
10719 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10720 local file_dir=$POOL_ROOT/file_tst
10724 # former test_200a test_200b
10725 pool_add $POOL || { rc=$? ; break; }
10726 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10727 # former test_200c test_200d
10728 mkdir -p $test_path
10729 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10730 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10731 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10732 || { rc=$? ; break; }
10733 # former test_200e test_200f
10734 local files=$((OSTCOUNT*3))
10735 pool_alloc_files $POOL $test_path $files "$ost_list" \
10736 || { rc=$? ; break; }
10737 pool_create_files $POOL $file_dir $files "$ost_list" \
10738 || { rc=$? ; break; }
10739 # former test_200g test_200h
10740 pool_lfs_df $POOL || { rc=$? ; break; }
10741 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10743 # former test_201a test_201b test_201c
10744 pool_remove_first_target $POOL || { rc=$? ; break; }
10746 local f=$test_path/$tfile
10747 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10748 pool_remove $POOL $f || { rc=$? ; break; }
10755 run_test 200 "OST pools"
10757 # usage: default_attr <count | size | offset>
10759 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
10762 # usage: check_default_stripe_attr
10763 check_default_stripe_attr() {
10764 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
10766 --stripe-count|--count)
10767 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
10768 --stripe-size|--size)
10769 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
10770 --stripe-index|--index)
10773 error "unknown getstripe attr '$1'"
10776 [ $ACTUAL != $EXPECTED ] &&
10777 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
10781 test_mkdir -p $DIR/$tdir
10782 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
10784 check_default_stripe_attr --stripe-count
10785 check_default_stripe_attr --stripe-size
10786 check_default_stripe_attr --stripe-index
10790 run_test 204a "Print default stripe attributes ================="
10793 test_mkdir -p $DIR/$tdir
10794 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10796 check_default_stripe_attr --stripe-size
10797 check_default_stripe_attr --stripe-index
10801 run_test 204b "Print default stripe size and offset ==========="
10804 test_mkdir -p $DIR/$tdir
10805 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10807 check_default_stripe_attr --stripe-count
10808 check_default_stripe_attr --stripe-index
10812 run_test 204c "Print default stripe count and offset ==========="
10815 test_mkdir -p $DIR/$tdir
10816 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10818 check_default_stripe_attr --stripe-count
10819 check_default_stripe_attr --stripe-size
10823 run_test 204d "Print default stripe count and size ============="
10826 test_mkdir -p $DIR/$tdir
10827 $SETSTRIPE -d $DIR/$tdir
10829 check_default_stripe_attr --stripe-count --raw
10830 check_default_stripe_attr --stripe-size --raw
10831 check_default_stripe_attr --stripe-index --raw
10835 run_test 204e "Print raw stripe attributes ================="
10838 test_mkdir -p $DIR/$tdir
10839 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10841 check_default_stripe_attr --stripe-size --raw
10842 check_default_stripe_attr --stripe-index --raw
10846 run_test 204f "Print raw stripe size and offset ==========="
10849 test_mkdir -p $DIR/$tdir
10850 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10852 check_default_stripe_attr --stripe-count --raw
10853 check_default_stripe_attr --stripe-index --raw
10857 run_test 204g "Print raw stripe count and offset ==========="
10860 test_mkdir -p $DIR/$tdir
10861 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10863 check_default_stripe_attr --stripe-count --raw
10864 check_default_stripe_attr --stripe-size --raw
10868 run_test 204h "Print raw stripe count and size ============="
10870 # Figure out which job scheduler is being used, if any,
10871 # or use a fake one
10872 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
10873 JOBENV=SLURM_JOB_ID
10874 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
10876 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
10878 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
10879 JOBENV=LOADL_STEP_ID
10880 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
10886 verify_jobstats() {
10890 # clear old jobstats
10891 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
10892 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
10894 # use a new JobID for this test, or we might see an old one
10895 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
10899 log "Using JobID environment variable $JOBENV=$JOBVAL"
10901 if [ $JOBENV = "FAKE_JOBID" ]; then
10902 FAKE_JOBID=$JOBVAL $cmd
10907 if [ "$target" = "mdt" -o "$target" = "both" ]; then
10908 FACET="$SINGLEMDS" # will need to get MDS number for DNE
10909 do_facet $FACET lctl get_param mdt.*.job_stats |
10910 grep $JOBVAL || error "No job stats found on MDT $FACET"
10912 if [ "$target" = "ost" -o "$target" = "both" ]; then
10914 do_facet $FACET lctl get_param obdfilter.*.job_stats |
10915 grep $JOBVAL || error "No job stats found on OST $FACET"
10921 NEW_JOBENV=${1:-$OLD_JOBENV}
10922 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
10923 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
10926 test_205() { # Job stats
10927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10928 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
10929 skip "Server doesn't support jobstats" && return 0
10932 OLD_JOBENV=`$LCTL get_param -n jobid_var`
10933 if [ $OLD_JOBENV != $JOBENV ]; then
10934 jobstats_set $JOBENV
10935 trap jobstats_set EXIT
10939 cmd="mkdir $DIR/$tfile"
10940 verify_jobstats "$cmd" "mdt"
10942 cmd="rm -fr $DIR/$tfile"
10943 verify_jobstats "$cmd" "mdt"
10945 cmd="mknod $DIR/$tfile c 1 3"
10946 verify_jobstats "$cmd" "mdt"
10948 cmd="rm -f $DIR/$tfile"
10949 verify_jobstats "$cmd" "mdt"
10951 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
10952 verify_jobstats "$cmd" "mdt"
10954 cmd="touch $DIR/$tfile"
10955 verify_jobstats "$cmd" "both"
10957 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
10958 verify_jobstats "$cmd" "ost"
10960 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
10961 verify_jobstats "$cmd" "ost"
10963 cmd="$TRUNCATE $DIR/$tfile 0"
10964 verify_jobstats "$cmd" "both"
10966 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
10967 verify_jobstats "$cmd" "mdt"
10970 rm -f $DIR/jobstats_test_rename
10972 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
10974 run_test 205 "Verify job stats"
10976 # LU-1480, LU-1773 and LU-1657
10978 mkdir -p $DIR/$tdir
10979 lfs setstripe -c -1 $DIR/$tdir
10980 #define OBD_FAIL_LOV_INIT 0x1403
10981 $LCTL set_param fail_loc=0xa0001403
10982 $LCTL set_param fail_val=1
10983 touch $DIR/$tdir/$tfile || true
10985 run_test 206 "fail lov_init_raid0() doesn't lbug"
10988 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10989 local fsz=`stat -c %s $DIR/$tfile`
10990 cancel_lru_locks mdc
10992 # do not return layout in getattr intent
10993 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
10994 $LCTL set_param fail_loc=0x170
10995 local sz=`stat -c %s $DIR/$tfile`
10997 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11001 run_test 207a "can refresh layout at glimpse"
11004 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11005 local cksum=`md5sum $DIR/$tfile`
11006 local fsz=`stat -c %s $DIR/$tfile`
11007 cancel_lru_locks mdc
11008 cancel_lru_locks osc
11010 # do not return layout in getattr intent
11011 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11012 $LCTL set_param fail_loc=0x171
11014 # it will refresh layout after the file is opened but before read issues
11015 echo checksum is "$cksum"
11016 echo "$cksum" |md5sum -c --quiet || error "file differs"
11020 run_test 207b "can refresh layout at open"
11023 # FIXME: in this test suite, only RD lease is used. This is okay
11024 # for now as only exclusive open is supported. After generic lease
11025 # is done, this test suite should be revised. - Jinshan
11027 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11028 { skip "Need MDS version at least 2.4.52"; return 0; }
11030 echo "==== test 1: verify get lease work"
11031 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11033 echo "==== test 2: verify lease can be broken by upcoming open"
11034 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11038 $MULTIOP $DIR/$tfile oO_RDONLY:c
11039 kill -USR1 $PID && wait $PID || error "break lease error"
11041 echo "==== test 3: verify lease can't be granted if an open already exists"
11042 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11046 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11047 kill -USR1 $PID && wait $PID || error "open file error"
11049 echo "==== test 4: lease can sustain over recovery"
11050 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11056 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11058 echo "==== test 5: lease broken can't be regained by replay"
11059 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11063 # open file to break lease and then recovery
11064 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11067 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11071 run_test 208 "Exclusive open"
11074 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11075 skip_env "must have disp_stripe" && return
11078 sync; sleep 5; sync;
11080 echo 3 > /proc/sys/vm/drop_caches
11081 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11083 # open/close 500 times
11084 for i in $(seq 500); do
11088 echo 3 > /proc/sys/vm/drop_caches
11089 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11091 echo "before: $req_before, after: $req_after"
11092 [ $((req_after - req_before)) -ge 300 ] &&
11093 error "open/close requests are not freed"
11096 run_test 209 "read-only open/close requests should be freed promptly"
11100 size=$((size % 8192 + 1))
11101 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11102 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11103 rm -f $DIR/f212 $DIR/f212.xyz
11105 run_test 212 "Sendfile test ============================================"
11108 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11109 cancel_lru_locks osc
11110 lctl set_param fail_loc=0x8000040f
11111 # generate a read lock
11112 cat $DIR/$tfile > /dev/null
11113 # write to the file, it will try to cancel the above read lock.
11114 cat /etc/hosts >> $DIR/$tfile
11116 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11118 test_214() { # for bug 20133
11119 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11120 for (( i=0; i < 340; i++ )) ; do
11121 touch $DIR/$tdir/d214c/a$i
11124 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11125 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11126 ls $DIR/d214c || error "ls $DIR/d214c failed"
11127 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11128 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11130 run_test 214 "hash-indexed directory test - bug 20133"
11132 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11133 create_lnet_proc_files() {
11134 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11135 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11137 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11138 rm -f "$TMP/lnet_$1.sys_tmp"
11141 # counterpart of create_lnet_proc_files
11142 remove_lnet_proc_files() {
11143 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11146 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11147 # 3rd arg as regexp for body
11148 check_lnet_proc_stats() {
11149 local l=$(cat "$TMP/lnet_$1" |wc -l)
11150 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11152 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11155 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11156 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11157 # optional and can be regexp for 2nd line (lnet.routes case)
11158 check_lnet_proc_entry() {
11159 local blp=2 # blp stands for 'position of 1st line of body'
11160 [ "$5" = "" ] || blp=3 # lnet.routes case
11162 local l=$(cat "$TMP/lnet_$1" |wc -l)
11163 # subtracting one from $blp because the body can be empty
11164 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11166 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11167 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11169 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11170 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11172 # bail out if any unexpected line happened
11173 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
11174 [ "$?" != 0 ] || error "$2 misformatted"
11177 test_215() { # for bugs 18102, 21079, 21517
11178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11179 local N='(0|[1-9][0-9]*)' # non-negative numeric
11180 local P='[1-9][0-9]*' # positive numeric
11181 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11182 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11183 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11184 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11186 local L1 # regexp for 1st line
11187 local L2 # regexp for 2nd line (optional)
11188 local BR # regexp for the rest (body)
11190 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11191 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11192 create_lnet_proc_files "stats"
11193 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11194 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11195 remove_lnet_proc_files "stats"
11197 # /proc/sys/lnet/routes should look like this:
11198 # Routing disabled/enabled
11199 # net hops priority state router
11200 # where net is a string like tcp0, hops > 0, priority >= 0,
11201 # state is up/down,
11202 # router is a string like 192.168.1.1@tcp2
11203 L1="^Routing (disabled|enabled)$"
11204 L2="^net +hops +priority +state +router$"
11205 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11206 create_lnet_proc_files "routes"
11207 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11208 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11209 remove_lnet_proc_files "routes"
11211 # /proc/sys/lnet/routers should look like this:
11212 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11213 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11214 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11215 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11216 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11217 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11218 create_lnet_proc_files "routers"
11219 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11220 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11221 remove_lnet_proc_files "routers"
11223 # /proc/sys/lnet/peers should look like this:
11224 # nid refs state last max rtr min tx min queue
11225 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11226 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11227 # numeric (0 or >0 or <0), queue >= 0.
11228 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11229 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11230 create_lnet_proc_files "peers"
11231 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11232 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11233 remove_lnet_proc_files "peers"
11235 # /proc/sys/lnet/buffers should look like this:
11236 # pages count credits min
11237 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11238 L1="^pages +count +credits +min$"
11239 BR="^ +$N +$N +$I +$I$"
11240 create_lnet_proc_files "buffers"
11241 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11242 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11243 remove_lnet_proc_files "buffers"
11245 # /proc/sys/lnet/nis should look like this:
11246 # nid status alive refs peer rtr max tx min
11247 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11248 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11249 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11250 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11251 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11252 create_lnet_proc_files "nis"
11253 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11254 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11255 remove_lnet_proc_files "nis"
11257 # can we successfully write to /proc/sys/lnet/stats?
11258 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11259 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11261 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11263 test_216() { # bug 20317
11264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11265 remote_ost_nodsh && skip "remote OST with nodsh" && return
11268 local facets=$(get_facets OST)
11269 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11271 save_lustre_params client "osc.*.contention_seconds" > $p
11272 save_lustre_params $facets \
11273 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11274 save_lustre_params $facets \
11275 "ldlm.namespaces.filter-*.contended_locks" >> $p
11276 save_lustre_params $facets \
11277 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11280 # agressive lockless i/o settings
11281 for node in $(osts_nodes); do
11282 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'
11284 lctl set_param -n osc.*.contention_seconds 60
11286 $DIRECTIO write $DIR/$tfile 0 10 4096
11287 $CHECKSTAT -s 40960 $DIR/$tfile
11289 # disable lockless i/o
11290 for node in $(osts_nodes); do
11291 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'
11293 lctl set_param -n osc.*.contention_seconds 0
11296 dd if=/dev/zero of=$DIR/$tfile count=0
11297 $CHECKSTAT -s 0 $DIR/$tfile
11299 restore_lustre_params <$p
11303 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11305 test_217() { # bug 22430
11306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11310 for node in $(nodes_list); do
11311 nid=$(host_nids_address $node $NETTYPE)
11312 if [[ $nid = *-* ]] ; then
11313 echo "lctl ping $nid@$NETTYPE"
11314 lctl ping $nid@$NETTYPE
11316 echo "skipping $node (no hyphen detected)"
11320 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11323 # do directio so as not to populate the page cache
11324 log "creating a 10 Mb file"
11325 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11326 log "starting reads"
11327 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11328 log "truncating the file"
11329 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11331 kill %+ || true # reads might have finished
11332 echo "wait until dd is finished"
11334 log "removing the temporary file"
11335 rm -rf $DIR/$tfile || error "tmp file removal failed"
11337 run_test 218 "parallel read and truncate should not deadlock ======================="
11340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11341 # write one partial page
11342 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11343 # set no grant so vvp_io_commit_write will do sync write
11344 $LCTL set_param fail_loc=0x411
11345 # write a full page at the end of file
11346 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11348 $LCTL set_param fail_loc=0
11349 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11350 $LCTL set_param fail_loc=0x411
11351 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11354 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11355 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11357 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11359 test_220() { #LU-325
11360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11361 remote_ost_nodsh && skip "remote OST with nodsh" && return
11364 test_mkdir -p $DIR/$tdir
11365 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11366 awk '{print $2}' | sed -e 's/_UUID$//')
11369 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11370 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11371 osc.$mdtosc_proc1.prealloc_last_id)
11372 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11373 osc.$mdtosc_proc1.prealloc_next_id)
11377 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11378 #define OBD_FAIL_OST_ENOINO 0x229
11379 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11380 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11381 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11383 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11385 MDSOBJS=$((last_id - next_id))
11386 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11388 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11389 echo "OST still has $count kbytes free"
11391 echo "create $MDSOBJS files @next_id..."
11392 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11394 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11395 osc.$mdtosc_proc1.prealloc_last_id)
11396 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11397 osc.$mdtosc_proc1.prealloc_next_id)
11399 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11404 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11405 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11407 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11408 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11409 echo "unlink $MDSOBJS files @$next_id..."
11410 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11412 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11415 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11416 dd if=`which date` of=$MOUNT/date oflag=sync
11417 chmod +x $MOUNT/date
11419 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11420 $LCTL set_param fail_loc=0x80001401
11422 $MOUNT/date > /dev/null
11425 run_test 221 "make sure fault and truncate race to not cause OOM"
11428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11430 test_mkdir -p $DIR/$tdir
11431 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11432 createmany -o $DIR/$tdir/$tfile 10
11433 cancel_lru_locks mdc
11434 cancel_lru_locks osc
11435 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11436 $LCTL set_param fail_loc=0x31a
11437 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11438 $LCTL set_param fail_loc=0
11441 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11446 test_mkdir -p $DIR/$tdir
11447 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11448 createmany -o $DIR/$tdir/$tfile 10
11449 cancel_lru_locks mdc
11450 cancel_lru_locks osc
11451 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11452 $LCTL set_param fail_loc=0x31a
11453 rm -r $DIR/$tdir || "AGL for rmdir failed"
11454 $LCTL set_param fail_loc=0
11456 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11461 test_mkdir -p $DIR/$tdir
11462 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11463 createmany -o $DIR/$tdir/$tfile 10
11464 cancel_lru_locks mdc
11465 cancel_lru_locks osc
11466 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11467 $LCTL set_param fail_loc=0x31b
11468 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11469 $LCTL set_param fail_loc=0
11472 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11474 test_224a() { # LU-1039, MRP-303
11475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11476 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11477 $LCTL set_param fail_loc=0x508
11478 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11479 $LCTL set_param fail_loc=0
11482 run_test 224a "Don't panic on bulk IO failure"
11484 test_224b() { # LU-1039, MRP-303
11485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11486 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11487 cancel_lru_locks osc
11488 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11489 $LCTL set_param fail_loc=0x515
11490 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11491 $LCTL set_param fail_loc=0
11494 run_test 224b "Don't panic on bulk IO failure"
11496 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11499 if [ -z ${MDSSURVEY} ]; then
11500 skip_env "mds-survey not found" && return
11503 [ $MDSCOUNT -ge 2 ] &&
11504 skip "skipping now for more than one MDT" && return
11506 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11507 { skip "Need MDS version at least 2.2.51"; return; }
11509 local mds=$(facet_host $SINGLEMDS)
11510 local target=$(do_nodes $mds 'lctl dl' | \
11511 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11513 local cmd1="file_count=1000 thrhi=4"
11514 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11515 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11516 local cmd="$cmd1 $cmd2 $cmd3"
11518 rm -f ${TMP}/mds_survey*
11520 eval $cmd || error "mds-survey with zero-stripe failed"
11521 cat ${TMP}/mds_survey*
11522 rm -f ${TMP}/mds_survey*
11524 run_test 225a "Metadata survey sanity with zero-stripe"
11527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11529 if [ -z ${MDSSURVEY} ]; then
11530 skip_env "mds-survey not found" && return
11532 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11533 { skip "Need MDS version at least 2.2.51"; return; }
11535 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11536 skip_env "Need to mount OST to test" && return
11539 [ $MDSCOUNT -ge 2 ] &&
11540 skip "skipping now for more than one MDT" && return
11541 local mds=$(facet_host $SINGLEMDS)
11542 local target=$(do_nodes $mds 'lctl dl' | \
11543 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11545 local cmd1="file_count=1000 thrhi=4"
11546 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11547 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11548 local cmd="$cmd1 $cmd2 $cmd3"
11550 rm -f ${TMP}/mds_survey*
11552 eval $cmd || error "mds-survey with stripe_count failed"
11553 cat ${TMP}/mds_survey*
11554 rm -f ${TMP}/mds_survey*
11556 run_test 225b "Metadata survey sanity with stripe_count = 1"
11558 mcreate_path2fid () {
11564 local path=$DIR/$tdir/$name
11569 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11570 error "cannot create $desc"
11572 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11574 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11576 fid_path=$($LFS fid2path $MOUNT $fid)
11578 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11580 [ "$path" == "$fid_path" ] ||
11581 error "fid2path returned $fid_path, expected $path"
11583 echo "pass with $path and $fid"
11588 mkdir -p $DIR/$tdir
11590 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11591 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11592 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11593 mcreate_path2fid 0040666 0 0 dir "directory"
11594 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11595 mcreate_path2fid 0100666 0 0 file "regular file"
11596 mcreate_path2fid 0120666 0 0 link "symbolic link"
11597 mcreate_path2fid 0140666 0 0 sock "socket"
11599 run_test 226a "call path2fid and fid2path on files of all type"
11602 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11606 mkdir -p $DIR/$tdir
11607 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11608 error "create remote directory failed"
11609 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11610 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11611 "character special file (null)"
11612 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11613 "character special file (no device)"
11614 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11615 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11616 "block special file (loop)"
11617 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11618 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11619 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11621 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11623 # LU-1299 Executing or running ldd on a truncated executable does not
11624 # cause an out-of-memory condition.
11626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11627 dd if=`which date` of=$MOUNT/date bs=1k count=1
11628 chmod +x $MOUNT/date
11630 $MOUNT/date > /dev/null
11631 ldd $MOUNT/date > /dev/null
11634 run_test 227 "running truncated executable does not cause OOM"
11636 # LU-1512 try to reuse idle OI blocks
11638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11639 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11640 skip "non-ldiskfs backend" && return
11642 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11643 local myDIR=$DIR/$tdir
11646 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11647 $LCTL set_param fail_loc=0x80001002
11648 createmany -o $myDIR/t- 10000
11649 $LCTL set_param fail_loc=0
11650 # The guard is current the largest FID holder
11652 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11654 local IDX=$(($SEQ % 64))
11656 do_facet $SINGLEMDS sync
11657 # Make sure journal flushed.
11659 local blk1=$(do_facet $SINGLEMDS \
11660 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11661 grep Blockcount | awk '{print $4}')
11663 # Remove old files, some OI blocks will become idle.
11664 unlinkmany $myDIR/t- 10000
11665 # Create new files, idle OI blocks should be reused.
11666 createmany -o $myDIR/t- 2000
11667 do_facet $SINGLEMDS sync
11668 # Make sure journal flushed.
11670 local blk2=$(do_facet $SINGLEMDS \
11671 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11672 grep Blockcount | awk '{print $4}')
11674 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11676 run_test 228a "try to reuse idle OI blocks"
11679 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11680 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11681 skip "non-ldiskfs backend" && return
11683 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11684 local myDIR=$DIR/$tdir
11687 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11688 $LCTL set_param fail_loc=0x80001002
11689 createmany -o $myDIR/t- 10000
11690 $LCTL set_param fail_loc=0
11691 # The guard is current the largest FID holder
11693 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11695 local IDX=$(($SEQ % 64))
11697 do_facet $SINGLEMDS sync
11698 # Make sure journal flushed.
11700 local blk1=$(do_facet $SINGLEMDS \
11701 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11702 grep Blockcount | awk '{print $4}')
11704 # Remove old files, some OI blocks will become idle.
11705 unlinkmany $myDIR/t- 10000
11708 stop $SINGLEMDS || error "Fail to stop MDT."
11710 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11712 df $MOUNT || error "Fail to df."
11713 # Create new files, idle OI blocks should be reused.
11714 createmany -o $myDIR/t- 2000
11715 do_facet $SINGLEMDS sync
11716 # Make sure journal flushed.
11718 local blk2=$(do_facet $SINGLEMDS \
11719 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11720 grep Blockcount | awk '{print $4}')
11722 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11724 run_test 228b "idle OI blocks can be reused after MDT restart"
11728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11729 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11730 skip "non-ldiskfs backend" && return
11732 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11733 local myDIR=$DIR/$tdir
11736 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11737 $LCTL set_param fail_loc=0x80001002
11738 # 20000 files can guarantee there are index nodes in the OI file
11739 createmany -o $myDIR/t- 20000
11740 $LCTL set_param fail_loc=0
11741 # The guard is current the largest FID holder
11743 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11745 local IDX=$(($SEQ % 64))
11747 do_facet $SINGLEMDS sync
11748 # Make sure journal flushed.
11750 local blk1=$(do_facet $SINGLEMDS \
11751 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11752 grep Blockcount | awk '{print $4}')
11754 # Remove old files, some OI blocks will become idle.
11755 unlinkmany $myDIR/t- 20000
11757 # The OI file should become empty now
11759 # Create new files, idle OI blocks should be reused.
11760 createmany -o $myDIR/t- 2000
11761 do_facet $SINGLEMDS sync
11762 # Make sure journal flushed.
11764 local blk2=$(do_facet $SINGLEMDS \
11765 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11766 grep Blockcount | awk '{print $4}')
11768 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11770 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
11772 test_229() { # LU-2482, LU-3448
11773 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
11774 skip "No HSM support on MDS of $(get_lustre_version)," \
11775 "need 2.4.53 at least" && return
11776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11777 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
11781 # Create a file with a released layout and stripe count 2.
11782 $MULTIOP $DIR/$tfile H2c ||
11783 error "failed to create file with released layout"
11785 $GETSTRIPE -v $DIR/$tfile
11787 local pattern=$($GETSTRIPE -L $DIR/$tfile)
11788 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
11790 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
11791 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
11792 stat $DIR/$tfile || error "failed to stat released file"
11794 chown $RUNAS_ID $DIR/$tfile ||
11795 error "chown $RUNAS_ID $DIR/$tfile failed"
11797 chgrp $RUNAS_ID $DIR/$tfile ||
11798 error "chgrp $RUNAS_ID $DIR/$tfile failed"
11800 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
11801 rm $DIR/$tfile || error "failed to remove released file"
11803 run_test 229 "getstripe/stat/rm/attr changes work on released files"
11806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11807 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11810 mkdir -p $DIR/$tdir/test_230_local
11811 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
11812 [ $mdt_idx -ne 0 ] &&
11813 error "create local directory on wrong MDT $mdt_idx"
11815 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
11816 error "create remote directory failed"
11817 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
11818 [ $mdt_idx -ne $MDTIDX ] &&
11819 error "create remote directory on wrong MDT $mdt_idx"
11821 createmany -o $DIR/$tdir/test_230/t- 10 ||
11822 error "create files on remote directory failed"
11823 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
11824 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
11825 rm -r $DIR/$tdir || error "unlink remote directory failed"
11827 run_test 230a "Create remote directory and files under the remote directory"
11830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11831 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11838 local migrate_dir=$DIR/$tdir/migrate_dir
11839 local other_dir=$DIR/$tdir/other_dir
11841 mkdir -p $migrate_dir
11842 mkdir -p $other_dir
11843 for ((i=0; i<10; i++)); do
11844 mkdir -p $migrate_dir/dir_${i}
11845 createmany -o $migrate_dir/dir_${i}/f 10 ||
11846 error "create files under remote dir failed $i"
11849 cp /etc/passwd $migrate_dir/$tfile
11850 cp /etc/passwd $other_dir/$tfile
11851 mkdir -p $migrate_dir/dir_default_stripe2
11852 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
11853 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
11855 mkdir -p $other_dir
11856 ln $migrate_dir/$tfile $other_dir/luna
11857 ln $migrate_dir/$tfile $migrate_dir/sofia
11858 ln $other_dir/$tfile $migrate_dir/david
11859 ln -s $migrate_dir/$tfile $other_dir/zachary
11860 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
11861 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
11863 $LFS mv -v -M $MDTIDX $migrate_dir ||
11864 error "migrate remote dir error"
11866 echo "migratate to MDT1, then checking.."
11867 for ((i=0; i<10; i++)); do
11868 for file in $(find $migrate_dir/dir_${i}); do
11869 mdt_index=$($LFS getstripe -M $file)
11870 [ $mdt_index == $MDTIDX ] ||
11871 error "$file is not on MDT${MDTIDX}"
11875 # the multiple link file should still in MDT0
11876 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
11877 [ $mdt_index == 0 ] ||
11878 error "$file is not on MDT${MDTIDX}"
11880 diff /etc/passwd $migrate_dir/$tfile ||
11881 error "$tfile different after migration"
11883 diff /etc/passwd $other_dir/luna ||
11884 error "luna different after migration"
11886 diff /etc/passwd $migrate_dir/sofia ||
11887 error "sofia different after migration"
11889 diff /etc/passwd $migrate_dir/david ||
11890 error "david different after migration"
11892 diff /etc/passwd $other_dir/zachary ||
11893 error "zachary different after migration"
11895 diff /etc/passwd $migrate_dir/${tfile}_ln ||
11896 error "${tfile}_ln different after migration"
11898 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
11899 error "${tfile}_ln_other different after migration"
11901 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
11902 [ $stripe_count = 2 ] ||
11903 error "dir strpe_count $d != 2 after migration."
11905 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
11906 [ $stripe_count = 2 ] ||
11907 error "file strpe_count $d != 2 after migration."
11909 #migrate back to MDT0
11911 $LFS mv -v -M $MDTIDX $migrate_dir ||
11912 error "migrate remote dir error"
11914 echo "migrate back to MDT0, checking.."
11915 for file in $(find $migrate_dir); do
11916 mdt_index=$($LFS getstripe -M $file)
11917 [ $mdt_index == $MDTIDX ] ||
11918 error "$file is not on MDT${MDTIDX}"
11921 diff /etc/passwd ${migrate_dir}/$tfile ||
11922 error "$tfile different after migration"
11924 diff /etc/passwd ${other_dir}/luna ||
11925 error "luna different after migration"
11927 diff /etc/passwd ${migrate_dir}/sofia ||
11928 error "sofia different after migration"
11930 diff /etc/passwd ${other_dir}/zachary ||
11931 error "zachary different after migration"
11933 diff /etc/passwd $migrate_dir/${tfile}_ln ||
11934 error "${tfile}_ln different after migration"
11936 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
11937 error "${tfile}_ln_other different after migration"
11939 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
11940 [ $stripe_count = 2 ] ||
11941 error "dir strpe_count $d != 2 after migration."
11943 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
11944 [ $stripe_count = 2 ] ||
11945 error "file strpe_count $d != 2 after migration."
11947 rm -rf $DIR/$tdir || error "rm dir failed after migration"
11949 run_test 230b "migrate directory"
11952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11953 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11958 #If migrating directory fails in the middle, all entries of
11959 #the directory is still accessiable.
11960 mkdir -p $DIR/$tdir
11962 createmany -o $DIR/$tdir/f 10 ||
11963 error "create files under ${tdir} failed"
11965 #failed after migrating 5 entries
11966 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
11967 do_facet mds1 lctl set_param fail_loc=0x20001801
11968 do_facet mds1 lctl set_param fail_val=5
11969 local t=`ls $DIR/$tdir | wc -l`
11970 $LFS mv -M $MDTIDX $DIR/$tdir &&
11971 error "migrate should failed after 5 entries"
11972 local u=`ls $DIR/$tdir | wc -l`
11973 [ "$u" == "$t" ] || error "$u != $t during migration"
11975 for file in $(find $DIR/$tdir); do
11976 stat $file || error "stat $file failed"
11979 do_facet mds1 lctl set_param fail_loc=0
11980 do_facet mds1 lctl set_param fail_val=0
11982 $LFS mv -M $MDTIDX $DIR/$tdir ||
11983 error "migrate open files should failed with open files"
11985 echo "Finish migration, then checking.."
11986 for file in $(find $DIR/$tdir); do
11987 mdt_index=$($LFS getstripe -M $file)
11988 [ $mdt_index == $MDTIDX ] ||
11989 error "$file is not on MDT${MDTIDX}"
11992 rm -rf $DIR/$tdir || error "rm dir failed after migration"
11994 run_test 230c "check directory accessiblity if migration is failed"
11997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11998 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12004 mkdir -p $DIR/$tdir
12006 for ((i=0; i<100; i++)); do
12007 mkdir -p $DIR/$tdir/dir_${i}
12008 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12009 error "create files under remote dir failed $i"
12012 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12014 echo "Finish migration, then checking.."
12015 for file in $(find $DIR/$tdir); do
12016 mdt_index=$($LFS getstripe -M $file)
12017 [ $mdt_index == $MDTIDX ] ||
12018 error "$file is not on MDT${MDTIDX}"
12021 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12023 run_test 230d "check migrate big directory"
12027 # For simplicity this test assumes that max_pages_per_rpc
12028 # is the same across all OSCs
12029 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
12030 local bulk_size=$((max_pages * 4096))
12032 mkdir -p $DIR/$tdir
12034 # clear the OSC stats
12035 $LCTL set_param osc.*.stats=0 &>/dev/null
12037 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12038 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12039 oflag=direct &>/dev/null || error "dd failed"
12041 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12042 if [ x$nrpcs != "x1" ]; then
12043 error "found $nrpc ost_write RPCs, not 1 as expected"
12046 # Drop the OSC cache, otherwise we will read from it
12047 cancel_lru_locks osc
12049 # clear the OSC stats
12050 $LCTL set_param osc.*.stats=0 &>/dev/null
12052 # Client reads $bulk_size.
12053 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12054 iflag=direct &>/dev/null || error "dd failed"
12056 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12057 if [ x$nrpcs != "x1" ]; then
12058 error "found $nrpc ost_read RPCs, not 1 as expected"
12061 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12064 mkdir -p $DIR/$tdir
12066 for i in {0..1023}; do
12067 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12068 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12069 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12073 run_test 231b "must not assert on fully utilized OST request buffer"
12076 mkdir -p $DIR/$tdir
12077 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12078 $LCTL set_param fail_loc=0x31c
12080 # ignore dd failure
12081 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12083 $LCTL set_param fail_loc=0
12084 umount_client $MOUNT || error "umount failed"
12085 mount_client $MOUNT || error "mount failed"
12087 run_test 232 "failed lock should not block umount"
12090 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12091 { skip "Need MDS version at least 2.3.64"; return; }
12093 local fid=$($LFS path2fid $MOUNT)
12094 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12095 error "cannot access $MOUNT using its FID '$fid'"
12097 run_test 233a "checking that OBF of the FS root succeeds"
12100 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12101 { skip "Need MDS version at least 2.5.90"; return; }
12103 local fid=$($LFS path2fid $MOUNT/.lustre)
12104 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12105 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12107 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12108 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12109 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12111 run_test 233b "checking that OBF of the FS .lustre succeeds"
12114 local p="$TMP/sanityN-$TESTNAME.parameters"
12115 save_lustre_params client "llite.*.xattr_cache" > $p
12116 lctl set_param llite.*.xattr_cache 1 ||
12117 { skip "xattr cache is not supported"; return 0; }
12119 mkdir -p $DIR/$tdir || error "mkdir failed"
12120 touch $DIR/$tdir/$tfile || error "touch failed"
12121 # OBD_FAIL_LLITE_XATTR_ENOMEM
12122 $LCTL set_param fail_loc=0x1405
12123 if [ ! -f /etc/SuSE-release ]; then
12124 # attr pre-2.4.44-7 had a bug with rc
12125 # LU-3703 - SLES clients have older attr
12126 getfattr -n user.attr $DIR/$tdir/$tfile &&
12127 error "getfattr should have failed with ENOMEM"
12129 $LCTL set_param fail_loc=0x0
12132 restore_lustre_params < $p
12135 run_test 234 "xattr cache should not crash on ENOMEM"
12138 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12139 skip "Need MDS version at least 2.4.52" && return
12140 flock_deadlock $DIR/$tfile
12145 124) error "process hangs on a deadlock"
12147 *) error "error executing flock_deadlock $DIR/$tfile"
12151 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12155 check_swap_layouts_support && return 0
12156 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12158 local ref1=/etc/passwd
12159 local ref2=/etc/group
12160 local file1=$DIR/$tdir/f1
12161 local file2=$DIR/$tdir/f2
12163 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12164 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12165 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12166 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12167 local fd=$(free_fd)
12168 local cmd="exec $fd<>$file2"
12171 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12172 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12175 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12180 run_test 236 "Layout swap on open unlinked file"
12182 # test to verify file handle related system calls
12183 # (name_to_handle_at/open_by_handle_at)
12184 # The new system calls are supported in glibc >= 2.14.
12187 echo "Test file_handle syscalls" > $DIR/$tfile
12188 check_fhandle_syscalls $DIR/$tfile ||
12189 error "check_fhandle_syscalls failed"
12191 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12193 test_striped_dir() {
12198 mkdir -p $DIR/$tdir
12199 $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
12200 error "set striped dir error"
12202 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12203 if [ "$stripe_count" != "2" ]; then
12204 error "stripe_count is $stripe_count, expect 2"
12207 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12208 if [ "$stripe_index" != "$mdt_index" ]; then
12209 error "stripe_index is $stripe_index, expect $mdt_index"
12212 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12213 error "nlink error after create striped dir"
12215 mkdir $DIR/$tdir/striped_dir/a
12216 mkdir $DIR/$tdir/striped_dir/b
12218 stat $DIR/$tdir/striped_dir/a ||
12219 error "create dir under striped dir failed"
12220 stat $DIR/$tdir/striped_dir/b ||
12221 error "create dir under striped dir failed"
12223 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12224 error "nlink error after mkdir"
12226 rmdir $DIR/$tdir/striped_dir/a
12227 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12228 error "nlink error after rmdir"
12230 rmdir $DIR/$tdir/striped_dir/b
12231 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12232 error "nlink error after rmdir"
12234 rmdir $DIR/$tdir/striped_dir ||
12235 error "rmdir striped dir error"
12240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12241 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12243 test_striped_dir 0 || error "failed on striped dir on MDT0"
12244 test_striped_dir 1 || error "failed on striped dir on MDT0"
12246 run_test 300a "basic striped dir sanity test"
12249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12250 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12256 test_mkdir $DIR/$tdir || error "mkdir fail"
12257 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12258 error "set striped dir error"
12259 for ((i=0; i<10; i++)); do
12260 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12262 touch $DIR/$tdir/striped_dir/file_$i ||
12263 error "touch error $i"
12264 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12265 [ $mtime1 -eq $mtime2 ] &&
12266 error "mtime not change after create"
12268 rm -f $DIR/$tdir/striped_dir/file_$i ||
12269 error "unlink error $i"
12270 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12271 [ $mtime2 -eq $mtime3 ] &&
12272 error "mtime did not change after unlink"
12276 run_test 300b "check ctime/mtime for striped dir"
12279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12280 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12283 mkdir -p $DIR/$tdir
12284 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12285 error "set striped dir error"
12287 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12288 error "chown striped dir failed"
12290 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12291 error "create 5k files failed"
12293 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12295 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12299 run_test 300c "chown && check ls under striped directory"
12302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12303 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12307 mkdir -p $DIR/$tdir
12308 $SETSTRIPE -c 2 $DIR/$tdir
12310 #local striped directory
12311 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12312 error "set striped dir error"
12313 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12314 error "create 10 files failed"
12316 #remote striped directory
12317 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12318 error "set striped dir error"
12319 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12320 error "create 10 files failed"
12322 for file in $(find $DIR/$tdir); do
12323 stripe_count=$($GETSTRIPE -c $file)
12324 [ $stripe_count -eq 2 ] ||
12325 error "wrong stripe $stripe_count for $file"
12330 run_test 300d "check default stripe under striped directory"
12333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12334 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12338 mkdir -p $DIR/$tdir
12340 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12341 error "set striped dir error"
12343 touch $DIR/$tdir/striped_dir/a
12344 touch $DIR/$tdir/striped_dir/b
12345 touch $DIR/$tdir/striped_dir/c
12347 mkdir $DIR/$tdir/striped_dir/dir_a
12348 mkdir $DIR/$tdir/striped_dir/dir_b
12349 mkdir $DIR/$tdir/striped_dir/dir_c
12351 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12352 error "set striped dir under striped dir error"
12354 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12355 error "set striped dir under striped dir error"
12357 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12358 error "set striped dir under striped dir error"
12360 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12361 error "rename file under striped dir should fail"
12363 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12364 error "rename dir under striped dir should fail"
12366 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12367 error "rename dir under different stripes should fail"
12369 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12370 error "rename file under striped dir should succeed"
12372 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12373 error "rename dir under striped dir should succeed"
12377 run_test 300e "check rename under striped directory"
12380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12381 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12386 mkdir -p $DIR/$tdir
12388 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12389 error "set striped dir error"
12391 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12392 error "set striped dir error"
12394 touch $DIR/$tdir/striped_dir/a
12395 mkdir $DIR/$tdir/striped_dir/dir_a
12396 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12397 error "create striped dir under striped dir fails"
12399 touch $DIR/$tdir/striped_dir1/b
12400 mkdir $DIR/$tdir/striped_dir1/dir_b
12401 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12402 error "create striped dir under striped dir fails"
12404 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12405 error "rename file under different striped dir should fail"
12407 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12408 error "rename dir under different striped dir should fail"
12410 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12411 error "rename striped dir under diff striped dir should fail"
12413 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12414 error "rename file under diff striped dirs fails"
12416 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12417 error "rename dir under diff striped dirs fails"
12421 run_test 300f "check rename cross striped directory"
12424 # tests that do cleanup/setup should be run at the end
12428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12430 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12431 $LCTL set_param fail_loc=0x903
12432 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12433 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12436 FAIL_ON_ERROR=true cleanup
12437 FAIL_ON_ERROR=true setup
12439 run_test 900 "umount should not race with any mgc requeue thread"
12442 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
12443 check_and_cleanup_lustre
12444 if [ "$I_MOUNTED" != "yes" ]; then
12445 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true