2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
19 SRCDIR=$(cd $(dirname $0); echo $PWD)
20 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 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 export MULTIOP=${MULTIOP:-multiop}
34 READS=${READS:-"reads"}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 MEMHOG=${MEMHOG:-memhog}
39 DIRECTIO=${DIRECTIO:-directio}
40 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
41 UMOUNT=${UMOUNT:-"umount -d"}
43 CHECK_GRANT=${CHECK_GRANT:-"yes"}
44 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
45 export PARALLEL=${PARALLEL:-"no"}
47 export NAME=${NAME:-local}
54 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
55 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b 230d"
63 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
64 # bug number for skipped test: LU-4536 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
66 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
73 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
74 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
83 check_swap_layouts_support()
85 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
86 { skip "Does not support layout lock."; return 0; }
90 check_and_setup_lustre
95 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
96 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
97 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
98 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
99 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
100 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
101 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
102 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
104 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
105 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
106 rm -rf $DIR/[Rdfs][0-9]*
108 # $RUNAS_ID may get set incorrectly somewhere else
109 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
111 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
115 if [ "${ONLY}" = "MOUNT" ] ; then
116 echo "Lustre is up, please go on"
120 echo "preparing for tests involving mounts"
121 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
123 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
124 echo # add a newline after mke2fs.
128 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
129 lctl set_param debug=-1 2> /dev/null || true
132 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
134 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
136 run_test 0a "touch; rm ====================="
139 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
140 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
142 run_test 0b "chmod 0755 $DIR ============================="
145 $LCTL get_param mdc.*.import | grep "state: FULL" ||
146 error "import not FULL"
147 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
150 run_test 0c "check import proc ============================="
153 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
154 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
155 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
156 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
159 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
161 run_test 1 "mkdir; remkdir; rmdir =============================="
164 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
165 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
166 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
168 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
170 run_test 2 "mkdir; touch; rmdir; check file ===================="
173 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
174 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
175 touch $DIR/$tdir/$tfile
176 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
178 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
180 run_test 3 "mkdir; touch; rmdir; check dir ====================="
182 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
186 test_mkdir $DIR/$tdir ||
187 error "Create remote directory failed"
189 touch $DIR/$tdir/$tfile ||
190 error "Create file under remote directory failed"
193 error "Expect error removing in-use dir $DIR/$tdir"
195 test -d $DIR/$tdir || error "Remote directory disappeared"
197 rm -rf $DIR/$tdir || error "remove remote dir error"
199 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
202 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
203 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
204 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
205 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
206 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
208 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
211 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
212 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
213 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
214 error "$tfile does not have perm 0666 or UID $UID"
215 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
216 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
217 error "$tfile should be 0666 and owned by UID $UID"
219 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
222 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
224 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
225 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
226 error "$tfile should be owned by UID $RUNAS_ID"
227 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
228 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
229 error "$tfile should be owned by UID $RUNAS_ID"
231 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
234 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
236 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
237 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
238 error "$tfile should be owned by GID $UID"
239 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
240 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
241 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
243 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
246 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
247 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
248 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
249 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
250 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
251 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
252 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
253 error "$tdir/d/subdir should be GID $RUNAS_GID"
255 run_test 6g "Is new dir in sgid dir inheriting group?"
257 test_6h() { # bug 7331
258 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
259 touch $DIR/$tfile || error "touch failed"
260 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
261 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
262 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
263 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
264 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
266 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
269 test_mkdir $DIR/$tdir
270 $MCREATE $DIR/$tdir/$tfile
271 chmod 0666 $DIR/$tdir/$tfile
272 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
273 error "$tdir/$tfile should be mode 0666"
275 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
278 if [ ! -d $DIR/$tdir ]; then
281 $MCREATE $DIR/$tdir/$tfile
282 echo -n foo > $DIR/$tdir/$tfile
283 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
284 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
286 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
289 test_mkdir $DIR/$tdir
290 touch $DIR/$tdir/$tfile
291 chmod 0666 $DIR/$tdir/$tfile
292 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
293 error "$tfile mode not 0666"
295 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
298 test_mkdir $DIR/$tdir
299 test_mkdir $DIR/$tdir/d2
300 test_mkdir $DIR/$tdir/d2/d3
301 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
303 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
306 test_mkdir $DIR/$tdir
307 test_mkdir $DIR/$tdir/d2
308 touch $DIR/$tdir/d2/$tfile
309 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
310 error "$tdir/d2/$tfile not a file"
312 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
315 test_mkdir $DIR/$tdir
316 test_mkdir $DIR/$tdir/d2
317 chmod 0666 $DIR/$tdir/d2
318 chmod 0705 $DIR/$tdir/d2
319 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
320 error "$tdir/d2 mode not 0705"
322 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
325 test_mkdir $DIR/$tdir
326 touch $DIR/$tdir/$tfile
327 chmod 0666 $DIR/$tdir/$tfile
328 chmod 0654 $DIR/$tdir/$tfile
329 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
330 error "$tdir/d2 mode not 0654"
332 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
335 test_mkdir $DIR/$tdir
336 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
338 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
339 error "$tdir/$tfile size not 0 after truncate"
341 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
344 test_mkdir $DIR/$tdir
345 touch $DIR/$tdir/$tfile
347 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
349 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
352 test_mkdir $DIR/$tdir
353 touch $DIR/$tdir/$tfile
354 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
355 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
356 error "$tdir/${tfile_2} not a file after rename"
358 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
361 test_mkdir $DIR/$tdir
362 touch $DIR/$tdir/$tfile
363 rm -rf $DIR/$tdir/$tfile
364 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
366 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
369 test_mkdir -p $DIR/$tdir
370 touch $DIR/$tdir/$tfile
371 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
373 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
374 error "$tdir/l-exist not a symlink"
375 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
376 error "$tdir/l-exist not referencing a file"
377 rm -f $DIR/$tdir/l-exist
378 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
380 run_test 17a "symlinks: create, remove (real) =================="
383 test_mkdir -p $DIR/$tdir
384 ln -s no-such-file $DIR/$tdir/l-dangle
386 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
387 error "$tdir/l-dangle not referencing no-such-file"
388 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
389 error "$tdir/l-dangle not referencing non-existent file"
390 rm -f $DIR/$tdir/l-dangle
391 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
393 run_test 17b "symlinks: create, remove (dangling) =============="
395 test_17c() { # bug 3440 - don't save failed open RPC for replay
396 test_mkdir -p $DIR/$tdir
397 ln -s foo $DIR/$tdir/$tfile
398 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
400 run_test 17c "symlinks: open dangling (should return error) ===="
403 test_mkdir -p $DIR/$tdir
404 ln -s foo $DIR/$tdir/$tfile
405 touch $DIR/$tdir/$tfile || error "creating to new symlink"
407 run_test 17d "symlinks: create dangling ========================"
410 test_mkdir -p $DIR/$tdir
411 local foo=$DIR/$tdir/$tfile
412 ln -s $foo $foo || error "create symlink failed"
413 ls -l $foo || error "ls -l failed"
414 ls $foo && error "ls not failed" || true
416 run_test 17e "symlinks: create recursive symlink (should return error) ===="
419 test_mkdir -p $DIR/$tdir
420 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
421 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
422 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
423 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
424 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
425 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
428 run_test 17f "symlinks: long and very long symlink name ========================"
430 # str_repeat(S, N) generate a string that is string S repeated N times
435 while [ $((n -= 1)) -ge 0 ]; do
441 # Long symlinks and LU-2241
443 test_mkdir -p $DIR/$tdir
444 local TESTS="59 60 61 4094 4095"
446 # Fix for inode size boundary in 2.1.4
447 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
450 # Patch not applied to 2.2 or 2.3 branches
451 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
452 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
455 # skip long symlink name for rhel6.5.
456 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
457 grep -q '6.5' /etc/redhat-release &>/dev/null &&
458 TESTS="59 60 61 4062 4063"
461 local SYMNAME=$(str_repeat 'x' $i)
462 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
463 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
466 run_test 17g "symlinks: really long symlink name and inode boundaries"
468 test_17h() { #bug 17378
469 remote_mds_nodsh && skip "remote MDS with nodsh" && return
470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
472 test_mkdir -p $DIR/$tdir
473 if [[ $MDSCOUNT -gt 1 ]]; then
474 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
478 $SETSTRIPE -c -1 $DIR/$tdir
479 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
480 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
481 touch $DIR/$tdir/$tfile || true
483 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
485 test_17i() { #bug 20018
486 remote_mds_nodsh && skip "remote MDS with nodsh" && return
487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
488 test_mkdir -c1 $DIR/$tdir
489 local foo=$DIR/$tdir/$tfile
491 if [[ $MDSCOUNT -gt 1 ]]; then
492 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
496 ln -s $foo $foo || error "create symlink failed"
497 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
498 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
499 ls -l $foo && error "error not detected"
502 run_test 17i "don't panic on short symlink"
504 test_17k() { #bug 22301
505 [[ -z "$(which rsync 2>/dev/null)" ]] &&
506 skip "no rsync command" && return 0
507 rsync --help | grep -q xattr ||
508 skip_env "$(rsync --version | head -n1) does not support xattrs"
509 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
510 test_mkdir -p $DIR/$tdir
511 test_mkdir -p $DIR/$tdir.new
512 touch $DIR/$tdir/$tfile
513 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
514 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
515 error "rsync failed with xattrs enabled"
517 run_test 17k "symlinks: rsync with xattrs enabled ========================="
519 test_17l() { # LU-279
520 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
521 skip "no getfattr command" && return 0
523 touch $DIR/$tdir/$tfile
524 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
525 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
526 # -h to not follow symlinks. -m '' to list all the xattrs.
527 # grep to remove first line: '# file: $path'.
528 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
530 lgetxattr_size_check $path $xattr ||
531 error "lgetxattr_size_check $path $xattr failed"
535 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
539 local short_sym="0123456789"
540 local WDIR=$DIR/${tdir}m
547 remote_mds_nodsh && skip "remote MDS with nodsh" && return
548 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
549 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
550 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
552 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
553 skip "only for ldiskfs MDT" && return 0
555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
559 # create a long symlink file
560 for ((i = 0; i < 4; ++i)); do
561 long_sym=${long_sym}${long_sym}
564 echo "create 512 short and long symlink files under $WDIR"
565 for ((i = 0; i < 256; ++i)); do
566 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
567 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
573 wait_delete_completed
575 echo "recreate the 512 symlink files with a shorter string"
576 for ((i = 0; i < 512; ++i)); do
577 # rewrite the symlink file with a shorter string
578 ln -sf ${long_sym} $WDIR/long-$i
579 ln -sf ${short_sym} $WDIR/short-$i
582 mds_index=$($LFS getstripe -M $WDIR)
583 mds_index=$((mds_index+1))
584 devname=$(mdsdevname $mds_index)
585 cmd="$E2FSCK -fnvd $devname"
587 echo "stop and checking mds${mds_index}: $cmd"
588 # e2fsck should not return error
590 do_facet mds${mds_index} $cmd || rc=$?
592 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
593 df $MOUNT > /dev/null 2>&1
594 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
595 "short/long symlink MDT: rc=$rc"
598 run_test 17m "run e2fsck against MDT which contains short/long symlink"
600 check_fs_consistency_17n() {
606 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
607 # so it only check MDT1/MDT2 instead of all of MDTs.
608 for mdt_index in $(seq 1 2); do
609 devname=$(mdsdevname $mdt_index)
610 cmd="$E2FSCK -fnvd $devname"
612 echo "stop and checking mds${mdt_index}: $cmd"
613 # e2fsck should not return error
615 do_facet mds${mdt_index} $cmd || rc=$?
617 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
618 error "mount mds${mdt_index} failed"
619 df $MOUNT > /dev/null 2>&1
620 [ $rc -ne 0 ] && break
628 remote_mds_nodsh && skip "remote MDS with nodsh" && return
629 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
630 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
631 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
633 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
634 skip "only for ldiskfs MDT" && return 0
636 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
641 for ((i=0; i<10; i++)); do
642 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
643 error "create remote dir error $i"
644 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
645 error "create files under remote dir failed $i"
648 check_fs_consistency_17n ||
649 error "e2fsck report error after create files under remote dir"
651 for ((i = 0; i < 10; i++)); do
652 rm -rf $DIR/$tdir/remote_dir_${i} ||
653 error "destroy remote dir error $i"
656 check_fs_consistency_17n ||
657 error "e2fsck report error after unlink files under remote dir"
659 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
660 skip "lustre < 2.4.50 does not support migrate mv " && return
662 for ((i = 0; i < 10; i++)); do
663 mkdir -p $DIR/$tdir/remote_dir_${i}
664 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
665 error "create files under remote dir failed $i"
666 $LFS mv --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
667 error "migrate remote dir error $i"
669 check_fs_consistency_17n || error "e2fsck report error after migration"
671 for ((i = 0; i < 10; i++)); do
672 rm -rf $DIR/$tdir/remote_dir_${i} ||
673 error "destroy remote dir error $i"
676 check_fs_consistency_17n || error "e2fsck report error after unlink"
678 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
681 remote_mds_nodsh && skip "remote MDS with nodsh" && return
682 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
683 skip "Need MDS version at least 2.3.64" && return
685 local WDIR=$DIR/${tdir}o
691 mdt_index=$($LFS getstripe -M $WDIR)
692 mdt_index=$((mdt_index+1))
693 mdtdevname=$(mdsdevname $mdt_index)
697 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS ||
698 error "mount mds${mdt_index} failed"
700 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
701 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
702 ls -l $WDIR/$tfile && rc=1
703 do_facet mds${mdt_index} lctl set_param fail_loc=0
704 [[ $rc -ne 0 ]] && error "stat file should fail"
707 run_test 17o "stat file with incompat LMA feature"
710 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
711 ls $DIR || error "Failed to ls $DIR: $?"
713 run_test 18 "touch .../f ; ls ... =============================="
719 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
721 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
724 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
726 run_test 19b "ls -l .../f19 (should return error) =============="
729 [ $RUNAS_ID -eq $UID ] &&
730 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
731 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
733 run_test 19c "$RUNAS touch .../f19 (should return error) =="
736 cat $DIR/f19 && error || true
738 run_test 19d "cat .../f19 (should return error) =============="
750 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
752 run_test 20 "touch .../f ; ls -l ... ==========================="
755 test_mkdir -p $DIR/$tdir
756 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
757 ln -s dangle $DIR/$tdir/link
758 echo foo >> $DIR/$tdir/link
759 cat $DIR/$tdir/dangle
760 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
761 $CHECKSTAT -f -t file $DIR/$tdir/link ||
762 error "$tdir/link not linked to a file"
764 run_test 21 "write to dangling link ============================"
768 test_mkdir -p $DIR/$tdir
769 chown $RUNAS_ID:$RUNAS_GID $WDIR
770 (cd $WDIR || error "cd $WDIR failed";
771 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
773 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
774 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
775 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
777 run_test 22 "unpack tar archive as non-root user ==============="
781 test_mkdir -p $DIR/$tdir
782 local file=$DIR/$tdir/$tfile
784 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
785 openfile -f O_CREAT:O_EXCL $file &&
786 error "$file recreate succeeded" || true
788 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
790 test_23b() { # bug 18988
791 test_mkdir -p $DIR/$tdir
792 local file=$DIR/$tdir/$tfile
795 echo foo > $file || error "write filed"
796 echo bar >> $file || error "append filed"
797 $CHECKSTAT -s 8 $file || error "wrong size"
800 run_test 23b "O_APPEND check =========================="
804 echo '-- same directory rename'
805 test_mkdir $DIR/$tdir
806 touch $DIR/$tdir/$tfile.1
807 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
808 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
810 run_test 24a "rename file to non-existent target"
813 test_mkdir $DIR/$tdir
814 touch $DIR/$tdir/$tfile.{1,2}
815 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
816 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
817 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
819 run_test 24b "rename file to existing target"
822 test_mkdir $DIR/$tdir
823 test_mkdir $DIR/$tdir/d$testnum.1
824 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
825 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
826 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
828 run_test 24c "rename directory to non-existent target"
831 test_mkdir -c1 $DIR/$tdir
832 test_mkdir -c1 $DIR/$tdir/d$testnum.1
833 test_mkdir -c1 $DIR/$tdir/d$testnum.2
834 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
835 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
836 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
838 run_test 24d "rename directory to existing target"
841 echo '-- cross directory renames --'
845 mv $DIR/R5a/f $DIR/R5b/g
846 $CHECKSTAT -a $DIR/R5a/f || error
847 $CHECKSTAT -t file $DIR/R5b/g || error
849 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
854 touch $DIR/R6a/f $DIR/R6b/g
855 mv $DIR/R6a/f $DIR/R6b/g
856 $CHECKSTAT -a $DIR/R6a/f || error
857 $CHECKSTAT -t file $DIR/R6b/g || error
859 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
864 test_mkdir $DIR/R7a/d
865 mv $DIR/R7a/d $DIR/R7b/e
866 $CHECKSTAT -a $DIR/R7a/d || error
867 $CHECKSTAT -t dir $DIR/R7b/e || error
869 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
872 test_mkdir -c1 $DIR/R8a
873 test_mkdir -c1 $DIR/R8b
874 test_mkdir -c1 $DIR/R8a/d
875 test_mkdir -c1 $DIR/R8b/e
876 mrename $DIR/R8a/d $DIR/R8b/e
877 $CHECKSTAT -a $DIR/R8a/d || error
878 $CHECKSTAT -t dir $DIR/R8b/e || error
880 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
883 echo "-- rename error cases"
887 mrename $DIR/R9/f $DIR/R9/a
888 $CHECKSTAT -t file $DIR/R9/f || error
889 $CHECKSTAT -t dir $DIR/R9/a || error
890 $CHECKSTAT -a $DIR/R9/a/f || error
892 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
896 mrename $DIR/R10/f $DIR/R10/g
897 $CHECKSTAT -t dir $DIR/R10 || error
898 $CHECKSTAT -a $DIR/R10/f || error
899 $CHECKSTAT -a $DIR/R10/g || error
901 run_test 24j "source does not exist ============================"
905 test_mkdir $DIR/R11a/d
907 mv $DIR/R11a/f $DIR/R11a/d
908 $CHECKSTAT -a $DIR/R11a/f || error
909 $CHECKSTAT -t file $DIR/R11a/d/f || error
911 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
913 # bug 2429 - rename foo foo foo creates invalid file
916 $MULTIOP $f OcNs || error
918 run_test 24l "Renaming a file to itself ========================"
922 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
923 # on ext3 this does not remove either the source or target files
924 # though the "expected" operation would be to remove the source
925 $CHECKSTAT -t file ${f} || error "${f} missing"
926 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
928 run_test 24m "Renaming a file to a hard link to itself ========="
932 # this stats the old file after it was renamed, so it should fail
936 $CHECKSTAT ${f}.rename
939 run_test 24n "Statting the old file after renaming (Posix rename 2)"
942 test_mkdir -p $DIR/d24o
943 rename_many -s random -v -n 10 $DIR/d24o
945 run_test 24o "rename of files during htree split ==============="
950 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
951 mrename $DIR/R12a $DIR/R12b
952 $CHECKSTAT -a $DIR/R12a || error
953 $CHECKSTAT -t dir $DIR/R12b || error
954 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
955 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
957 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
959 cleanup_multiop_pause() {
965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
968 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
969 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
972 trap cleanup_multiop_pause EXIT
973 mrename $DIR/R13a $DIR/R13b
974 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
975 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
976 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
977 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
978 cleanup_multiop_pause
979 wait $MULTIPID || error "multiop close failed"
981 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
983 test_24r() { #bug 3789
985 test_mkdir $DIR/R14a/b
986 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
987 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
988 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
990 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
994 test_mkdir $DIR/R15a/b
995 test_mkdir $DIR/R15a/b/c
996 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
997 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
998 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1000 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1002 test_mkdir $DIR/R16a
1003 test_mkdir $DIR/R16a/b
1004 test_mkdir $DIR/R16a/b/c
1005 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1006 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1007 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1009 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1011 test_24u() { # bug12192
1012 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1013 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1015 run_test 24u "create stripe file"
1021 simple_cleanup_common() {
1024 wait_delete_completed
1027 max_pages_per_rpc() {
1028 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1032 local NRFILES=100000
1033 local FREE_INODES=$(mdt_free_inodes 0)
1034 [[ $FREE_INODES -lt $NRFILES ]] &&
1035 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1039 trap simple_cleanup_common EXIT
1041 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1042 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1045 createmany -m $DIR/$tdir/$tfile $NRFILES
1047 cancel_lru_locks mdc
1048 lctl set_param mdc.*.stats clear
1050 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1052 # LU-5 large readdir
1053 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1054 # 8 bytes for name(filename is mostly 5 in this test) +
1055 # 8 bytes for luda_type
1056 # take into account of overhead in lu_dirpage header and end mark in
1057 # each page, plus one in RPC_NUM calculation.
1059 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1060 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1061 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1062 awk '/^mds_readpage/ {print $2}')
1063 [[ $mds_readpage -gt $RPC_NUM ]] &&
1064 error "large readdir doesn't take effect"
1066 simple_cleanup_common
1068 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1070 test_24w() { # bug21506
1072 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1073 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1074 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1075 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1076 [[ "$SZ1" -eq "$SZ2" ]] ||
1077 error "Error reading at the end of the file $tfile"
1079 run_test 24w "Reading a file larger than 4Gb"
1082 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1085 local remote_dir=$DIR/$tdir/remote_dir
1088 $LFS mkdir -i $MDTIDX $remote_dir ||
1089 error "create remote directory failed"
1091 mkdir -p $DIR/$tdir/src_dir
1092 touch $DIR/$tdir/src_file
1093 mkdir -p $remote_dir/tgt_dir
1094 touch $remote_dir/tgt_file
1096 mrename $remote_dir $DIR/ &&
1097 error "rename dir cross MDT works!"
1099 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1100 error "rename dir cross MDT works!"
1102 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1103 error "rename file cross MDT works!"
1105 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1106 error "ln file cross MDT should not work!"
1108 rm -rf $DIR/$tdir || error "Can not delete directories"
1110 run_test 24x "cross rename/link should be failed"
1113 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1116 local remote_dir=$DIR/$tdir/remote_dir
1119 $LFS mkdir -i $MDTIDX $remote_dir ||
1120 error "create remote directory failed"
1122 mkdir -p $remote_dir/src_dir
1123 touch $remote_dir/src_file
1124 mkdir -p $remote_dir/tgt_dir
1125 touch $remote_dir/tgt_file
1127 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1128 error "rename subdir in the same remote dir failed!"
1130 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1131 error "rename files in the same remote dir failed!"
1133 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1134 error "link files in the same remote dir failed!"
1136 rm -rf $DIR/$tdir || error "Can not delete directories"
1138 run_test 24y "rename/link on the same dir should succeed"
1141 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1144 local remote_src=$DIR/$tdir/remote_dir
1145 local remote_tgt=$DIR/$tdir/remote_tgt
1148 $LFS mkdir -i $MDTIDX $remote_src ||
1149 error "create remote directory failed"
1151 $LFS mkdir -i $MDTIDX $remote_tgt ||
1152 error "create remote directory failed"
1154 mrename $remote_src $remote_tgt &&
1155 error "rename remote dirs should not work!"
1157 # If target dir does not exists, it should succeed
1159 mrename $remote_src $remote_tgt ||
1160 error "rename remote dirs(tgt dir does not exists) failed!"
1162 rm -rf $DIR/$tdir || error "Can not delete directories"
1164 run_test 24z "rename one remote dir to another remote dir should fail"
1166 test_24A() { # LU-3182
1171 createmany -m $DIR/$tdir/$tfile $NFILES
1172 local t=$(ls $DIR/$tdir | wc -l)
1173 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1174 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1175 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1176 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1179 rm -rf $DIR/$tdir || error "Can not delete directories"
1181 run_test 24A "readdir() returns correct number of entries."
1183 test_24B() { # LU-4805
1184 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1188 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1189 error "create striped dir failed"
1191 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1192 [ $count -eq 2 ] || error "Expected 2, got $count"
1194 touch $DIR/$tdir/striped_dir/a
1196 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1197 [ $count -eq 3 ] || error "Expected 3, got $count"
1199 touch $DIR/$tdir/striped_dir/.f
1201 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1202 [ $count -eq 4 ] || error "Expected 4, got $count"
1204 rm -rf $DIR/$tdir || error "Can not delete directories"
1206 run_test 24B "readdir for striped dir return correct number of entries"
1209 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1215 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1216 error "create striped dir failed"
1218 cd $DIR/$tdir/d0/striped_dir
1220 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1221 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1222 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1224 [ "$d0_ino" = "$parent_ino" ] ||
1225 error ".. wrong, expect $d0_ino, get $parent_ino"
1227 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1228 error "mv striped dir failed"
1230 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1232 [ "$d1_ino" = "$parent_ino" ] ||
1233 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1235 run_test 24C "check .. in striped dir"
1237 test_24D() { # LU-6101
1242 createmany -m $DIR/$tdir/$tfile $NFILES
1243 local t=$(ls $DIR/$tdir | wc -l)
1244 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1245 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1246 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1247 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1250 rm -rf $DIR/$tdir || error "Can not delete directories"
1252 run_test 24D "readdir() returns correct number of entries after cursor reload"
1255 echo '== symlink sanity ============================================='
1259 touch $DIR/s25/foo || error
1261 run_test 25a "create file in symlinked directory ==============="
1264 [ ! -d $DIR/d25 ] && test_25a
1265 $CHECKSTAT -t file $DIR/s25/foo || error
1267 run_test 25b "lookup file in symlinked directory ==============="
1271 test_mkdir $DIR/d26/d26-2
1272 ln -s d26/d26-2 $DIR/s26
1273 touch $DIR/s26/foo || error
1275 run_test 26a "multiple component symlink ======================="
1278 test_mkdir -p $DIR/d26b/d26-2
1279 ln -s d26b/d26-2/foo $DIR/s26-2
1280 touch $DIR/s26-2 || error
1282 run_test 26b "multiple component symlink at end of lookup ======"
1285 test_mkdir $DIR/d26.2
1286 touch $DIR/d26.2/foo
1287 ln -s d26.2 $DIR/s26.2-1
1288 ln -s s26.2-1 $DIR/s26.2-2
1289 ln -s s26.2-2 $DIR/s26.2-3
1290 chmod 0666 $DIR/s26.2-3/foo
1292 run_test 26c "chain of symlinks ================================"
1294 # recursive symlinks (bug 439)
1296 ln -s d26-3/foo $DIR/d26-3
1298 run_test 26d "create multiple component recursive symlink ======"
1301 [ ! -h $DIR/d26-3 ] && test_26d
1304 run_test 26e "unlink multiple component recursive symlink ======"
1306 # recursive symlinks (bug 7022)
1308 test_mkdir -p $DIR/$tdir
1309 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1310 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1311 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1312 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1313 cd $tfile || error "cd $tfile failed"
1314 ln -s .. dotdot || error "ln dotdot failed"
1315 ln -s dotdot/lndir lndir || error "ln lndir failed"
1316 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1317 output=`ls $tfile/$tfile/lndir/bar1`
1318 [ "$output" = bar1 ] && error "unexpected output"
1319 rm -r $tfile || error "rm $tfile failed"
1320 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1322 run_test 26f "rm -r of a directory which has recursive symlink ="
1325 echo '== stripe sanity =============================================='
1326 test_mkdir -p $DIR/d27 || error "mkdir failed"
1328 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1329 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1330 log "== test_27a: write to one stripe file ========================="
1331 cp /etc/hosts $DIR/d27/f0 || error
1333 run_test 27a "one stripe file =================================="
1336 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1337 test_mkdir -p $DIR/d27
1338 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1339 $GETSTRIPE -c $DIR/d27/f01
1340 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1341 error "two-stripe file doesn't have two stripes"
1343 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1345 run_test 27b "create and write to two stripe file"
1348 test_mkdir -p $DIR/d27
1349 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1350 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1351 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1353 run_test 27d "create file with default settings ================"
1356 test_mkdir -p $DIR/d27
1357 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1358 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1359 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1361 run_test 27e "setstripe existing file (should return error) ======"
1364 test_mkdir $DIR/$tdir
1365 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1366 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1367 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1368 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1369 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1370 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1372 run_test 27f "setstripe with bad stripe size (should return error)"
1375 test_mkdir -p $DIR/d27
1376 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1377 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1378 error "$DIR/d27/fnone has object"
1380 run_test 27g "$GETSTRIPE with no objects"
1383 test_mkdir $DIR/$tdir
1384 touch $DIR/$tdir/$tfile || error "touch failed"
1385 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1386 error "missing objects"
1388 run_test 27i "$GETSTRIPE with some objects"
1391 test_mkdir -p $DIR/d27
1392 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1394 run_test 27j "setstripe with bad stripe offset (should return error)"
1396 test_27k() { # bug 2844
1397 test_mkdir -p $DIR/d27
1399 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1400 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1401 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1402 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1403 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1404 dd if=/dev/zero of=$FILE bs=4k count=1
1405 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1406 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1408 run_test 27k "limit i_blksize for broken user apps ============="
1411 test_mkdir -p $DIR/d27
1412 mcreate $DIR/f27l || error "creating file"
1413 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1414 error "setstripe should have failed" || true
1416 run_test 27l "check setstripe permissions (should return error)"
1419 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1421 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1422 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1425 trap simple_cleanup_common EXIT
1426 test_mkdir -p $DIR/$tdir
1427 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1428 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1429 error "dd should fill OST0"
1431 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1433 [ $i -gt 256 ] && break
1436 touch $DIR/$tdir/f27m_$i
1437 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1438 error "OST0 was full but new created file still use it"
1440 touch $DIR/$tdir/f27m_$i
1441 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1442 error "OST0 was full but new created file still use it"
1443 simple_cleanup_common
1445 run_test 27m "create file while OST0 was full =================="
1448 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1452 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1453 # if the OST isn't full anymore.
1455 local OSTIDX=${1:-""}
1457 local list=$(comma_list $(osts_nodes))
1458 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1460 do_nodes $list lctl set_param fail_loc=0
1461 sync # initiate all OST_DESTROYs from MDS to OST
1465 exhaust_precreations() {
1468 local FAILIDX=${3:-$OSTIDX}
1469 local ofacet=ost$((OSTIDX + 1))
1471 test_mkdir -p -c1 $DIR/$tdir
1472 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1473 local mfacet=mds$((mdtidx + 1))
1474 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1476 local OST=$(ostname_from_index $OSTIDX)
1479 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1480 local last_id=$(do_facet $mfacet lctl get_param -n \
1481 osc.$mdtosc_proc1.prealloc_last_id)
1482 local next_id=$(do_facet $mfacet lctl get_param -n \
1483 osc.$mdtosc_proc1.prealloc_next_id)
1485 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1486 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1488 test_mkdir -p $DIR/$tdir/${OST}
1489 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1490 #define OBD_FAIL_OST_ENOSPC 0x215
1491 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1492 echo "Creating to objid $last_id on ost $OST..."
1493 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1494 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1495 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1499 exhaust_all_precreations() {
1501 for (( i=0; i < OSTCOUNT; i++ )) ; do
1502 exhaust_precreations $i $1 -1
1507 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1508 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1509 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1510 remote_ost_nodsh && skip "remote OST with nodsh" && return
1513 rm -f $DIR/$tdir/$tfile
1514 exhaust_precreations 0 0x80000215
1515 $SETSTRIPE -c -1 $DIR/$tdir
1516 touch $DIR/$tdir/$tfile || error
1517 $GETSTRIPE $DIR/$tdir/$tfile
1520 run_test 27n "create file with some full OSTs =================="
1523 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1524 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1525 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1526 remote_ost_nodsh && skip "remote OST with nodsh" && return
1529 rm -f $DIR/$tdir/$tfile
1530 exhaust_all_precreations 0x215
1532 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1537 run_test 27o "create file with all full OSTs (should error) ===="
1540 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1542 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1543 remote_ost_nodsh && skip "remote OST with nodsh" && return
1546 rm -f $DIR/$tdir/$tfile
1547 test_mkdir -p $DIR/$tdir
1549 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1550 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1551 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1553 exhaust_precreations 0 0x80000215
1554 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1555 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1556 $GETSTRIPE $DIR/$tdir/$tfile
1560 run_test 27p "append to a truncated file with some full OSTs ==="
1563 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1566 remote_ost_nodsh && skip "remote OST with nodsh" && return
1569 rm -f $DIR/$tdir/$tfile
1571 test_mkdir -p $DIR/$tdir
1572 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1573 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1574 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1576 exhaust_all_precreations 0x215
1578 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1579 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1583 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1586 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1588 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1589 remote_ost_nodsh && skip "remote OST with nodsh" && return
1592 rm -f $DIR/$tdir/$tfile
1593 exhaust_precreations 0 0x80000215
1595 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1599 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1601 test_27s() { # bug 10725
1602 test_mkdir -p $DIR/$tdir
1603 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1604 local stripe_count=0
1605 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1606 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1607 error "stripe width >= 2^32 succeeded" || true
1610 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1612 test_27t() { # bug 10864
1617 $WLFS getstripe $tfile
1620 run_test 27t "check that utils parse path correctly"
1622 test_27u() { # bug 4900
1623 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1626 local list=$(comma_list $(mdts_nodes))
1628 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1629 do_nodes $list $LCTL set_param fail_loc=0x139
1630 test_mkdir -p $DIR/$tdir
1632 createmany -o $DIR/$tdir/t- 1000
1633 do_nodes $list $LCTL set_param fail_loc=0
1635 TLOG=$DIR/$tfile.getstripe
1636 $GETSTRIPE $DIR/$tdir > $TLOG
1637 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1638 unlinkmany $DIR/$tdir/t- 1000
1639 [[ $OBJS -gt 0 ]] &&
1640 error "$OBJS objects created on OST-0. See $TLOG" || pass
1642 run_test 27u "skip object creation on OSC w/o objects =========="
1644 test_27v() { # bug 4900
1645 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1648 remote_ost_nodsh && skip "remote OST with nodsh" && return
1650 exhaust_all_precreations 0x215
1653 test_mkdir -p $DIR/$tdir
1654 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1656 touch $DIR/$tdir/$tfile
1657 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1659 for (( i=1; i < OSTCOUNT; i++ )); do
1660 do_facet ost$i lctl set_param fail_loc=0x705
1662 local START=`date +%s`
1663 createmany -o $DIR/$tdir/$tfile 32
1665 local FINISH=`date +%s`
1666 local TIMEOUT=`lctl get_param -n timeout`
1667 local PROCESS=$((FINISH - START))
1668 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1669 error "$FINISH - $START >= $TIMEOUT / 2"
1670 sleep $((TIMEOUT / 2 - PROCESS))
1673 run_test 27v "skip object creation on slow OST ================="
1675 test_27w() { # bug 10997
1676 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1677 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1678 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1679 error "stripe size $size != 65536" || true
1680 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1681 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1683 run_test 27w "check $SETSTRIPE -S option"
1686 [[ $OSTCOUNT -lt 2 ]] &&
1687 skip_env "skipping multiple stripe count/offset test" && return
1689 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1690 for i in $(seq 1 $OSTCOUNT); do
1692 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1693 error "setstripe -c $i -i $offset failed"
1694 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1695 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1696 [ $count -ne $i ] && error "stripe count $count != $i" || true
1697 [ $index -ne $offset ] &&
1698 error "stripe offset $index != $offset" || true
1701 run_test 27wa "check $SETSTRIPE -c -i options"
1704 remote_ost_nodsh && skip "remote OST with nodsh" && return
1705 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1707 OFFSET=$(($OSTCOUNT - 1))
1709 local OST=$(ostname_from_index $OSTIDX)
1711 test_mkdir -p $DIR/$tdir
1712 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1713 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1715 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1716 for i in `seq 0 $OFFSET`; do
1717 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1718 error "OST0 was degraded but new created file still use it"
1720 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1722 run_test 27x "create files while OST0 is degraded"
1725 [[ $OSTCOUNT -lt 2 ]] &&
1726 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1727 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1728 remote_ost_nodsh && skip "remote OST with nodsh" && return
1729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1731 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1732 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1733 osc.$mdtosc.prealloc_last_id)
1734 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1735 osc.$mdtosc.prealloc_next_id)
1736 local fcount=$((last_id - next_id))
1737 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1738 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1740 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1741 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1742 local OST_DEACTIVE_IDX=-1
1747 for OSC in $MDS_OSCS; do
1748 OST=$(osc_to_ost $OSC)
1749 OSTIDX=$(index_from_ostuuid $OST)
1750 if [ $OST_DEACTIVE_IDX == -1 ]; then
1751 OST_DEACTIVE_IDX=$OSTIDX
1753 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1754 echo $OSC "is Deactivated:"
1755 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1759 OSTIDX=$(index_from_ostuuid $OST)
1761 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1763 for OSC in $MDS_OSCS; do
1764 OST=$(osc_to_ost $OSC)
1765 OSTIDX=$(index_from_ostuuid $OST)
1766 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1767 echo $OST "is degraded:"
1768 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1769 obdfilter.$OST.degraded=1
1774 createmany -o $DIR/$tdir/$tfile $fcount
1776 for OSC in $MDS_OSCS; do
1777 OST=$(osc_to_ost $OSC)
1778 OSTIDX=$(index_from_ostuuid $OST)
1779 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1780 echo $OST "is recovered from degraded:"
1781 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1782 obdfilter.$OST.degraded=0
1784 do_facet $SINGLEMDS lctl --device %$OSC activate
1788 # all osp devices get activated, hence -1 stripe count restored
1791 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1792 # devices get activated.
1794 $SETSTRIPE -c -1 $DIR/$tfile
1795 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1797 [ $stripecnt -ne $OSTCOUNT ] &&
1798 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1801 run_test 27y "create files while OST0 is degraded and the rest inactive"
1807 lmm_count=$($GETSTRIPE -c $1)
1808 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1809 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1811 local old_ifs="$IFS"
1813 fid=($($LFS path2fid $1))
1816 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1817 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1819 # compare lmm_seq and lu_fid->f_seq
1820 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1821 # compare lmm_object_id and lu_fid->oid
1822 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1824 # check the trusted.fid attribute of the OST objects of the file
1825 local have_obdidx=false
1827 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1828 # skip lines up to and including "obdidx"
1829 [ -z "$obdidx" ] && break
1830 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1831 $have_obdidx || continue
1833 local ost=$((obdidx + 1))
1834 local dev=$(ostdevname $ost)
1837 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1839 seq=$(echo $seq | sed -e "s/^0x//g")
1840 if [ $seq == 0 ]; then
1841 oid_hex=$(echo $oid)
1843 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1845 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1849 # Don't unmount/remount the OSTs if we don't need to do that.
1850 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1851 # update too, until that use mount/ll_decode_filter_fid/mount.
1852 # Re-enable when debugfs will understand new filter_fid.
1854 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1855 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1856 $dev 2>/dev/null" | grep "parent=")
1859 mount_fstype ost$ost
1860 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1861 $(facet_mntpt ost$ost)/$obj_file)
1862 unmount_fstype ost$ost
1863 start ost$ost $dev $OST_MOUNT_OPTS
1866 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1868 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1870 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1871 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1872 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1873 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1874 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1876 if echo $ff_parent | grep -q 'stripe='; then
1877 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1880 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1881 # into f_ver in this case. See the comment on
1884 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1888 # compare lmm_seq and filter_fid->ff_parent.f_seq
1889 [ $ff_pseq = $lmm_seq ] ||
1890 error "FF parent SEQ $ff_pseq != $lmm_seq"
1891 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1892 [ $ff_poid = $lmm_oid ] ||
1893 error "FF parent OID $ff_poid != $lmm_oid"
1894 (($ff_pstripe == $stripe_nr)) ||
1895 error "FF stripe $ff_pstripe != $stripe_nr"
1897 stripe_nr=$((stripe_nr + 1))
1902 remote_ost_nodsh && skip "remote OST with nodsh" && return
1903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1904 test_mkdir -p $DIR/$tdir
1906 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1907 { error "setstripe -c -1 failed"; return 1; }
1908 # We need to send a write to every object to get parent FID info set.
1909 # This _should_ also work for setattr, but does not currently.
1910 # touch $DIR/$tdir/$tfile-1 ||
1911 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1912 { error "dd $tfile-1 failed"; return 2; }
1913 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1914 { error "setstripe -c -1 failed"; return 3; }
1915 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1916 { error "dd $tfile-2 failed"; return 4; }
1918 # make sure write RPCs have been sent to OSTs
1921 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1922 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1924 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1926 test_27A() { # b=19102
1927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1928 local restore_size=$($GETSTRIPE -S $MOUNT)
1929 local restore_count=$($GETSTRIPE -c $MOUNT)
1930 local restore_offset=$($GETSTRIPE -i $MOUNT)
1931 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1932 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1933 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1934 local default_size=$($GETSTRIPE -S $MOUNT)
1935 local default_offset=$($GETSTRIPE -i $MOUNT)
1936 local dsize=$((1024 * 1024))
1937 [ $default_size -eq $dsize ] ||
1938 error "stripe size $default_size != $dsize"
1939 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1940 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1942 run_test 27A "check filesystem-wide default LOV EA values"
1944 test_27B() { # LU-2523
1945 test_mkdir -p $DIR/$tdir
1946 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1948 # open f1 with O_LOV_DELAY_CREATE
1950 # call setstripe ioctl on open file descriptor for f1
1952 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1956 # open f1 with O_LOV_DELAY_CREATE
1958 # call setstripe ioctl on open file descriptor for f1
1960 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1962 # Allow multiop to fail in imitation of NFS's busted semantics.
1965 run_test 27B "call setstripe on open unlinked file/rename victim"
1967 test_27C() { #LU-2871
1968 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1976 test_mkdir -p $DIR/$tdir
1978 for i in $(seq 0 $((OSTCOUNT - 1))); do
1979 # set stripe across all OSTs starting from OST$i
1980 $SETSTRIPE -i $i -c -1 $tfile$i
1981 # get striping information
1982 ost_idx=($($GETSTRIPE $tfile$i |
1983 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1987 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1988 error "${#ost_idx[@]} != $OSTCOUNT"
1990 for index in $(seq 0 $((OSTCOUNT - 1))); do
1992 for j in $(echo ${ost_idx[@]}); do
1993 if [ $index -eq $j ]; then
1999 error "Can not find $index in ${ost_idx[@]}"
2003 run_test 27C "check full striping across all OSTs"
2006 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2007 local POOL=${POOL:-testpool}
2009 local last_ost=$(($OSTCOUNT - 1))
2011 local ost_list=$(seq $first_ost $ost_step $last_ost)
2012 local ost_range="$first_ost $last_ost $ost_step"
2015 pool_add $POOL || error "pool_add failed"
2016 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2017 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2018 error "llapi_layout_test failed"
2019 cleanup_pools || error "cleanup_pools failed"
2021 run_test 27D "validate llapi_layout API"
2023 # Verify that default_easize is increased from its initial value after
2024 # accessing a widely striped file.
2026 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2028 # 72 bytes is the minimum space required to store striping
2029 # information for a file striped across one OST:
2030 # (sizeof(struct lov_user_md_v3) +
2031 # sizeof(struct lov_user_ost_data_v1))
2033 $LCTL set_param -n llite.*.default_easize $min_easize ||
2034 error "lctl set_param failed"
2035 local easize=$($LCTL get_param -n llite.*.default_easize)
2037 [ $easize -eq $min_easize ] ||
2038 error "failed to set default_easize"
2040 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2041 error "setstripe failed"
2045 easize=$($LCTL get_param -n llite.*.default_easize)
2047 [ $easize -gt $min_easize ] ||
2048 error "default_easize not updated"
2050 run_test 27E "check that default extended attribute size properly increases"
2052 # createtest also checks that device nodes are created and
2053 # then visible correctly (#2091)
2054 test_28() { # bug 2091
2056 $CREATETEST $DIR/d28/ct || error
2058 run_test 28 "create/mknod/mkdir with bad file types ============"
2061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2062 cancel_lru_locks mdc
2068 declare -i LOCKCOUNTORIG=0
2069 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2070 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2072 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2074 declare -i LOCKUNUSEDCOUNTORIG=0
2075 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2076 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2083 declare -i LOCKCOUNTCURRENT=0
2084 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2085 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2088 declare -i LOCKUNUSEDCOUNTCURRENT=0
2089 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2090 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2093 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2094 $LCTL set_param -n ldlm.dump_namespaces ""
2095 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2096 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2097 log "dumped log to $TMP/test_29.dk (bug 5793)"
2100 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2101 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2102 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2103 log "dumped log to $TMP/test_29.dk (bug 5793)"
2107 run_test 29 "IT_GETATTR regression ============================"
2109 test_30a() { # was test_30
2110 cp $(which ls) $DIR || cp /bin/ls $DIR
2114 run_test 30a "execute binary from Lustre (execve) =============="
2117 cp `which ls` $DIR || cp /bin/ls $DIR
2119 $RUNAS $DIR/ls / || error
2122 run_test 30b "execute binary from Lustre as non-root ==========="
2124 test_30c() { # b=22376
2125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2126 cp `which ls` $DIR || cp /bin/ls $DIR
2128 cancel_lru_locks mdc
2129 cancel_lru_locks osc
2130 $RUNAS $DIR/ls / || error
2133 run_test 30c "execute binary from Lustre without read perms ===="
2136 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2137 $CHECKSTAT -a $DIR/f31 || error
2139 run_test 31a "open-unlink file =================================="
2142 touch $DIR/f31 || error
2143 ln $DIR/f31 $DIR/f31b || error
2144 $MULTIOP $DIR/f31b Ouc || error
2145 $CHECKSTAT -t file $DIR/f31 || error
2147 run_test 31b "unlink file with multiple links while open ======="
2150 touch $DIR/f31 || error
2151 ln $DIR/f31 $DIR/f31c || error
2152 multiop_bg_pause $DIR/f31 O_uc || return 1
2154 $MULTIOP $DIR/f31c Ouc
2155 kill -USR1 $MULTIPID
2158 run_test 31c "open-unlink file with multiple links ============="
2161 opendirunlink $DIR/d31d $DIR/d31d || error
2162 $CHECKSTAT -a $DIR/d31d || error
2164 run_test 31d "remove of open directory ========================="
2166 test_31e() { # bug 2904
2167 openfilleddirunlink $DIR/d31e || error
2169 run_test 31e "remove of open non-empty directory ==============="
2171 test_31f() { # bug 4554
2172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2174 test_mkdir $DIR/d31f
2175 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2176 cp /etc/hosts $DIR/d31f
2178 $GETSTRIPE $DIR/d31f/hosts
2179 multiop_bg_pause $DIR/d31f D_c || return 1
2182 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2183 test_mkdir $DIR/d31f
2184 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2185 cp /etc/hosts $DIR/d31f
2187 $GETSTRIPE $DIR/d31f/hosts
2188 multiop_bg_pause $DIR/d31f D_c || return 1
2191 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2192 wait $MULTIPID || error "first opendir $MULTIPID failed"
2196 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2197 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2200 run_test 31f "remove of open directory with open-unlink file ==="
2203 echo "-- cross directory link --"
2204 test_mkdir -c1 $DIR/${tdir}ga
2205 test_mkdir -c1 $DIR/${tdir}gb
2206 touch $DIR/${tdir}ga/f
2207 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2208 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2209 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2210 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2211 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2213 run_test 31g "cross directory link==============="
2216 echo "-- cross directory link --"
2217 test_mkdir -c1 $DIR/${tdir}
2218 test_mkdir -c1 $DIR/${tdir}/dir
2219 touch $DIR/${tdir}/f
2220 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2221 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2222 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2223 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2224 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2226 run_test 31h "cross directory link under child==============="
2229 echo "-- cross directory link --"
2230 test_mkdir -c1 $DIR/$tdir
2231 test_mkdir -c1 $DIR/$tdir/dir
2232 touch $DIR/$tdir/dir/f
2233 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2234 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2235 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2236 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2237 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2239 run_test 31i "cross directory link under parent==============="
2242 test_mkdir -c1 -p $DIR/$tdir
2243 test_mkdir -c1 -p $DIR/$tdir/dir1
2244 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2245 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2246 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2247 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2250 run_test 31j "link for directory==============="
2253 test_mkdir -c1 -p $DIR/$tdir
2255 touch $DIR/$tdir/exist
2256 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2257 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2258 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2259 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2260 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2261 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2262 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2265 run_test 31k "link to file: the same, non-existing, dir==============="
2271 touch $DIR/d31m2/exist
2272 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2273 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2274 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2275 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2276 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2277 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2280 run_test 31m "link to file: the same, non-existing, dir==============="
2283 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2284 nlink=$(stat --format=%h $DIR/$tfile)
2285 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2287 local cmd="exec $fd<$DIR/$tfile"
2290 trap "eval $cmd" EXIT
2291 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2292 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2293 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2294 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2295 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2298 run_test 31n "check link count of unlinked file"
2301 local TEMPNAME=$(mktemp $1_XXXXXX)
2302 mlink $TEMPNAME $1 2> /dev/null &&
2303 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2307 test_31o() { # LU-2901
2309 for LOOP in $(seq 100); do
2310 rm -f $DIR/$tdir/$tfile*
2311 for THREAD in $(seq 8); do
2312 link_one $DIR/$tdir/$tfile.$LOOP &
2315 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2316 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2317 error "$LINKS duplicate links to $tfile.$LOOP" &&
2321 run_test 31o "duplicate hard links with same filename"
2324 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2327 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2328 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2330 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2331 error "open unlink test1 failed"
2332 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2333 error "open unlink test2 failed"
2335 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2336 error "test1 still exists"
2337 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2338 error "test2 still exists"
2340 run_test 31p "remove of open striped directory"
2342 cleanup_test32_mount() {
2344 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2349 echo "== more mountpoints and symlinks ================="
2350 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2351 trap cleanup_test32_mount EXIT
2352 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2353 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2354 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2355 cleanup_test32_mount
2357 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2361 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2362 trap cleanup_test32_mount EXIT
2363 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2364 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2365 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2366 cleanup_test32_mount
2368 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2372 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2373 trap cleanup_test32_mount EXIT
2374 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2375 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2376 test_mkdir -p $DIR/$tdir/d2/test_dir
2377 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2378 cleanup_test32_mount
2380 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2384 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2385 trap cleanup_test32_mount EXIT
2386 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2387 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2388 test_mkdir -p $DIR/$tdir/d2/test_dir
2389 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2390 cleanup_test32_mount
2392 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2395 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2396 test_mkdir -p $DIR/d32e/tmp
2397 TMP_DIR=$DIR/d32e/tmp
2398 ln -s $DIR/d32e $TMP_DIR/symlink11
2399 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2400 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2401 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2403 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2406 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2407 test_mkdir -p $DIR/d32f/tmp
2408 TMP_DIR=$DIR/d32f/tmp
2409 ln -s $DIR/d32f $TMP_DIR/symlink11
2410 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2411 ls $DIR/d32f/tmp/symlink11 || error
2412 ls $DIR/d32f/symlink01 || error
2414 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2417 TMP_DIR=$DIR/$tdir/tmp
2418 test_mkdir -p $DIR/$tdir/tmp
2419 test_mkdir $DIR/${tdir}2
2420 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2421 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2422 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2423 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2424 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2425 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2427 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2430 rm -fr $DIR/$tdir $DIR/${tdir}2
2431 TMP_DIR=$DIR/$tdir/tmp
2432 test_mkdir -p $DIR/$tdir/tmp
2433 test_mkdir $DIR/${tdir}2
2434 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2435 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2436 ls $TMP_DIR/symlink12 || error
2437 ls $DIR/$tdir/symlink02 || error
2439 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2443 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2444 trap cleanup_test32_mount EXIT
2445 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2446 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2447 touch $DIR/$tdir/test_file
2448 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2449 cleanup_test32_mount
2451 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2455 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2456 trap cleanup_test32_mount EXIT
2457 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2458 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2459 touch $DIR/$tdir/test_file
2460 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2461 cleanup_test32_mount
2463 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2468 trap cleanup_test32_mount EXIT
2469 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2470 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2471 test_mkdir -p $DIR/$tdir/d2
2472 touch $DIR/$tdir/d2/test_file || error
2473 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2474 cleanup_test32_mount
2476 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2481 trap cleanup_test32_mount EXIT
2482 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2483 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2484 test_mkdir -p $DIR/$tdir/d2
2485 touch $DIR/$tdir/d2/test_file
2486 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2487 cleanup_test32_mount
2489 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2493 test_mkdir -p $DIR/d32m/tmp
2494 TMP_DIR=$DIR/d32m/tmp
2495 ln -s $DIR $TMP_DIR/symlink11
2496 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2497 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2498 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2500 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2504 test_mkdir -p $DIR/d32n/tmp
2505 TMP_DIR=$DIR/d32n/tmp
2506 ln -s $DIR $TMP_DIR/symlink11
2507 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2508 ls -l $DIR/d32n/tmp/symlink11 || error
2509 ls -l $DIR/d32n/symlink01 || error
2511 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2515 test_mkdir -p $DIR/d32o/tmp
2516 TMP_DIR=$DIR/d32o/tmp
2517 ln -s $DIR/$tfile $TMP_DIR/symlink12
2518 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2519 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2520 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2521 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2522 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2524 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2534 test_mkdir -p $DIR/d32p/tmp
2536 TMP_DIR=$DIR/d32p/tmp
2538 ln -s $DIR/$tfile $TMP_DIR/symlink12
2540 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2542 cat $DIR/d32p/tmp/symlink12 || error
2544 cat $DIR/d32p/symlink02 || error
2547 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2549 cleanup_testdir_mount() {
2551 $UMOUNT -d $DIR/$tdir
2555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2556 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2557 trap cleanup_testdir_mount EXIT
2558 test_mkdir -p $DIR/$tdir
2559 touch $DIR/$tdir/under_the_mount
2560 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2561 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2562 cleanup_testdir_mount
2564 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2568 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2569 trap cleanup_testdir_mount EXIT
2570 test_mkdir -p $DIR/$tdir
2571 touch $DIR/$tdir/under_the_mount
2572 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2573 ls $DIR/$tdir | grep -q under_the_mount && error || true
2574 cleanup_testdir_mount
2576 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2581 chmod 444 $DIR/$tfile
2582 chown $RUNAS_ID $DIR/$tfile
2584 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2587 run_test 33aa "write file with mode 444 (should return error) ===="
2591 test_mkdir -p $DIR/d33
2592 chown $RUNAS_ID $DIR/d33
2593 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2594 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2595 error "open RDWR" || true
2597 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2601 test_mkdir -p $DIR/d33
2602 chown $RUNAS_ID $DIR/d33
2603 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2605 run_test 33b "test open file with malformed flags (No panic)"
2608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2614 remote_ost_nodsh && skip "remote OST with nodsh" && return
2617 test_mkdir -p $DIR/d33
2618 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2621 for ostnum in $(seq $OSTCOUNT); do
2622 # test-framework's OST numbering is one-based, while Lustre's
2624 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2625 # Parsing llobdstat's output sucks; we could grep the /proc
2626 # path, but that's likely to not be as portable as using the
2627 # llobdstat utility. So we parse lctl output instead.
2628 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2629 obdfilter/$ostname/stats |
2630 awk '/^write_bytes/ {print $7}' )
2631 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2632 if (( ${write_bytes:-0} > 0 ))
2639 $all_zeros || return 0
2642 echo foo > $DIR/d33/bar
2646 # Total up write_bytes after writing. We'd better find non-zeros.
2647 for ostnum in $(seq $OSTCOUNT); do
2648 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2649 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2650 obdfilter/$ostname/stats |
2651 awk '/^write_bytes/ {print $7}' )
2652 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2653 if (( ${write_bytes:-0} > 0 ))
2662 for ostnum in $(seq $OSTCOUNT); do
2663 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2664 echo "Check that write_bytes is present in obdfilter/*/stats:"
2665 do_facet ost$ostnum lctl get_param -n \
2666 obdfilter/$ostname/stats
2668 error "OST not keeping write_bytes stats (b22312)"
2671 run_test 33c "test llobdstat and write_bytes"
2674 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2677 local remote_dir=$DIR/$tdir/remote_dir
2680 $LFS mkdir -i $MDTIDX $remote_dir ||
2681 error "create remote directory failed"
2683 touch $remote_dir/$tfile
2684 chmod 444 $remote_dir/$tfile
2685 chown $RUNAS_ID $remote_dir/$tfile
2687 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2689 chown $RUNAS_ID $remote_dir
2690 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2691 error "create" || true
2692 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2693 error "open RDWR" || true
2694 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2695 error "create" || true
2697 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2700 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2704 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2705 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2706 mkdir $DIR/$tdir/local_dir
2708 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2709 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2710 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2712 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2713 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2715 rmdir $DIR/$tdir/* || error "rmdir failed"
2718 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2719 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2720 mkdir $DIR/$tdir/local_dir
2722 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2723 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2724 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2726 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2727 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2729 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2732 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2733 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2734 mkdir $DIR/$tdir/local_dir
2736 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2737 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2738 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2740 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2741 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2743 run_test 33e "mkdir and striped directory should have same mode"
2747 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2751 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2754 chmod go+rwx $DIR/$tdir
2755 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2756 trap cleanup_33f EXIT
2758 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2759 error "cannot create striped directory"
2761 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2762 error "cannot create files in striped directory"
2764 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2765 error "cannot remove files in striped directory"
2767 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2768 error "cannot remove striped directory"
2772 run_test 33f "nonroot user can create, access, and remove a striped directory"
2774 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2777 $MCREATE $DIR/f34 || error
2778 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2779 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2780 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2781 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2783 run_test 34a "truncate file that has not been opened ==========="
2786 [ ! -f $DIR/f34 ] && test_34a
2787 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2788 $OPENFILE -f O_RDONLY $DIR/f34
2789 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2790 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2792 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2795 [ ! -f $DIR/f34 ] && test_34a
2796 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2797 $OPENFILE -f O_RDWR $DIR/f34
2798 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2799 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2801 run_test 34c "O_RDWR opening file-with-size works =============="
2804 [ ! -f $DIR/f34 ] && test_34a
2805 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2806 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2809 run_test 34d "write to sparse file ============================="
2813 $MCREATE $DIR/f34e || error
2814 $TRUNCATE $DIR/f34e 1000 || error
2815 $CHECKSTAT -s 1000 $DIR/f34e || error
2816 $OPENFILE -f O_RDWR $DIR/f34e
2817 $CHECKSTAT -s 1000 $DIR/f34e || error
2819 run_test 34e "create objects, some with size and some without =="
2821 test_34f() { # bug 6242, 6243
2822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2825 $MCREATE $DIR/f34f || error
2826 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2827 dd if=$DIR/f34f of=$TMP/f34f
2828 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2829 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2830 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2831 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2832 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2834 run_test 34f "read from a file with no objects until EOF ======="
2837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2838 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2839 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2840 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2841 cancel_lru_locks osc
2842 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2843 error "wrong size after lock cancel"
2845 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2846 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2847 error "expanding truncate failed"
2848 cancel_lru_locks osc
2849 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2850 error "wrong expanded size after lock cancel"
2852 run_test 34g "truncate long file ==============================="
2855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2859 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2860 sync # Flush the cache so that multiop below does not block on cache
2861 # flush when getting the group lock
2862 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2865 # Since just timed wait is not good enough, let's do a sync write
2866 # that way we are sure enough time for a roundtrip + processing
2867 # passed + 2 seconds of extra margin.
2868 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2872 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2873 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2877 local nsz=`stat -c %s $DIR/$tfile`
2878 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2880 run_test 34h "ftruncate file under grouplock should not block"
2883 cp /bin/sh $DIR/f35a
2885 chown $RUNAS_ID $DIR/f35a
2886 $RUNAS $DIR/f35a && error || true
2889 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2893 utime $DIR/f36 || error
2895 run_test 36a "MDS utime check (mknod, utime) ==================="
2899 utime $DIR/f36 || error
2901 run_test 36b "OST utime check (open, utime) ===================="
2906 chown $RUNAS_ID $DIR/d36
2907 $RUNAS utime $DIR/d36/f36 || error
2909 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2912 [ ! -d $DIR/d36 ] && test_36c
2913 echo "" > $DIR/d36/f36
2914 $RUNAS utime $DIR/d36/f36 || error
2916 run_test 36d "non-root OST utime check (open, utime) ==========="
2919 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2920 test_mkdir -p $DIR/$tdir
2921 touch $DIR/$tdir/$tfile
2922 $RUNAS utime $DIR/$tdir/$tfile && \
2923 error "utime worked, expected failure" || true
2925 run_test 36e "utime on non-owned file (should return error) ===="
2929 local LANG_SAVE=$LANG
2930 local LC_LANG_SAVE=$LC_LANG
2931 export LANG=C LC_LANG=C # for date language
2933 DATESTR="Dec 20 2000"
2934 test_mkdir -p $DIR/$tdir
2935 lctl set_param fail_loc=$fl
2937 cp /etc/hosts $DIR/$tdir/$tfile
2938 sync & # write RPC generated with "current" inode timestamp, but delayed
2940 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2941 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2942 cancel_lru_locks osc
2943 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2945 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2946 echo "BEFORE: $LS_BEFORE" && \
2947 echo "AFTER : $LS_AFTER" && \
2948 echo "WANT : $DATESTR" && \
2949 error "$DIR/$tdir/$tfile timestamps changed" || true
2951 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2956 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2957 subr_36fh "0x80000214"
2959 run_test 36f "utime on file racing with OST BRW write =========="
2962 remote_ost_nodsh && skip "remote OST with nodsh" && return
2963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2968 test_mkdir -p $DIR/$tdir
2969 fmd_max_age=$(do_facet ost1 \
2970 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2973 fmd_before=$(do_facet ost1 \
2974 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2975 touch $DIR/$tdir/$tfile
2976 sleep $((fmd_max_age + 12))
2977 fmd_after=$(do_facet ost1 \
2978 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2980 echo "fmd_before: $fmd_before"
2981 echo "fmd_after: $fmd_after"
2982 [[ $fmd_after -gt $fmd_before ]] &&
2983 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2984 error "fmd didn't expire after ping" || true
2986 run_test 36g "filter mod data cache expiry ====================="
2989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2990 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2991 subr_36fh "0x80000227"
2993 run_test 36h "utime on file racing with OST BRW write =========="
2996 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2999 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3001 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3002 local new_mtime=$((mtime + 200))
3004 #change Modify time of striped dir
3005 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3006 error "change mtime failed"
3008 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3010 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3012 run_test 36i "change mtime on striped directory"
3014 # test_37 - duplicate with tests 32q 32r
3017 local file=$DIR/$tfile
3019 openfile -f O_DIRECTORY $file
3022 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3023 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3025 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3029 touch $DIR/${tfile}2
3030 # ls -l $DIR/$tfile $DIR/${tfile}2
3031 # ls -lu $DIR/$tfile $DIR/${tfile}2
3032 # ls -lc $DIR/$tfile $DIR/${tfile}2
3034 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3035 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3037 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3039 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3041 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3042 error "O_TRUNC didn't change timestamps"
3045 run_test 39 "mtime changed on create ==========================="
3048 test_mkdir -p -c1 $DIR/$tdir
3049 cp -p /etc/passwd $DIR/$tdir/fopen
3050 cp -p /etc/passwd $DIR/$tdir/flink
3051 cp -p /etc/passwd $DIR/$tdir/funlink
3052 cp -p /etc/passwd $DIR/$tdir/frename
3053 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3056 echo "aaaaaa" >> $DIR/$tdir/fopen
3057 echo "aaaaaa" >> $DIR/$tdir/flink
3058 echo "aaaaaa" >> $DIR/$tdir/funlink
3059 echo "aaaaaa" >> $DIR/$tdir/frename
3061 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3062 local link_new=`stat -c %Y $DIR/$tdir/flink`
3063 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3064 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3066 cat $DIR/$tdir/fopen > /dev/null
3067 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3068 rm -f $DIR/$tdir/funlink2
3069 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3071 for (( i=0; i < 2; i++ )) ; do
3072 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3073 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3074 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3075 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3077 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3078 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3079 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3080 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3082 cancel_lru_locks osc
3083 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3086 run_test 39b "mtime change on open, link, unlink, rename ======"
3088 # this should be set to past
3089 TEST_39_MTIME=`date -d "1 year ago" +%s`
3095 local mtime0=`stat -c %Y $DIR1/$tfile`
3097 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3098 local mtime1=`stat -c %Y $DIR1/$tfile`
3099 [ "$mtime1" = $TEST_39_MTIME ] || \
3100 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3103 echo hello >> $DIR1/$tfile
3105 local mtime2=`stat -c %Y $DIR1/$tfile`
3106 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3107 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3109 mv $DIR1/$tfile $DIR1/$tfile-1
3111 for (( i=0; i < 2; i++ )) ; do
3112 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3113 [ "$mtime2" = "$mtime3" ] || \
3114 error "mtime ($mtime2) changed (to $mtime3) on rename"
3116 cancel_lru_locks osc
3117 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3120 run_test 39c "mtime change on rename ==========================="
3124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3127 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3129 for (( i=0; i < 2; i++ )) ; do
3130 local mtime=`stat -c %Y $DIR1/$tfile`
3131 [ $mtime = $TEST_39_MTIME ] || \
3132 error "mtime($mtime) is not set to $TEST_39_MTIME"
3134 cancel_lru_locks osc
3135 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3138 run_test 39d "create, utime, stat =============================="
3142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3144 local mtime1=`stat -c %Y $DIR1/$tfile`
3146 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3148 for (( i=0; i < 2; i++ )) ; do
3149 local mtime2=`stat -c %Y $DIR1/$tfile`
3150 [ $mtime2 = $TEST_39_MTIME ] || \
3151 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3153 cancel_lru_locks osc
3154 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3157 run_test 39e "create, stat, utime, stat ========================"
3161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3163 mtime1=`stat -c %Y $DIR1/$tfile`
3166 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3168 for (( i=0; i < 2; i++ )) ; do
3169 local mtime2=`stat -c %Y $DIR1/$tfile`
3170 [ $mtime2 = $TEST_39_MTIME ] || \
3171 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3173 cancel_lru_locks osc
3174 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3177 run_test 39f "create, stat, sleep, utime, stat ================="
3181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3182 echo hello >> $DIR1/$tfile
3183 local mtime1=`stat -c %Y $DIR1/$tfile`
3186 chmod o+r $DIR1/$tfile
3188 for (( i=0; i < 2; i++ )) ; do
3189 local mtime2=`stat -c %Y $DIR1/$tfile`
3190 [ "$mtime1" = "$mtime2" ] || \
3191 error "lost mtime: $mtime2, should be $mtime1"
3193 cancel_lru_locks osc
3194 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3197 run_test 39g "write, chmod, stat ==============================="
3201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3206 echo hello >> $DIR1/$tfile
3207 local mtime1=`stat -c %Y $DIR1/$tfile`
3209 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3211 if [ "$d1" != "$d2" ]; then
3212 echo "write and touch not within one second"
3214 for (( i=0; i < 2; i++ )) ; do
3215 local mtime2=`stat -c %Y $DIR1/$tfile`
3216 [ "$mtime2" = $TEST_39_MTIME ] || \
3217 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3219 cancel_lru_locks osc
3220 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3224 run_test 39h "write, utime within one second, stat ============="
3227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3231 echo hello >> $DIR1/$tfile
3232 local mtime1=`stat -c %Y $DIR1/$tfile`
3234 mv $DIR1/$tfile $DIR1/$tfile-1
3236 for (( i=0; i < 2; i++ )) ; do
3237 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3239 [ "$mtime1" = "$mtime2" ] || \
3240 error "lost mtime: $mtime2, should be $mtime1"
3242 cancel_lru_locks osc
3243 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3246 run_test 39i "write, rename, stat =============================="
3249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3250 start_full_debug_logging
3254 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3255 lctl set_param fail_loc=0x80000412
3256 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3257 error "multiop failed"
3259 local mtime1=`stat -c %Y $DIR1/$tfile`
3261 mv $DIR1/$tfile $DIR1/$tfile-1
3263 kill -USR1 $multipid
3264 wait $multipid || error "multiop close failed"
3266 for (( i=0; i < 2; i++ )) ; do
3267 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3268 [ "$mtime1" = "$mtime2" ] ||
3269 error "mtime is lost on close: $mtime2, " \
3272 cancel_lru_locks osc
3273 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3275 lctl set_param fail_loc=0
3276 stop_full_debug_logging
3278 run_test 39j "write, rename, close, stat ======================="
3281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3285 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3287 local mtime1=`stat -c %Y $DIR1/$tfile`
3289 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3291 kill -USR1 $multipid
3292 wait $multipid || error "multiop close failed"
3294 for (( i=0; i < 2; i++ )) ; do
3295 local mtime2=`stat -c %Y $DIR1/$tfile`
3297 [ "$mtime2" = $TEST_39_MTIME ] || \
3298 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3300 cancel_lru_locks osc
3301 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3304 run_test 39k "write, utime, close, stat ========================"
3306 # this should be set to future
3307 TEST_39_ATIME=`date -d "1 year" +%s`
3310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3311 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3312 local atime_diff=$(do_facet $SINGLEMDS \
3313 lctl get_param -n mdd.*MDT0000*.atime_diff)
3317 # test setting directory atime to future
3318 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3319 local atime=$(stat -c %X $DIR/$tdir)
3320 [ "$atime" = $TEST_39_ATIME ] || \
3321 error "atime is not set to future: $atime, $TEST_39_ATIME"
3323 # test setting directory atime from future to now
3324 local d1=$(date +%s)
3326 local d2=$(date +%s)
3328 cancel_lru_locks mdc
3329 atime=$(stat -c %X $DIR/$tdir)
3330 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3331 error "atime is not updated from future: $atime, $d1<atime<$d2"
3333 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3336 # test setting directory atime when now > dir atime + atime_diff
3340 cancel_lru_locks mdc
3341 atime=$(stat -c %X $DIR/$tdir)
3342 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3343 error "atime is not updated : $atime, should be $d2"
3345 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3348 # test not setting directory atime when now < dir atime + atime_diff
3350 cancel_lru_locks mdc
3351 atime=$(stat -c %X $DIR/$tdir)
3352 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3353 error "atime is updated to $atime, should remain $d1<atime<$d2"
3355 do_facet $SINGLEMDS \
3356 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3358 run_test 39l "directory atime update ==========================="
3361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3364 local far_past_mtime=$(date -d "May 29 1953" +%s)
3365 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3367 touch -m -d @$far_past_mtime $DIR1/$tfile
3368 touch -a -d @$far_past_atime $DIR1/$tfile
3370 for (( i=0; i < 2; i++ )) ; do
3371 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3372 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3373 error "atime or mtime set incorrectly"
3375 cancel_lru_locks osc
3376 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3379 run_test 39m "test atime and mtime before 1970"
3381 test_39n() { # LU-3832
3382 local atime_diff=$(do_facet $SINGLEMDS \
3383 lctl get_param -n mdd.*MDT0000*.atime_diff)
3388 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3391 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3392 atime0=$(stat -c %X $DIR/$tfile)
3395 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3396 atime1=$(stat -c %X $DIR/$tfile)
3399 cancel_lru_locks mdc
3400 cancel_lru_locks osc
3401 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3402 atime2=$(stat -c %X $DIR/$tfile)
3404 do_facet $SINGLEMDS \
3405 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3407 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3408 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3410 run_test 39n "check that O_NOATIME is honored"
3413 TESTDIR=$DIR/$tdir/$tfile
3414 [ -e $TESTDIR ] && rm -rf $TESTDIR
3415 test_mkdir -p $TESTDIR
3421 links2=$(stat -c %h .)
3422 [ $(($links1 + 2)) != $links2 ] &&
3423 error "wrong links count $(($links1 + 2)) != $links2"
3425 links3=$(stat -c %h .)
3426 [ $(($links1 + 1)) != $links3 ] &&
3427 error "wrong links count $links1 != $links3"
3430 run_test 39o "directory cached attributes updated after create ========"
3433 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3435 TESTDIR=$DIR/$tdir/$tfile
3436 [ -e $TESTDIR ] && rm -rf $TESTDIR
3441 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3442 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3444 links2=$(stat -c %h .)
3445 [ $(($links1 + 2)) != $links2 ] &&
3446 error "wrong links count $(($links1 + 2)) != $links2"
3448 links3=$(stat -c %h .)
3449 [ $(($links1 + 1)) != $links3 ] &&
3450 error "wrong links count $links1 != $links3"
3453 run_test 39p "remote directory cached attributes updated after create ========"
3457 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3458 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3459 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3460 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3461 error "$tfile is not 4096 bytes in size"
3463 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3467 small_write $DIR/f41 18
3469 run_test 41 "test small file write + fstat ====================="
3471 count_ost_writes() {
3472 lctl get_param -n osc.*.stats |
3473 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3474 END { printf("%0.0f", writes) }'
3481 BG_DIRTY_RATIO_SAVE=10
3482 MAX_BG_DIRTY_RATIO=25
3486 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3487 # dirty_ratio, dirty_background_ratio
3488 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3489 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3490 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3491 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3493 # if file not here, we are a 2.4 kernel
3494 kill -CONT `pidof kupdated`
3499 # setup the trap first, so someone cannot exit the test at the
3500 # exact wrong time and mess up a machine
3501 trap start_writeback EXIT
3502 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3503 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3504 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3505 sysctl -w vm.dirty_writeback_centisecs=0
3506 sysctl -w vm.dirty_writeback_centisecs=0
3507 # save and increase /proc/sys/vm/dirty_ratio
3508 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3509 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3510 # save and increase /proc/sys/vm/dirty_background_ratio
3511 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3512 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3514 # if file not here, we are a 2.4 kernel
3515 kill -STOP `pidof kupdated`
3519 # ensure that all stripes have some grant before we test client-side cache
3521 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3522 dd if=/dev/zero of=$i bs=4k count=1
3527 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3528 # file truncation, and file removal.
3530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3532 cancel_lru_locks osc
3534 sync; sleep 1; sync # just to be safe
3535 BEFOREWRITES=`count_ost_writes`
3536 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3537 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3538 AFTERWRITES=`count_ost_writes`
3539 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3540 error "$BEFOREWRITES < $AFTERWRITES"
3543 run_test 42a "ensure that we don't flush on close =============="
3546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3548 cancel_lru_locks osc
3551 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3552 BEFOREWRITES=$(count_ost_writes)
3553 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3554 AFTERWRITES=$(count_ost_writes)
3555 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3556 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3558 BEFOREWRITES=$(count_ost_writes)
3559 sync || error "sync: $?"
3560 AFTERWRITES=$(count_ost_writes)
3561 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3562 error "$BEFOREWRITES < $AFTERWRITES on sync"
3564 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3568 run_test 42b "test destroy of file with cached dirty data ======"
3570 # if these tests just want to test the effect of truncation,
3571 # they have to be very careful. consider:
3572 # - the first open gets a {0,EOF}PR lock
3573 # - the first write conflicts and gets a {0, count-1}PW
3574 # - the rest of the writes are under {count,EOF}PW
3575 # - the open for truncate tries to match a {0,EOF}PR
3576 # for the filesize and cancels the PWs.
3577 # any number of fixes (don't get {0,EOF} on open, match
3578 # composite locks, do smarter file size management) fix
3579 # this, but for now we want these tests to verify that
3580 # the cancellation with truncate intent works, so we
3581 # start the file with a full-file pw lock to match against
3582 # until the truncate.
3587 cancel_lru_locks osc
3589 # prime the file with 0,EOF PW to match
3593 # now the real test..
3594 dd if=/dev/zero of=$file bs=1024 count=100
3595 BEFOREWRITES=`count_ost_writes`
3596 $TRUNCATE $file $offset
3597 cancel_lru_locks osc
3598 AFTERWRITES=`count_ost_writes`
3603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3605 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3606 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3609 run_test 42c "test partial truncate of file with cached dirty data"
3612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3614 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3615 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3618 run_test 42d "test complete truncate of file with cached dirty data"
3620 test_42e() { # bug22074
3621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3622 local TDIR=$DIR/${tdir}e
3623 local pagesz=$(page_size)
3624 local pages=16 # hardcoded 16 pages, don't change it.
3625 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3626 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3630 test_mkdir -p $DIR/${tdir}e
3631 $SETSTRIPE -c 1 $TDIR
3632 createmany -o $TDIR/f $files
3634 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3636 # we assume that with $OSTCOUNT files, at least one of them will
3637 # be allocated on OST0.
3638 warmup_files=$((OSTCOUNT * max_dirty_mb))
3639 createmany -o $TDIR/w $warmup_files
3641 # write a large amount of data into one file and sync, to get good
3642 # avail_grant number from OST.
3643 for ((i=0; i<$warmup_files; i++)); do
3644 idx=$($GETSTRIPE -i $TDIR/w$i)
3645 [ $idx -ne 0 ] && continue
3646 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3649 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3651 $LCTL get_param $proc_osc0/cur_dirty_bytes
3652 $LCTL get_param $proc_osc0/cur_grant_bytes
3654 # create as much dirty pages as we can while not to trigger the actual
3655 # RPCs directly. but depends on the env, VFS may trigger flush during this
3656 # period, hopefully we are good.
3657 for ((i=0; i<$warmup_files; i++)); do
3658 idx=$($GETSTRIPE -i $TDIR/w$i)
3659 [ $idx -ne 0 ] && continue
3660 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3662 $LCTL get_param $proc_osc0/cur_dirty_bytes
3663 $LCTL get_param $proc_osc0/cur_grant_bytes
3665 # perform the real test
3666 $LCTL set_param $proc_osc0/rpc_stats 0
3667 for ((;i<$files; i++)); do
3668 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3669 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3672 $LCTL get_param $proc_osc0/rpc_stats
3675 local have_ppr=false
3676 $LCTL get_param $proc_osc0/rpc_stats |
3677 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3678 # skip lines until we are at the RPC histogram data
3679 [ "$PPR" == "pages" ] && have_ppr=true && continue
3680 $have_ppr || continue
3682 # we only want the percent stat for < 16 pages
3683 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3685 percent=$((percent + WPCT))
3686 if [[ $percent -gt 15 ]]; then
3687 error "less than 16-pages write RPCs" \
3694 run_test 42e "verify sub-RPC writes are not done synchronously"
3697 test_mkdir -p $DIR/$tdir
3698 cp -p /bin/ls $DIR/$tdir/$tfile
3699 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3701 # give multiop a chance to open
3704 $DIR/$tdir/$tfile && error || true
3707 run_test 43 "execution of file opened for write should return -ETXTBSY"
3710 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3711 test_mkdir -p $DIR/$tdir
3712 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3713 cp -p multiop $DIR/$tdir/multiop
3714 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3717 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3718 kill -USR1 $MULTIOP_PID || return 2
3719 wait $MULTIOP_PID || return 3
3720 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3722 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3725 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3726 test_mkdir -p $DIR/$tdir
3727 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3728 cp -p multiop $DIR/$tdir/multiop
3729 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3732 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3733 kill -USR1 $MULTIOP_PID || return 2
3734 wait $MULTIOP_PID || return 3
3735 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3737 run_test 43b "truncate of file being executed should return -ETXTBSY"
3740 local testdir="$DIR/$tdir"
3741 test_mkdir -p $DIR/$tdir
3743 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3744 ( cd $testdir && md5sum -c)
3746 run_test 43c "md5sum of copy into lustre========================"
3749 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3750 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3751 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3753 run_test 44 "zero length read from a sparse stripe ============="
3756 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3758 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3759 [[ $nstripe -gt $OSTCOUNT ]] &&
3760 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3762 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3764 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3765 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3769 OFFSETS="0 $((stride/2)) $((stride-1))"
3770 for offset in $OFFSETS; do
3771 for i in $(seq 0 $((nstripe-1))); do
3772 local GLOBALOFFSETS=""
3774 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3775 local myfn=$DIR/d44a-$size
3776 echo "--------writing $myfn at $size"
3777 ll_sparseness_write $myfn $size ||
3778 error "ll_sparseness_write"
3779 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3780 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3781 error "ll_sparseness_verify $GLOBALOFFSETS"
3783 for j in $(seq 0 $((nstripe-1))); do
3785 size=$((((j + $nstripe )*$stride + $offset)))
3786 ll_sparseness_write $myfn $size ||
3787 error "ll_sparseness_write"
3788 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3790 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3791 error "ll_sparseness_verify $GLOBALOFFSETS"
3796 run_test 44a "test sparse pwrite ==============================="
3800 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3806 before=`dirty_osc_total`
3807 echo executing "\"$*\""
3809 after=`dirty_osc_total`
3810 echo before $before, after $after
3813 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3815 # Obtain grants from OST if it supports it
3816 echo blah > ${f}_grant
3819 do_dirty_record "echo blah > $f"
3820 [[ $before -eq $after ]] && error "write wasn't cached"
3821 do_dirty_record "> $f"
3822 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3823 do_dirty_record "echo blah > $f"
3824 [[ $before -eq $after ]] && error "write wasn't cached"
3825 do_dirty_record "sync"
3826 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3827 do_dirty_record "echo blah > $f"
3828 [[ $before -eq $after ]] && error "write wasn't cached"
3829 do_dirty_record "cancel_lru_locks osc"
3830 [[ $before -gt $after ]] ||
3831 error "lock cancellation didn't lower dirty count"
3834 run_test 45 "osc io page accounting ============================"
3836 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3837 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3838 # objects offset and an assert hit when an rpc was built with 1023's mapped
3839 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3841 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3845 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3847 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3848 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3852 run_test 46 "dirtying a previously written page ================"
3854 # test_47 is removed "Device nodes check" is moved to test_28
3856 test_48a() { # bug 2399
3857 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3858 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3859 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3861 test_mkdir $DIR/$tdir
3863 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3864 test_mkdir $DIR/$tdir || error "recreate directory failed"
3865 touch foo || error "'touch foo' failed after recreating cwd"
3866 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3867 touch .foo || error "'touch .foo' failed after recreating cwd"
3868 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3869 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3870 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3871 cd . || error "'cd .' failed after recreating cwd"
3872 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3873 rmdir . && error "'rmdir .' worked after recreating cwd"
3874 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3875 cd .. || error "'cd ..' failed after recreating cwd"
3877 run_test 48a "Access renamed working dir (should return errors)="
3879 test_48b() { # bug 2399
3881 test_mkdir $DIR/$tdir
3883 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3884 touch foo && error "'touch foo' worked after removing cwd"
3885 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3886 touch .foo && error "'touch .foo' worked after removing cwd"
3887 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3888 ls . > /dev/null && error "'ls .' worked after removing cwd"
3889 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3890 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3891 test_mkdir . && error "'mkdir .' worked after removing cwd"
3892 rmdir . && error "'rmdir .' worked after removing cwd"
3893 ln -s . foo && error "'ln -s .' worked after removing cwd"
3894 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3896 run_test 48b "Access removed working dir (should return errors)="
3898 test_48c() { # bug 2350
3899 #lctl set_param debug=-1
3902 test_mkdir -p $DIR/$tdir/dir
3904 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3905 $TRACE touch foo && error "touch foo worked after removing cwd"
3906 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3907 touch .foo && error "touch .foo worked after removing cwd"
3908 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3909 $TRACE ls . && error "'ls .' worked after removing cwd"
3910 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3911 is_patchless || ( $TRACE cd . &&
3912 error "'cd .' worked after removing cwd" )
3913 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3914 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3915 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3916 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3918 run_test 48c "Access removed working subdir (should return errors)"
3920 test_48d() { # bug 2350
3921 #lctl set_param debug=-1
3924 test_mkdir -p $DIR/$tdir/dir
3926 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3927 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3928 $TRACE touch foo && error "'touch foo' worked after removing parent"
3929 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3930 touch .foo && error "'touch .foo' worked after removing parent"
3931 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3932 $TRACE ls . && error "'ls .' worked after removing parent"
3933 $TRACE ls .. && error "'ls ..' worked after removing parent"
3934 is_patchless || ( $TRACE cd . &&
3935 error "'cd .' worked after recreate parent" )
3936 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3937 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3938 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3939 is_patchless || ( $TRACE cd .. &&
3940 error "'cd ..' worked after removing parent" || true )
3942 run_test 48d "Access removed parent subdir (should return errors)"
3944 test_48e() { # bug 4134
3945 #lctl set_param debug=-1
3948 test_mkdir -p $DIR/$tdir/dir
3950 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3951 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3952 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3953 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3954 # On a buggy kernel addition of "touch foo" after cd .. will
3955 # produce kernel oops in lookup_hash_it
3956 touch ../foo && error "'cd ..' worked after recreate parent"
3958 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3960 run_test 48e "Access to recreated parent subdir (should return errors)"
3962 test_49() { # LU-1030
3963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3964 # get ost1 size - lustre-OST0000
3965 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3967 # write 800M at maximum
3968 [[ $ost1_size -lt 2 ]] && ost1_size=2
3969 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3971 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3972 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3975 # change max_pages_per_rpc while writing the file
3976 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3977 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3978 # loop until dd process exits
3979 while ps ax -opid | grep -wq $dd_pid; do
3980 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3981 sleep $((RANDOM % 5 + 1))
3983 # restore original max_pages_per_rpc
3984 $LCTL set_param $osc1_mppc=$orig_mppc
3985 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3987 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3991 test_mkdir $DIR/$tdir
3993 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3995 run_test 50 "special situations: /proc symlinks ==============="
3997 test_51a() { # was test_51
3998 # bug 1516 - create an empty entry right after ".." then split dir
3999 test_mkdir -c1 $DIR/$tdir
4000 touch $DIR/$tdir/foo
4001 $MCREATE $DIR/$tdir/bar
4003 createmany -m $DIR/$tdir/longfile 201
4005 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4006 $MCREATE $DIR/$tdir/longfile$FNUM
4011 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4013 run_test 51a "special situations: split htree with empty entry =="
4015 export NUMTEST=70000
4017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4018 local BASE=$DIR/d${base}.${TESTSUITE}
4020 # cleanup the directory
4023 test_mkdir -p -c1 $BASE
4027 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4028 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4029 [[ $numfree -lt 21000 ]] &&
4030 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4033 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4034 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4036 # need to check free space for the directories as well
4037 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4038 numfree=$((blkfree / 4))
4039 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4040 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4042 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4046 echo "failed" > $BASE/fnum
4047 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4050 run_test 51b "exceed 64k subdirectory nlink limit"
4052 test_51ba() { # LU-993
4053 local BASE=$DIR/d${base}.${TESTSUITE}
4054 # unlink all but 100 subdirectories, then check it still works
4056 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4058 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4059 local DELETE=$((NUMTEST - LEFT))
4061 # continue on to run this test even if 51b didn't finish,
4062 # just to delete the many subdirectories created.
4063 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4065 # for ldiskfs the nlink count should be 1, but this is OSD specific
4066 # and so this is listed for informational purposes only
4067 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4068 unlinkmany -d $BASE/d $DELETE
4071 if [ $RC -ne 0 ]; then
4072 if [ "$NUMPREV" == "failed" ]; then
4073 skip "previous setup failed"
4076 error "unlink of first $DELETE subdirs failed"
4081 echo "nlink between: $(stat -c %h $BASE)"
4082 # trim the first line of ls output
4083 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4084 [ $FOUND -ne $LEFT ] &&
4085 error "can't find subdirs: found only $FOUND/$LEFT"
4087 unlinkmany -d $BASE/d $DELETE $LEFT ||
4088 error "unlink of second $LEFT subdirs failed"
4089 # regardless of whether the backing filesystem tracks nlink accurately
4090 # or not, the nlink count shouldn't be more than "." and ".." here
4091 local AFTER=$(stat -c %h $BASE)
4092 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4093 echo "nlink after: $AFTER"
4095 run_test 51ba "verify nlink for many subdirectory cleanup"
4098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4099 [[ $OSTCOUNT -lt 3 ]] &&
4100 skip_env "skipping test with few OSTs" && return
4101 test_mkdir -p $DIR/$tdir
4102 createmany -o $DIR/$tdir/t- 1000
4103 $GETSTRIPE $DIR/$tdir > $TMP/files
4104 for N in $(seq 0 $((OSTCOUNT - 1))); do
4105 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4106 END { printf("%0.0f", objs) }' $TMP/files)
4107 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4108 '($1 == '$N') { objs += 1 } \
4109 END { printf("%0.0f", objs) }')
4110 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4112 unlinkmany $DIR/$tdir/t- 1000
4115 for N in $(seq 1 $((OSTCOUNT - 1))); do
4116 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4117 error "OST $N has less objects vs OST $NLAST" \
4118 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4119 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4120 error "OST $N has less objects vs OST $NLAST" \
4121 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4123 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4124 error "OST $N has less #0 objects vs OST $NLAST" \
4125 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4126 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4127 error "OST $N has less #0 objects vs OST $NLAST" \
4128 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4132 run_test 51d "check object distribution ===================="
4135 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4136 skip "Only applicable to ldiskfs-based MDTs"
4140 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4141 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4143 touch $DIR/$tdir/d0/foo
4144 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4145 error "file exceed 65000 nlink limit!"
4146 unlinkmany $DIR/$tdir/d0/f- 65001
4149 run_test 51e "check file nlink limit"
4152 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4153 test_mkdir -p $DIR/$tdir
4154 touch $DIR/$tdir/foo
4155 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4156 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4157 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4158 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4159 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4161 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4162 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4163 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4165 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4166 cp -r $DIR/$tdir /tmp/
4167 rm -fr $DIR/$tdir || error "cleanup rm failed"
4169 run_test 52a "append-only flag test (should return errors) ====="
4172 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4173 test_mkdir -p $DIR/$tdir
4174 touch $DIR/$tdir/foo
4175 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4176 cat test > $DIR/$tdir/foo && error "cat test worked"
4177 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4178 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4179 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4181 echo foo >> $DIR/$tdir/foo && error "echo worked"
4182 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4183 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4184 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4185 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4187 chattr -i $DIR/$tdir/foo || error "chattr failed"
4189 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4191 run_test 52b "immutable flag test (should return errors) ======="
4194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4195 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4196 remote_ost_nodsh && skip "remote OST with nodsh" && return
4209 local support_last_seq=true
4211 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4212 support_last_seq=false
4215 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4217 for value in $(do_facet $SINGLEMDS \
4218 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4219 param=$(echo ${value[0]} | cut -d "=" -f1)
4220 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4222 if $support_last_seq; then
4223 param_seq=$(echo $param |
4224 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4225 mds_last_seq=$(do_facet $SINGLEMDS \
4226 $LCTL get_param -n $param_seq)
4228 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4230 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4231 node=$(facet_active_host ost$((ostnum+1)))
4232 param="obdfilter.$ostname.last_id"
4233 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4234 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4235 ost_last_id=$ost_last
4237 if $support_last_seq; then
4238 ost_last_id=$(echo $ost_last |
4239 awk -F':' '{print $2}' |
4241 ost_last_seq=$(echo $ost_last |
4242 awk -F':' '{print $1}')
4243 [[ $ost_last_seq = $mds_last_seq ]] || continue
4246 if [[ $ost_last_id != $mds_last ]]; then
4247 error "$ost_last_id != $mds_last"
4254 $found || error "can not match last_seq/last_id for $mdtosc"
4257 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4260 $SOCKETSERVER $DIR/socket ||
4261 error "$SOCKETSERVER $DIR/socket failed: $?"
4262 $SOCKETCLIENT $DIR/socket ||
4263 error "$SOCKETCLIENT $DIR/socket failed: $?"
4264 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4266 run_test 54a "unix domain socket test =========================="
4272 dd if=/dev/zero of=$f bs=$(page_size) count=1
4274 run_test 54b "char device works in lustre ======================"
4277 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4278 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4279 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4281 for i in $(seq 3 7); do
4282 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4290 loopdev="$DIR/loop54c"
4293 $UMOUNT -d $DIR/$tdir || rc=$?
4294 losetup -d $loopdev || true
4295 losetup -d $LOOPDEV || true
4296 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4302 loopdev="$DIR/loop54c"
4305 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4306 trap cleanup_54c EXIT
4307 mknod $loopdev b 7 $LOOPNUM
4308 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4309 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4310 losetup $loopdev $DIR/$tfile ||
4311 error "can't set up $loopdev for $DIR/$tfile"
4312 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4313 test_mkdir -p $DIR/$tdir
4314 mount -t ext2 $loopdev $DIR/$tdir ||
4315 error "error mounting $loopdev on $DIR/$tdir"
4316 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4319 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4323 run_test 54c "block device works in lustre ====================="
4329 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4331 run_test 54d "fifo device works in lustre ======================"
4336 cp -aL /dev/console $f
4337 echo $string > $f || error "echo $string to $f failed"
4339 run_test 54e "console/tty device works in lustre ======================"
4341 #The test_55 used to be iopen test and it was removed by bz#24037.
4342 #run_test 55 "check iopen_connect_dentry() ======================"
4344 test_56a() { # was test_56
4347 test_mkdir -p $DIR/$tdir/dir
4349 NUMFILESx2=$(($NUMFILES * 2))
4350 for i in $(seq 1 $NUMFILES); do
4351 touch $DIR/$tdir/file$i
4352 touch $DIR/$tdir/dir/file$i
4355 # test lfs getstripe with --recursive
4356 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4357 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4358 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4359 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4360 [[ $FILENUM -eq $NUMFILES ]] ||
4361 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4362 echo "$GETSTRIPE --recursive passed."
4364 # test lfs getstripe with file instead of dir
4365 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4366 [[ $FILENUM -eq 1 ]] ||
4367 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4368 echo "$GETSTRIPE file1 passed."
4370 #test lfs getstripe with --verbose
4371 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4372 grep -c lmm_magic) -eq $NUMFILES ]] ||
4373 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4374 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4375 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4376 echo "$GETSTRIPE --verbose passed."
4378 #test lfs getstripe with --obd
4379 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4380 grep -q "unknown obduuid" ||
4381 error "$GETSTRIPE --obd wrong_uuid should return error message"
4383 [[ $OSTCOUNT -lt 2 ]] &&
4384 skip_env "skipping other $GETSTRIPE --obd test" && return
4387 OBDUUID=$(ostuuid_from_index $OSTIDX)
4388 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4389 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4390 [[ $FOUND -eq $FILENUM ]] ||
4391 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4392 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4393 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4394 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4395 error "$GETSTRIPE --obd: should not show file on other obd"
4396 echo "$GETSTRIPE --obd passed"
4398 run_test 56a "check $GETSTRIPE"
4403 local LOCAL_NUMFILES="$1"
4404 local LOCAL_NUMDIRS="$2"
4405 local MKDIR_PARAMS="$3"
4406 local DIR_STRIPE_PARAMS="$4"
4408 if [ ! -d "$TDIR" ] ; then
4409 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4410 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4411 for i in `seq 1 $LOCAL_NUMFILES` ; do
4414 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4415 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4416 for j in `seq 1 $LOCAL_NUMFILES` ; do
4417 touch $TDIR/dir$i/file$j
4423 setup_56_special() {
4427 if [ ! -e "$TDIR/loop1b" ] ; then
4428 for i in `seq 1 $LOCAL_NUMFILES` ; do
4429 mknod $TDIR/loop${i}b b 7 $i
4430 mknod $TDIR/null${i}c c 1 3
4431 ln -s $TDIR/file1 $TDIR/link${i}l
4433 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4434 mknod $TDIR/dir$i/loop${i}b b 7 $i
4435 mknod $TDIR/dir$i/null${i}c c 1 3
4436 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4445 setup_56 $NUMFILES $NUMDIRS
4447 EXPECTED=$(($NUMDIRS + 2))
4448 # test lfs find with -name
4449 for i in $(seq 1 $NUMFILES) ; do
4450 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4451 [ $NUMS -eq $EXPECTED ] ||
4452 error "lfs find -name \"*$i\" $TDIR wrong: "\
4453 "found $NUMS, expected $EXPECTED"
4456 run_test 56g "check lfs find -name ============================="
4462 setup_56 $NUMFILES $NUMDIRS
4464 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4465 # test lfs find with ! -name
4466 for i in $(seq 1 $NUMFILES) ; do
4467 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4468 [ $NUMS -eq $EXPECTED ] ||
4469 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4470 "found $NUMS, expected $EXPECTED"
4473 run_test 56h "check lfs find ! -name ============================="
4477 test_mkdir -p $DIR/$tdir
4478 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4479 CMD="$LFIND -ost $UUID $DIR/$tdir"
4481 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4483 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4487 setup_56_special $NUMFILES $NUMDIRS
4489 EXPECTED=$((NUMDIRS + 1))
4490 CMD="$LFIND -type d $TDIR"
4491 NUMS=$($CMD | wc -l)
4492 [ $NUMS -eq $EXPECTED ] ||
4493 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4495 run_test 56j "check lfs find -type d ============================="
4499 setup_56_special $NUMFILES $NUMDIRS
4501 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4502 CMD="$LFIND -type f $TDIR"
4503 NUMS=$($CMD | wc -l)
4504 [ $NUMS -eq $EXPECTED ] ||
4505 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4507 run_test 56k "check lfs find -type f ============================="
4511 setup_56_special $NUMFILES $NUMDIRS
4513 EXPECTED=$((NUMDIRS + NUMFILES))
4514 CMD="$LFIND -type b $TDIR"
4515 NUMS=$($CMD | wc -l)
4516 [ $NUMS -eq $EXPECTED ] ||
4517 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4519 run_test 56l "check lfs find -type b ============================="
4523 setup_56_special $NUMFILES $NUMDIRS
4525 EXPECTED=$((NUMDIRS + NUMFILES))
4526 CMD="$LFIND -type c $TDIR"
4527 NUMS=$($CMD | wc -l)
4528 [ $NUMS -eq $EXPECTED ] ||
4529 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4531 run_test 56m "check lfs find -type c ============================="
4535 setup_56_special $NUMFILES $NUMDIRS
4537 EXPECTED=$((NUMDIRS + NUMFILES))
4538 CMD="$LFIND -type l $TDIR"
4539 NUMS=$($CMD | wc -l)
4540 [ $NUMS -eq $EXPECTED ] ||
4541 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4543 run_test 56n "check lfs find -type l ============================="
4547 setup_56 $NUMFILES $NUMDIRS
4548 utime $TDIR/file1 > /dev/null || error "utime (1)"
4549 utime $TDIR/file2 > /dev/null || error "utime (2)"
4550 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4551 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4552 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4553 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4556 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4557 [ $NUMS -eq $EXPECTED ] || \
4558 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4561 CMD="$LFIND -mtime 0 $TDIR"
4562 NUMS=$($CMD | wc -l)
4563 [ $NUMS -eq $EXPECTED ] ||
4564 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4566 run_test 56o "check lfs find -mtime for old files =========================="
4569 [ $RUNAS_ID -eq $UID ] &&
4570 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4573 setup_56 $NUMFILES $NUMDIRS
4575 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4577 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4578 NUMS=$($CMD | wc -l)
4579 [ $NUMS -eq $EXPECTED ] || \
4580 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4582 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4583 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4584 NUMS=$($CMD | wc -l)
4585 [ $NUMS -eq $EXPECTED ] || \
4586 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4588 run_test 56p "check lfs find -uid and ! -uid ==============================="
4591 [ $RUNAS_ID -eq $UID ] &&
4592 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4595 setup_56 $NUMFILES $NUMDIRS
4597 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4600 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4601 NUMS=$($CMD | wc -l)
4602 [ $NUMS -eq $EXPECTED ] ||
4603 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4605 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4606 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4607 NUMS=$($CMD | wc -l)
4608 [ $NUMS -eq $EXPECTED ] ||
4609 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4611 run_test 56q "check lfs find -gid and ! -gid ==============================="
4615 setup_56 $NUMFILES $NUMDIRS
4618 CMD="$LFIND -size 0 -type f $TDIR"
4619 NUMS=$($CMD | wc -l)
4620 [ $NUMS -eq $EXPECTED ] ||
4621 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4623 CMD="$LFIND ! -size 0 -type f $TDIR"
4624 NUMS=$($CMD | wc -l)
4625 [ $NUMS -eq $EXPECTED ] ||
4626 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4627 echo "test" > $TDIR/$tfile
4628 echo "test2" > $TDIR/$tfile.2 && sync
4630 CMD="$LFIND -size 5 -type f $TDIR"
4631 NUMS=$($CMD | wc -l)
4632 [ $NUMS -eq $EXPECTED ] ||
4633 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4635 CMD="$LFIND -size +5 -type f $TDIR"
4636 NUMS=$($CMD | wc -l)
4637 [ $NUMS -eq $EXPECTED ] ||
4638 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4640 CMD="$LFIND -size +0 -type f $TDIR"
4641 NUMS=$($CMD | wc -l)
4642 [ $NUMS -eq $EXPECTED ] ||
4643 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4645 CMD="$LFIND ! -size -5 -type f $TDIR"
4646 NUMS=$($CMD | wc -l)
4647 [ $NUMS -eq $EXPECTED ] ||
4648 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4650 CMD="$LFIND -size -5 -type f $TDIR"
4651 NUMS=$($CMD | wc -l)
4652 [ $NUMS -eq $EXPECTED ] ||
4653 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4655 run_test 56r "check lfs find -size works =========================="
4657 test_56s() { # LU-611
4659 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4661 if [[ $OSTCOUNT -gt 1 ]]; then
4662 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4666 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4670 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4671 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4672 NUMS=$($CMD | wc -l)
4673 [ $NUMS -eq $EXPECTED ] || {
4675 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4678 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4679 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4680 NUMS=$($CMD | wc -l)
4681 [ $NUMS -eq $EXPECTED ] || {
4683 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4687 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4688 NUMS=$($CMD | wc -l)
4689 [ $NUMS -eq $EXPECTED ] || {
4691 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4694 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4695 NUMS=$($CMD | wc -l)
4696 [ $NUMS -eq $EXPECTED ] || {
4698 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4702 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4703 NUMS=$($CMD | wc -l)
4704 [ $NUMS -eq $EXPECTED ] || {
4706 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4709 run_test 56s "check lfs find -stripe-count works"
4711 test_56t() { # LU-611
4713 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4715 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4717 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4718 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4719 NUMS=$($CMD | wc -l)
4720 [ $NUMS -eq $EXPECTED ] ||
4721 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4723 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4724 NUMS=$($CMD | wc -l)
4725 [ $NUMS -eq $EXPECTED ] ||
4726 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4728 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4729 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4730 NUMS=$($CMD | wc -l)
4731 [ $NUMS -eq $EXPECTED ] ||
4732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4734 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4735 NUMS=$($CMD | wc -l)
4736 [ $NUMS -eq $EXPECTED ] ||
4737 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4740 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4741 NUMS=$($CMD | wc -l)
4742 [ $NUMS -eq $EXPECTED ] ||
4743 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4745 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4746 NUMS=$($CMD | wc -l)
4747 [ $NUMS -eq $EXPECTED ] ||
4748 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4751 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4752 NUMS=$($CMD | wc -l)
4753 [ $NUMS -eq $EXPECTED ] ||
4754 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4756 run_test 56t "check lfs find -stripe-size works"
4758 test_56u() { # LU-611
4760 setup_56 $NUMFILES $NUMDIRS "-i 0"
4762 if [[ $OSTCOUNT -gt 1 ]]; then
4763 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4769 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4770 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4771 NUMS=$($CMD | wc -l)
4772 [ $NUMS -eq $EXPECTED ] ||
4773 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4776 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4777 NUMS=$($CMD | wc -l)
4778 [ $NUMS -eq $EXPECTED ] ||
4779 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4781 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4782 NUMS=$($CMD | wc -l)
4783 [ $NUMS -eq $EXPECTED ] ||
4784 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4787 # This should produce an error and not return any files
4788 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4789 NUMS=$($CMD 2>/dev/null | wc -l)
4790 [ $NUMS -eq $EXPECTED ] ||
4791 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4793 if [[ $OSTCOUNT -gt 1 ]]; then
4794 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4795 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4796 NUMS=$($CMD | wc -l)
4797 [ $NUMS -eq $EXPECTED ] ||
4798 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4801 run_test 56u "check lfs find -stripe-index works"
4808 setup_56 $NUMFILES $NUMDIRS
4810 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4811 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4813 for file in $($LFIND -mdt $UUID $TDIR); do
4814 file_mdt_idx=$($GETSTRIPE -M $file)
4815 [ $file_mdt_idx -eq $MDT_IDX ] ||
4816 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4819 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4822 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4827 rm -rf $TDIR || error "remove $TDIR failed"
4828 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4831 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4832 error "$GETSTRIPE -S -d $TDIR failed"
4833 stripe_size=${stripe_size%% *}
4835 local file_size=$((stripe_size * OSTCOUNT))
4836 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4837 local required_space=$((file_num * file_size))
4838 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4839 [[ $free_space -le $((required_space / 1024)) ]] &&
4840 skip_env "need at least $required_space bytes free space," \
4841 "have $free_space kbytes" && return
4844 local dd_count=$((file_size / dd_bs))
4846 # write data into the files
4850 for i in $(seq 1 $NUMFILES); do
4852 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4853 error "write data into $file failed"
4855 for i in $(seq 1 $NUMDIRS); do
4856 for j in $(seq 1 $NUMFILES); do
4857 file=$TDIR/dir$i/file$j
4858 yes | dd bs=$dd_bs count=$dd_count of=$file \
4860 error "write data into $file failed"
4865 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4868 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4870 eval $cmd || error "$cmd failed"
4872 check_stripe_count $TDIR/file1 $expected
4874 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4876 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4877 # OST 1 if it is on OST 0. This file is small enough to
4878 # be on only one stripe.
4879 file=$TDIR/migr_1_ost
4880 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4881 error "write data into $file failed"
4882 local obdidx=$($LFS getstripe -i $file)
4883 local oldmd5=$(md5sum $file)
4885 [[ $obdidx -eq 0 ]] && newobdidx=1
4886 cmd="$LFS migrate -i $newobdidx $file"
4888 eval $cmd || error "$cmd failed"
4889 local realobdix=$($LFS getstripe -i $file)
4890 local newmd5=$(md5sum $file)
4891 [[ $newobdidx -ne $realobdix ]] &&
4892 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4893 [[ "$oldmd5" != "$newmd5" ]] &&
4894 error "md5sum differ: $oldmd5, $newmd5"
4898 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4900 eval $cmd || error "$cmd failed"
4902 for j in $(seq 1 $NUMFILES); do
4903 check_stripe_count $TDIR/dir1/file$j $expected
4906 # lfs_migrate works with lfs find
4907 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4908 $LFS_MIGRATE -y -c $expected"
4910 eval $cmd || error "$cmd failed"
4912 for i in $(seq 2 $NUMFILES); do
4913 check_stripe_count $TDIR/file$i $expected
4915 for i in $(seq 2 $NUMDIRS); do
4916 for j in $(seq 1 $NUMFILES); do
4917 check_stripe_count $TDIR/dir$i/file$j $expected
4921 run_test 56w "check lfs_migrate -c stripe_count works"
4924 check_swap_layouts_support && return 0
4925 [[ $OSTCOUNT -lt 2 ]] &&
4926 skip_env "need 2 OST, skipping test" && return
4928 local dir0=$DIR/$tdir/$testnum
4929 mkdir -p $dir0 || error "creating dir $dir0"
4931 local ref1=/etc/passwd
4932 local file1=$dir0/file1
4934 $SETSTRIPE -c 2 $file1
4936 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4937 stripe=$($GETSTRIPE -c $file1)
4938 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4939 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4944 run_test 56x "lfs migration support"
4947 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4948 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4952 local dir0=$DIR/$tdir/$testnum
4953 mkdir -p $dir0 || error "creating dir $dir0"
4954 local f1=$dir0/file1
4955 local f2=$dir0/file2
4957 touch $f1 || error "creating std file $f1"
4958 $MULTIOP $f2 H2c || error "creating released file $f2"
4960 # a directory can be raid0, so ask only for files
4961 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4962 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4964 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4965 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4967 # only files can be released, so no need to force file search
4968 res=$($LFIND $dir0 -L released)
4969 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4971 res=$($LFIND $dir0 \! -L released)
4972 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4975 run_test 56y "lfs find -L raid0|released"
4977 test_56z() { # LU-4824
4978 # This checks to make sure 'lfs find' continues after errors
4979 # There are two classes of errors that should be caught:
4980 # - If multiple paths are provided, all should be searched even if one
4982 # - If errors are encountered during the search, it should not terminate
4985 test_mkdir $DIR/$tdir
4986 for i in d{0..9}; do
4987 test_mkdir $DIR/$tdir/$i
4989 touch $DIR/$tdir/d{0..9}/$tfile
4990 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4991 error "$LFS find did not return an error"
4992 # Make a directory unsearchable. This should NOT be the last entry in
4993 # directory order. Arbitrarily pick the 6th entry
4994 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
4995 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
4996 # The user should be able to see 10 directories and 9 files
4997 [ $count == 19 ] || error "$LFS find did not continue after error"
4999 run_test 56z "lfs find should continue after an error"
5001 test_56aa() { # LU-5937
5002 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5005 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5007 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5008 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5010 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5012 run_test 56aa "lfs find --size under striped dir"
5015 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5016 # note test will not do anything if MDS is not local
5017 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5018 skip "Only applicable to ldiskfs-based MDTs"
5022 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5023 local MNTDEV="osd*.*MDT*.mntdev"
5024 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5025 [ -z "$DEV" ] && error "can't access $MNTDEV"
5026 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5027 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5028 error "can't access $DEV"
5029 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5030 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5034 run_test 57a "verify MDS filesystem created with large inodes =="
5037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5038 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5039 skip "Only applicable to ldiskfs-based MDTs"
5043 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5044 local dir=$DIR/$tdir
5048 local FILEN=$dir/f$FILECOUNT
5050 rm -rf $dir || error "removing $dir"
5051 test_mkdir -p -c1 $dir || error "creating $dir"
5052 local mdtidx=$($LFS getstripe -M $dir)
5053 local mdtname=MDT$(printf %04x $mdtidx)
5054 local facet=mds$((mdtidx + 1))
5056 echo "mcreating $FILECOUNT files"
5057 createmany -m $dir/f 1 $FILECOUNT || \
5058 error "creating files in $dir"
5060 # verify that files do not have EAs yet
5061 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5062 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5066 df $dir #make sure we get new statfs data
5067 local MDSFREE=$(do_facet $facet \
5068 lctl get_param -n osd*.*$mdtname.kbytesfree)
5069 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5070 echo "opening files to create objects/EAs"
5072 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5073 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5076 # verify that files have EAs now
5077 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5078 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5080 sleep 1 #make sure we get new statfs data
5082 local MDSFREE2=$(do_facet $facet \
5083 lctl get_param -n osd*.*$mdtname.kbytesfree)
5084 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5085 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5086 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5087 error "MDC before $MDCFREE != after $MDCFREE2"
5089 echo "MDC before $MDCFREE != after $MDCFREE2"
5090 echo "unable to confirm if MDS has large inodes"
5095 run_test 57b "default LOV EAs are stored inside large inodes ==="
5098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5099 [ -z "$(which wiretest 2>/dev/null)" ] &&
5100 skip_env "could not find wiretest" && return
5103 run_test 58 "verify cross-platform wire constants =============="
5106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5107 echo "touch 130 files"
5108 createmany -o $DIR/f59- 130
5110 unlinkmany $DIR/f59- 130
5112 # wait for commitment of removal
5113 wait_delete_completed
5115 run_test 59 "verify cancellation of llog records async ========="
5117 TEST60_HEAD="test_60 run $RANDOM"
5119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5120 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5121 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5122 skip_env "missing subtest run-llog.sh" && return
5123 log "$TEST60_HEAD - from kernel mode"
5124 do_facet mgs sh run-llog.sh
5126 run_test 60a "llog sanity tests run from kernel module =========="
5128 test_60b() { # bug 6411
5129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5131 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5143 [[ $LLOG_COUNT -gt 50 ]] &&
5144 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5146 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5150 echo "create 5000 files"
5151 createmany -o $DIR/f60c- 5000
5152 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5153 lctl set_param fail_loc=0x80000137
5154 unlinkmany $DIR/f60c- 5000
5155 lctl set_param fail_loc=0
5157 run_test 60c "unlink file when mds full"
5160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5161 SAVEPRINTK=$(lctl get_param -n printk)
5163 # verify "lctl mark" is even working"
5164 MESSAGE="test message ID $RANDOM $$"
5165 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5166 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5168 lctl set_param printk=0 || error "set lnet.printk failed"
5169 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5170 MESSAGE="new test message ID $RANDOM $$"
5171 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5172 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5173 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5175 lctl set_param -n printk="$SAVEPRINTK"
5177 run_test 60d "test printk console message masking"
5180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5182 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5183 cancel_lru_locks osc
5184 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5187 run_test 61 "mmap() writes don't make sync hang ================"
5189 # bug 2330 - insufficient obd_match error checking causes LBUG
5191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5194 cancel_lru_locks osc
5195 lctl set_param fail_loc=0x405
5196 cat $f && error "cat succeeded, expect -EIO"
5197 lctl set_param fail_loc=0
5199 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5200 # match every page all of the time.
5201 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5203 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5204 # Though this test is irrelevant anymore, it helped to reveal some
5205 # other grant bugs (LU-4482), let's keep it.
5206 test_63a() { # was test_63
5207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5208 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5209 for i in `seq 10` ; do
5210 dd if=/dev/zero of=$DIR/f63 bs=8k &
5216 rm -f $DIR/f63 || true
5218 run_test 63a "Verify oig_wait interruption does not crash ======="
5220 # bug 2248 - async write errors didn't return to application on sync
5221 # bug 3677 - async write errors left page locked
5223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5225 lctl set_param debug=-1
5227 # ensure we have a grant to do async writes
5228 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5231 sync # sync lest earlier test intercept the fail_loc
5233 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5234 lctl set_param fail_loc=0x80000406
5235 $MULTIOP $DIR/$tfile Owy && \
5236 error "sync didn't return ENOMEM"
5237 sync; sleep 2; sync # do a real sync this time to flush page
5238 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5239 error "locked page left in cache after async error" || true
5242 run_test 63b "async write errors should be returned to fsync ==="
5245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5247 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5249 run_test 64a "verify filter grant calculations (in kernel) ====="
5252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5253 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5255 run_test 64b "check out-of-space detection on client ==========="
5258 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5260 run_test 64c "verify grant shrink ========================------"
5262 # bug 1414 - set/get directories' stripe info
5264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5265 test_mkdir -p $DIR/$tdir
5267 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5269 run_test 65a "directory with no stripe info ===================="
5272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5273 test_mkdir -p $DIR/$tdir
5274 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5277 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5279 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5283 if [[ $OSTCOUNT -gt 1 ]]; then
5284 test_mkdir -p $DIR/$tdir
5285 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5286 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5288 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5291 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5295 test_mkdir -p $DIR/$tdir
5296 if [[ $STRIPECOUNT -le 0 ]]; then
5298 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5299 #LOV_MAX_STRIPE_COUNT is 2000
5300 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5302 sc=$(($STRIPECOUNT - 1))
5304 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5305 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5306 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5307 error "lverify failed"
5309 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5313 test_mkdir -p $DIR/$tdir
5315 $SETSTRIPE $DIR/$tdir || error "setstripe"
5316 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5317 error "no stripe info failed"
5319 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5321 run_test 65e "directory setstripe defaults ======================="
5324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5325 test_mkdir -p $DIR/${tdir}f
5326 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5328 run_test 65f "dir setstripe permission (should return error) ==="
5331 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5332 test_mkdir -p $DIR/$tdir
5333 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5335 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5336 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5337 error "delete default stripe failed"
5339 run_test 65g "directory setstripe -d ==========================="
5342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5343 test_mkdir -p $DIR/$tdir
5344 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5346 test_mkdir -p $DIR/$tdir/dd1
5347 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5348 error "stripe info inherit failed"
5350 run_test 65h "directory stripe info inherit ===================="
5352 test_65i() { # bug6367
5353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5354 $SETSTRIPE -S 65536 -c -1 $MOUNT
5356 run_test 65i "set non-default striping on root directory (bug 6367)="
5358 test_65ia() { # bug12836
5359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5360 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5362 run_test 65ia "getstripe on -1 default directory striping"
5364 test_65ib() { # bug12836
5365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5366 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5368 run_test 65ib "getstripe -v on -1 default directory striping"
5370 test_65ic() { # bug12836
5371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5372 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5374 run_test 65ic "new find on -1 default directory striping"
5376 test_65j() { # bug6367
5377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5379 # if we aren't already remounting for each test, do so for this test
5380 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5381 cleanup || error "failed to unmount"
5384 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5386 run_test 65j "set default striping on root directory (bug 6367)="
5388 test_65k() { # bug11679
5389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5390 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5391 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5393 echo "Check OST status: "
5394 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5395 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5397 for OSC in $MDS_OSCS; do
5398 echo $OSC "is activate"
5399 do_facet $SINGLEMDS lctl --device %$OSC activate
5403 for INACTIVE_OSC in $MDS_OSCS; do
5404 echo "Deactivate: " $INACTIVE_OSC
5405 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5406 for STRIPE_OSC in $MDS_OSCS; do
5407 OST=`osc_to_ost $STRIPE_OSC`
5408 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5409 awk -F: /$OST/'{ print $1 }' | head -n 1`
5411 [ -f $DIR/$tdir/$IDX ] && continue
5412 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5413 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5415 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5418 echo $INACTIVE_OSC "is Activate."
5419 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5422 run_test 65k "validate manual striping works properly with deactivated OSCs"
5424 test_65l() { # bug 12836
5425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5426 test_mkdir -p $DIR/$tdir/test_dir
5427 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5428 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5430 run_test 65l "lfs find on -1 stripe dir ========================"
5432 # bug 2543 - update blocks count on client
5434 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5436 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5437 sync; sync_all_data; sync; sync_all_data
5438 cancel_lru_locks osc
5439 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5440 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5442 run_test 66 "update inode blocks count on client ==============="
5447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5449 if [ ! -z "$LLOOP" ]; then
5450 if swapon -s | grep -q $LLOOP; then
5451 swapoff $LLOOP || error "swapoff failed"
5454 $LCTL blockdev_detach $LLOOP || error "detach failed"
5458 if [ ! -z "$LLITELOOPLOAD" ]; then
5466 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5470 swapon -s | awk '($1 == "'$1'") { print $4 }'
5473 # test case for lloop driver, basic function
5475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5476 [ "$UID" != 0 ] && skip_env "must run as root" && return
5477 llite_lloop_enabled || \
5478 { skip_env "llite_lloop module disabled" && return; }
5480 trap cleanup_68 EXIT
5482 if ! module_loaded llite_lloop; then
5483 if load_module llite/llite_lloop; then
5486 skip_env "can't find module llite_lloop"
5491 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5492 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5493 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5495 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5496 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5500 run_test 68a "lloop driver - basic test ========================"
5502 # excercise swapping to lustre by adding a high priority swapfile entry
5503 # and then consuming memory until it is used.
5504 test_68b() { # was test_68
5505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5506 [ "$UID" != 0 ] && skip_env "must run as root" && return
5507 lctl get_param -n devices | grep -q obdfilter && \
5508 skip "local OST" && return
5510 grep -q llite_lloop /proc/modules
5511 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5513 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5514 skip "can't reliably test swap with TCP" && return
5516 MEMTOTAL=`meminfo MemTotal`
5517 NR_BLOCKS=$((MEMTOTAL>>8))
5518 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5520 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5521 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5524 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5526 trap cleanup_68 EXIT
5528 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5530 echo "before: `swapon -s | grep $LLOOP`"
5531 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5532 echo "after: `swapon -s | grep $LLOOP`"
5533 SWAPUSED=`swap_used $LLOOP`
5537 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5539 run_test 68b "support swapping to Lustre ========================"
5541 # bug5265, obdfilter oa2dentry return -ENOENT
5542 # #define OBD_FAIL_OST_ENOENT 0x217
5544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5545 remote_ost_nodsh && skip "remote OST with nodsh" && return
5548 $SETSTRIPE -c 1 -i 0 $f
5550 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5552 do_facet ost1 lctl set_param fail_loc=0x217
5553 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5554 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5556 do_facet ost1 lctl set_param fail_loc=0
5557 $DIRECTIO write $f 0 2 || error "write error"
5559 cancel_lru_locks osc
5560 $DIRECTIO read $f 0 1 || error "read error"
5562 do_facet ost1 lctl set_param fail_loc=0x217
5563 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5565 do_facet ost1 lctl set_param fail_loc=0
5568 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5571 test_mkdir -p $DIR/$tdir
5572 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5574 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5576 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5578 [ "$RUNAS_ID" = "$UID" ] &&
5579 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5581 # Check that testing environment is properly set up. Skip if not
5582 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5583 skip_env "User $RUNAS_ID does not exist - skipping"
5587 chmod 777 $DIR/$tfile
5588 chmod ug+s $DIR/$tfile
5589 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5590 error "$RUNAS dd $DIR/$tfile failed"
5591 # See if we are still setuid/sgid
5592 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5593 error "S/gid is not dropped on write"
5594 # Now test that MDS is updated too
5595 cancel_lru_locks mdc
5596 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5597 error "S/gid is not dropped on MDS"
5600 run_test 72a "Test that remove suid works properly (bug5695) ===="
5602 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5605 [ "$RUNAS_ID" = "$UID" ] && \
5606 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5607 [ "$RUNAS_ID" -eq 0 ] && \
5608 skip_env "RUNAS_ID = 0 -- skipping" && return
5610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5611 # Check that testing environment is properly set up. Skip if not
5612 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5613 skip_env "User $RUNAS_ID does not exist - skipping"
5616 touch $DIR/${tfile}-f{g,u}
5617 test_mkdir $DIR/${tfile}-dg
5618 test_mkdir $DIR/${tfile}-du
5619 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5620 chmod g+s $DIR/${tfile}-{f,d}g
5621 chmod u+s $DIR/${tfile}-{f,d}u
5622 for perm in 777 2777 4777; do
5623 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5624 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5625 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5626 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5630 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5632 # bug 3462 - multiple simultaneous MDC requests
5634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5635 test_mkdir $DIR/d73-1
5636 test_mkdir $DIR/d73-2
5637 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5640 lctl set_param fail_loc=0x80000129
5641 $MULTIOP $DIR/d73-1/f73-2 Oc &
5643 lctl set_param fail_loc=0
5645 $MULTIOP $DIR/d73-2/f73-3 Oc &
5649 wait $pid1 || return 1
5653 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5654 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5655 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5659 run_test 73 "multiple MDC requests (should not deadlock)"
5661 test_74a() { # bug 6149, 6184
5662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5663 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5665 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5666 # will spin in a tight reconnection loop
5668 $LCTL set_param fail_loc=0x8000030e
5669 # get any lock that won't be difficult - lookup works.
5671 $LCTL set_param fail_loc=0
5675 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5677 test_74b() { # bug 13310
5678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5679 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5681 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5682 # will spin in a tight reconnection loop
5683 $LCTL set_param fail_loc=0x8000030e
5684 # get a "difficult" lock
5686 $LCTL set_param fail_loc=0
5690 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5693 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5694 #define OBD_FAIL_LDLM_NEW_LOCK
5695 $LCTL set_param fail_loc=0x319
5696 touch $DIR/$tfile && error "touch successful"
5697 $LCTL set_param fail_loc=0
5700 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5703 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5706 get_inode_slab_tunables() {
5707 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5710 set_inode_slab_tunables() {
5711 echo "lustre_inode_cache $1" > /proc/slabinfo
5714 test_76() { # Now for bug 20433, added originally in bug 1443
5715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5716 local SLAB_SETTINGS=`get_inode_slab_tunables`
5717 local CPUS=`getconf _NPROCESSORS_ONLN`
5718 # we cannot set limit below 1 which means 1 inode in each
5719 # per-cpu cache is still allowed
5720 set_inode_slab_tunables "1 1 0"
5721 cancel_lru_locks osc
5722 BEFORE_INODES=$(num_inodes)
5723 echo "before inodes: $BEFORE_INODES"
5725 [ "$SLOW" = "no" ] && COUNT=100
5726 for i in $(seq $COUNT); do
5730 cancel_lru_locks osc
5731 AFTER_INODES=$(num_inodes)
5732 echo "after inodes: $AFTER_INODES"
5734 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5736 AFTER_INODES=$(num_inodes)
5738 echo "wait $wait seconds inodes: $AFTER_INODES"
5739 if [ $wait -gt 30 ]; then
5740 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5743 set_inode_slab_tunables "$SLAB_SETTINGS"
5745 run_test 76 "confirm clients recycle inodes properly ===="
5751 # Note: in sptlrpc modes which enable its own bulk checksum, the
5752 # original crc32_le bulk checksum will be automatically disabled,
5753 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5754 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5755 # In this case set_checksums() will not be no-op, because sptlrpc
5756 # bulk checksum will be enabled all through the test.
5758 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5759 lctl set_param -n osc.*.checksums $1
5763 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5764 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5765 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5766 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5769 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5770 log "set checksum type to $1"
5773 F77_TMP=$TMP/f77-temp
5776 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5777 error "error writing to $F77_TMP"
5780 test_77a() { # bug 10889
5781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5782 $GSS && skip "could not run with gss" && return
5783 [ ! -f $F77_TMP ] && setup_f77
5785 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5789 run_test 77a "normal checksum read/write operation"
5791 test_77b() { # bug 10889
5792 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5793 $GSS && skip "could not run with gss" && return
5794 [ ! -f $F77_TMP ] && setup_f77
5795 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5796 $LCTL set_param fail_loc=0x80000409
5799 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5800 error "dd error: $?"
5801 $LCTL set_param fail_loc=0
5803 for algo in $CKSUM_TYPES; do
5804 cancel_lru_locks osc
5805 set_checksum_type $algo
5806 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5807 $LCTL set_param fail_loc=0x80000408
5808 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5809 $LCTL set_param fail_loc=0
5812 set_checksum_type $ORIG_CSUM_TYPE
5815 run_test 77b "checksum error on client write, read"
5817 test_77d() { # bug 10889
5818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5819 $GSS && skip "could not run with gss" && return
5820 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5821 $LCTL set_param fail_loc=0x80000409
5823 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5824 error "direct write: rc=$?"
5825 $LCTL set_param fail_loc=0
5828 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5829 $LCTL set_param fail_loc=0x80000408
5831 cancel_lru_locks osc
5832 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5833 error "direct read: rc=$?"
5834 $LCTL set_param fail_loc=0
5837 run_test 77d "checksum error on OST direct write, read"
5839 test_77f() { # bug 10889
5840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5841 $GSS && skip "could not run with gss" && return
5843 for algo in $CKSUM_TYPES; do
5844 cancel_lru_locks osc
5845 set_checksum_type $algo
5846 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5847 $LCTL set_param fail_loc=0x409
5848 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5849 error "direct write succeeded"
5850 $LCTL set_param fail_loc=0
5852 set_checksum_type $ORIG_CSUM_TYPE
5855 run_test 77f "repeat checksum error on write (expect error)"
5857 test_77g() { # bug 10889
5858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5859 $GSS && skip "could not run with gss" && return
5860 remote_ost_nodsh && skip "remote OST with nodsh" && return
5862 [ ! -f $F77_TMP ] && setup_f77
5864 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5865 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5866 do_facet ost1 lctl set_param fail_loc=0x8000021a
5868 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5869 error "write error: rc=$?"
5870 do_facet ost1 lctl set_param fail_loc=0
5873 cancel_lru_locks osc
5874 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5875 do_facet ost1 lctl set_param fail_loc=0x8000021b
5877 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5878 do_facet ost1 lctl set_param fail_loc=0
5881 run_test 77g "checksum error on OST write, read"
5883 test_77i() { # bug 13805
5884 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5885 $GSS && skip "could not run with gss" && return
5886 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5887 lctl set_param fail_loc=0x40b
5888 remount_client $MOUNT
5889 lctl set_param fail_loc=0
5890 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5891 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5892 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5893 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5895 remount_client $MOUNT
5897 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5899 test_77j() { # bug 13805
5900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5901 $GSS && skip "could not run with gss" && return
5902 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5903 lctl set_param fail_loc=0x40c
5904 remount_client $MOUNT
5905 lctl set_param fail_loc=0
5906 sleep 2 # wait async osc connect to finish
5907 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5908 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5909 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5910 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5912 remount_client $MOUNT
5914 run_test 77j "client only supporting ADLER32"
5916 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5920 test_78() { # bug 10901
5921 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5922 remote_ost || { skip_env "local OST" && return; }
5925 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5926 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5927 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5928 echo "MemTotal: $MEMTOTAL"
5930 # reserve 256MB of memory for the kernel and other running processes,
5931 # and then take 1/2 of the remaining memory for the read/write buffers.
5932 if [ $MEMTOTAL -gt 512 ] ;then
5933 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5935 # for those poor memory-starved high-end clusters...
5936 MEMTOTAL=$((MEMTOTAL / 2))
5938 echo "Mem to use for directio: $MEMTOTAL"
5940 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5941 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5942 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5943 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5945 echo "Smallest OST: $SMALLESTOST"
5946 [[ $SMALLESTOST -lt 10240 ]] &&
5947 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5949 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5950 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5952 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5953 echo "File size: $F78SIZE"
5954 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5955 for i in $(seq 1 $NSEQ); do
5956 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5957 echo directIO rdwr round $i of $NSEQ
5958 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5963 run_test 78 "handle large O_DIRECT writes correctly ============"
5965 test_79() { # bug 12743
5966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5967 wait_delete_completed
5969 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5970 BKFREE=$(calc_osc_kbytes kbytesfree)
5971 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5973 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5974 DFTOTAL=`echo $STRING | cut -d, -f1`
5975 DFUSED=`echo $STRING | cut -d, -f2`
5976 DFAVAIL=`echo $STRING | cut -d, -f3`
5977 DFFREE=$(($DFTOTAL - $DFUSED))
5979 ALLOWANCE=$((64 * $OSTCOUNT))
5981 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5982 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5983 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5985 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5986 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5987 error "df free($DFFREE) mismatch OST free($BKFREE)"
5989 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5990 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5991 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5994 run_test 79 "df report consistency check ======================="
5996 test_80() { # bug 10718
5997 remote_ost_nodsh && skip "remote OST with nodsh" && return
5998 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5999 # relax strong synchronous semantics for slow backends like ZFS
6000 local soc="obdfilter.*.sync_on_lock_cancel"
6001 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6003 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6004 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6005 facet_active_host $host; done | sort -u)
6006 do_nodes $hosts lctl set_param $soc=never
6009 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6011 local BEFORE=`date +%s`
6012 cancel_lru_locks osc
6013 local AFTER=`date +%s`
6014 local DIFF=$((AFTER-BEFORE))
6015 if [ $DIFF -gt 1 ] ; then
6016 error "elapsed for 1M@1T = $DIFF"
6019 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6023 run_test 80 "Page eviction is equally fast at high offsets too ===="
6025 test_81a() { # LU-456
6026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6027 remote_ost_nodsh && skip "remote OST with nodsh" && return
6028 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6029 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6030 do_facet ost1 lctl set_param fail_loc=0x80000228
6032 # write should trigger a retry and success
6033 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6034 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6036 if [ $RC -ne 0 ] ; then
6037 error "write should success, but failed for $RC"
6040 run_test 81a "OST should retry write when get -ENOSPC ==============="
6042 test_81b() { # LU-456
6043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6044 remote_ost_nodsh && skip "remote OST with nodsh" && return
6045 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6046 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6047 do_facet ost1 lctl set_param fail_loc=0x228
6049 # write should retry several times and return -ENOSPC finally
6050 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6051 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6054 if [ $RC -ne $ENOSPC ] ; then
6055 error "dd should fail for -ENOSPC, but succeed."
6058 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6060 test_82() { # LU-1031
6061 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6065 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6067 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6069 kill -USR1 $MULTIPID2
6071 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6072 error "First grouplock does not block second one"
6074 echo "Second grouplock blocks first one"
6076 kill -USR1 $MULTIPID1
6080 run_test 82 "Basic grouplock test ==============================="
6083 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6085 test_mkdir -p $DIR/d99cvsroot
6086 chown $RUNAS_ID $DIR/d99cvsroot
6087 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6090 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6093 run_test 99a "cvs init ========================================="
6096 [ -z "$(which cvs 2>/dev/null)" ] &&
6097 skip_env "could not find cvs" && return
6098 [ ! -d $DIR/d99cvsroot ] && test_99a
6100 # some versions of cvs import exit(1) when asked to import links or
6101 # files they can't read. ignore those files.
6102 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6103 ! -perm +4 -printf '-I %f\n')
6104 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6105 d99reposname vtag rtag
6107 run_test 99b "cvs import ======================================="
6110 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6111 [ ! -d $DIR/d99cvsroot ] && test_99b
6113 test_mkdir -p $DIR/d99reposname
6114 chown $RUNAS_ID $DIR/d99reposname
6115 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6117 run_test 99c "cvs checkout ====================================="
6120 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6121 [ ! -d $DIR/d99cvsroot ] && test_99c
6122 cd $DIR/d99reposname
6124 $RUNAS cvs add -m 'addmsg' foo99
6126 run_test 99d "cvs add =========================================="
6129 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6130 [ ! -d $DIR/d99cvsroot ] && test_99c
6131 cd $DIR/d99reposname
6134 run_test 99e "cvs update ======================================="
6137 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6138 [ ! -d $DIR/d99cvsroot ] && test_99d
6139 cd $DIR/d99reposname
6140 $RUNAS cvs commit -m 'nomsg' foo99
6141 rm -fr $DIR/d99cvsroot
6143 run_test 99f "cvs commit ======================================="
6146 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6147 [ "$NETTYPE" = tcp ] || \
6148 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6151 remote_ost_nodsh && skip "remote OST with nodsh" && return
6152 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6154 { skip "useless for local single node setup" && return; }
6156 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6157 [ "$PROT" != "tcp" ] && continue
6158 RPORT=$(echo $REMOTE | cut -d: -f2)
6159 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6162 LPORT=`echo $LOCAL | cut -d: -f2`
6163 if [ $LPORT -ge 1024 ]; then
6164 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6166 error_exit "local: $LPORT > 1024, remote: $RPORT"
6169 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6171 run_test 100 "check local port using privileged port ==========="
6173 function get_named_value()
6182 echo $line | sed "s/^$tag[ ]*//"
6189 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6190 awk '/^max_cached_mb/ { print $2 }')
6193 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6199 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6203 local cache_limit=32
6205 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6206 trap cleanup_101a EXIT
6207 $LCTL set_param -n llite.*.read_ahead_stats 0
6208 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6211 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6213 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6214 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6217 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6218 get_named_value 'read but discarded' | cut -d" " -f1); do
6219 discard=$(($discard + $s))
6223 if [[ $(($discard * 10)) -gt $nreads ]]; then
6224 $LCTL get_param osc.*-osc*.rpc_stats
6225 $LCTL get_param llite.*.read_ahead_stats
6226 error "too many ($discard) discarded pages"
6228 rm -f $DIR/$tfile || true
6230 run_test 101a "check read-ahead for random reads ================"
6233 test_mkdir -p $DIR/$tdir
6234 local STRIPE_SIZE=$1
6235 local FILE_LENGTH=$2
6238 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6240 local list=$(comma_list $(osts_nodes))
6241 set_osd_param $list '' read_cache_enable 0
6242 set_osd_param $list '' writethrough_cache_enable 0
6244 trap cleanup_test101bc EXIT
6245 # prepare the read-ahead file
6246 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6248 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6249 count=$FILE_SIZE_MB 2> /dev/null
6253 cleanup_test101bc() {
6258 local list=$(comma_list $(osts_nodes))
6259 set_osd_param $list '' read_cache_enable 1
6260 set_osd_param $list '' writethrough_cache_enable 1
6264 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6269 local STRIPE_SIZE=$2
6270 local FILE_LENGTH=$3
6271 local RA_INC=1048576
6272 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6273 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6274 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6275 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6276 get_named_value 'read but discarded' |
6277 cut -d" " -f1 | calc_total)
6278 if [[ $DISCARD -gt $discard_limit ]]; then
6279 $LCTL get_param llite.*.read_ahead_stats
6280 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6282 echo "Read-ahead success for size ${READ_SIZE}"
6287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6288 [[ $OSTCOUNT -lt 2 ]] &&
6289 skip_env "skipping stride IO stride-ahead test" && return
6290 local STRIPE_SIZE=1048576
6291 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6292 if [ $SLOW == "yes" ]; then
6293 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6295 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6298 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6300 # prepare the read-ahead file
6301 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6302 cancel_lru_locks osc
6303 for BIDX in 2 4 8 16 32 64 128 256
6305 local BSIZE=$((BIDX*4096))
6306 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6307 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6308 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6309 $LCTL set_param -n llite.*.read_ahead_stats 0
6310 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6311 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6312 cancel_lru_locks osc
6313 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6318 run_test 101b "check stride-io mode read-ahead ================="
6321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6322 local STRIPE_SIZE=1048576
6323 local FILE_LENGTH=$((STRIPE_SIZE*100))
6327 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6329 cancel_lru_locks osc
6330 $LCTL set_param osc.*.rpc_stats 0
6331 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6332 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6333 local stats=$($LCTL get_param -n $osc_rpc_stats)
6334 local lines=$(echo "$stats" | awk 'END {print NR;}')
6337 if [ $lines -le 20 ]; then
6340 for size in 1 2 4 8; do
6341 local rpc=$(echo "$stats" |
6342 awk '($1 == "'$size':") {print $2; exit; }')
6344 error "Small $((size*4))k read IO $rpc !"
6346 echo "$osc_rpc_stats check passed!"
6351 run_test 101c "check stripe_size aligned read-ahead ================="
6354 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6355 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6360 local file=$DIR/$tfile
6361 local sz_MB=${FILESIZE_101d:-500}
6362 local ra_MB=${READAHEAD_MB:-40}
6364 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6365 [ $free_MB -lt $sz_MB ] &&
6366 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6368 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6369 $SETSTRIPE -c -1 $file || error "setstripe failed"
6371 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6372 echo Cancel LRU locks on lustre client to flush the client cache
6373 cancel_lru_locks osc
6375 echo Disable read-ahead
6376 local old_READAHEAD=$(set_read_ahead 0)
6378 echo Reading the test file $file with read-ahead disabled
6379 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6381 echo Cancel LRU locks on lustre client to flush the client cache
6382 cancel_lru_locks osc
6383 echo Enable read-ahead with ${ra_MB}MB
6384 set_read_ahead $ra_MB
6386 echo Reading the test file $file with read-ahead enabled
6387 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6389 echo "read-ahead disabled time read $raOFF"
6390 echo "read-ahead enabled time read $raON"
6392 set_read_ahead $old_READAHEAD
6394 wait_delete_completed
6396 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6397 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6399 run_test 101d "file read with and without read-ahead enabled"
6402 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6403 local file=$DIR/$tfile
6404 local size_KB=500 #KB
6408 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6409 local need_KB=$((count * size_KB))
6410 [[ $free_KB -le $need_KB ]] &&
6411 skip_env "Need free space $need_KB, have $free_KB" && return
6413 echo "Creating $count ${size_KB}K test files"
6414 for ((i = 0; i < $count; i++)); do
6415 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6418 echo "Cancel LRU locks on lustre client to flush the client cache"
6419 cancel_lru_locks osc
6421 echo "Reset readahead stats"
6422 $LCTL set_param -n llite.*.read_ahead_stats 0
6424 for ((i = 0; i < $count; i++)); do
6425 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6428 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6429 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6431 for ((i = 0; i < $count; i++)); do
6432 rm -rf $file.$i 2>/dev/null
6435 #10000 means 20% reads are missing in readahead
6436 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6438 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6440 cleanup_test101f() {
6442 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6443 rm -rf $DIR/$tfile 2>/dev/null
6447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6448 local file=$DIR/$tfile
6451 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6452 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6453 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6454 trap cleanup_test101f EXIT
6456 echo Cancel LRU locks on lustre client to flush the client cache
6457 cancel_lru_locks osc
6459 echo Reset readahead stats
6460 $LCTL set_param -n llite.*.read_ahead_stats 0
6461 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6462 # readahead should read in 2M file on second read, so only miss
6464 echo Random 4K reads on 2M file for 1000 times
6465 $READS -f $file -s 2097152 -b 4096 -n $nreads
6467 echo checking missing pages
6468 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6469 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6471 [ $miss -lt 3 ] || error "misses too much pages!"
6474 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6477 test_mkdir -p $DIR/$tdir
6478 chown $RUNAS_ID $DIR/$tdir
6481 STRIPE_COUNT=$OSTCOUNT
6482 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6484 trap cleanup_test102 EXIT
6486 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6488 for num in 1 2 3 4; do
6489 for count in $(seq 1 $STRIPE_COUNT); do
6490 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6491 local size=`expr $STRIPE_SIZE \* $num`
6492 local file=file"$num-$idx-$count"
6493 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6499 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6505 rm -rf $DIR/d0.sanity/d102
6509 local testfile=$DIR/$tfile
6513 [ "$UID" != 0 ] && skip_env "must run as root" && return
6514 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6515 skip_env "must have user_xattr" && return
6517 [ -z "$(which setfattr 2>/dev/null)" ] &&
6518 skip_env "could not find setfattr" && return
6520 echo "set/get xattr..."
6521 setfattr -n trusted.name1 -v value1 $testfile ||
6522 error "setfattr -n trusted.name1=value1 $testfile failed"
6523 getfattr -n trusted.name1 $testfile 2> /dev/null |
6524 grep "trusted.name1=.value1" ||
6525 error "$testfile missing trusted.name1=value1"
6527 setfattr -n user.author1 -v author1 $testfile ||
6528 error "setfattr -n user.author1=author1 $testfile failed"
6529 getfattr -n user.author1 $testfile 2> /dev/null |
6530 grep "user.author1=.author1" ||
6531 error "$testfile missing trusted.author1=author1"
6534 setfattr -n trusted.name2 -v value2 $testfile ||
6535 error "$testfile unable to set trusted.name2"
6536 setfattr -n trusted.name3 -v value3 $testfile ||
6537 error "$testfile unable to set trusted.name3"
6538 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6539 grep "trusted.name" | wc -l) -eq 3 ] ||
6540 error "$testfile missing 3 trusted.name xattrs"
6542 setfattr -n user.author2 -v author2 $testfile ||
6543 error "$testfile unable to set user.author2"
6544 setfattr -n user.author3 -v author3 $testfile ||
6545 error "$testfile unable to set user.author3"
6546 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6547 grep "user.author" | wc -l) -eq 3 ] ||
6548 error "$testfile missing 3 user.author xattrs"
6550 echo "remove xattr..."
6551 setfattr -x trusted.name1 $testfile ||
6552 error "$testfile error deleting trusted.name1"
6553 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6554 error "$testfile did not delete trusted.name1 xattr"
6556 setfattr -x user.author1 $testfile ||
6557 error "$testfile error deleting user.author1"
6558 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6559 error "$testfile did not delete trusted.name1 xattr"
6561 # b10667: setting lustre special xattr be silently discarded
6562 echo "set lustre special xattr ..."
6563 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6564 error "$testfile allowed setting trusted.lov"
6566 run_test 102a "user xattr test =================================="
6569 [ -z "$(which setfattr 2>/dev/null)" ] &&
6570 skip_env "could not find setfattr" && return
6572 # b10930: get/set/list trusted.lov xattr
6573 echo "get/set/list trusted.lov xattr ..."
6574 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6575 local testfile=$DIR/$tfile
6576 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6577 error "setstripe failed"
6578 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6579 error "getstripe failed"
6580 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6581 error "can't get trusted.lov from $testfile"
6583 local testfile2=${testfile}2
6584 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6585 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6588 setfattr -n trusted.lov -v $value $testfile2
6589 local stripe_size=$($GETSTRIPE -S $testfile2)
6590 local stripe_count=$($GETSTRIPE -c $testfile2)
6591 [[ $stripe_size -eq 65536 ]] ||
6592 error "stripe size $stripe_size != 65536"
6593 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6594 error "stripe count $stripe_count != $STRIPECOUNT"
6597 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6600 [ -z "$(which setfattr 2>/dev/null)" ] &&
6601 skip_env "could not find setfattr" && return
6603 # b10930: get/set/list lustre.lov xattr
6604 echo "get/set/list lustre.lov xattr ..."
6605 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6606 test_mkdir -p $DIR/$tdir
6607 chown $RUNAS_ID $DIR/$tdir
6608 local testfile=$DIR/$tdir/$tfile
6609 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6610 error "setstripe failed"
6611 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6612 error "getstripe failed"
6613 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6614 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6616 local testfile2=${testfile}2
6617 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6618 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6620 $RUNAS $MCREATE $testfile2
6621 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6622 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6623 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6624 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6625 [ $stripe_count -eq $STRIPECOUNT ] ||
6626 error "stripe count $stripe_count != $STRIPECOUNT"
6628 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6630 compare_stripe_info1() {
6631 local stripe_index_all_zero=true
6633 for num in 1 2 3 4; do
6634 for count in $(seq 1 $STRIPE_COUNT); do
6635 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6636 local size=$((STRIPE_SIZE * num))
6637 local file=file"$num-$offset-$count"
6638 stripe_size=$($LFS getstripe -S $PWD/$file)
6639 [[ $stripe_size -ne $size ]] &&
6640 error "$file: size $stripe_size != $size"
6641 stripe_count=$($LFS getstripe -c $PWD/$file)
6642 # allow fewer stripes to be created, ORI-601
6643 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6644 error "$file: count $stripe_count != $count"
6645 stripe_index=$($LFS getstripe -i $PWD/$file)
6646 [[ $stripe_index -ne 0 ]] &&
6647 stripe_index_all_zero=false
6651 $stripe_index_all_zero &&
6652 error "all files are being extracted starting from OST index 0"
6657 [ -n "$(which tar 2>/dev/null)" ] &&
6658 strings $(which tar) | grep -q "lustre" && echo tar
6662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6663 # b10930: tar test for trusted.lov xattr
6664 TAR=$(find_lustre_tar)
6665 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6666 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6668 test_mkdir -p $DIR/d102d
6669 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6671 compare_stripe_info1
6673 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6676 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6677 # b10930: tar test for trusted.lov xattr
6678 TAR=$(find_lustre_tar)
6679 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6680 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6682 test_mkdir -p $DIR/d102f
6684 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6686 compare_stripe_info1
6688 run_test 102f "tar copy files, not keep osts ==========="
6691 local xsize=${1:-1024} # in bytes
6692 local file=$DIR/$tfile
6694 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6695 skip "must have user_xattr" && return 0
6696 [ -z "$(which setfattr 2>/dev/null)" ] &&
6697 skip_env "could not find setfattr" && return 0
6698 [ -z "$(which getfattr 2>/dev/null)" ] &&
6699 skip_env "could not find getfattr" && return 0
6703 local value="$(generate_string $xsize)"
6705 local xbig=trusted.big
6706 log "save $xbig on $file"
6707 setfattr -n $xbig -v $value $file ||
6708 error "saving $xbig on $file failed"
6710 local orig=$(get_xattr_value $xbig $file)
6711 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6713 local xsml=trusted.sml
6714 log "save $xsml on $file"
6715 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6717 local new=$(get_xattr_value $xbig $file)
6718 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6720 log "grow $xsml on $file"
6721 setfattr -n $xsml -v "$value" $file ||
6722 error "growing $xsml on $file failed"
6724 new=$(get_xattr_value $xbig $file)
6725 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6726 log "$xbig still valid after growing $xsml"
6731 test_102h() { # bug 15777
6734 run_test 102h "grow xattr from inside inode to external block"
6737 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6738 grow_xattr $(max_xattr_size)
6740 run_test 102ha "grow xattr from inside inode to external inode"
6742 test_102i() { # bug 17038
6743 [ -z "$(which getfattr 2>/dev/null)" ] &&
6744 skip "could not find getfattr" && return
6746 ln -s $DIR/$tfile $DIR/${tfile}link
6747 getfattr -n trusted.lov $DIR/$tfile ||
6748 error "lgetxattr on $DIR/$tfile failed"
6749 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6750 grep -i "no such attr" ||
6751 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6752 rm -f $DIR/$tfile $DIR/${tfile}link
6754 run_test 102i "lgetxattr test on symbolic link ============"
6757 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6758 TAR=$(find_lustre_tar)
6759 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6760 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6761 setup_test102 "$RUNAS"
6762 test_mkdir -p $DIR/d102j
6763 chown $RUNAS_ID $DIR/d102j
6764 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6766 compare_stripe_info1 "$RUNAS"
6768 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6771 [ -z "$(which setfattr 2>/dev/null)" ] &&
6772 skip "could not find setfattr" && return
6774 # b22187 just check that does not crash for regular file.
6775 setfattr -n trusted.lov $DIR/$tfile
6776 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6777 local test_kdir=$DIR/d102k
6778 test_mkdir $test_kdir
6779 local default_size=`$GETSTRIPE -S $test_kdir`
6780 local default_count=`$GETSTRIPE -c $test_kdir`
6781 local default_offset=`$GETSTRIPE -i $test_kdir`
6782 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6783 error 'dir setstripe failed'
6784 setfattr -n trusted.lov $test_kdir
6785 local stripe_size=`$GETSTRIPE -S $test_kdir`
6786 local stripe_count=`$GETSTRIPE -c $test_kdir`
6787 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6788 [ $stripe_size -eq $default_size ] ||
6789 error "stripe size $stripe_size != $default_size"
6790 [ $stripe_count -eq $default_count ] ||
6791 error "stripe count $stripe_count != $default_count"
6792 [ $stripe_offset -eq $default_offset ] ||
6793 error "stripe offset $stripe_offset != $default_offset"
6794 rm -rf $DIR/$tfile $test_kdir
6796 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6799 [ -z "$(which getfattr 2>/dev/null)" ] &&
6800 skip "could not find getfattr" && return
6802 # LU-532 trusted. xattr is invisible to non-root
6803 local testfile=$DIR/$tfile
6807 echo "listxattr as user..."
6808 chown $RUNAS_ID $testfile
6809 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6810 grep -q "trusted" &&
6811 error "$testfile trusted xattrs are user visible"
6815 run_test 102l "listxattr size test =================================="
6817 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6818 local path=$DIR/$tfile
6821 listxattr_size_check $path || error "listattr_size_check $path failed"
6823 run_test 102m "Ensure listxattr fails on small bufffer ========"
6827 getxattr() { # getxattr path name
6828 # Return the base64 encoding of the value of xattr name on path.
6832 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6834 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6836 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6838 getfattr --absolute-names --encoding=base64 --name=$name $path |
6839 awk -F= -v name=$name '$1 == name {
6840 print substr($0, index($0, "=") + 1);
6844 test_102n() { # LU-4101 mdt: protect internal xattrs
6845 local file0=$DIR/$tfile.0
6846 local file1=$DIR/$tfile.1
6847 local xattr0=$TMP/$tfile.0
6848 local xattr1=$TMP/$tfile.1
6852 [ -z "$(which setfattr 2>/dev/null)" ] &&
6853 skip "could not find setfattr" && return
6855 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6857 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6861 rm -rf $file0 $file1 $xattr0 $xattr1
6864 # Get 'before' xattrs of $file1.
6865 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6867 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6868 # Try to copy xattr from $file0 to $file1.
6869 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6871 setfattr --name=trusted.$name --value="$value" $file1 ||
6872 error "setxattr 'trusted.$name' failed"
6874 # Try to set a garbage xattr.
6875 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6877 setfattr --name=trusted.$name --value="$value" $file1 ||
6878 error "setxattr 'trusted.$name' failed"
6880 # Try to remove the xattr from $file1. We don't care if this
6881 # appears to succeed or fail, we just don't want there to be
6882 # any changes or crashes.
6883 setfattr --remove=$trusted.$name $file1 2> /dev/null
6886 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6889 # Try to copy xattr from $file0 to $file1.
6890 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6892 setfattr --name=trusted.$name --value="$value" $file1 ||
6893 error "setxattr 'trusted.$name' failed"
6895 # Try to set a garbage xattr.
6896 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6898 setfattr --name=trusted.$name --value="$value" $file1 ||
6899 error "setxattr 'trusted.$name' failed"
6901 # Try to remove the xattr from $file1. We don't care if this
6902 # appears to succeed or fail, we just don't want there to be
6903 # any changes or crashes.
6904 setfattr --remove=$trusted.$name $file1 2> /dev/null
6907 # Get 'after' xattrs of file1.
6908 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6910 if ! diff $xattr0 $xattr1; then
6911 error "before and after xattrs of '$file1' differ"
6914 rm -rf $file0 $file1 $xattr0 $xattr1
6918 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6920 test_102p() { # LU-4703 setxattr did not check ownership
6921 local testfile=$DIR/$tfile
6923 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6924 skip "MDS needs to be at least 2.5.56" && return
6928 echo "setfacl as user..."
6929 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6930 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6932 echo "setfattr as user..."
6933 setfacl -m "u:$RUNAS_ID:---" $testfile
6934 $RUNAS setfattr -x system.posix_acl_access $testfile
6935 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6937 run_test 102p "check setxattr(2) correctly fails without permission"
6940 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
6942 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
6945 touch $DIR/$tfile || error "touch"
6946 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
6947 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
6948 rm $DIR/$tfile || error "rm"
6950 run_test 102r "set EAs with empty values"
6954 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6959 [ "$UID" != 0 ] && skip_env "must run as root" && return
6960 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6961 skip "must have acl enabled" && return
6962 [ -z "$(which setfacl 2>/dev/null)" ] &&
6963 skip_env "could not find setfacl" && return
6964 $GSS && skip "could not run under gss" && return
6966 gpasswd -a daemon bin # LU-5641
6967 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
6969 declare -a identity_old
6971 for num in $(seq $MDSCOUNT); do
6972 switch_identity $num true || identity_old[$num]=$?
6979 echo "performing cp ..."
6980 run_acl_subtest cp || error "run_acl_subtest cp failed"
6981 echo "performing getfacl-noacl..."
6982 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6983 echo "performing misc..."
6984 run_acl_subtest misc || error "misc test failed"
6985 echo "performing permissions..."
6986 run_acl_subtest permissions || error "permissions failed"
6987 echo "performing setfacl..."
6988 run_acl_subtest setfacl || error "setfacl test failed"
6990 # inheritance test got from HP
6991 echo "performing inheritance..."
6992 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6993 chmod +x make-tree || error "chmod +x failed"
6994 run_acl_subtest inheritance || error "inheritance test failed"
6997 echo "LU-974 ignore umask when acl is enabled..."
6998 run_acl_subtest 974 || error "LU-974 umask test failed"
6999 if [ $MDSCOUNT -ge 2 ]; then
7000 run_acl_subtest 974_remote ||
7001 error "LU-974 umask test failed under remote dir"
7004 echo "LU-2561 newly created file is same size as directory..."
7005 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7006 run_acl_subtest 2561 || error "LU-2561 test failed"
7008 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7011 run_acl_subtest 4924 || error "LU-4924 test failed"
7016 for num in $(seq $MDSCOUNT); do
7017 if [ "${identity_old[$num]}" = 1 ]; then
7018 switch_identity $num false || identity_old[$num]=$?
7022 run_test 103a "acl test ========================================="
7026 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7027 local mountopts=$MDS_MOUNT_OPTS
7029 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7033 stop $SINGLEMDS || error "failed to stop MDT."
7035 if [ -z "$MDS_MOUNT_OPTS" ]; then
7036 MDS_MOUNT_OPTS="-o noacl"
7038 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7040 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7041 error "failed to start MDT."
7042 MDS_MOUNT_OPTS=$mountopts
7046 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7050 stop $SINGLEMDS || error "failed to stop MDT."
7052 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7053 error "failed to start MDT."
7058 run_test 103b "MDS mount option 'noacl'"
7062 cp -rp $DIR/$tdir $DIR/$tdir.bak
7064 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7065 error "$DIR/$tdir shouldn't contain default ACL"
7066 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7067 error "$DIR/$tdir.bak shouldn't contain default ACL"
7070 run_test 103c "'cp -rp' won't set empty acl"
7073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7075 lfs df || error "lfs df failed"
7076 lfs df -ih || error "lfs df -ih failed"
7077 lfs df -h $DIR || error "lfs df -h $DIR failed"
7078 lfs df -i $DIR || error "lfs df -i $DIR failed"
7079 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7080 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7082 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7083 lctl --device %$OSC deactivate
7084 lfs df || error "lfs df with deactivated OSC failed"
7085 lctl --device %$OSC activate
7086 # wait the osc back to normal
7087 wait_osc_import_state client ost FULL
7089 lfs df || error "lfs df with reactivated OSC failed"
7092 run_test 104a "lfs df [-ih] [path] test ========================="
7095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7096 [ $RUNAS_ID -eq $UID ] &&
7097 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7099 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7100 grep "Permission denied" | wc -l)))
7101 if [ $denied_cnt -ne 0 ]; then
7102 error "lfs check servers test failed"
7105 run_test 104b "$RUNAS lfs check servers test ===================="
7108 # doesn't work on 2.4 kernels
7110 if $(flock_is_enabled); then
7111 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7113 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7117 run_test 105a "flock when mounted without -o flock test ========"
7121 if $(flock_is_enabled); then
7122 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7124 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7128 run_test 105b "fcntl when mounted without -o flock test ========"
7132 if $(flock_is_enabled); then
7133 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7135 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7139 run_test 105c "lockf when mounted without -o flock test ========"
7141 test_105d() { # bug 15924
7142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7143 test_mkdir -p $DIR/$tdir
7144 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7145 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7146 $LCTL set_param fail_loc=0x80000315
7147 flocks_test 2 $DIR/$tdir
7149 run_test 105d "flock race (should not freeze) ========"
7151 test_105e() { # bug 22660 && 22040
7152 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7154 flocks_test 3 $DIR/$tfile
7156 run_test 105e "Two conflicting flocks from same process ======="
7158 test_106() { #bug 10921
7159 test_mkdir -p $DIR/$tdir
7160 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7161 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7163 run_test 106 "attempt exec of dir followed by chown of that dir"
7166 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7173 local save_pattern=$(sysctl -n kernel.core_pattern)
7174 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7175 sysctl -w kernel.core_pattern=$file
7176 sysctl -w kernel.core_uses_pid=0
7184 kill -s 11 $SLEEPPID
7186 if [ -e $file ]; then
7187 size=`stat -c%s $file`
7188 [ $size -eq 0 ] && error "Fail to create core file $file"
7190 error "Fail to create core file $file"
7193 sysctl -w kernel.core_pattern=$save_pattern
7194 sysctl -w kernel.core_uses_pid=$save_uses_pid
7197 run_test 107 "Coredump on SIG"
7200 test_mkdir -p $DIR/$tdir
7201 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7202 error "mkdir with 255 char failed"
7203 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7204 error "mkdir with 256 char should fail, but did not"
7205 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7206 error "create with 255 char failed"
7207 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7208 error "create with 256 char should fail, but did not"
7213 run_test 110 "filename length checking"
7216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7217 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7218 tail -1 | cut -c11-20)
7219 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7220 echo "Starting with $OSTIO_pre threads"
7223 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7224 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7225 echo "$NUMTEST creates/unlinks"
7226 test_mkdir -p $DIR/$tdir
7227 createmany -o $DIR/$tdir/$tfile $NUMTEST
7228 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7230 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7231 tail -1 | cut -c11-20)
7233 # don't return an error
7234 [ $OSTIO_post == $OSTIO_pre ] && echo \
7235 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7236 echo "This may be fine, depending on what ran before this test" &&
7237 echo "and how fast this system is." && return
7239 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7241 run_test 115 "verify dynamic thread creation===================="
7244 wait_delete_completed
7245 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7246 echo OST kbytes available: ${AVAIL[@]}
7247 MAXI=0; MAXV=${AVAIL[0]}
7248 MINI=0; MINV=${AVAIL[0]}
7249 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7250 #echo OST $i: ${AVAIL[i]}kb
7251 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7252 MAXV=${AVAIL[i]}; MAXI=$i
7254 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7255 MINV=${AVAIL[i]}; MINI=$i
7258 echo Min free space: OST $MINI: $MINV
7259 echo Max free space: OST $MAXI: $MAXV
7262 test_116a() { # was previously test_116()
7263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7264 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7266 echo -n "Free space priority "
7267 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7272 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7273 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7275 trap simple_cleanup_common EXIT
7278 # Check if we need to generate uneven OSTs
7279 test_mkdir -p $DIR/$tdir/OST${MINI}
7280 local FILL=$(($MINV / 4))
7281 local DIFF=$(($MAXV - $MINV))
7282 local DIFF2=$(($DIFF * 100 / $MINV))
7284 local threshold=$(do_facet $SINGLEMDS \
7285 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7286 threshold=${threshold%%%}
7287 echo -n "Check for uneven OSTs: "
7288 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7290 if [[ $DIFF2 -gt $threshold ]]; then
7292 echo "Don't need to fill OST$MINI"
7294 # generate uneven OSTs. Write 2% over the QOS threshold value
7296 DIFF=$(($threshold - $DIFF2 + 2))
7297 DIFF2=$(( ($MINV * $DIFF)/100 ))
7298 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7299 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7300 error "setstripe failed"
7301 DIFF=$(($DIFF2 / 2048))
7303 while [ $i -lt $DIFF ]; do
7305 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7306 bs=2M count=1 2>/dev/null
7315 DIFF=$(($MAXV - $MINV))
7316 DIFF2=$(($DIFF * 100 / $MINV))
7317 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7318 if [[ $DIFF2 -gt $threshold ]]; then
7321 echo "failed - QOS mode won't be used"
7322 skip "QOS imbalance criteria not met"
7323 simple_cleanup_common
7327 MINI1=$MINI; MINV1=$MINV
7328 MAXI1=$MAXI; MAXV1=$MAXV
7330 # now fill using QOS
7331 $SETSTRIPE -c 1 $DIR/$tdir
7332 FILL=$(($FILL / 200))
7333 if [ $FILL -gt 600 ]; then
7336 echo "writing $FILL files to QOS-assigned OSTs"
7338 while [ $i -lt $FILL ]; do
7340 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7344 echo "wrote $i 200k files"
7348 echo "Note: free space may not be updated, so measurements might be off"
7350 DIFF2=$(($MAXV - $MINV))
7351 echo "free space delta: orig $DIFF final $DIFF2"
7352 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7353 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7354 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7355 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7356 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7357 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7359 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7361 # Figure out which files were written where
7362 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7363 awk '/'$MINI1': / {print $2; exit}')
7365 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7366 echo "$MINC files created on smaller OST $MINI1"
7367 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7368 awk '/'$MAXI1': / {print $2; exit}')
7370 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7371 echo "$MAXC files created on larger OST $MAXI1"
7372 FILL=$(($MAXC * 100 / $MINC - 100))
7373 [[ $MINC -gt 0 ]] &&
7374 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7375 [[ $MAXC -gt $MINC ]] ||
7376 error_ignore LU-9 "stripe QOS didn't balance free space"
7377 simple_cleanup_common
7379 run_test 116a "stripe QOS: free space balance ==================="
7381 test_116b() { # LU-2093
7382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7383 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7384 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7385 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7386 [ -z "$old_rr" ] && skip "no QOS" && return 0
7387 do_facet $SINGLEMDS lctl set_param \
7388 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7390 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7391 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7392 do_facet $SINGLEMDS lctl set_param fail_loc=0
7394 do_facet $SINGLEMDS lctl set_param \
7395 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7397 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7399 test_117() # bug 10891
7401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7402 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7403 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7404 lctl set_param fail_loc=0x21e
7405 > $DIR/$tfile || error "truncate failed"
7406 lctl set_param fail_loc=0
7407 echo "Truncate succeeded."
7410 run_test 117 "verify osd extend =========="
7412 NO_SLOW_RESENDCOUNT=4
7413 export OLD_RESENDCOUNT=""
7414 set_resend_count () {
7415 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7416 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7417 lctl set_param -n $PROC_RESENDCOUNT $1
7418 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7421 # for reduce test_118* time (b=14842)
7422 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7424 # Reset async IO behavior after error case
7426 FILE=$DIR/reset_async
7428 # Ensure all OSCs are cleared
7429 $SETSTRIPE -c -1 $FILE
7430 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7435 test_118a() #bug 11710
7437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7440 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7441 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7442 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7444 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7445 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7450 run_test 118a "verify O_SYNC works =========="
7454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7455 remote_ost_nodsh && skip "remote OST with nodsh" && return
7459 #define OBD_FAIL_OST_ENOENT 0x217
7460 set_nodes_failloc "$(osts_nodes)" 0x217
7461 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7463 set_nodes_failloc "$(osts_nodes)" 0
7464 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7465 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7468 if [[ $RC -eq 0 ]]; then
7469 error "Must return error due to dropped pages, rc=$RC"
7473 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7474 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7478 echo "Dirty pages not leaked on ENOENT"
7480 # Due to the above error the OSC will issue all RPCs syncronously
7481 # until a subsequent RPC completes successfully without error.
7482 $MULTIOP $DIR/$tfile Ow4096yc
7487 run_test 118b "Reclaim dirty pages on fatal error =========="
7491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7493 # for 118c, restore the original resend count, LU-1940
7494 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7495 set_resend_count $OLD_RESENDCOUNT
7496 remote_ost_nodsh && skip "remote OST with nodsh" && return
7500 #define OBD_FAIL_OST_EROFS 0x216
7501 set_nodes_failloc "$(osts_nodes)" 0x216
7503 # multiop should block due to fsync until pages are written
7504 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7508 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7509 error "Multiop failed to block on fsync, pid=$MULTIPID"
7512 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7514 if [[ $WRITEBACK -eq 0 ]]; then
7515 error "No page in writeback, writeback=$WRITEBACK"
7518 set_nodes_failloc "$(osts_nodes)" 0
7521 if [[ $RC -ne 0 ]]; then
7522 error "Multiop fsync failed, rc=$RC"
7525 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7526 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7528 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7529 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7533 echo "Dirty pages flushed via fsync on EROFS"
7536 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7538 # continue to use small resend count to reduce test_118* time (b=14842)
7539 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7544 remote_ost_nodsh && skip "remote OST with nodsh" && return
7548 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7549 set_nodes_failloc "$(osts_nodes)" 0x214
7550 # multiop should block due to fsync until pages are written
7551 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7555 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7556 error "Multiop failed to block on fsync, pid=$MULTIPID"
7559 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7561 if [[ $WRITEBACK -eq 0 ]]; then
7562 error "No page in writeback, writeback=$WRITEBACK"
7565 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7566 set_nodes_failloc "$(osts_nodes)" 0
7568 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7569 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7571 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7572 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7576 echo "Dirty pages gaurenteed flushed via fsync"
7579 run_test 118d "Fsync validation inject a delay of the bulk =========="
7582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7585 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7586 lctl set_param fail_loc=0x8000040a
7588 # Should simulate EINVAL error which is fatal
7589 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7591 if [[ $RC -eq 0 ]]; then
7592 error "Must return error due to dropped pages, rc=$RC"
7595 lctl set_param fail_loc=0x0
7597 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7598 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7599 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7601 if [[ $LOCKED -ne 0 ]]; then
7602 error "Locked pages remain in cache, locked=$LOCKED"
7605 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7606 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7610 echo "No pages locked after fsync"
7615 run_test 118f "Simulate unrecoverable OSC side error =========="
7618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7621 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7622 lctl set_param fail_loc=0x406
7624 # simulate local -ENOMEM
7625 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7628 lctl set_param fail_loc=0
7629 if [[ $RC -eq 0 ]]; then
7630 error "Must return error due to dropped pages, rc=$RC"
7633 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7634 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7635 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7637 if [[ $LOCKED -ne 0 ]]; then
7638 error "Locked pages remain in cache, locked=$LOCKED"
7641 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7642 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7646 echo "No pages locked after fsync"
7651 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7655 remote_ost_nodsh && skip "remote OST with nodsh" && return
7659 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7660 set_nodes_failloc "$(osts_nodes)" 0x20e
7661 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7662 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7665 set_nodes_failloc "$(osts_nodes)" 0
7666 if [[ $RC -eq 0 ]]; then
7667 error "Must return error due to dropped pages, rc=$RC"
7670 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7671 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7672 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7674 if [[ $LOCKED -ne 0 ]]; then
7675 error "Locked pages remain in cache, locked=$LOCKED"
7678 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7679 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7683 echo "No pages locked after fsync"
7687 run_test 118h "Verify timeout in handling recoverables errors =========="
7689 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7693 remote_ost_nodsh && skip "remote OST with nodsh" && return
7697 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7698 set_nodes_failloc "$(osts_nodes)" 0x20e
7700 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7701 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7704 set_nodes_failloc "$(osts_nodes)" 0
7708 if [[ $RC -ne 0 ]]; then
7709 error "got error, but should be not, rc=$RC"
7712 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7713 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7714 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7715 if [[ $LOCKED -ne 0 ]]; then
7716 error "Locked pages remain in cache, locked=$LOCKED"
7719 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7720 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7724 echo "No pages locked after fsync"
7728 run_test 118i "Fix error before timeout in recoverable error =========="
7730 [ "$SLOW" = "no" ] && set_resend_count 4
7733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7734 remote_ost_nodsh && skip "remote OST with nodsh" && return
7738 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7739 set_nodes_failloc "$(osts_nodes)" 0x220
7741 # return -EIO from OST
7742 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7744 set_nodes_failloc "$(osts_nodes)" 0x0
7745 if [[ $RC -eq 0 ]]; then
7746 error "Must return error due to dropped pages, rc=$RC"
7749 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7750 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7751 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7752 if [[ $LOCKED -ne 0 ]]; then
7753 error "Locked pages remain in cache, locked=$LOCKED"
7756 # in recoverable error on OST we want resend and stay until it finished
7757 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7758 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7762 echo "No pages locked after fsync"
7766 run_test 118j "Simulate unrecoverable OST side error =========="
7770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7771 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7773 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7774 set_nodes_failloc "$(osts_nodes)" 0x20e
7775 test_mkdir -p $DIR/$tdir
7777 for ((i=0;i<10;i++)); do
7778 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7779 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7786 set_nodes_failloc "$(osts_nodes)" 0
7789 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7795 test_mkdir -p $DIR/$tdir
7796 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7799 run_test 118l "fsync dir ========="
7801 test_118m() # LU-3066
7803 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7804 test_mkdir -p $DIR/$tdir
7805 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7808 run_test 118m "fdatasync dir ========="
7810 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7812 test_119a() # bug 11737
7814 BSIZE=$((512 * 1024))
7815 directio write $DIR/$tfile 0 1 $BSIZE
7816 # We ask to read two blocks, which is more than a file size.
7817 # directio will indicate an error when requested and actual
7818 # sizes aren't equeal (a normal situation in this case) and
7819 # print actual read amount.
7820 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7821 if [ "$NOB" != "$BSIZE" ]; then
7822 error "read $NOB bytes instead of $BSIZE"
7826 run_test 119a "Short directIO read must return actual read amount"
7828 test_119b() # bug 11737
7830 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7832 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7833 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7835 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7836 error "direct read failed"
7839 run_test 119b "Sparse directIO read must return actual read amount"
7841 test_119c() # bug 13099
7844 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7845 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7848 run_test 119c "Testing for direct read hitting hole"
7850 test_119d() # bug 15950
7852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7853 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7854 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7856 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7857 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7858 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7859 lctl set_param fail_loc=0x40d
7860 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7863 cat $DIR/$tfile > /dev/null &
7864 lctl set_param fail_loc=0
7867 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7869 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7870 error "the read rpcs have not completed in 2s"
7872 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7874 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7878 test_mkdir -p $DIR/$tdir
7879 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7880 skip "no early lock cancel on server" && return 0
7882 lru_resize_disable mdc
7883 lru_resize_disable osc
7884 cancel_lru_locks mdc
7885 # asynchronous object destroy at MDT could cause bl ast to client
7886 cancel_lru_locks osc
7888 stat $DIR/$tdir > /dev/null
7889 can1=$(do_facet $SINGLEMDS \
7890 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7891 awk '/ldlm_cancel/ {print $2}')
7892 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7893 awk '/ldlm_bl_callback/ {print $2}')
7894 test_mkdir -c1 $DIR/$tdir/d1
7895 can2=$(do_facet $SINGLEMDS \
7896 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7897 awk '/ldlm_cancel/ {print $2}')
7898 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7899 awk '/ldlm_bl_callback/ {print $2}')
7900 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7901 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7902 lru_resize_enable mdc
7903 lru_resize_enable osc
7905 run_test 120a "Early Lock Cancel: mkdir test"
7908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7909 test_mkdir $DIR/$tdir
7910 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7911 skip "no early lock cancel on server" && return 0
7912 lru_resize_disable mdc
7913 lru_resize_disable osc
7914 cancel_lru_locks mdc
7915 stat $DIR/$tdir > /dev/null
7916 can1=$(do_facet $SINGLEMDS \
7917 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7918 awk '/ldlm_cancel/ {print $2}')
7919 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7920 awk '/ldlm_bl_callback/ {print $2}')
7922 can2=$(do_facet $SINGLEMDS \
7923 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7924 awk '/ldlm_cancel/ {print $2}')
7925 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7926 awk '/ldlm_bl_callback/ {print $2}')
7927 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7928 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7929 lru_resize_enable mdc
7930 lru_resize_enable osc
7932 run_test 120b "Early Lock Cancel: create test"
7935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7936 test_mkdir -c1 $DIR/$tdir
7937 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7938 skip "no early lock cancel on server" && return 0
7939 lru_resize_disable mdc
7940 lru_resize_disable osc
7941 test_mkdir -p -c1 $DIR/$tdir/d1
7942 test_mkdir -p -c1 $DIR/$tdir/d2
7943 touch $DIR/$tdir/d1/f1
7944 cancel_lru_locks mdc
7945 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7946 can1=$(do_facet $SINGLEMDS \
7947 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7948 awk '/ldlm_cancel/ {print $2}')
7949 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7950 awk '/ldlm_bl_callback/ {print $2}')
7951 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7952 can2=$(do_facet $SINGLEMDS \
7953 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7954 awk '/ldlm_cancel/ {print $2}')
7955 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7956 awk '/ldlm_bl_callback/ {print $2}')
7957 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7958 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7959 lru_resize_enable mdc
7960 lru_resize_enable osc
7962 run_test 120c "Early Lock Cancel: link test"
7965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7966 test_mkdir -p -c1 $DIR/$tdir
7967 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7968 skip "no early lock cancel on server" && return 0
7969 lru_resize_disable mdc
7970 lru_resize_disable osc
7972 cancel_lru_locks mdc
7973 stat $DIR/$tdir > /dev/null
7974 can1=$(do_facet $SINGLEMDS \
7975 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7976 awk '/ldlm_cancel/ {print $2}')
7977 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7978 awk '/ldlm_bl_callback/ {print $2}')
7979 chmod a+x $DIR/$tdir
7980 can2=$(do_facet $SINGLEMDS \
7981 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7982 awk '/ldlm_cancel/ {print $2}')
7983 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7984 awk '/ldlm_bl_callback/ {print $2}')
7985 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7986 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7987 lru_resize_enable mdc
7988 lru_resize_enable osc
7990 run_test 120d "Early Lock Cancel: setattr test"
7993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7994 test_mkdir -p -c1 $DIR/$tdir
7995 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7996 skip "no early lock cancel on server" && return 0
7997 lru_resize_disable mdc
7998 lru_resize_disable osc
7999 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8000 cancel_lru_locks mdc
8001 cancel_lru_locks osc
8002 dd if=$DIR/$tdir/f1 of=/dev/null
8003 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8004 # XXX client can not do early lock cancel of OST lock
8005 # during unlink (LU-4206), so cancel osc lock now.
8006 cancel_lru_locks osc
8007 can1=$(do_facet $SINGLEMDS \
8008 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8009 awk '/ldlm_cancel/ {print $2}')
8010 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8011 awk '/ldlm_bl_callback/ {print $2}')
8012 unlink $DIR/$tdir/f1
8014 can2=$(do_facet $SINGLEMDS \
8015 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8016 awk '/ldlm_cancel/ {print $2}')
8017 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8018 awk '/ldlm_bl_callback/ {print $2}')
8019 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8020 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8021 lru_resize_enable mdc
8022 lru_resize_enable osc
8024 run_test 120e "Early Lock Cancel: unlink test"
8027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8028 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8029 skip "no early lock cancel on server" && return 0
8030 test_mkdir -p -c1 $DIR/$tdir
8031 lru_resize_disable mdc
8032 lru_resize_disable osc
8033 test_mkdir -p -c1 $DIR/$tdir/d1
8034 test_mkdir -p -c1 $DIR/$tdir/d2
8035 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8036 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8037 cancel_lru_locks mdc
8038 cancel_lru_locks osc
8039 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8040 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8041 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8042 # XXX client can not do early lock cancel of OST lock
8043 # during rename (LU-4206), so cancel osc lock now.
8044 cancel_lru_locks osc
8045 can1=$(do_facet $SINGLEMDS \
8046 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8047 awk '/ldlm_cancel/ {print $2}')
8048 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8049 awk '/ldlm_bl_callback/ {print $2}')
8050 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8052 can2=$(do_facet $SINGLEMDS \
8053 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8054 awk '/ldlm_cancel/ {print $2}')
8055 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8056 awk '/ldlm_bl_callback/ {print $2}')
8057 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8058 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8059 lru_resize_enable mdc
8060 lru_resize_enable osc
8062 run_test 120f "Early Lock Cancel: rename test"
8065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8066 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8067 skip "no early lock cancel on server" && return 0
8068 lru_resize_disable mdc
8069 lru_resize_disable osc
8071 echo create $count files
8072 test_mkdir -p $DIR/$tdir
8073 cancel_lru_locks mdc
8074 cancel_lru_locks osc
8077 can0=$(do_facet $SINGLEMDS \
8078 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8079 awk '/ldlm_cancel/ {print $2}')
8080 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8081 awk '/ldlm_bl_callback/ {print $2}')
8082 createmany -o $DIR/$tdir/f $count
8084 can1=$(do_facet $SINGLEMDS \
8085 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8086 awk '/ldlm_cancel/ {print $2}')
8087 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8088 awk '/ldlm_bl_callback/ {print $2}')
8090 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8091 echo rm $count files
8094 can2=$(do_facet $SINGLEMDS \
8095 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8096 awk '/ldlm_cancel/ {print $2}')
8097 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8098 awk '/ldlm_bl_callback/ {print $2}')
8100 echo total: $count removes in $((t2-t1))
8101 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8103 # wait for commitment of removal
8104 lru_resize_enable mdc
8105 lru_resize_enable osc
8107 run_test 120g "Early Lock Cancel: performance test"
8109 test_121() { #bug #10589
8110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8112 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8113 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8114 lctl set_param fail_loc=0x310
8115 cancel_lru_locks osc > /dev/null
8116 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8117 lctl set_param fail_loc=0
8118 [[ $reads -eq $writes ]] ||
8119 error "read $reads blocks, must be $writes blocks"
8121 run_test 121 "read cancel race ========="
8123 test_123a() { # was test 123, statahead(bug 11401)
8124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8126 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8127 log "testing on UP system. Performance may be not as good as expected."
8132 test_mkdir -p $DIR/$tdir
8133 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8134 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8136 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8137 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8139 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8140 lctl set_param -n llite.*.statahead_max 0
8141 lctl get_param llite.*.statahead_max
8142 cancel_lru_locks mdc
8143 cancel_lru_locks osc
8145 time ls -l $DIR/$tdir | wc -l
8147 delta=$((etime - stime))
8148 log "ls $i files without statahead: $delta sec"
8149 lctl set_param llite.*.statahead_max=$max
8151 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8152 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8153 cancel_lru_locks mdc
8154 cancel_lru_locks osc
8156 time ls -l $DIR/$tdir | wc -l
8158 delta_sa=$((etime - stime))
8159 log "ls $i files with statahead: $delta_sa sec"
8160 lctl get_param -n llite.*.statahead_stats
8161 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8163 [[ $swrong -lt $ewrong ]] &&
8164 log "statahead was stopped, maybe too many locks held!"
8165 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8167 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8168 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8169 lctl set_param -n llite.*.statahead_max 0
8170 lctl get_param llite.*.statahead_max
8171 cancel_lru_locks mdc
8172 cancel_lru_locks osc
8174 time ls -l $DIR/$tdir | wc -l
8176 delta=$((etime - stime))
8177 log "ls $i files again without statahead: $delta sec"
8178 lctl set_param llite.*.statahead_max=$max
8179 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8180 if [ $SLOWOK -eq 0 ]; then
8181 error "ls $i files is slower with statahead!"
8183 log "ls $i files is slower with statahead!"
8189 [ $delta -gt 20 ] && break
8190 [ $delta -gt 8 ] && MULT=$((50 / delta))
8191 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8199 delta=$((etime - stime))
8200 log "rm -r $DIR/$tdir/: $delta seconds"
8202 lctl get_param -n llite.*.statahead_stats
8204 run_test 123a "verify statahead work"
8206 test_123b () { # statahead(bug 15027)
8207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8208 test_mkdir -p $DIR/$tdir
8209 createmany -o $DIR/$tdir/$tfile-%d 1000
8211 cancel_lru_locks mdc
8212 cancel_lru_locks osc
8214 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8215 lctl set_param fail_loc=0x80000803
8216 ls -lR $DIR/$tdir > /dev/null
8218 lctl set_param fail_loc=0x0
8219 lctl get_param -n llite.*.statahead_stats
8224 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8228 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8229 skip "no lru resize on server" && return 0
8231 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8233 log "create $NR files at $DIR/$tdir"
8234 createmany -o $DIR/$tdir/f $NR ||
8235 error "failed to create $NR files in $DIR/$tdir"
8237 cancel_lru_locks mdc
8238 ls -l $DIR/$tdir > /dev/null
8242 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8243 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8244 LRU_SIZE=$($LCTL get_param -n $PARAM)
8245 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8246 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8248 log "NS=$(basename $NSDIR)"
8253 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8254 skip "Not enough cached locks created!"
8261 # We know that lru resize allows one client to hold $LIMIT locks
8262 # for 10h. After that locks begin to be killed by client.
8264 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8266 if [ $LIMIT -lt $LRU_SIZE ]; then
8267 skip "Limit is too small $LIMIT"
8271 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8272 # killing locks. Some time was spent for creating locks. This means
8273 # that up to the moment of sleep finish we must have killed some of
8274 # them (10-100 locks). This depends on how fast ther were created.
8275 # Many of them were touched in almost the same moment and thus will
8276 # be killed in groups.
8277 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8279 # Use $LRU_SIZE_B here to take into account real number of locks
8280 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8281 local LRU_SIZE_B=$LRU_SIZE
8283 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8284 log "OLD_LVF=$OLD_LVF"
8285 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8287 # Let's make sure that we really have some margin. Client checks
8288 # cached locks every 10 sec.
8290 log "Sleep ${SLEEP} sec"
8292 while ((SEC<$SLEEP)); do
8296 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8300 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8301 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8303 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8304 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8305 unlinkmany $DIR/$tdir/f $NR
8309 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8310 log "unlink $NR files at $DIR/$tdir"
8311 unlinkmany $DIR/$tdir/f $NR
8313 run_test 124a "lru resize ======================================="
8315 get_max_pool_limit()
8317 local limit=$($LCTL get_param \
8318 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8321 if [[ $l -gt $max ]]; then
8329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8330 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8331 skip "no lru resize on server" && return 0
8333 LIMIT=$(get_max_pool_limit)
8335 NR=$(($(default_lru_size)*20))
8336 if [[ $NR -gt $LIMIT ]]; then
8337 log "Limit lock number by $LIMIT locks"
8340 lru_resize_disable mdc
8341 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8342 error "failed to create $DIR/$tdir/disable_lru_resize"
8344 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8345 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8346 cancel_lru_locks mdc
8349 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8352 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8355 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8359 nolruresize_delta=$((etime-stime))
8360 log "ls -la time: $nolruresize_delta seconds"
8361 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8362 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8364 lru_resize_enable mdc
8365 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8366 error "failed to create $DIR/$tdir/enable_lru_resize"
8368 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8369 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8370 cancel_lru_locks mdc
8373 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8376 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8379 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8383 lruresize_delta=$((etime-stime))
8384 log "ls -la time: $lruresize_delta seconds"
8385 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8387 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8388 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8389 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8390 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8392 log "lru resize performs the same with no lru resize"
8394 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8396 run_test 124b "lru resize (performance test) ======================="
8399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8400 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8401 skip "no lru resize on server" && return 0
8403 # cache ununsed locks on client
8405 cancel_lru_locks mdc
8406 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8407 createmany -o $DIR/$tdir/f $nr ||
8408 error "failed to create $nr files in $DIR/$tdir"
8409 ls -l $DIR/$tdir > /dev/null
8411 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8412 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8413 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8414 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8415 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8417 # set lru_max_age to 1 sec
8418 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8419 echo "sleep $((recalc_p * 2)) seconds..."
8420 sleep $((recalc_p * 2))
8422 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8423 # restore lru_max_age
8424 $LCTL set_param -n $nsdir.lru_max_age $max_age
8425 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8426 unlinkmany $DIR/$tdir/f $nr
8428 run_test 124c "LRUR cancel very aged locks"
8430 test_125() { # 13358
8431 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8432 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8433 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8434 test_mkdir -p $DIR/d125 || error "mkdir failed"
8435 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8436 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8437 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8439 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8441 test_126() { # bug 12829/13455
8442 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8443 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8444 $GSS && skip "must run as gss disabled" && return
8446 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8447 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8449 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8451 run_test 126 "check that the fsgid provided by the client is taken into account"
8453 test_127a() { # bug 15521
8454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8455 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8456 $LCTL set_param osc.*.stats=0
8457 FSIZE=$((2048 * 1024))
8458 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8459 cancel_lru_locks osc
8460 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8462 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8463 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8464 echo "got $COUNT $NAME"
8465 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8466 eval $NAME=$COUNT || error "Wrong proc format"
8469 read_bytes|write_bytes)
8470 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8471 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8472 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8473 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8474 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8475 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8476 error "sumsquare is too small: $SUMSQ"
8477 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8478 error "sumsquare is too big: $SUMSQ"
8482 done < $DIR/${tfile}.tmp
8484 #check that we actually got some stats
8485 [ "$read_bytes" ] || error "Missing read_bytes stats"
8486 [ "$write_bytes" ] || error "Missing write_bytes stats"
8487 [ "$read_bytes" != 0 ] || error "no read done"
8488 [ "$write_bytes" != 0 ] || error "no write done"
8490 run_test 127a "verify the client stats are sane"
8492 test_127b() { # bug LU-333
8493 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8494 $LCTL set_param llite.*.stats=0
8495 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8496 # perform 2 reads and writes so MAX is different from SUM.
8497 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8498 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8499 cancel_lru_locks osc
8500 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8501 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8503 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8504 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8505 echo "got $COUNT $NAME"
8506 eval $NAME=$COUNT || error "Wrong proc format"
8510 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8511 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8512 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8513 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8516 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8517 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8518 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8519 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8523 done < $TMP/${tfile}.tmp
8525 #check that we actually got some stats
8526 [ "$read_bytes" ] || error "Missing read_bytes stats"
8527 [ "$write_bytes" ] || error "Missing write_bytes stats"
8528 [ "$read_bytes" != 0 ] || error "no read done"
8529 [ "$write_bytes" != 0 ] || error "no write done"
8531 run_test 127b "verify the llite client stats are sane"
8533 test_128() { # bug 15212
8535 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8540 result=$(grep error $TMP/$tfile.log)
8542 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8544 run_test 128 "interactive lfs for 2 consecutive find's"
8551 local LDPROC=/proc/fs/ldiskfs
8552 local facets=$(get_facets MDS)
8554 for facet in ${facets//,/ }; do
8555 canondev=$(ldiskfs_canon \
8556 *.$(convert_facet2label $facet).mntdev $facet)
8557 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8558 LDPROC=/sys/fs/ldiskfs
8559 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8565 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8566 skip "Only applicable to ldiskfs-based MDTs"
8569 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8574 test_mkdir -p $DIR/$tdir
8576 # block size of mds1
8577 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8578 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8579 local MAX=$((MDSBLOCKSIZE * 3))
8581 local I=$(stat -c%s "$DIR/$tdir")
8583 local STRIPE_COUNT=1
8584 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8585 MAX=$((MAX*STRIPE_COUNT))
8586 while [[ $I -le $MAX ]]; do
8587 $MULTIOP $DIR/$tdir/$J Oc
8589 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8590 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8591 #and EFBIG for previous versions
8592 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8594 echo "return code $rc received as expected"
8595 multiop $DIR/$tdir/$J Oc ||
8596 error_exit "multiop failed w/o dir size limit"
8598 I=$(stat -c%s "$DIR/$tdir")
8600 if [ $(lustre_version_code $SINGLEMDS) -lt \
8601 $(version_code 2.4.51) ]
8603 [[ $I -eq $MAX ]] && return 0
8605 [[ $I -gt $MAX ]] && return 0
8607 error_exit "current dir size $I, previous limit $MAX"
8608 elif [ $rc -ne 0 ]; then
8610 error_exit "return code $rc received instead of expected " \
8611 "$EFBIG or $ENOSPC, files in dir $I"
8614 I=$(stat -c%s "$DIR/$tdir")
8618 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8620 run_test 129 "test directory size limit ========================"
8629 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8630 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8633 trap cleanup_130 EXIT RETURN
8635 local fm_file=$DIR/$tfile
8636 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8637 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8638 error "dd failed for $fm_file"
8640 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8641 filefrag -ves $fm_file
8643 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8644 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8645 [ $RC != 0 ] && error "filefrag $fm_file failed"
8647 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8648 grep -v "ext:" | grep -v "found")
8649 lun=$($GETSTRIPE -i $fm_file)
8651 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8654 for line in $filefrag_op
8656 frag_lun=`echo $line | cut -d: -f5`
8657 ext_len=`echo $line | cut -d: -f4`
8658 if (( $frag_lun != $lun )); then
8660 error "FIEMAP on 1-stripe file($fm_file) failed"
8663 (( tot_len += ext_len ))
8666 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8668 error "FIEMAP on 1-stripe file($fm_file) failed;"
8674 echo "FIEMAP on single striped file succeeded"
8676 run_test 130a "FIEMAP (1-stripe file)"
8679 [ "$OSTCOUNT" -lt "2" ] &&
8680 skip_env "skipping FIEMAP on 2-stripe file test" && return
8682 [ "$OSTCOUNT" -ge "10" ] &&
8683 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8685 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8686 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8689 trap cleanup_130 EXIT RETURN
8691 local fm_file=$DIR/$tfile
8692 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8693 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8694 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8696 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8697 error "dd failed on $fm_file"
8699 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8700 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8701 grep -v "ext:" | grep -v "found")
8703 last_lun=$(echo $filefrag_op | cut -d: -f5)
8708 for line in $filefrag_op
8710 frag_lun=`echo $line | cut -d: -f5`
8711 ext_len=`echo $line | cut -d: -f4`
8712 if (( $frag_lun != $last_lun )); then
8713 if (( tot_len != 1024 )); then
8715 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8722 (( tot_len += ext_len ))
8725 if (( num_luns != 2 || tot_len != 1024 )); then
8727 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8733 echo "FIEMAP on 2-stripe file succeeded"
8735 run_test 130b "FIEMAP (2-stripe file)"
8738 [ "$OSTCOUNT" -lt "2" ] &&
8739 skip_env "skipping FIEMAP on 2-stripe file" && return
8741 [ "$OSTCOUNT" -ge "10" ] &&
8742 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8744 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8745 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8748 trap cleanup_130 EXIT RETURN
8750 local fm_file=$DIR/$tfile
8751 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8752 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8753 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8755 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8757 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8758 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8760 last_lun=`echo $filefrag_op | cut -d: -f5`
8765 for line in $filefrag_op
8767 frag_lun=`echo $line | cut -d: -f5`
8768 ext_len=`echo $line | cut -d: -f4`
8769 if (( $frag_lun != $last_lun )); then
8770 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8771 if (( logical != 512 )); then
8773 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8776 if (( tot_len != 512 )); then
8778 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8785 (( tot_len += ext_len ))
8788 if (( num_luns != 2 || tot_len != 512 )); then
8790 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8796 echo "FIEMAP on 2-stripe file with hole succeeded"
8798 run_test 130c "FIEMAP (2-stripe file with hole)"
8801 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8803 [ "$OSTCOUNT" -ge "10" ] &&
8804 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8806 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8807 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8809 trap cleanup_130 EXIT RETURN
8811 local fm_file=$DIR/$tfile
8812 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8813 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8814 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8816 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8817 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8818 error "dd failed on $fm_file"
8820 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8821 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8822 grep -v "ext:" | grep -v "found"`
8824 last_lun=`echo $filefrag_op | cut -d: -f5`
8829 for line in $filefrag_op
8831 frag_lun=`echo $line | cut -d: -f5`
8832 ext_len=`echo $line | cut -d: -f4`
8833 if (( $frag_lun != $last_lun )); then
8834 if (( tot_len != 1024 )); then
8836 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8843 (( tot_len += ext_len ))
8846 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8848 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8854 echo "FIEMAP on N-stripe file succeeded"
8856 run_test 130d "FIEMAP (N-stripe file)"
8859 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8861 [ "$OSTCOUNT" -ge "10" ] &&
8862 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8864 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8865 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8867 trap cleanup_130 EXIT RETURN
8869 local fm_file=$DIR/$tfile
8870 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8871 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8872 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8875 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8876 for ((i = 0; i < $NUM_BLKS; i++))
8878 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8881 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8882 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8884 last_lun=`echo $filefrag_op | cut -d: -f5`
8889 for line in $filefrag_op
8891 frag_lun=`echo $line | cut -d: -f5`
8892 ext_len=`echo $line | cut -d: -f4`
8893 if (( $frag_lun != $last_lun )); then
8894 if (( tot_len != $EXPECTED_LEN )); then
8896 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8903 (( tot_len += ext_len ))
8906 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8908 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8914 echo "FIEMAP with continuation calls succeeded"
8916 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8918 # Test for writev/readv
8920 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8921 error "writev test failed"
8922 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8923 error "readv failed"
8926 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8929 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8930 error "append writev test failed"
8931 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8932 error "append writev test failed"
8935 run_test 131b "test append writev"
8938 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8941 run_test 131c "test read/write on file w/o objects"
8944 rwv -f $DIR/$tfile -w -n 1 1572864
8945 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8946 if [ "$NOB" != 1572864 ]; then
8947 error "Short read filed: read $NOB bytes instead of 1572864"
8951 run_test 131d "test short read"
8954 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8955 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8956 error "read hitting hole failed"
8959 run_test 131e "test read hitting hole"
8965 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8967 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8969 *) error "Wrong argument $1" ;;
8972 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8973 # if the argument $3 is zero, it means any stat increment is ok.
8974 if [[ $3 -gt 0 ]]; then
8975 count=$(echo $res | awk '{ print $2 }')
8976 [[ $count -ne $3 ]] &&
8977 error "The $2 counter on $1 is wrong - expected $3"
8982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8983 remote_ost_nodsh && skip "remote OST with nodsh" && return
8984 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8986 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8987 { skip "MDS doesn't support rename stats"; return; }
8988 local testdir=$DIR/${tdir}/stats_testdir
8989 mkdir -p $DIR/${tdir}
8992 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8993 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8995 # verify mdt stats first.
8996 mkdir ${testdir} || error "mkdir failed"
8997 check_stats $SINGLEMDS "mkdir" 1
8998 touch ${testdir}/${tfile} || "touch failed"
8999 check_stats $SINGLEMDS "open" 1
9000 check_stats $SINGLEMDS "close" 1
9001 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9002 check_stats $SINGLEMDS "mknod" 1
9003 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9004 check_stats $SINGLEMDS "unlink" 1
9005 rm -f ${testdir}/${tfile} || error "file remove failed"
9006 check_stats $SINGLEMDS "unlink" 2
9008 # remove working dir and check mdt stats again.
9009 rmdir ${testdir} || error "rmdir failed"
9010 check_stats $SINGLEMDS "rmdir" 1
9012 local testdir1=$DIR/${tdir}/stats_testdir1
9014 mkdir -p ${testdir1}
9015 touch ${testdir1}/test1
9016 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9017 check_stats $SINGLEMDS "crossdir_rename" 1
9019 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9020 check_stats $SINGLEMDS "samedir_rename" 1
9024 run_test 133a "Verifying MDT stats ========================================"
9027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9028 remote_ost_nodsh && skip "remote OST with nodsh" && return
9029 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9030 local testdir=$DIR/${tdir}/stats_testdir
9031 mkdir -p ${testdir} || error "mkdir failed"
9032 touch ${testdir}/${tfile} || "touch failed"
9033 cancel_lru_locks mdc
9036 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9037 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9039 # extra mdt stats verification.
9040 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9041 check_stats $SINGLEMDS "setattr" 1
9042 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9043 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9045 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9046 check_stats $SINGLEMDS "getattr" 1
9048 $LFS df || error "lfs failed"
9049 check_stats $SINGLEMDS "statfs" 1
9053 run_test 133b "Verifying extra MDT stats =================================="
9056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9057 remote_ost_nodsh && skip "remote OST with nodsh" && return
9058 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9059 local testdir=$DIR/${tdir}/stats_testdir
9060 test_mkdir -p ${testdir} || error "mkdir failed"
9062 # verify obdfilter stats.
9063 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9065 cancel_lru_locks osc
9066 wait_delete_completed
9069 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9070 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9072 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9074 cancel_lru_locks osc
9075 check_stats ost "write" 1
9077 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9078 check_stats ost "read" 1
9080 > ${testdir}/${tfile} || error "truncate failed"
9081 check_stats ost "punch" 1
9083 rm -f ${testdir}/${tfile} || error "file remove failed"
9084 wait_delete_completed
9085 check_stats ost "destroy" 1
9089 run_test 133c "Verifying OST stats ========================================"
9096 while [ $value -ge 2 ]; do
9101 if [ $orig -gt $order ]; then
9109 local size=('K' 'M' 'G' 'T');
9111 local size_string=$value
9113 while [ $value -ge 1024 ]; do
9114 if [ $i -gt 3 ]; then
9115 #T is the biggest unit we get here, if that is bigger,
9117 size_string=${value}T
9120 value=$((value >> 10))
9121 if [ $value -lt 1024 ]; then
9122 size_string=${value}${size[$i]}
9133 local context=${2:-.}
9134 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9136 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9142 remote_ost_nodsh && skip "remote OST with nodsh" && return
9143 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9144 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9145 { skip "MDS doesn't support rename stats"; return; }
9147 local testdir1=$DIR/${tdir}/stats_testdir1
9148 local testdir2=$DIR/${tdir}/stats_testdir2
9150 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9152 mkdir -p ${testdir1} || error "mkdir failed"
9153 mkdir -p ${testdir2} || error "mkdir failed"
9155 createmany -o $testdir1/test 512 || error "createmany failed"
9157 # check samedir rename size
9158 mv ${testdir1}/test0 ${testdir1}/test_0
9160 local testdir1_size=$(ls -l $DIR/${tdir} |
9161 awk '/stats_testdir1/ {print $5}')
9162 local testdir2_size=$(ls -l $DIR/${tdir} |
9163 awk '/stats_testdir2/ {print $5}')
9165 testdir1_size=$(order_2 $testdir1_size)
9166 testdir2_size=$(order_2 $testdir2_size)
9168 testdir1_size=$(size_in_KMGT $testdir1_size)
9169 testdir2_size=$(size_in_KMGT $testdir2_size)
9171 echo "source rename dir size: ${testdir1_size}"
9172 echo "target rename dir size: ${testdir2_size}"
9174 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9175 eval $cmd || error "$cmd failed"
9176 local samedir=$($cmd | grep 'same_dir')
9177 local same_sample=$(get_rename_size $testdir1_size)
9178 [ -z "$samedir" ] && error "samedir_rename_size count error"
9179 [[ $same_sample -eq 1 ]] ||
9180 error "samedir_rename_size error $same_sample"
9181 echo "Check same dir rename stats success"
9183 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9185 # check crossdir rename size
9186 mv ${testdir1}/test_0 ${testdir2}/test_0
9188 testdir1_size=$(ls -l $DIR/${tdir} |
9189 awk '/stats_testdir1/ {print $5}')
9190 testdir2_size=$(ls -l $DIR/${tdir} |
9191 awk '/stats_testdir2/ {print $5}')
9193 testdir1_size=$(order_2 $testdir1_size)
9194 testdir2_size=$(order_2 $testdir2_size)
9196 testdir1_size=$(size_in_KMGT $testdir1_size)
9197 testdir2_size=$(size_in_KMGT $testdir2_size)
9199 echo "source rename dir size: ${testdir1_size}"
9200 echo "target rename dir size: ${testdir2_size}"
9202 eval $cmd || error "$cmd failed"
9203 local crossdir=$($cmd | grep 'crossdir')
9204 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9205 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9206 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9207 [[ $src_sample -eq 1 ]] ||
9208 error "crossdir_rename_size error $src_sample"
9209 [[ $tgt_sample -eq 1 ]] ||
9210 error "crossdir_rename_size error $tgt_sample"
9211 echo "Check cross dir rename stats success"
9214 run_test 133d "Verifying rename_stats ========================================"
9217 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9218 remote_ost_nodsh && skip "remote OST with nodsh" && return
9219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9220 local testdir=$DIR/${tdir}/stats_testdir
9221 local ctr f0 f1 bs=32768 count=42 sum
9223 mkdir -p ${testdir} || error "mkdir failed"
9225 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9227 for ctr in {write,read}_bytes; do
9229 cancel_lru_locks osc
9231 do_facet ost1 $LCTL set_param -n \
9232 "obdfilter.*.exports.clear=clear"
9234 if [ $ctr = write_bytes ]; then
9236 f1=${testdir}/${tfile}
9238 f0=${testdir}/${tfile}
9242 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9245 cancel_lru_locks osc
9247 sum=$(do_facet ost1 $LCTL get_param \
9248 "obdfilter.*.exports.*.stats" |
9249 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9250 $1 == ctr { sum += $7 }
9251 END { printf("%0.0f", sum) }')
9253 if ((sum != bs * count)); then
9254 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9260 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9265 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9266 /sys/fs/lustre/ /sys/fs/lnet/"
9268 for dir in $dirs; do
9269 if [ -d $dir ]; then
9270 proc_dirs="$proc_dirs $dir"
9276 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9277 remote_ost_nodsh && skip "remote OST with nodsh" && return
9278 # First without trusting modes.
9279 find $proc_dirs -exec cat '{}' \; &> /dev/null
9281 # Second verifying readability.
9284 -exec cat '{}' \; &> /dev/null ||
9285 error "proc file read failed"
9287 for facet in $SINGLEMDS ost1; do
9288 do_facet $facet find $proc_dirs \
9289 ! -name req_history \
9290 -exec cat '{}' \\\; &> /dev/null
9292 do_facet $facet find $proc_dirs \
9293 ! -name req_history \
9295 -exec cat '{}' \\\; &> /dev/null ||
9296 error "proc file read failed"
9299 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9304 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9305 /sys/fs/lustre/ /sys/fs/lnet/"
9307 for dir in $dirs; do
9308 if [ -d $dir ]; then
9309 proc_dirs="$proc_dirs $dir"
9315 # Second verifying readability.
9318 -not -name force_lbug \
9319 -not -name changelog_mask \
9320 -exec badarea_io '{}' \; &> /dev/null ||
9321 error "find $proc_dirs failed"
9323 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9324 skip "Too old lustre on MDS" && return
9326 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9327 skip "Too old lustre on ost1" && return
9329 for facet in $SINGLEMDS ost1; do
9330 do_facet $facet find $proc_dirs \
9332 -not -name force_lbug \
9333 -not -name changelog_mask \
9334 -exec badarea_io '{}' \\\; &> /dev/null ||
9335 error "$facet find $proc_dirs failed"
9339 # remount the FS in case writes/reads /proc break the FS
9340 cleanup || error "failed to unmount"
9341 setup || error "failed to setup"
9344 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9346 test_140() { #bug-17379
9347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9348 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9349 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9350 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9352 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9353 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9355 while i=`expr $i + 1`; do
9356 test_mkdir -p $i || error "Creating dir $i"
9357 cd $i || error "Changing to $i"
9358 ln -s ../stat stat || error "Creating stat symlink"
9359 # Read the symlink until ELOOP present,
9360 # not LBUGing the system is considered success,
9361 # we didn't overrun the stack.
9362 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9364 if [ $ret -eq 40 ]; then
9367 error "Open stat symlink"
9373 echo "The symlink depth = $i"
9374 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9375 error "Invalid symlink depth"
9377 # Test recursive symlink
9378 ln -s symlink_self symlink_self
9379 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9380 echo "open symlink_self returns $ret"
9381 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9383 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9387 local TF="$TMP/$tfile"
9389 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9391 cancel_lru_locks osc
9392 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9393 remount_client $MOUNT
9395 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9398 $TRUNCATE $DIR/$tfile 6000
9399 cancel_lru_locks osc
9400 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9403 echo "12345" >>$DIR/$tfile
9404 cancel_lru_locks osc
9405 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9408 echo "12345" >>$DIR/$tfile
9409 cancel_lru_locks osc
9410 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9415 run_test 150 "truncate/append tests"
9417 #LU-2902 roc_hit was not able to read all values from lproc
9418 function roc_hit_init() {
9419 local list=$(comma_list $(osts_nodes))
9420 local dir=$DIR/$tdir-check
9421 local file=$dir/file
9427 #use setstripe to do a write to every ost
9428 for i in $(seq 0 $((OSTCOUNT-1))); do
9429 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9430 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9431 idx=$(printf %04x $i)
9432 BEFORE=$(get_osd_param $list *OST*$idx stats |
9433 awk '$1 == "cache_access" {sum += $7}
9434 END { printf("%0.0f", sum) }')
9436 cancel_lru_locks osc
9437 cat $file >/dev/null
9439 AFTER=$(get_osd_param $list *OST*$idx stats |
9440 awk '$1 == "cache_access" {sum += $7}
9441 END { printf("%0.0f", sum) }')
9443 echo BEFORE:$BEFORE AFTER:$AFTER
9444 if ! let "AFTER - BEFORE == 4"; then
9446 error "roc_hit is not safe to use"
9454 function roc_hit() {
9455 local list=$(comma_list $(osts_nodes))
9456 echo $(get_osd_param $list '' stats |
9457 awk '$1 == "cache_hit" {sum += $7}
9458 END { printf("%0.0f", sum) }')
9461 function set_cache() {
9464 if [ "$2" == "off" ]; then
9467 local list=$(comma_list $(osts_nodes))
9468 set_osd_param $list '' $1_cache_enable $on
9470 cancel_lru_locks osc
9474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9475 remote_ost_nodsh && skip "remote OST with nodsh" && return
9478 local list=$(comma_list $(osts_nodes))
9480 # check whether obdfilter is cache capable at all
9481 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9482 echo "not cache-capable obdfilter"
9486 # check cache is enabled on all obdfilters
9487 if get_osd_param $list '' read_cache_enable | grep 0; then
9488 echo "oss cache is disabled"
9492 set_osd_param $list '' writethrough_cache_enable 1
9494 # check write cache is enabled on all obdfilters
9495 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9496 echo "oss write cache is NOT enabled"
9502 #define OBD_FAIL_OBD_NO_LRU 0x609
9503 do_nodes $list $LCTL set_param fail_loc=0x609
9505 # pages should be in the case right after write
9506 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9509 local BEFORE=$(roc_hit)
9510 cancel_lru_locks osc
9511 cat $DIR/$tfile >/dev/null
9512 local AFTER=$(roc_hit)
9514 do_nodes $list $LCTL set_param fail_loc=0
9516 if ! let "AFTER - BEFORE == CPAGES"; then
9517 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9520 # the following read invalidates the cache
9521 cancel_lru_locks osc
9522 set_osd_param $list '' read_cache_enable 0
9523 cat $DIR/$tfile >/dev/null
9525 # now data shouldn't be found in the cache
9527 cancel_lru_locks osc
9528 cat $DIR/$tfile >/dev/null
9530 if let "AFTER - BEFORE != 0"; then
9531 error "IN CACHE: before: $BEFORE, after: $AFTER"
9534 set_osd_param $list '' read_cache_enable 1
9537 run_test 151 "test cache on oss and controls ==============================="
9540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9541 local TF="$TMP/$tfile"
9543 # simulate ENOMEM during write
9544 #define OBD_FAIL_OST_NOMEM 0x226
9545 lctl set_param fail_loc=0x80000226
9546 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9548 sync || error "sync failed"
9549 lctl set_param fail_loc=0
9551 # discard client's cache
9552 cancel_lru_locks osc
9554 # simulate ENOMEM during read
9555 lctl set_param fail_loc=0x80000226
9556 cmp $TF $DIR/$tfile || error "cmp failed"
9557 lctl set_param fail_loc=0
9561 run_test 152 "test read/write with enomem ============================"
9564 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9566 run_test 153 "test if fdatasync does not crash ======================="
9568 dot_lustre_fid_permission_check() {
9570 local ffid=$MOUNT/.lustre/fid/$fid
9573 echo "stat fid $fid"
9574 stat $ffid > /dev/null || error "stat $ffid failed."
9575 echo "touch fid $fid"
9576 touch $ffid || error "touch $ffid failed."
9577 echo "write to fid $fid"
9578 cat /etc/hosts > $ffid || error "write $ffid failed."
9579 echo "read fid $fid"
9580 diff /etc/hosts $ffid || error "read $ffid failed."
9581 echo "append write to fid $fid"
9582 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9583 echo "rename fid $fid"
9584 mv $ffid $test_dir/$tfile.1 &&
9585 error "rename $ffid to $tfile.1 should fail."
9586 touch $test_dir/$tfile.1
9587 mv $test_dir/$tfile.1 $ffid &&
9588 error "rename $tfile.1 to $ffid should fail."
9589 rm -f $test_dir/$tfile.1
9590 echo "truncate fid $fid"
9591 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9592 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9593 echo "link fid $fid"
9594 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9596 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9597 echo "setfacl fid $fid"
9598 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9599 echo "getfacl fid $fid"
9600 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9602 echo "unlink fid $fid"
9603 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9604 echo "mknod fid $fid"
9605 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9607 fid=[0xf00000400:0x1:0x0]
9608 ffid=$MOUNT/.lustre/fid/$fid
9610 echo "stat non-exist fid $fid"
9611 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9612 echo "write to non-exist fid $fid"
9613 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9614 echo "link new fid $fid"
9615 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9617 mkdir -p $test_dir/$tdir
9618 touch $test_dir/$tdir/$tfile
9619 fid=$($LFS path2fid $test_dir/$tdir)
9622 error "error: could not get fid for $test_dir/$dir/$tfile."
9624 ffid=$MOUNT/.lustre/fid/$fid
9627 ls $ffid > /dev/null || error "ls $ffid failed."
9628 echo "touch $fid/$tfile.1"
9629 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9631 echo "touch $MOUNT/.lustre/fid/$tfile"
9632 touch $MOUNT/.lustre/fid/$tfile && \
9633 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9635 echo "setxattr to $MOUNT/.lustre/fid"
9636 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9638 echo "listxattr for $MOUNT/.lustre/fid"
9639 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9641 echo "delxattr from $MOUNT/.lustre/fid"
9642 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9644 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9645 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9646 error "touch invalid fid should fail."
9648 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9649 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9650 error "touch non-normal fid should fail."
9652 echo "rename $tdir to $MOUNT/.lustre/fid"
9653 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9654 error "rename to $MOUNT/.lustre/fid should fail."
9656 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9658 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9659 local new_obf_mode=777
9661 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9662 chmod $new_obf_mode $DIR/.lustre/fid ||
9663 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9665 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9666 [ $obf_mode -eq $new_obf_mode ] ||
9667 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9669 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9670 chmod $old_obf_mode $DIR/.lustre/fid ||
9671 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9674 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9675 fid=$($LFS path2fid $test_dir/$tfile-2)
9677 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9679 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9680 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9681 error "create lov data thru .lustre failed"
9683 echo "cp /etc/passwd $test_dir/$tfile-2"
9684 cp /etc/passwd $test_dir/$tfile-2 ||
9685 error "copy to $test_dir/$tfile-2 failed."
9686 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9687 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9688 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9690 rm -rf $test_dir/tfile.lnk
9691 rm -rf $test_dir/$tfile-2
9695 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9696 skip "Need MDS version at least 2.4.1" && return
9699 local FID=$($LFS path2fid $DIR/$tfile)
9700 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9702 # check that we get the same pathname back
9703 local FOUND=$($LFS fid2path $MOUNT "$FID")
9704 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9705 [ "$FOUND" != "$DIR/$tfile" ] &&
9706 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9710 run_test 154A "lfs path2fid and fid2path basic checks"
9713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9714 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9715 { skip "Need MDS version at least 2.2.51"; return 0; }
9716 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9718 cp /etc/hosts $DIR/$tfile
9720 fid=$($LFS path2fid $DIR/$tfile)
9722 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9724 dot_lustre_fid_permission_check "$fid" $DIR ||
9725 error "dot lustre permission check $fid failed"
9727 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9729 touch $MOUNT/.lustre/file &&
9730 error "creation is not allowed under .lustre"
9732 mkdir $MOUNT/.lustre/dir &&
9733 error "mkdir is not allowed under .lustre"
9737 run_test 154a "Open-by-FID"
9740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9741 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9742 { skip "Need MDS version at least 2.2.51"; return 0; }
9744 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9746 local remote_dir=$DIR/$tdir/remote_dir
9751 $LFS mkdir -i $MDTIDX $remote_dir ||
9752 error "create remote directory failed"
9754 cp /etc/hosts $remote_dir/$tfile
9756 fid=$($LFS path2fid $remote_dir/$tfile)
9758 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9760 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9761 error "dot lustre permission check $fid failed"
9764 run_test 154b "Open-by-FID for remote directory"
9767 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9768 skip "Need MDS version at least 2.4.1" && return
9770 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9771 local FID1=$($LFS path2fid $DIR/$tfile.1)
9772 local FID2=$($LFS path2fid $DIR/$tfile.2)
9773 local FID3=$($LFS path2fid $DIR/$tfile.3)
9776 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9777 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9778 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9780 [ "$FID" = "${!want}" ] ||
9781 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9785 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
9787 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9788 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9792 run_test 154c "lfs path2fid and fid2path multiple arguments"
9795 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9796 skip "Need MDS version at least 2.5.53" && return
9799 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9803 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9810 local fid=$($LFS path2fid $DIR/$tfile)
9813 cmd="exec $fd<$DIR/$tfile"
9815 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9816 echo "$fid_list" | grep "$fid"
9819 cmd="exec $fd>/dev/null"
9821 if [ $rc -ne 0 ]; then
9822 error "FID $fid not found in open files list $fid_list"
9825 run_test 154d "Verify open file fid"
9829 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9830 skip "Need MDS version at least 2.6.50" && return
9832 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9833 error ".lustre returned by readdir"
9836 run_test 154e ".lustre is not returned by readdir"
9839 # create parent directory on a single MDT to avoid cross-MDT hardlinks
9840 test_mkdir -p -c1 $DIR/$tdir/d
9841 # test dirs inherit from its stripe
9842 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
9843 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
9844 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
9845 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
9848 # get fid of parents
9849 local FID0=$($LFS path2fid $DIR/$tdir/d)
9850 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
9851 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
9852 local FID3=$($LFS path2fid $DIR)
9854 # check that path2fid --parents returns expected <parent_fid>/name
9855 # 1) test for a directory (single parent)
9856 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
9857 [ "$parent" == "$FID0/foo1" ] ||
9858 error "expected parent: $FID0/foo1, got: $parent"
9860 # 2) test for a file with nlink > 1 (multiple parents)
9861 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
9862 echo "$parent" | grep -F "$FID1/$tfile" ||
9863 error "$FID1/$tfile not returned in parent list"
9864 echo "$parent" | grep -F "$FID2/link" ||
9865 error "$FID2/link not returned in parent list"
9867 # 3) get parent by fid
9868 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
9869 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9870 echo "$parent" | grep -F "$FID1/$tfile" ||
9871 error "$FID1/$tfile not returned in parent list (by fid)"
9872 echo "$parent" | grep -F "$FID2/link" ||
9873 error "$FID2/link not returned in parent list (by fid)"
9875 # 4) test for entry in root directory
9876 parent=$($LFS path2fid --parents $DIR/f)
9877 echo "$parent" | grep -F "$FID3/f" ||
9878 error "$FID3/f not returned in parent list"
9880 # 5) test it on root directory
9881 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
9882 error "$MOUNT should not have parents"
9884 # enable xattr caching and check that linkea is correctly updated
9885 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9886 save_lustre_params client "llite.*.xattr_cache" > $save
9887 lctl set_param llite.*.xattr_cache 1
9889 # 6.1) linkea update on rename
9890 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
9892 # get parents by fid
9893 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9894 # foo1 should no longer be returned in parent list
9895 echo "$parent" | grep -F "$FID1" &&
9896 error "$FID1 should no longer be in parent list"
9897 # the new path should appear
9898 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
9899 error "$FID2/$tfile.moved is not in parent list"
9901 # 6.2) linkea update on unlink
9902 rm -f $DIR/$tdir/d/foo2/link
9903 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9904 # foo2/link should no longer be returned in parent list
9905 echo "$parent" | grep -F "$FID2/link" &&
9906 error "$FID2/link should no longer be in parent list"
9910 restore_lustre_params < $save
9912 run_test 154f "get parent fids by reading link ea"
9916 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
9917 { skip "Need MDS version at least 2.6.92"; return 0; }
9920 llapi_fid_test -d $DIR/$tdir
9922 run_test 154g "various llapi FID tests"
9924 test_155_small_load() {
9925 local temp=$TMP/$tfile
9926 local file=$DIR/$tfile
9928 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9929 error "dd of=$temp bs=6096 count=1 failed"
9931 cancel_lru_locks osc
9932 cmp $temp $file || error "$temp $file differ"
9934 $TRUNCATE $temp 6000
9935 $TRUNCATE $file 6000
9936 cmp $temp $file || error "$temp $file differ (truncate1)"
9938 echo "12345" >>$temp
9939 echo "12345" >>$file
9940 cmp $temp $file || error "$temp $file differ (append1)"
9942 echo "12345" >>$temp
9943 echo "12345" >>$file
9944 cmp $temp $file || error "$temp $file differ (append2)"
9950 test_155_big_load() {
9951 remote_ost_nodsh && skip "remote OST with nodsh" && return
9952 local temp=$TMP/$tfile
9953 local file=$DIR/$tfile
9956 local cache_size=$(do_facet ost$((MAXI+1)) \
9957 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9958 local large_file_size=$((cache_size * 2))
9960 echo "OSS cache size: $cache_size KB"
9961 echo "Large file size: $large_file_size KB"
9963 [ $MAXV -le $large_file_size ] && \
9964 skip_env "max available OST size needs > $large_file_size KB" && \
9967 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9969 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9970 error "dd of=$temp bs=$large_file_size count=1k failed"
9973 cancel_lru_locks osc
9974 cmp $temp $file || error "$temp $file differ"
9981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9983 set_cache writethrough on
9986 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9991 set_cache writethrough off
9994 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9999 set_cache writethrough on
10000 test_155_small_load
10002 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10007 set_cache writethrough off
10008 test_155_small_load
10010 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10015 set_cache writethrough on
10018 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10023 set_cache writethrough off
10026 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10031 set_cache writethrough on
10034 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10039 set_cache writethrough off
10042 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10045 remote_ost_nodsh && skip "remote OST with nodsh" && return
10046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10050 local file="$DIR/$tfile"
10052 [ "$(facet_fstype ost1)" = "zfs" ] &&
10053 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
10058 log "Turn on read and write cache"
10060 set_cache writethrough on
10062 log "Write data and read it back."
10063 log "Read should be satisfied from the cache."
10064 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10066 cancel_lru_locks osc
10067 cat $file >/dev/null
10069 if ! let "AFTER - BEFORE == CPAGES"; then
10070 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10072 log "cache hits:: before: $BEFORE, after: $AFTER"
10075 log "Read again; it should be satisfied from the cache."
10077 cancel_lru_locks osc
10078 cat $file >/dev/null
10080 if ! let "AFTER - BEFORE == CPAGES"; then
10081 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10083 log "cache hits:: before: $BEFORE, after: $AFTER"
10087 log "Turn off the read cache and turn on the write cache"
10089 set_cache writethrough on
10091 log "Read again; it should be satisfied from the cache."
10093 cancel_lru_locks osc
10094 cat $file >/dev/null
10096 if ! let "AFTER - BEFORE == CPAGES"; then
10097 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10099 log "cache hits:: before: $BEFORE, after: $AFTER"
10102 log "Read again; it should not be satisfied from the cache."
10104 cancel_lru_locks osc
10105 cat $file >/dev/null
10107 if ! let "AFTER - BEFORE == 0"; then
10108 error "IN CACHE: before: $BEFORE, after: $AFTER"
10110 log "cache hits:: before: $BEFORE, after: $AFTER"
10113 log "Write data and read it back."
10114 log "Read should be satisfied from the cache."
10115 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10117 cancel_lru_locks osc
10118 cat $file >/dev/null
10120 if ! let "AFTER - BEFORE == CPAGES"; then
10121 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10123 log "cache hits:: before: $BEFORE, after: $AFTER"
10126 log "Read again; it should not be satisfied from the cache."
10128 cancel_lru_locks osc
10129 cat $file >/dev/null
10131 if ! let "AFTER - BEFORE == 0"; then
10132 error "IN CACHE: before: $BEFORE, after: $AFTER"
10134 log "cache hits:: before: $BEFORE, after: $AFTER"
10138 log "Turn off read and write cache"
10140 set_cache writethrough off
10142 log "Write data and read it back"
10143 log "It should not be satisfied from the cache."
10145 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10146 cancel_lru_locks osc
10148 cat $file >/dev/null
10150 if ! let "AFTER - BEFORE == 0"; then
10151 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10153 log "cache hits:: before: $BEFORE, after: $AFTER"
10156 log "Turn on the read cache and turn off the write cache"
10158 set_cache writethrough off
10160 log "Write data and read it back"
10161 log "It should not be satisfied from the cache."
10163 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10165 cancel_lru_locks osc
10166 cat $file >/dev/null
10168 if ! let "AFTER - BEFORE == 0"; then
10169 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10171 log "cache hits:: before: $BEFORE, after: $AFTER"
10174 log "Read again; it should be satisfied from the cache."
10176 cancel_lru_locks osc
10177 cat $file >/dev/null
10179 if ! let "AFTER - BEFORE == CPAGES"; then
10180 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10182 log "cache hits:: before: $BEFORE, after: $AFTER"
10187 run_test 156 "Verification of tunables ============================"
10191 if [[ $MDSCOUNT -gt 1 ]]; then
10192 error_ignore bz17935 $*
10200 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10202 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10204 if [ $MASK -eq 1 ]; then
10205 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10207 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10211 changelog_extract_field() {
10215 local identifier=$4
10217 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10218 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10224 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10225 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10226 { skip "Need MDS version at least 2.2.0"; return; }
10228 local CL_USERS="mdd.$MDT0.changelog_users"
10229 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10230 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10231 echo "Registered as changelog user $USER"
10232 $GET_CL_USERS | grep -q $USER ||
10233 error "User $USER not found in changelog_users"
10236 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10237 touch $DIR/$tdir/pics/2008/zachy/timestamp
10238 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10239 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10240 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10241 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10242 rm $DIR/$tdir/pics/desktop.jpg
10244 $LFS changelog $MDT0 | tail -5
10246 echo "verifying changelog mask"
10247 changelog_chmask "MKDIR"
10248 changelog_chmask "CLOSE"
10250 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10251 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10253 changelog_chmask "MKDIR"
10254 changelog_chmask "CLOSE"
10256 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10257 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10259 $LFS changelog $MDT0
10260 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10261 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10262 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10263 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10266 echo "verifying target fid"
10267 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10268 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10269 [ "$fidc" == "$fidf" ] ||
10270 err17935 "fid in changelog $fidc != file fid $fidf"
10271 echo "verifying parent fid"
10272 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10273 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10274 [ "$fidc" == "$fidf" ] ||
10275 err17935 "pfid in changelog $fidc != dir fid $fidf"
10277 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10278 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10279 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10280 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10281 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10282 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10284 MIN_REC=$($GET_CL_USERS |
10285 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10286 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10287 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10288 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10289 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10291 # LU-3446 changelog index reset on MDT restart
10292 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10293 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10294 $LFS changelog_clear $MDT0 $USER 0
10295 stop $SINGLEMDS || error "Fail to stop MDT."
10296 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10297 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10298 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10299 [ $CUR_REC1 == $CUR_REC2 ] ||
10300 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10302 echo "verifying user deregister"
10303 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10304 $GET_CL_USERS | grep -q $USER &&
10305 error "User $USER still in changelog_users"
10307 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10308 if [ $USERS -eq 0 ]; then
10309 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10310 touch $DIR/$tdir/chloe
10311 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10312 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10313 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10315 echo "$USERS other changelog users; can't verify off"
10318 run_test 160a "changelog sanity"
10320 test_160b() { # LU-3587
10321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10322 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10323 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10324 { skip "Need MDS version at least 2.2.0"; return; }
10326 local CL_USERS="mdd.$MDT0.changelog_users"
10327 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10328 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10329 echo "Registered as changelog user $USER"
10330 $GET_CL_USERS | grep -q $USER ||
10331 error "User $USER not found in changelog_users"
10333 local LONGNAME1=$(str_repeat a 255)
10334 local LONGNAME2=$(str_repeat b 255)
10337 echo "creating very long named file"
10338 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10339 echo "moving very long named file"
10340 mv $LONGNAME1 $LONGNAME2
10342 $LFS changelog $MDT0 | grep RENME
10344 echo "deregistering $USER"
10345 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10349 run_test 160b "Verify that very long rename doesn't crash in changelog"
10353 local server_version=$(lustre_version_code $SINGLEMDS)
10355 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10356 [[ $server_version -gt $(version_code 2.5.1) &&
10357 $server_version -lt $(version_code 2.5.50) ]] ||
10358 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10361 # Registration step
10362 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10363 changelog_register -n)
10366 mkdir -p $DIR/$tdir
10367 $MCREATE $DIR/$tdir/foo_160c
10368 changelog_chmask "TRUNC"
10369 $TRUNCATE $DIR/$tdir/foo_160c 200
10370 changelog_chmask "TRUNC"
10371 $TRUNCATE $DIR/$tdir/foo_160c 199
10372 $LFS changelog $MDT0
10373 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10374 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10375 $LFS changelog_clear $MDT0 $USER 0
10377 # Deregistration step
10378 echo "deregistering $USER"
10379 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10381 run_test 160c "verify that changelog log catch the truncate event"
10384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10385 test_mkdir -p -c1 $DIR/$tdir
10386 cp /etc/hosts $DIR/$tdir/$tfile
10387 test_mkdir -c1 $DIR/$tdir/foo1
10388 test_mkdir -c1 $DIR/$tdir/foo2
10389 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10390 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10391 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10392 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10393 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10394 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10395 $LFS fid2path $DIR $FID
10396 err17935 "bad link ea"
10399 rm $DIR/$tdir/foo2/zachary
10401 rm $DIR/$tdir/foo2/thor
10403 rm $DIR/$tdir/$tfile
10405 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10406 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10408 $LFS fid2path $DIR $FID
10409 err17935 "bad link rename"
10411 rm $DIR/$tdir/foo2/maggie
10414 local longname=filename_avg_len_is_thirty_two_
10415 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10416 error "failed to hardlink many files"
10417 links=$($LFS fid2path $DIR $FID | wc -l)
10418 echo -n "${links}/1000 links in link EA"
10419 [[ $links -gt 60 ]] ||
10420 err17935 "expected at least 60 links in link EA"
10421 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10422 error "failed to unlink many hardlinks"
10424 run_test 161a "link ea sanity"
10427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10428 [ $MDSCOUNT -lt 2 ] &&
10429 skip "skipping remote directory test" && return
10431 local remote_dir=$DIR/$tdir/remote_dir
10433 mkdir -p $DIR/$tdir
10434 $LFS mkdir -i $MDTIDX $remote_dir ||
10435 error "create remote directory failed"
10437 cp /etc/hosts $remote_dir/$tfile
10438 mkdir -p $remote_dir/foo1
10439 mkdir -p $remote_dir/foo2
10440 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10441 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10442 ln $remote_dir/$tfile $remote_dir/foo1/luna
10443 ln $remote_dir/$tfile $remote_dir/foo2/thor
10445 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10447 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10448 $LFS fid2path $DIR $FID
10449 err17935 "bad link ea"
10452 rm $remote_dir/foo2/zachary
10454 rm $remote_dir/foo2/thor
10456 rm $remote_dir/$tfile
10458 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10459 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10460 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10461 $LFS fid2path $DIR $FID
10462 err17935 "bad link rename"
10464 rm $remote_dir/foo2/maggie
10467 local longname=filename_avg_len_is_thirty_two_
10468 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10469 error "failed to hardlink many files"
10470 links=$($LFS fid2path $DIR $FID | wc -l)
10471 echo -n "${links}/1000 links in link EA"
10472 [[ ${links} -gt 60 ]] ||
10473 err17935 "expected at least 60 links in link EA"
10474 unlinkmany $remote_dir/foo2/$longname 1000 ||
10475 error "failed to unlink many hardlinks"
10477 run_test 161b "link ea sanity under remote directory"
10480 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10482 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10483 skip "Need MDS version at least 2.1.5" && return
10485 # define CLF_RENAME_LAST 0x0001
10486 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10487 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10488 changelog_register -n)
10490 mkdir -p $DIR/$tdir
10491 touch $DIR/$tdir/foo_161c
10492 touch $DIR/$tdir/bar_161c
10493 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10494 $LFS changelog $MDT0 | grep RENME
10495 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10497 $LFS changelog_clear $MDT0 $USER 0
10498 if [ x$flags != "x0x1" ]; then
10499 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10501 error "flag $flags is not 0x1"
10503 echo "rename overwrite a target having nlink = 1," \
10504 "changelog record has flags of $flags"
10506 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10507 touch $DIR/$tdir/foo_161c
10508 touch $DIR/$tdir/bar_161c
10509 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10510 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10511 $LFS changelog $MDT0 | grep RENME
10512 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10513 $LFS changelog_clear $MDT0 $USER 0
10514 if [ x$flags != "x0x0" ]; then
10515 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10517 error "flag $flags is not 0x0"
10519 echo "rename overwrite a target having nlink > 1," \
10520 "changelog record has flags of $flags"
10522 # rename doesn't overwrite a target (changelog flag 0x0)
10523 touch $DIR/$tdir/foo_161c
10524 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10525 $LFS changelog $MDT0 | grep RENME
10526 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10527 $LFS changelog_clear $MDT0 $USER 0
10528 if [ x$flags != "x0x0" ]; then
10529 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10531 error "flag $flags is not 0x0"
10533 echo "rename doesn't overwrite a target," \
10534 "changelog record has flags of $flags"
10536 # define CLF_UNLINK_LAST 0x0001
10537 # unlink a file having nlink = 1 (changelog flag 0x1)
10538 rm -f $DIR/$tdir/foo2_161c
10539 $LFS changelog $MDT0 | grep UNLNK
10540 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10541 $LFS changelog_clear $MDT0 $USER 0
10542 if [ x$flags != "x0x1" ]; then
10543 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10545 error "flag $flags is not 0x1"
10547 echo "unlink a file having nlink = 1," \
10548 "changelog record has flags of $flags"
10550 # unlink a file having nlink > 1 (changelog flag 0x0)
10551 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10552 rm -f $DIR/$tdir/foobar_161c
10553 $LFS changelog $MDT0 | grep UNLNK
10554 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10555 $LFS changelog_clear $MDT0 $USER 0
10556 if [ x$flags != "x0x0" ]; then
10557 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10559 error "flag $flags is not 0x0"
10561 echo "unlink a file having nlink > 1," \
10562 "changelog record has flags of $flags"
10563 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10565 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10572 local path=$(${LFS} fid2path $*)
10573 # Remove the '//' indicating a remote directory
10574 path=$(echo $path | sed 's#//#/#g')
10577 if [ $RC -ne 0 ]; then
10578 err17935 "path looked up of $expected failed. Error $RC"
10580 elif [ "${path}" != "${expected}" ]; then
10581 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10584 echo "fid $fid resolves to path $path (expected $expected)"
10588 # Make changes to filesystem
10589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10590 test_mkdir -p -c1 $DIR/$tdir/d2
10591 touch $DIR/$tdir/d2/$tfile
10592 touch $DIR/$tdir/d2/x1
10593 touch $DIR/$tdir/d2/x2
10594 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10595 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10597 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10598 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10599 error "check path $tdir/d2/$tfile failed"
10602 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10603 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10604 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10605 error "check path $tdir/d2/p/q/r/slink failed"
10607 # softlink to wrong file
10608 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10609 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10610 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10611 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10614 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10615 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10616 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10617 # fid2path dir/fsname should both work
10618 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10619 error "check path $tdir/d2/a/b/c/new_file failed"
10620 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10621 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10623 # hardlink count: check that there are 2 links
10624 # Doesnt work with CMD yet: 17935
10625 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10626 err17935 "expected 2 links"
10628 # hardlink indexing: remove the first link
10629 rm $DIR/$tdir/d2/p/q/r/hlink
10630 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10631 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10635 run_test 162 "path lookup sanity"
10638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10639 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10642 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10643 error "create striped dir failed"
10645 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10646 tail -n 1 | awk '{print $2}')
10647 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10649 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10650 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10653 for ((i=0;i<5;i++)); do
10654 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10655 error "get fid for f$i failed"
10656 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10657 error "check path $tdir/striped_dir/f$i failed"
10659 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10660 error "get fid for d$i failed"
10661 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10662 error "check path $tdir/striped_dir/d$i failed"
10667 run_test 162b "striped directory path lookup sanity"
10669 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10671 test_mkdir $DIR/$tdir.local
10672 test_mkdir $DIR/$tdir.remote
10673 local lpath=$tdir.local
10674 local rpath=$tdir.remote
10676 for ((i = 0; i <= 101; i++)); do
10679 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10680 error "get fid for local directory $DIR/$lpath failed"
10681 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10682 error "check path for local directory $DIR/$lpath failed"
10685 test_mkdir $DIR/$rpath
10686 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10687 error "get fid for remote directory $DIR/$rpath failed"
10688 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10689 error "check path for remote directory $DIR/$rpath failed"
10694 run_test 162c "fid2path works with paths 100 or more directories deep"
10697 # do directio so as not to populate the page cache
10698 log "creating a 10 Mb file"
10699 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10700 log "starting reads"
10701 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10702 log "truncating the file"
10703 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10705 kill %+ || true # reads might have finished
10706 echo "wait until dd is finished"
10708 log "removing the temporary file"
10709 rm -rf $DIR/$tfile || error "tmp file removal failed"
10711 run_test 169 "parallel read and truncate should not deadlock"
10714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10715 $LCTL clear # bug 18514
10716 $LCTL debug_daemon start $TMP/${tfile}_log_good
10718 $LCTL debug_daemon stop
10719 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10720 error "sed failed to read log_good"
10722 $LCTL debug_daemon start $TMP/${tfile}_log_good
10724 $LCTL debug_daemon stop
10726 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10727 error "lctl df log_bad failed"
10729 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10730 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10732 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10733 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10735 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10736 error "bad_line good_line1 good_line2 are empty"
10738 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10739 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10740 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10742 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10743 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10744 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10746 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10747 error "bad_line_new good_line_new are empty"
10749 local expected_good=$((good_line1 + good_line2*2))
10751 rm -f $TMP/${tfile}*
10752 # LU-231, short malformed line may not be counted into bad lines
10753 if [ $bad_line -ne $bad_line_new ] &&
10754 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10755 error "expected $bad_line bad lines, but got $bad_line_new"
10759 if [ $expected_good -ne $good_line_new ]; then
10760 error "expected $expected_good good lines, but got $good_line_new"
10765 run_test 170 "test lctl df to handle corrupted log ====================="
10767 test_171() { # bug20592
10768 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10769 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10770 $LCTL set_param fail_loc=0x50e
10771 $LCTL set_param fail_val=3000
10772 multiop_bg_pause $DIR/$tfile O_s || true
10774 kill -USR1 $MULTIPID
10778 if dmesg | grep "recursive fault"; then
10779 error "caught a recursive fault"
10781 $LCTL set_param fail_loc=0
10784 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10786 # it would be good to share it with obdfilter-survey/iokit-libecho code
10787 setup_obdecho_osc () {
10790 local obdfilter_name=$2
10791 echo "Creating new osc for $obdfilter_name on $ost_nid"
10792 # make sure we can find loopback nid
10793 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10795 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10796 ${obdfilter_name}_osc_UUID || rc=2; }
10797 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10798 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10802 cleanup_obdecho_osc () {
10803 local obdfilter_name=$1
10804 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10805 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10812 local pages=${3:-64}
10817 local obd_size=$(get_obd_size $node $OBD)
10818 local page_size=$(get_page_size $node)
10819 if [[ -n "$obd_size" ]]; then
10820 local new_count=$((obd_size / (pages * page_size / 1024)))
10821 [[ $new_count -ge $count ]] || count=$new_count
10824 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10825 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10827 if [ $rc -eq 0 ]; then
10828 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10829 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10831 echo "New object id is $id"
10832 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10834 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10835 "test_brw $count w v $pages $id" || rc=4; }
10836 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10838 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10839 "cleanup" || rc=5; }
10840 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10841 "detach" || rc=6; }
10842 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10848 remote_ost_nodsh && skip "remote OST with nodsh" && return
10850 local rmmod_local=0
10852 if ! module_loaded obdecho; then
10853 load_module obdecho/obdecho
10857 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10858 local host=$(lctl get_param -n osc.$osc.import |
10859 awk '/current_connection:/ {print $2}' )
10860 local target=$(lctl get_param -n osc.$osc.import |
10861 awk '/target:/ {print $2}' )
10862 target=${target%_UUID}
10864 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10865 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10866 [[ -n $target ]] && cleanup_obdecho_osc $target
10867 [ $rmmod_local -eq 1 ] && rmmod obdecho
10870 run_test 180a "test obdecho on osc"
10873 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10874 remote_ost_nodsh && skip "remote OST with nodsh" && return
10876 local rmmod_remote=0
10878 do_facet ost1 "lsmod | grep -q obdecho || " \
10879 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10880 "modprobe obdecho; }" && rmmod_remote=1
10881 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10882 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10883 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10886 run_test 180b "test obdecho directly on obdfilter"
10888 test_180c() { # LU-2598
10889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10890 remote_ost_nodsh && skip "remote OST with nodsh" && return
10891 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10892 skip "Need MDS version at least 2.4.0" && return
10895 local rmmod_remote=false
10896 local pages=16384 # 64MB bulk I/O RPC size
10899 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10900 rmmod_remote=true || error "failed to load module obdecho"
10902 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10904 if [ -n "$target" ]; then
10905 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10907 echo "there is no obdfilter target on ost1"
10910 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10913 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10915 test_181() { # bug 22177
10916 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10917 # create enough files to index the directory
10918 createmany -o $DIR/$tdir/foobar 4000
10919 # print attributes for debug purpose
10922 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10924 # remove the files & current working dir
10925 unlinkmany $DIR/$tdir/foobar 4000
10927 kill -USR1 $MULTIPID
10929 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10932 run_test 181 "Test open-unlinked dir ========================"
10935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10936 # disable MDC RPC lock wouldn't crash client
10940 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10941 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10942 $LCTL set_param fail_loc=0x804
10944 for (( i=0; i < $tcount; i++ )) ; do
10945 mkdir $DIR/$tdir/$i
10946 createmany -o $DIR/$tdir/$i/f- $fcount &
10950 for (( i=0; i < $tcount; i++ )) ; do
10951 unlinkmany $DIR/$tdir/$i/f- $fcount &
10957 $LCTL set_param fail_loc=0
10959 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10961 test_183() { # LU-2275
10962 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10963 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10964 skip "Need MDS version at least 2.3.56" && return
10966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10967 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10968 echo aaa > $DIR/$tdir/$tfile
10970 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10971 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10973 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10974 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10976 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10978 # Flush negative dentry cache
10979 touch $DIR/$tdir/$tfile
10981 # We are not checking for any leaked references here, they'll
10982 # become evident next time we do cleanup with module unload.
10985 run_test 183 "No crash or request leak in case of strange dispositions ========"
10987 # test suite 184 is for LU-2016, LU-2017
10989 check_swap_layouts_support && return 0
10991 dir0=$DIR/$tdir/$testnum
10992 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10997 $SETSTRIPE -c1 $file1
10999 $SETSTRIPE -c2 $file2
11001 gen1=$($GETSTRIPE -g $file1)
11002 gen2=$($GETSTRIPE -g $file2)
11004 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11005 gen=$($GETSTRIPE -g $file1)
11006 [[ $gen1 != $gen ]] ||
11007 "Layout generation on $file1 does not change"
11008 gen=$($GETSTRIPE -g $file2)
11009 [[ $gen2 != $gen ]] ||
11010 "Layout generation on $file2 does not change"
11012 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11013 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11015 run_test 184a "Basic layout swap"
11018 check_swap_layouts_support && return 0
11020 dir0=$DIR/$tdir/$testnum
11021 mkdir -p $dir0 || error "creating dir $dir0"
11028 $SETSTRIPE -c1 $file1
11029 $SETSTRIPE -c2 $file2
11030 $SETSTRIPE -c1 $file3
11031 chown $RUNAS_ID $file3
11032 gen1=$($GETSTRIPE -g $file1)
11033 gen2=$($GETSTRIPE -g $file2)
11035 $LFS swap_layouts $dir1 $dir2 &&
11036 error "swap of directories layouts should fail"
11037 $LFS swap_layouts $dir1 $file1 &&
11038 error "swap of directory and file layouts should fail"
11039 $RUNAS $LFS swap_layouts $file1 $file2 &&
11040 error "swap of file we cannot write should fail"
11041 $LFS swap_layouts $file1 $file3 &&
11042 error "swap of file with different owner should fail"
11043 /bin/true # to clear error code
11045 run_test 184b "Forbidden layout swap (will generate errors)"
11048 check_swap_layouts_support && return 0
11050 local dir0=$DIR/$tdir/$testnum
11051 mkdir -p $dir0 || error "creating dir $dir0"
11053 local ref1=$dir0/ref1
11054 local ref2=$dir0/ref2
11055 local file1=$dir0/file1
11056 local file2=$dir0/file2
11057 # create a file large enough for the concurrent test
11058 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11059 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11060 echo "ref file size: ref1($(stat -c %s $ref1))," \
11061 "ref2($(stat -c %s $ref2))"
11064 dd if=$ref1 of=$file1 bs=16k &
11067 # Make sure dd starts to copy file
11068 while [ ! -f $file1 ]; do sleep 0.1; done
11070 $LFS swap_layouts $file1 $file2
11073 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11074 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11076 # how many bytes copied before swapping layout
11077 local copied=$(stat -c %s $file2)
11078 local remaining=$(stat -c %s $ref1)
11079 remaining=$((remaining - copied))
11080 echo "Copied $copied bytes before swapping layout..."
11082 cmp -n $copied $file1 $ref2 | grep differ &&
11083 error "Content mismatch [0, $copied) of ref2 and file1"
11084 cmp -n $copied $file2 $ref1 ||
11085 error "Content mismatch [0, $copied) of ref1 and file2"
11086 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11087 error "Content mismatch [$copied, EOF) of ref1 and file1"
11090 rm -f $ref1 $ref2 $file1 $file2
11092 run_test 184c "Concurrent write and layout swap"
11095 check_swap_layouts_support && return 0
11096 [ -z "$(which getfattr 2>/dev/null)" ] &&
11097 skip "no getfattr command" && return 0
11099 local file1=$DIR/$tdir/$tfile-1
11100 local file2=$DIR/$tdir/$tfile-2
11101 local file3=$DIR/$tdir/$tfile-3
11105 mkdir -p $DIR/$tdir
11106 touch $file1 || error "create $file1 failed"
11107 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11108 error "create $file2 failed"
11109 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11110 error "create $file3 failed"
11111 lovea1=$($LFS getstripe $file1 | sed 1d)
11113 $LFS swap_layouts $file2 $file3 ||
11114 error "swap $file2 $file3 layouts failed"
11115 $LFS swap_layouts $file1 $file2 ||
11116 error "swap $file1 $file2 layouts failed"
11118 lovea2=$($LFS getstripe $file2 | sed 1d)
11119 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11121 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11122 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11124 run_test 184d "allow stripeless layouts swap"
11127 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11128 { skip "Need MDS version at least 2.6.94"; return 0; }
11129 check_swap_layouts_support && return 0
11130 [ -z "$(which getfattr 2>/dev/null)" ] &&
11131 skip "no getfattr command" && return 0
11133 local file1=$DIR/$tdir/$tfile-1
11134 local file2=$DIR/$tdir/$tfile-2
11135 local file3=$DIR/$tdir/$tfile-3
11138 mkdir -p $DIR/$tdir
11139 touch $file1 || error "create $file1 failed"
11140 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11141 error "create $file2 failed"
11142 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11143 error "create $file3 failed"
11145 $LFS swap_layouts $file1 $file2 ||
11146 error "swap $file1 $file2 layouts failed"
11148 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11149 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11151 echo 123 > $file1 || error "Should be able to write into $file1"
11153 $LFS swap_layouts $file1 $file3 ||
11154 error "swap $file1 $file3 layouts failed"
11156 echo 123 > $file1 || error "Should be able to write into $file1"
11158 rm -rf $file1 $file2 $file3
11160 run_test 184e "Recreate layout after stripeless layout swaps"
11162 test_185() { # LU-2441
11163 # LU-3553 - no volatile file support in old servers
11164 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11165 { skip "Need MDS version at least 2.3.60"; return 0; }
11167 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11168 touch $DIR/$tdir/spoo
11169 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11170 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11171 error "cannot create/write a volatile file"
11172 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11173 error "FID is still valid after close"
11175 multiop_bg_pause $DIR/$tdir vVw4096_c
11182 # assume that the next FID for this client is sequential, since stdout
11183 # is unfortunately eaten by multiop_bg_pause
11184 local n=$((${fidv[1]} + 1))
11185 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11186 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11187 error "FID is missing before close"
11188 kill -USR1 $multi_pid
11189 # 1 second delay, so if mtime change we will see it
11191 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11192 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11194 run_test 185 "Volatile file support"
11197 local dir0=$DIR/$tdir/$testnum
11198 mkdir -p $dir0 || error "creating dir $dir0"
11200 local file=$dir0/file1
11201 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11202 local dv1=$($LFS data_version $file)
11203 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11204 local dv2=$($LFS data_version $file)
11205 [[ $dv1 != $dv2 ]] ||
11206 error "data version did not change on write $dv1 == $dv2"
11211 run_test 187a "Test data version change"
11214 local dir0=$DIR/$tdir/$testnum
11215 mkdir -p $dir0 || error "creating dir $dir0"
11217 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11218 [[ ${DV[0]} != ${DV[1]} ]] ||
11219 error "data version did not change on write"\
11220 " ${DV[0]} == ${DV[1]}"
11225 run_test 187b "Test data version change on volatile file"
11228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11229 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11231 local POOL=${POOL:-cea1}
11232 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11233 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11236 local last_ost=$(($OSTCOUNT - 1))
11238 local ost_list=$(seq $first_ost $ost_step $last_ost)
11239 local ost_range="$first_ost $last_ost $ost_step"
11240 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11241 local file_dir=$POOL_ROOT/file_tst
11242 local subdir=$test_path/subdir
11246 # former test_200a test_200b
11247 pool_add $POOL || { rc=$? ; break; }
11248 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11249 # former test_200c test_200d
11250 mkdir -p $test_path
11251 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11252 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11254 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11255 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11256 || { rc=$? ; break; }
11257 # former test_200e test_200f
11258 local files=$((OSTCOUNT*3))
11259 pool_alloc_files $POOL $test_path $files "$ost_list" \
11260 || { rc=$? ; break; }
11261 pool_create_files $POOL $file_dir $files "$ost_list" \
11262 || { rc=$? ; break; }
11263 # former test_200g test_200h
11264 pool_lfs_df $POOL || { rc=$? ; break; }
11265 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11267 # former test_201a test_201b test_201c
11268 pool_remove_first_target $POOL || { rc=$? ; break; }
11270 local f=$test_path/$tfile
11271 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11272 pool_remove $POOL $f || { rc=$? ; break; }
11279 run_test 200 "OST pools"
11281 # usage: default_attr <count | size | offset>
11283 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11286 # usage: check_default_stripe_attr
11287 check_default_stripe_attr() {
11288 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11290 --stripe-count|--count)
11291 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11292 --stripe-size|--size)
11293 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11294 --stripe-index|--index)
11297 error "unknown getstripe attr '$1'"
11300 [ $ACTUAL != $EXPECTED ] &&
11301 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11305 test_mkdir -p $DIR/$tdir
11306 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11308 check_default_stripe_attr --stripe-count
11309 check_default_stripe_attr --stripe-size
11310 check_default_stripe_attr --stripe-index
11314 run_test 204a "Print default stripe attributes ================="
11317 test_mkdir -p $DIR/$tdir
11318 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11320 check_default_stripe_attr --stripe-size
11321 check_default_stripe_attr --stripe-index
11325 run_test 204b "Print default stripe size and offset ==========="
11328 test_mkdir -p $DIR/$tdir
11329 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11331 check_default_stripe_attr --stripe-count
11332 check_default_stripe_attr --stripe-index
11336 run_test 204c "Print default stripe count and offset ==========="
11339 test_mkdir -p $DIR/$tdir
11340 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11342 check_default_stripe_attr --stripe-count
11343 check_default_stripe_attr --stripe-size
11347 run_test 204d "Print default stripe count and size ============="
11350 test_mkdir -p $DIR/$tdir
11351 $SETSTRIPE -d $DIR/$tdir
11353 check_default_stripe_attr --stripe-count --raw
11354 check_default_stripe_attr --stripe-size --raw
11355 check_default_stripe_attr --stripe-index --raw
11359 run_test 204e "Print raw stripe attributes ================="
11362 test_mkdir -p $DIR/$tdir
11363 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11365 check_default_stripe_attr --stripe-size --raw
11366 check_default_stripe_attr --stripe-index --raw
11370 run_test 204f "Print raw stripe size and offset ==========="
11373 test_mkdir -p $DIR/$tdir
11374 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11376 check_default_stripe_attr --stripe-count --raw
11377 check_default_stripe_attr --stripe-index --raw
11381 run_test 204g "Print raw stripe count and offset ==========="
11384 test_mkdir -p $DIR/$tdir
11385 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11387 check_default_stripe_attr --stripe-count --raw
11388 check_default_stripe_attr --stripe-size --raw
11392 run_test 204h "Print raw stripe count and size ============="
11394 # Figure out which job scheduler is being used, if any,
11395 # or use a fake one
11396 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11397 JOBENV=SLURM_JOB_ID
11398 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11400 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11402 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11403 JOBENV=LOADL_STEP_ID
11404 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11410 verify_jobstats() {
11414 # clear old jobstats
11415 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11416 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11418 # use a new JobID for this test, or we might see an old one
11419 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11423 log "Using JobID environment variable $JOBENV=$JOBVAL"
11425 if [ $JOBENV = "FAKE_JOBID" ]; then
11426 FAKE_JOBID=$JOBVAL $cmd
11431 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11432 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11433 do_facet $FACET lctl get_param mdt.*.job_stats |
11434 grep $JOBVAL || error "No job stats found on MDT $FACET"
11436 if [ "$target" = "ost" -o "$target" = "both" ]; then
11438 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11439 grep $JOBVAL || error "No job stats found on OST $FACET"
11445 NEW_JOBENV=${1:-$OLD_JOBENV}
11446 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11447 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11450 test_205() { # Job stats
11451 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11452 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11453 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11454 skip "Server doesn't support jobstats" && return 0
11455 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11458 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11459 if [ $OLD_JOBENV != $JOBENV ]; then
11460 jobstats_set $JOBENV
11461 trap jobstats_set EXIT
11464 local user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11465 changelog_register -n)
11466 echo "Registered as changelog user $user"
11469 cmd="mkdir $DIR/$tfile"
11470 verify_jobstats "$cmd" "mdt"
11472 cmd="rm -fr $DIR/$tfile"
11473 verify_jobstats "$cmd" "mdt"
11475 cmd="mknod $DIR/$tfile c 1 3"
11476 verify_jobstats "$cmd" "mdt"
11478 cmd="rm -f $DIR/$tfile"
11479 verify_jobstats "$cmd" "mdt"
11481 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11482 verify_jobstats "$cmd" "mdt"
11484 cmd="touch $DIR/$tfile"
11485 verify_jobstats "$cmd" "both"
11487 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11488 verify_jobstats "$cmd" "ost"
11490 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11491 verify_jobstats "$cmd" "ost"
11493 cmd="$TRUNCATE $DIR/$tfile 0"
11494 verify_jobstats "$cmd" "both"
11496 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11497 verify_jobstats "$cmd" "mdt"
11499 # Ensure that jobid are present in changelog (if supported by MDS)
11500 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11502 $LFS changelog $MDT0 | tail -9
11503 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11504 [ $jobids -eq 9 ] ||
11505 error "Wrong changelog jobid count $jobids != 9"
11509 jobstats_set $JOBENV
11511 $LFS changelog $MDT0 | tail -1
11512 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11513 [ $jobids -eq 0 ] ||
11514 error "Unexpected jobids when jobid_var=$JOBENV"
11518 rm -f $DIR/jobstats_test_rename
11520 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11522 run_test 205 "Verify job stats"
11524 # LU-1480, LU-1773 and LU-1657
11526 mkdir -p $DIR/$tdir
11527 $SETSTRIPE -c -1 $DIR/$tdir
11528 #define OBD_FAIL_LOV_INIT 0x1403
11529 $LCTL set_param fail_loc=0xa0001403
11530 $LCTL set_param fail_val=1
11531 touch $DIR/$tdir/$tfile || true
11533 run_test 206 "fail lov_init_raid0() doesn't lbug"
11536 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11537 local fsz=`stat -c %s $DIR/$tfile`
11538 cancel_lru_locks mdc
11540 # do not return layout in getattr intent
11541 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11542 $LCTL set_param fail_loc=0x170
11543 local sz=`stat -c %s $DIR/$tfile`
11545 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11549 run_test 207a "can refresh layout at glimpse"
11552 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11553 local cksum=`md5sum $DIR/$tfile`
11554 local fsz=`stat -c %s $DIR/$tfile`
11555 cancel_lru_locks mdc
11556 cancel_lru_locks osc
11558 # do not return layout in getattr intent
11559 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11560 $LCTL set_param fail_loc=0x171
11562 # it will refresh layout after the file is opened but before read issues
11563 echo checksum is "$cksum"
11564 echo "$cksum" |md5sum -c --quiet || error "file differs"
11568 run_test 207b "can refresh layout at open"
11571 # FIXME: in this test suite, only RD lease is used. This is okay
11572 # for now as only exclusive open is supported. After generic lease
11573 # is done, this test suite should be revised. - Jinshan
11575 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11576 { skip "Need MDS version at least 2.4.52"; return 0; }
11577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11579 echo "==== test 1: verify get lease work"
11580 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11582 echo "==== test 2: verify lease can be broken by upcoming open"
11583 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11587 $MULTIOP $DIR/$tfile oO_RDONLY:c
11588 kill -USR1 $PID && wait $PID || error "break lease error"
11590 echo "==== test 3: verify lease can't be granted if an open already exists"
11591 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11595 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11596 kill -USR1 $PID && wait $PID || error "open file error"
11598 echo "==== test 4: lease can sustain over recovery"
11599 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11605 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11607 echo "==== test 5: lease broken can't be regained by replay"
11608 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11612 # open file to break lease and then recovery
11613 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11616 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11620 run_test 208 "Exclusive open"
11623 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11624 skip_env "must have disp_stripe" && return
11627 sync; sleep 5; sync;
11629 echo 3 > /proc/sys/vm/drop_caches
11630 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11632 # open/close 500 times
11633 for i in $(seq 500); do
11637 echo 3 > /proc/sys/vm/drop_caches
11638 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11640 echo "before: $req_before, after: $req_after"
11641 [ $((req_after - req_before)) -ge 300 ] &&
11642 error "open/close requests are not freed"
11645 run_test 209 "read-only open/close requests should be freed promptly"
11649 size=$((size % 8192 + 1))
11650 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11651 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11652 rm -f $DIR/f212 $DIR/f212.xyz
11654 run_test 212 "Sendfile test ============================================"
11657 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11658 cancel_lru_locks osc
11659 lctl set_param fail_loc=0x8000040f
11660 # generate a read lock
11661 cat $DIR/$tfile > /dev/null
11662 # write to the file, it will try to cancel the above read lock.
11663 cat /etc/hosts >> $DIR/$tfile
11665 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11667 test_214() { # for bug 20133
11668 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11669 for (( i=0; i < 340; i++ )) ; do
11670 touch $DIR/$tdir/d214c/a$i
11673 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11674 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11675 ls $DIR/d214c || error "ls $DIR/d214c failed"
11676 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11677 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11679 run_test 214 "hash-indexed directory test - bug 20133"
11681 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11682 create_lnet_proc_files() {
11683 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11684 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11686 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11687 rm -f "$TMP/lnet_$1.sys_tmp"
11690 # counterpart of create_lnet_proc_files
11691 remove_lnet_proc_files() {
11692 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11695 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11696 # 3rd arg as regexp for body
11697 check_lnet_proc_stats() {
11698 local l=$(cat "$TMP/lnet_$1" |wc -l)
11699 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11701 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11704 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11705 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11706 # optional and can be regexp for 2nd line (lnet.routes case)
11707 check_lnet_proc_entry() {
11708 local blp=2 # blp stands for 'position of 1st line of body'
11709 [ -z "$5" ] || blp=3 # lnet.routes case
11711 local l=$(cat "$TMP/lnet_$1" |wc -l)
11712 # subtracting one from $blp because the body can be empty
11713 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11715 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11716 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11718 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11719 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11721 # bail out if any unexpected line happened
11722 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11723 [ "$?" != 0 ] || error "$2 misformatted"
11726 test_215() { # for bugs 18102, 21079, 21517
11727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11728 local N='(0|[1-9][0-9]*)' # non-negative numeric
11729 local P='[1-9][0-9]*' # positive numeric
11730 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11731 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11732 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11733 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11735 local L1 # regexp for 1st line
11736 local L2 # regexp for 2nd line (optional)
11737 local BR # regexp for the rest (body)
11739 # lnet.stats should look as 11 space-separated non-negative numerics
11740 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11741 create_lnet_proc_files "stats"
11742 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11743 remove_lnet_proc_files "stats"
11745 # lnet.routes should look like this:
11746 # Routing disabled/enabled
11747 # net hops priority state router
11748 # where net is a string like tcp0, hops > 0, priority >= 0,
11749 # state is up/down,
11750 # router is a string like 192.168.1.1@tcp2
11751 L1="^Routing (disabled|enabled)$"
11752 L2="^net +hops +priority +state +router$"
11753 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11754 create_lnet_proc_files "routes"
11755 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11756 remove_lnet_proc_files "routes"
11758 # lnet.routers should look like this:
11759 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11760 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11761 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11762 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11763 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11764 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11765 create_lnet_proc_files "routers"
11766 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11767 remove_lnet_proc_files "routers"
11769 # lnet.peers should look like this:
11770 # nid refs state last max rtr min tx min queue
11771 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11772 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11773 # numeric (0 or >0 or <0), queue >= 0.
11774 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11775 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11776 create_lnet_proc_files "peers"
11777 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11778 remove_lnet_proc_files "peers"
11780 # lnet.buffers should look like this:
11781 # pages count credits min
11782 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11783 L1="^pages +count +credits +min$"
11784 BR="^ +$N +$N +$I +$I$"
11785 create_lnet_proc_files "buffers"
11786 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11787 remove_lnet_proc_files "buffers"
11789 # lnet.nis should look like this:
11790 # nid status alive refs peer rtr max tx min
11791 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11792 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11793 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11794 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11795 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11796 create_lnet_proc_files "nis"
11797 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11798 remove_lnet_proc_files "nis"
11800 # can we successfully write to lnet.stats?
11801 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
11802 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11804 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
11806 test_216() { # bug 20317
11807 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11808 remote_ost_nodsh && skip "remote OST with nodsh" && return
11811 local facets=$(get_facets OST)
11812 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11814 save_lustre_params client "osc.*.contention_seconds" > $p
11815 save_lustre_params $facets \
11816 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11817 save_lustre_params $facets \
11818 "ldlm.namespaces.filter-*.contended_locks" >> $p
11819 save_lustre_params $facets \
11820 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11823 # agressive lockless i/o settings
11824 for node in $(osts_nodes); do
11825 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'
11827 lctl set_param -n osc.*.contention_seconds 60
11829 $DIRECTIO write $DIR/$tfile 0 10 4096
11830 $CHECKSTAT -s 40960 $DIR/$tfile
11832 # disable lockless i/o
11833 for node in $(osts_nodes); do
11834 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'
11836 lctl set_param -n osc.*.contention_seconds 0
11839 dd if=/dev/zero of=$DIR/$tfile count=0
11840 $CHECKSTAT -s 0 $DIR/$tfile
11842 restore_lustre_params <$p
11846 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11848 test_217() { # bug 22430
11849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11853 for node in $(nodes_list); do
11854 nid=$(host_nids_address $node $NETTYPE)
11855 if [[ $nid = *-* ]] ; then
11856 echo "lctl ping $nid@$NETTYPE"
11857 lctl ping $nid@$NETTYPE
11859 echo "skipping $node (no hyphen detected)"
11863 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11866 # do directio so as not to populate the page cache
11867 log "creating a 10 Mb file"
11868 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11869 log "starting reads"
11870 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11871 log "truncating the file"
11872 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11874 kill %+ || true # reads might have finished
11875 echo "wait until dd is finished"
11877 log "removing the temporary file"
11878 rm -rf $DIR/$tfile || error "tmp file removal failed"
11880 run_test 218 "parallel read and truncate should not deadlock ======================="
11883 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11884 # write one partial page
11885 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11886 # set no grant so vvp_io_commit_write will do sync write
11887 $LCTL set_param fail_loc=0x411
11888 # write a full page at the end of file
11889 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11891 $LCTL set_param fail_loc=0
11892 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11893 $LCTL set_param fail_loc=0x411
11894 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11897 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11898 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11900 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11902 test_220() { #LU-325
11903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11904 remote_ost_nodsh && skip "remote OST with nodsh" && return
11907 test_mkdir -p $DIR/$tdir
11908 local OST=$($LFS osts | grep ${OSTIDX}": " | \
11909 awk '{print $2}' | sed -e 's/_UUID$//')
11912 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11913 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11914 osc.$mdtosc_proc1.prealloc_last_id)
11915 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11916 osc.$mdtosc_proc1.prealloc_next_id)
11920 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11921 #define OBD_FAIL_OST_ENOINO 0x229
11922 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11923 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11924 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11926 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11928 MDSOBJS=$((last_id - next_id))
11929 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11931 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11932 echo "OST still has $count kbytes free"
11934 echo "create $MDSOBJS files @next_id..."
11935 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11937 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11938 osc.$mdtosc_proc1.prealloc_last_id)
11939 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11940 osc.$mdtosc_proc1.prealloc_next_id)
11942 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11947 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11948 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11950 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11951 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11952 echo "unlink $MDSOBJS files @$next_id..."
11953 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11955 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11959 dd if=`which date` of=$MOUNT/date oflag=sync
11960 chmod +x $MOUNT/date
11962 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11963 $LCTL set_param fail_loc=0x80001401
11965 $MOUNT/date > /dev/null
11968 run_test 221 "make sure fault and truncate race to not cause OOM"
11971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11973 test_mkdir -p $DIR/$tdir
11974 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11975 createmany -o $DIR/$tdir/$tfile 10
11976 cancel_lru_locks mdc
11977 cancel_lru_locks osc
11978 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11979 $LCTL set_param fail_loc=0x31a
11980 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11981 $LCTL set_param fail_loc=0
11984 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11987 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11989 test_mkdir -p $DIR/$tdir
11990 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11991 createmany -o $DIR/$tdir/$tfile 10
11992 cancel_lru_locks mdc
11993 cancel_lru_locks osc
11994 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11995 $LCTL set_param fail_loc=0x31a
11996 rm -r $DIR/$tdir || "AGL for rmdir failed"
11997 $LCTL set_param fail_loc=0
11999 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12004 test_mkdir -p $DIR/$tdir
12005 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12006 createmany -o $DIR/$tdir/$tfile 10
12007 cancel_lru_locks mdc
12008 cancel_lru_locks osc
12009 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12010 $LCTL set_param fail_loc=0x31b
12011 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12012 $LCTL set_param fail_loc=0
12015 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12017 test_224a() { # LU-1039, MRP-303
12018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12019 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12020 $LCTL set_param fail_loc=0x508
12021 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12022 $LCTL set_param fail_loc=0
12025 run_test 224a "Don't panic on bulk IO failure"
12027 test_224b() { # LU-1039, MRP-303
12028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12029 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12030 cancel_lru_locks osc
12031 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12032 $LCTL set_param fail_loc=0x515
12033 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12034 $LCTL set_param fail_loc=0
12037 run_test 224b "Don't panic on bulk IO failure"
12039 test_224c() { # LU-6441
12040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12041 local pages_per_rpc=$($LCTL get_param \
12042 osc.*.max_pages_per_rpc)
12043 local at_max=$($LCTL get_param -n at_max)
12044 local timeout=$($LCTL get_param -n timeout)
12045 local test_at="$LCTL get_param -n at_max"
12046 local param_at="$FSNAME.sys.at_max"
12047 local test_timeout="$LCTL get_param -n timeout"
12048 local param_timeout="$FSNAME.sys.timeout"
12050 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12052 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12053 error "conf_param at_max=0 failed"
12054 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12055 error "conf_param timeout=5 failed"
12057 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12058 $LCTL set_param fail_loc=0x520
12059 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12061 $LCTL set_param fail_loc=0
12063 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12064 error "conf_param at_max=$at_max failed"
12065 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12066 $timeout || error "conf_param timeout=$timeout failed"
12068 $LCTL set_param -n $pages_per_rpc
12070 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12072 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12075 if [ -z ${MDSSURVEY} ]; then
12076 skip_env "mds-survey not found" && return
12079 [ $MDSCOUNT -ge 2 ] &&
12080 skip "skipping now for more than one MDT" && return
12082 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12083 { skip "Need MDS version at least 2.2.51"; return; }
12085 local mds=$(facet_host $SINGLEMDS)
12086 local target=$(do_nodes $mds 'lctl dl' | \
12087 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12089 local cmd1="file_count=1000 thrhi=4"
12090 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12091 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12092 local cmd="$cmd1 $cmd2 $cmd3"
12094 rm -f ${TMP}/mds_survey*
12096 eval $cmd || error "mds-survey with zero-stripe failed"
12097 cat ${TMP}/mds_survey*
12098 rm -f ${TMP}/mds_survey*
12100 run_test 225a "Metadata survey sanity with zero-stripe"
12103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12105 if [ -z ${MDSSURVEY} ]; then
12106 skip_env "mds-survey not found" && return
12108 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12109 { skip "Need MDS version at least 2.2.51"; return; }
12111 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12112 skip_env "Need to mount OST to test" && return
12115 [ $MDSCOUNT -ge 2 ] &&
12116 skip "skipping now for more than one MDT" && return
12117 local mds=$(facet_host $SINGLEMDS)
12118 local target=$(do_nodes $mds 'lctl dl' | \
12119 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12121 local cmd1="file_count=1000 thrhi=4"
12122 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12123 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12124 local cmd="$cmd1 $cmd2 $cmd3"
12126 rm -f ${TMP}/mds_survey*
12128 eval $cmd || error "mds-survey with stripe_count failed"
12129 cat ${TMP}/mds_survey*
12130 rm -f ${TMP}/mds_survey*
12132 run_test 225b "Metadata survey sanity with stripe_count = 1"
12134 mcreate_path2fid () {
12140 local path=$DIR/$tdir/$name
12145 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12146 error "cannot create $desc"
12148 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12150 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12152 fid_path=$($LFS fid2path $MOUNT $fid)
12154 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12156 [ "$path" == "$fid_path" ] ||
12157 error "fid2path returned $fid_path, expected $path"
12159 echo "pass with $path and $fid"
12164 mkdir -p $DIR/$tdir
12166 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12167 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12168 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12169 mcreate_path2fid 0040666 0 0 dir "directory"
12170 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12171 mcreate_path2fid 0100666 0 0 file "regular file"
12172 mcreate_path2fid 0120666 0 0 link "symbolic link"
12173 mcreate_path2fid 0140666 0 0 sock "socket"
12175 run_test 226a "call path2fid and fid2path on files of all type"
12178 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12182 mkdir -p $DIR/$tdir
12183 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12184 error "create remote directory failed"
12185 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12186 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12187 "character special file (null)"
12188 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12189 "character special file (no device)"
12190 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12191 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12192 "block special file (loop)"
12193 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12194 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12195 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12197 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12199 # LU-1299 Executing or running ldd on a truncated executable does not
12200 # cause an out-of-memory condition.
12202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12203 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12204 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12205 chmod +x $MOUNT/date
12207 $MOUNT/date > /dev/null
12208 ldd $MOUNT/date > /dev/null
12211 run_test 227 "running truncated executable does not cause OOM"
12213 # LU-1512 try to reuse idle OI blocks
12215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12216 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12217 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12218 skip "non-ldiskfs backend" && return
12220 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12221 local myDIR=$DIR/$tdir
12224 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12225 $LCTL set_param fail_loc=0x80001002
12226 createmany -o $myDIR/t- 10000
12227 $LCTL set_param fail_loc=0
12228 # The guard is current the largest FID holder
12230 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12232 local IDX=$(($SEQ % 64))
12234 do_facet $SINGLEMDS sync
12235 # Make sure journal flushed.
12237 local blk1=$(do_facet $SINGLEMDS \
12238 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12239 grep Blockcount | awk '{print $4}')
12241 # Remove old files, some OI blocks will become idle.
12242 unlinkmany $myDIR/t- 10000
12243 # Create new files, idle OI blocks should be reused.
12244 createmany -o $myDIR/t- 2000
12245 do_facet $SINGLEMDS sync
12246 # Make sure journal flushed.
12248 local blk2=$(do_facet $SINGLEMDS \
12249 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12250 grep Blockcount | awk '{print $4}')
12252 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12254 run_test 228a "try to reuse idle OI blocks"
12257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12258 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12259 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12260 skip "non-ldiskfs backend" && return
12262 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12263 local myDIR=$DIR/$tdir
12266 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12267 $LCTL set_param fail_loc=0x80001002
12268 createmany -o $myDIR/t- 10000
12269 $LCTL set_param fail_loc=0
12270 # The guard is current the largest FID holder
12272 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12274 local IDX=$(($SEQ % 64))
12276 do_facet $SINGLEMDS sync
12277 # Make sure journal flushed.
12279 local blk1=$(do_facet $SINGLEMDS \
12280 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12281 grep Blockcount | awk '{print $4}')
12283 # Remove old files, some OI blocks will become idle.
12284 unlinkmany $myDIR/t- 10000
12287 stop $SINGLEMDS || error "Fail to stop MDT."
12289 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12291 df $MOUNT || error "Fail to df."
12292 # Create new files, idle OI blocks should be reused.
12293 createmany -o $myDIR/t- 2000
12294 do_facet $SINGLEMDS sync
12295 # Make sure journal flushed.
12297 local blk2=$(do_facet $SINGLEMDS \
12298 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12299 grep Blockcount | awk '{print $4}')
12301 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12303 run_test 228b "idle OI blocks can be reused after MDT restart"
12307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12308 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12309 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12310 skip "non-ldiskfs backend" && return
12312 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12313 local myDIR=$DIR/$tdir
12316 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12317 $LCTL set_param fail_loc=0x80001002
12318 # 20000 files can guarantee there are index nodes in the OI file
12319 createmany -o $myDIR/t- 20000
12320 $LCTL set_param fail_loc=0
12321 # The guard is current the largest FID holder
12323 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12325 local IDX=$(($SEQ % 64))
12327 do_facet $SINGLEMDS sync
12328 # Make sure journal flushed.
12330 local blk1=$(do_facet $SINGLEMDS \
12331 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12332 grep Blockcount | awk '{print $4}')
12334 # Remove old files, some OI blocks will become idle.
12335 unlinkmany $myDIR/t- 20000
12337 # The OI file should become empty now
12339 # Create new files, idle OI blocks should be reused.
12340 createmany -o $myDIR/t- 2000
12341 do_facet $SINGLEMDS sync
12342 # Make sure journal flushed.
12344 local blk2=$(do_facet $SINGLEMDS \
12345 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12346 grep Blockcount | awk '{print $4}')
12348 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12350 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12352 test_229() { # LU-2482, LU-3448
12353 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12354 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12357 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12361 # Create a file with a released layout and stripe count 2.
12362 $MULTIOP $DIR/$tfile H2c ||
12363 error "failed to create file with released layout"
12365 $GETSTRIPE -v $DIR/$tfile
12367 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12368 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12370 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12371 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12372 stat $DIR/$tfile || error "failed to stat released file"
12374 chown $RUNAS_ID $DIR/$tfile ||
12375 error "chown $RUNAS_ID $DIR/$tfile failed"
12377 chgrp $RUNAS_ID $DIR/$tfile ||
12378 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12380 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12381 rm $DIR/$tfile || error "failed to remove released file"
12383 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12387 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12390 test_mkdir $DIR/$tdir
12391 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12392 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12393 [ $mdt_idx -ne 0 ] &&
12394 error "create local directory on wrong MDT $mdt_idx"
12396 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12397 error "create remote directory failed"
12398 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12399 [ $mdt_idx -ne $MDTIDX ] &&
12400 error "create remote directory on wrong MDT $mdt_idx"
12402 createmany -o $DIR/$tdir/test_230/t- 10 ||
12403 error "create files on remote directory failed"
12404 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12405 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12406 rm -r $DIR/$tdir || error "unlink remote directory failed"
12408 run_test 230a "Create remote directory and files under the remote directory"
12411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12412 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12419 local migrate_dir=$DIR/$tdir/migrate_dir
12420 local other_dir=$DIR/$tdir/other_dir
12422 test_mkdir $DIR/$tdir
12423 test_mkdir -i0 -c1 $migrate_dir
12424 test_mkdir -i0 -c1 $other_dir
12425 for ((i=0; i<10; i++)); do
12426 mkdir -p $migrate_dir/dir_${i}
12427 createmany -o $migrate_dir/dir_${i}/f 10 ||
12428 error "create files under remote dir failed $i"
12431 cp /etc/passwd $migrate_dir/$tfile
12432 cp /etc/passwd $other_dir/$tfile
12433 chattr +SAD $migrate_dir
12434 chattr +SAD $migrate_dir/$tfile
12436 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12437 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12438 local old_dir_mode=$(stat -c%f $migrate_dir)
12439 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12441 mkdir -p $migrate_dir/dir_default_stripe2
12442 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12443 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12445 mkdir -p $other_dir
12446 ln $migrate_dir/$tfile $other_dir/luna
12447 ln $migrate_dir/$tfile $migrate_dir/sofia
12448 ln $other_dir/$tfile $migrate_dir/david
12449 ln -s $migrate_dir/$tfile $other_dir/zachary
12450 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12451 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12453 $LFS mv -v -M $MDTIDX $migrate_dir ||
12454 error "migrate remote dir error"
12456 echo "migratate to MDT1, then checking.."
12457 for ((i = 0; i < 10; i++)); do
12458 for file in $(find $migrate_dir/dir_${i}); do
12459 mdt_index=$($LFS getstripe -M $file)
12460 [ $mdt_index == $MDTIDX ] ||
12461 error "$file is not on MDT${MDTIDX}"
12465 # the multiple link file should still in MDT0
12466 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12467 [ $mdt_index == 0 ] ||
12468 error "$file is not on MDT${MDTIDX}"
12470 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12471 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12472 error " expect $old_dir_flag get $new_dir_flag"
12474 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12475 [ "$old_file_flag" = "$new_file_flag" ] ||
12476 error " expect $old_file_flag get $new_file_flag"
12478 local new_dir_mode=$(stat -c%f $migrate_dir)
12479 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12480 error "expect mode $old_dir_mode get $new_dir_mode"
12482 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12483 [ "$old_file_mode" = "$new_file_mode" ] ||
12484 error "expect mode $old_file_mode get $new_file_mode"
12486 diff /etc/passwd $migrate_dir/$tfile ||
12487 error "$tfile different after migration"
12489 diff /etc/passwd $other_dir/luna ||
12490 error "luna different after migration"
12492 diff /etc/passwd $migrate_dir/sofia ||
12493 error "sofia different after migration"
12495 diff /etc/passwd $migrate_dir/david ||
12496 error "david different after migration"
12498 diff /etc/passwd $other_dir/zachary ||
12499 error "zachary different after migration"
12501 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12502 error "${tfile}_ln different after migration"
12504 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12505 error "${tfile}_ln_other different after migration"
12507 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12508 [ $stripe_count = 2 ] ||
12509 error "dir strpe_count $d != 2 after migration."
12511 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12512 [ $stripe_count = 2 ] ||
12513 error "file strpe_count $d != 2 after migration."
12515 #migrate back to MDT0
12517 $LFS mv -v -M $MDTIDX $migrate_dir ||
12518 error "migrate remote dir error"
12520 echo "migrate back to MDT0, checking.."
12521 for file in $(find $migrate_dir); do
12522 mdt_index=$($LFS getstripe -M $file)
12523 [ $mdt_index == $MDTIDX ] ||
12524 error "$file is not on MDT${MDTIDX}"
12527 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12528 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12529 error " expect $old_dir_flag get $new_dir_flag"
12531 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12532 [ "$old_file_flag" = "$new_file_flag" ] ||
12533 error " expect $old_file_flag get $new_file_flag"
12535 local new_dir_mode=$(stat -c%f $migrate_dir)
12536 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12537 error "expect mode $old_dir_mode get $new_dir_mode"
12539 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12540 [ "$old_file_mode" = "$new_file_mode" ] ||
12541 error "expect mode $old_file_mode get $new_file_mode"
12543 diff /etc/passwd ${migrate_dir}/$tfile ||
12544 error "$tfile different after migration"
12546 diff /etc/passwd ${other_dir}/luna ||
12547 error "luna different after migration"
12549 diff /etc/passwd ${migrate_dir}/sofia ||
12550 error "sofia different after migration"
12552 diff /etc/passwd ${other_dir}/zachary ||
12553 error "zachary different after migration"
12555 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12556 error "${tfile}_ln different after migration"
12558 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12559 error "${tfile}_ln_other different after migration"
12561 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12562 [ $stripe_count = 2 ] ||
12563 error "dir strpe_count $d != 2 after migration."
12565 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12566 [ $stripe_count = 2 ] ||
12567 error "file strpe_count $d != 2 after migration."
12569 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12571 run_test 230b "migrate directory"
12574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12575 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12579 local migrate_dir=$DIR/$tdir/migrate_dir
12581 #If migrating directory fails in the middle, all entries of
12582 #the directory is still accessiable.
12583 test_mkdir $DIR/$tdir
12584 test_mkdir -i0 -c1 $migrate_dir
12586 createmany -o $migrate_dir/f 10 ||
12587 error "create files under ${migrate_dir} failed"
12589 #failed after migrating 5 entries
12590 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12591 do_facet mds1 lctl set_param fail_loc=0x20001801
12592 do_facet mds1 lctl set_param fail_val=5
12593 local t=$(ls $migrate_dir | wc -l)
12594 $LFS mv --mdt-index $MDTIDX $migrate_dir &&
12595 error "migrate should fail after 5 entries"
12596 local u=$(ls $migrate_dir | wc -l)
12597 [ "$u" == "$t" ] || error "$u != $t during migration"
12599 for file in $(find $migrate_dir); do
12600 stat $file || error "stat $file failed"
12603 do_facet mds1 lctl set_param fail_loc=0
12604 do_facet mds1 lctl set_param fail_val=0
12606 $LFS mv -M $MDTIDX $migrate_dir ||
12607 error "migrate open files should failed with open files"
12609 echo "Finish migration, then checking.."
12610 for file in $(find $migrate_dir); do
12611 mdt_index=$($LFS getstripe -M $file)
12612 [ $mdt_index == $MDTIDX ] ||
12613 error "$file is not on MDT${MDTIDX}"
12616 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12618 run_test 230c "check directory accessiblity if migration is failed"
12621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12622 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12625 local migrate_dir=$DIR/$tdir/migrate_dir
12629 test_mkdir $DIR/$tdir
12630 test_mkdir -i0 -c1 $migrate_dir
12632 for ((i=0; i<100; i++)); do
12633 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12634 createmany -o $migrate_dir/dir_${i}/f 100 ||
12635 error "create files under remote dir failed $i"
12638 $LFS mv -M $MDTIDX -v $migrate_dir || error "migrate remote dir error"
12640 echo "Finish migration, then checking.."
12641 for file in $(find $migrate_dir); do
12642 mdt_index=$($LFS getstripe -M $file)
12643 [ $mdt_index == $MDTIDX ] ||
12644 error "$file is not on MDT${MDTIDX}"
12647 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12649 run_test 230d "check migrate big directory"
12653 # For simplicity this test assumes that max_pages_per_rpc
12654 # is the same across all OSCs
12655 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12656 local bulk_size=$((max_pages * 4096))
12658 mkdir -p $DIR/$tdir
12660 # clear the OSC stats
12661 $LCTL set_param osc.*.stats=0 &>/dev/null
12663 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12664 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12665 oflag=direct &>/dev/null || error "dd failed"
12667 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12668 if [ x$nrpcs != "x1" ]; then
12669 error "found $nrpc ost_write RPCs, not 1 as expected"
12672 # Drop the OSC cache, otherwise we will read from it
12673 cancel_lru_locks osc
12675 # clear the OSC stats
12676 $LCTL set_param osc.*.stats=0 &>/dev/null
12678 # Client reads $bulk_size.
12679 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12680 iflag=direct &>/dev/null || error "dd failed"
12682 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12683 if [ x$nrpcs != "x1" ]; then
12684 error "found $nrpc ost_read RPCs, not 1 as expected"
12687 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12690 mkdir -p $DIR/$tdir
12692 for i in {0..1023}; do
12693 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12694 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12695 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12699 run_test 231b "must not assert on fully utilized OST request buffer"
12702 mkdir -p $DIR/$tdir
12703 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12704 $LCTL set_param fail_loc=0x31c
12706 # ignore dd failure
12707 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12709 $LCTL set_param fail_loc=0
12710 umount_client $MOUNT || error "umount failed"
12711 mount_client $MOUNT || error "mount failed"
12713 run_test 232 "failed lock should not block umount"
12716 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12717 { skip "Need MDS version at least 2.3.64"; return; }
12719 local fid=$($LFS path2fid $MOUNT)
12720 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12721 error "cannot access $MOUNT using its FID '$fid'"
12723 run_test 233a "checking that OBF of the FS root succeeds"
12726 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12727 { skip "Need MDS version at least 2.5.90"; return; }
12729 local fid=$($LFS path2fid $MOUNT/.lustre)
12730 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12731 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12733 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12734 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12735 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12737 run_test 233b "checking that OBF of the FS .lustre succeeds"
12740 local p="$TMP/sanityN-$TESTNAME.parameters"
12741 save_lustre_params client "llite.*.xattr_cache" > $p
12742 lctl set_param llite.*.xattr_cache 1 ||
12743 { skip "xattr cache is not supported"; return 0; }
12745 mkdir -p $DIR/$tdir || error "mkdir failed"
12746 touch $DIR/$tdir/$tfile || error "touch failed"
12747 # OBD_FAIL_LLITE_XATTR_ENOMEM
12748 $LCTL set_param fail_loc=0x1405
12749 # output of the form: attr 2 4 44 3 fc13 x86_64
12750 V=($(IFS=".-" rpm -q attr))
12751 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
12752 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
12753 # attr pre-2.4.44-7 had a bug with rc
12754 # LU-3703 - SLES 11 and FC13 clients have older attr
12755 getfattr -n user.attr $DIR/$tdir/$tfile &&
12756 error "getfattr should have failed with ENOMEM"
12758 skip "LU-3703: attr version $(getfattr --version) too old"
12760 $LCTL set_param fail_loc=0x0
12763 restore_lustre_params < $p
12766 run_test 234 "xattr cache should not crash on ENOMEM"
12769 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12770 skip "Need MDS version at least 2.4.52" && return
12771 flock_deadlock $DIR/$tfile
12776 124) error "process hangs on a deadlock"
12778 *) error "error executing flock_deadlock $DIR/$tfile"
12782 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12786 check_swap_layouts_support && return 0
12787 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12789 local ref1=/etc/passwd
12790 local ref2=/etc/group
12791 local file1=$DIR/$tdir/f1
12792 local file2=$DIR/$tdir/f2
12794 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12795 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12796 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12797 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12798 local fd=$(free_fd)
12799 local cmd="exec $fd<>$file2"
12802 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12803 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12806 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12811 run_test 236 "Layout swap on open unlinked file"
12813 # test to verify file handle related system calls
12814 # (name_to_handle_at/open_by_handle_at)
12815 # The new system calls are supported in glibc >= 2.14.
12818 echo "Test file_handle syscalls" > $DIR/$tfile ||
12819 error "write failed"
12820 check_fhandle_syscalls $DIR/$tfile ||
12821 error "check_fhandle_syscalls failed"
12823 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12825 # LU-4659 linkea consistency
12827 local server_version=$(lustre_version_code $SINGLEMDS)
12829 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12830 [[ $server_version -gt $(version_code 2.5.1) &&
12831 $server_version -lt $(version_code 2.5.50) ]] ||
12832 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12835 ln $DIR/$tfile $DIR/$tfile.lnk
12836 touch $DIR/$tfile.new
12837 mv $DIR/$tfile.new $DIR/$tfile
12838 local fid1=$($LFS path2fid $DIR/$tfile)
12839 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
12840 local path1=$($LFS fid2path $FSNAME "$fid1")
12841 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12842 local path2=$($LFS fid2path $FSNAME "$fid2")
12843 [ $tfile.lnk == $path2 ] ||
12844 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12847 run_test 238 "Verify linkea consistency"
12850 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
12851 skip "Need MDS version at least 2.5.60" && return
12852 local list=$(comma_list $(mdts_nodes))
12854 mkdir -p $DIR/$tdir
12855 createmany -o $DIR/$tdir/f- 5000
12856 unlinkmany $DIR/$tdir/f- 5000
12857 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12858 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12859 osc.*MDT*.sync_in_flight" | calc_sum)
12860 [ "$changes" -eq 0 ] || error "$changes not synced"
12862 run_test 239 "osp_sync test"
12865 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12867 mkdir -p $DIR/$tdir
12869 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12870 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12871 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12872 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12874 umount_client $MOUNT || error "umount failed"
12875 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12876 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12877 mount_client $MOUNT || error "failed to mount client"
12879 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12880 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12882 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12885 for LOOP in $(seq $1); do
12886 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
12887 cancel_lru_locks osc
12892 for LOOP in $(seq $1); do
12893 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
12894 iflag=direct 2>/dev/null
12899 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12901 cancel_lru_locks osc
12902 test_241_bio 1000 &
12907 run_test 241 "bio vs dio"
12910 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12912 test_241_dio 1000 &
12917 run_test 241b "dio vs dio"
12920 mkdir -p $DIR/$tdir
12921 touch $DIR/$tdir/$tfile
12923 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
12924 do_facet mds1 lctl set_param fail_loc=0x105
12925 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
12927 do_facet mds1 lctl set_param fail_loc=0
12928 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
12930 run_test 242 "mdt_readpage failure should not cause directory unreadable"
12934 test_mkdir -p $DIR/$tdir
12935 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
12937 run_test 243 "various group lock tests"
12941 test_mkdir -p $DIR/$tdir
12942 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
12943 sendfile_grouplock $DIR/$tdir/$tfile || \
12944 error "sendfile+grouplock failed"
12947 run_test 244 "sendfile with group lock tests"
12950 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
12951 && skip "no 16TB file size limit on ZFS" && return
12953 $SETSTRIPE -c 1 $DIR/$tfile
12954 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
12955 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
12956 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
12957 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
12958 conv=notrunc,fsync && error "append succeeded"
12961 run_test 250 "Write above 16T limit"
12964 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
12966 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
12967 #Skip once - writing the first stripe will succeed
12968 $LCTL set_param fail_loc=0xa0001407 fail_val=1
12969 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
12970 error "short write happened"
12972 $LCTL set_param fail_loc=0xa0001407 fail_val=1
12973 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
12974 error "short read happened"
12978 run_test 251 "Handling short read and write correctly"
12980 cleanup_test_300() {
12984 test_striped_dir() {
12989 mkdir -p $DIR/$tdir
12991 SAVE_UMASK=$(umask)
12992 trap cleanup_test_300 RETURN EXIT
12994 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12995 $DIR/$tdir/striped_dir ||
12996 error "set striped dir error"
12998 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12999 [ "$mode" = "755" ] || error "expect 755 got $mode"
13001 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13002 if [ "$stripe_count" != "2" ]; then
13003 error "stripe_count is $stripe_count, expect 2"
13006 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13007 if [ "$stripe_index" != "$mdt_index" ]; then
13008 error "stripe_index is $stripe_index, expect $mdt_index"
13011 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13012 error "nlink error after create striped dir"
13014 mkdir $DIR/$tdir/striped_dir/a
13015 mkdir $DIR/$tdir/striped_dir/b
13017 stat $DIR/$tdir/striped_dir/a ||
13018 error "create dir under striped dir failed"
13019 stat $DIR/$tdir/striped_dir/b ||
13020 error "create dir under striped dir failed"
13022 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13023 error "nlink error after mkdir"
13025 rmdir $DIR/$tdir/striped_dir/a
13026 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13027 error "nlink error after rmdir"
13029 rmdir $DIR/$tdir/striped_dir/b
13030 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13031 error "nlink error after rmdir"
13033 chattr +i $DIR/$tdir/striped_dir
13034 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13035 error "immutable flags not working under striped dir!"
13036 chattr -i $DIR/$tdir/striped_dir
13038 rmdir $DIR/$tdir/striped_dir ||
13039 error "rmdir striped dir error"
13047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13048 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13050 test_striped_dir 0 || error "failed on striped dir on MDT0"
13051 test_striped_dir 1 || error "failed on striped dir on MDT0"
13053 run_test 300a "basic striped dir sanity test"
13056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13057 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13063 test_mkdir $DIR/$tdir || error "mkdir fail"
13064 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13065 error "set striped dir error"
13066 for ((i=0; i<10; i++)); do
13067 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13069 touch $DIR/$tdir/striped_dir/file_$i ||
13070 error "touch error $i"
13071 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13072 [ $mtime1 -eq $mtime2 ] &&
13073 error "mtime not change after create"
13075 rm -f $DIR/$tdir/striped_dir/file_$i ||
13076 error "unlink error $i"
13077 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13078 [ $mtime2 -eq $mtime3 ] &&
13079 error "mtime did not change after unlink"
13083 run_test 300b "check ctime/mtime for striped dir"
13086 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13087 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13090 mkdir -p $DIR/$tdir
13091 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13092 error "set striped dir error"
13094 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13095 error "chown striped dir failed"
13097 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13098 error "create 5k files failed"
13100 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13102 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13106 run_test 300c "chown && check ls under striped directory"
13109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13110 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13114 mkdir -p $DIR/$tdir
13115 $SETSTRIPE -c 2 $DIR/$tdir
13117 #local striped directory
13118 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13119 error "set striped dir error"
13120 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13121 error "create 10 files failed"
13123 #remote striped directory
13124 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13125 error "set striped dir error"
13126 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13127 error "create 10 files failed"
13129 for file in $(find $DIR/$tdir); do
13130 stripe_count=$($GETSTRIPE -c $file)
13131 [ $stripe_count -eq 2 ] ||
13132 error "wrong stripe $stripe_count for $file"
13137 run_test 300d "check default stripe under striped directory"
13140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13141 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13145 mkdir -p $DIR/$tdir
13147 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13148 error "set striped dir error"
13150 touch $DIR/$tdir/striped_dir/a
13151 touch $DIR/$tdir/striped_dir/b
13152 touch $DIR/$tdir/striped_dir/c
13154 mkdir $DIR/$tdir/striped_dir/dir_a
13155 mkdir $DIR/$tdir/striped_dir/dir_b
13156 mkdir $DIR/$tdir/striped_dir/dir_c
13158 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13159 error "set striped dir under striped dir error"
13161 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13162 error "set striped dir under striped dir error"
13164 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13165 error "set striped dir under striped dir error"
13167 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
13168 error "rename file under striped dir should fail"
13170 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
13171 error "rename dir under striped dir should fail"
13173 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
13174 error "rename dir under different stripes should fail"
13176 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13177 error "rename file under striped dir should succeed"
13179 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
13180 error "rename dir under striped dir should succeed"
13184 run_test 300e "check rename under striped directory"
13187 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13188 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13193 mkdir -p $DIR/$tdir
13195 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13196 error "set striped dir error"
13198 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13199 error "set striped dir error"
13201 touch $DIR/$tdir/striped_dir/a
13202 mkdir $DIR/$tdir/striped_dir/dir_a
13203 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13204 error "create striped dir under striped dir fails"
13206 touch $DIR/$tdir/striped_dir1/b
13207 mkdir $DIR/$tdir/striped_dir1/dir_b
13208 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13209 error "create striped dir under striped dir fails"
13211 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
13212 error "rename file under different striped dir should fail"
13214 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
13215 error "rename dir under different striped dir should fail"
13217 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
13218 error "rename striped dir under diff striped dir should fail"
13220 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13221 error "rename file under diff striped dirs fails"
13223 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
13224 error "rename dir under diff striped dirs fails"
13228 run_test 300f "check rename cross striped directory"
13230 test_300_check_default_striped_dir()
13233 local default_count=$2
13234 local default_index=$3
13237 local dir_stripe_index
13240 echo "checking $dirname $default_count $default_index"
13241 $LFS setdirstripe -D -c $default_count -i $default_index \
13242 -t all_char $DIR/$tdir/$dirname ||
13243 error "set default stripe on striped dir error"
13244 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13245 [ $stripe_count -eq $default_count ] ||
13246 error "expect $default_count get $stripe_count for $dirname"
13248 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13249 [ $stripe_index -eq $default_index ] ||
13250 error "expect $default_index get $stripe_index for $dirname"
13252 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13253 error "create dirs failed"
13255 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13256 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13257 for dir in $(find $DIR/$tdir/$dirname/*); do
13258 stripe_count=$($LFS getdirstripe -c $dir)
13259 [ $stripe_count -eq $default_count ] ||
13260 error "stripe count $default_count != $stripe_count for $dir"
13262 stripe_index=$($LFS getdirstripe -i $dir)
13263 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13264 error "$stripe_index != $default_index for $dir"
13266 #check default stripe
13267 stripe_count=$($LFS getdirstripe -D -c $dir)
13268 [ $stripe_count -eq $default_count ] ||
13269 error "default count $default_count != $stripe_count for $dir"
13271 stripe_index=$($LFS getdirstripe -D -i $dir)
13272 [ $stripe_index -eq $default_index ] ||
13273 error "default index $default_index != $stripe_index for $dir"
13275 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13279 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13285 mkdir $DIR/$tdir/normal_dir
13287 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13288 test_300_check_default_striped_dir normal_dir 1 0
13289 test_300_check_default_striped_dir normal_dir 2 1
13290 test_300_check_default_striped_dir normal_dir 2 -1
13292 #delete default stripe information
13293 echo "delete default stripeEA"
13294 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13295 error "set default stripe on striped dir error"
13297 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13298 for dir in $(find $DIR/$tdir/normal_dir/*); do
13299 stripe_count=$($LFS getdirstripe -c $dir)
13300 [ $stripe_count -eq 0 ] ||
13301 error "expect 1 get $stripe_count for $dir"
13302 stripe_index=$($LFS getdirstripe -i $dir)
13303 [ $stripe_index -eq 0 ] ||
13304 error "expect 0 get $stripe_index for $dir"
13307 run_test 300g "check default striped directory for normal directory"
13310 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13315 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13316 $DIR/$tdir/striped_dir ||
13317 error "set striped dir error"
13319 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13320 test_300_check_default_striped_dir striped_dir 1 0
13321 test_300_check_default_striped_dir striped_dir 2 1
13322 test_300_check_default_striped_dir striped_dir 2 -1
13324 #delete default stripe information
13325 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13326 error "set default stripe on striped dir error"
13328 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13329 for dir in $(find $DIR/$tdir/striped_dir/*); do
13330 stripe_count=$($LFS getdirstripe -c $dir)
13331 [ $stripe_count -eq 0 ] ||
13332 error "expect 1 get $stripe_count for $dir"
13335 run_test 300h "check default striped directory for striped directory"
13338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13339 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13345 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13346 error "set striped dir error"
13348 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13349 error "create files under striped dir failed"
13351 # unfortunately, we need to umount to clear dir layout cache for now
13352 # once we fully implement dir layout, we can drop this
13353 umount_client $MOUNT || error "umount failed"
13354 mount_client $MOUNT || error "mount failed"
13356 #set the stripe to be unknown hash type
13357 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13358 $LCTL set_param fail_loc=0x1901
13359 for ((i = 0; i < 10; i++)); do
13360 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13361 error "stat f-$i failed"
13362 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13365 touch $DIR/$tdir/striped_dir/f0 &&
13366 error "create under striped dir with unknown hash should fail"
13368 $LCTL set_param fail_loc=0
13370 umount_client $MOUNT || error "umount failed"
13371 mount_client $MOUNT || error "mount failed"
13375 run_test 300i "client handle unknown hash type striped directory"
13377 test_400a() { # LU-1606, was conf-sanity test_74
13378 local extra_flags=''
13379 local out=$TMP/$tfile
13380 local prefix=/usr/include/lustre
13383 if ! which $CC > /dev/null 2>&1; then
13384 skip_env "$CC is not installed"
13388 if ! [[ -d $prefix ]]; then
13389 # Assume we're running in tree and fixup the include path.
13390 extra_flags+=" -I$LUSTRE/../libcfs/include"
13391 extra_flags+=" -I$LUSTRE/include"
13392 extra_flags+=" -L$LUSTRE/utils"
13395 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13396 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13397 error "client api broken"
13400 run_test 400a "Lustre client api program can compile and link"
13402 test_400b() { # LU-1606, LU-5011
13404 local out=$TMP/$tfile
13405 local prefix=/usr/include/lustre
13407 # We use a hard coded prefix so that this test will not fail
13408 # when run in tree. There are headers in lustre/include/lustre/
13409 # that are not packaged (like lustre_idl.h) and have more
13410 # complicated include dependencies (like config.h and lnet/types.h).
13411 # Since this test about correct packaging we just skip them when
13412 # they don't exist (see below) rather than try to fixup cppflags.
13414 if ! which $CC > /dev/null 2>&1; then
13415 skip_env "$CC is not installed"
13419 for header in $prefix/*.h; do
13420 if ! [[ -f "$header" ]]; then
13424 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13425 continue # liblustreapi.h is deprecated.
13428 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13429 error "cannot compile '$header'"
13432 run_test 400b "packaged headers can be compiled"
13435 # tests that do cleanup/setup should be run at the end
13439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13441 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13442 $LCTL set_param fail_loc=0x903
13444 cancel_lru_locks MGC
13446 FAIL_ON_ERROR=true cleanup
13447 FAIL_ON_ERROR=true setup
13449 run_test 900 "umount should not race with any mgc requeue thread"
13452 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13453 check_and_cleanup_lustre
13454 if [ "$I_MOUNTED" != "yes" ]; then
13455 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true